zcw-shared 1.46.2 → 1.47.0
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/dist/functions/async/sleep.d.ts +5 -0
- package/dist/functions/async/sleep.js +6 -0
- package/dist/functions/async/sleep.js.map +1 -0
- package/dist/functions/async/timeout.d.ts +6 -0
- package/dist/functions/async/timeout.js +12 -0
- package/dist/functions/async/timeout.js.map +1 -0
- package/dist/functions/browser/computePosition.d.ts +6 -0
- package/dist/functions/browser/computePosition.js +49 -0
- package/dist/functions/browser/computePosition.js.map +1 -0
- package/dist/functions/browser/createSharedKeyboardCenter.d.ts +18 -0
- package/dist/functions/browser/createSharedKeyboardCenter.js +58 -0
- package/dist/functions/browser/createSharedKeyboardCenter.js.map +1 -0
- package/dist/functions/browser/createThrottledEventListener.d.ts +11 -0
- package/dist/functions/browser/createThrottledEventListener.js +51 -0
- package/dist/functions/browser/createThrottledEventListener.js.map +1 -0
- package/dist/functions/browser/demonstrateResourceLoading.d.ts +32 -0
- package/dist/functions/browser/demonstrateResourceLoading.js +169 -0
- package/dist/functions/browser/demonstrateResourceLoading.js.map +1 -0
- package/dist/functions/browser/detectOverflow.d.ts +12 -0
- package/dist/functions/browser/detectOverflow.js +17 -0
- package/dist/functions/browser/detectOverflow.js.map +1 -0
- package/dist/functions/browser/getAlignment.d.ts +2 -0
- package/dist/functions/browser/getAlignment.js +5 -0
- package/dist/functions/browser/getAlignment.js.map +1 -0
- package/dist/functions/browser/getBasePlacement.d.ts +2 -0
- package/dist/functions/browser/getBasePlacement.js +4 -0
- package/dist/functions/browser/getBasePlacement.js.map +1 -0
- package/dist/functions/browser/getCrossAxisFlip.d.ts +2 -0
- package/dist/functions/browser/getCrossAxisFlip.js +11 -0
- package/dist/functions/browser/getCrossAxisFlip.js.map +1 -0
- package/dist/functions/browser/getElementRect.d.ts +3 -0
- package/dist/functions/browser/getElementRect.js +14 -0
- package/dist/functions/browser/getElementRect.js.map +1 -0
- package/dist/functions/browser/getFlipPlacements.d.ts +2 -0
- package/dist/functions/browser/getFlipPlacements.js +13 -0
- package/dist/functions/browser/getFlipPlacements.js.map +1 -0
- package/dist/functions/browser/getMainAxisFlip.d.ts +2 -0
- package/dist/functions/browser/getMainAxisFlip.js +17 -0
- package/dist/functions/browser/getMainAxisFlip.js.map +1 -0
- package/dist/functions/browser/getRelativePosition.d.ts +3 -0
- package/dist/functions/browser/getRelativePosition.js +14 -0
- package/dist/functions/browser/getRelativePosition.js.map +1 -0
- package/dist/functions/browser/getViewportRect.d.ts +7 -0
- package/dist/functions/browser/getViewportRect.js +15 -0
- package/dist/functions/browser/getViewportRect.js.map +1 -0
- package/dist/functions/browser/isValidPlacement.d.ts +2 -0
- package/dist/functions/browser/isValidPlacement.js +16 -0
- package/dist/functions/browser/isValidPlacement.js.map +1 -0
- package/dist/functions/browser/pickFile.d.ts +15 -0
- package/dist/functions/browser/pickFile.js +48 -0
- package/dist/functions/browser/pickFile.js.map +1 -0
- package/dist/functions/build/generateExports.d.ts +26 -0
- package/dist/functions/build/generateExports.js +34 -0
- package/dist/functions/build/generateExports.js.map +1 -0
- package/dist/functions/core/diff/diff.d.ts +25 -0
- package/dist/functions/core/diff/diff.js +316 -0
- package/dist/functions/core/diff/diff.js.map +1 -0
- package/dist/functions/core/diff/vueDiff.d.ts +38 -0
- package/dist/functions/core/diff/vueDiff.js +333 -0
- package/dist/functions/core/diff/vueDiff.js.map +1 -0
- package/dist/functions/core/generator/generatorUtils.d.ts +16 -0
- package/dist/functions/core/generator/generatorUtils.js +139 -0
- package/dist/functions/core/generator/generatorUtils.js.map +1 -0
- package/dist/functions/core/type/isType.d.ts +11 -0
- package/dist/functions/core/type/isType.js +30 -0
- package/dist/functions/core/type/isType.js.map +1 -0
- package/dist/functions/data/array-object/chunk.d.ts +1 -0
- package/dist/functions/data/array-object/chunk.js +11 -0
- package/dist/functions/data/array-object/chunk.js.map +1 -0
- package/dist/functions/data/array-object/deepClone.d.ts +12 -0
- package/dist/functions/data/array-object/deepClone.js +131 -0
- package/dist/functions/data/array-object/deepClone.js.map +1 -0
- package/dist/functions/data/array-object/evolve.d.ts +3 -0
- package/dist/functions/data/array-object/evolve.js +15 -0
- package/dist/functions/data/array-object/evolve.js.map +1 -0
- package/dist/functions/data/array-object/flatten.d.ts +7 -0
- package/dist/functions/data/array-object/flatten.js +60 -0
- package/dist/functions/data/array-object/flatten.js.map +1 -0
- package/dist/functions/data/array-object/flattenObject.d.ts +5 -0
- package/dist/functions/data/array-object/flattenObject.js +102 -0
- package/dist/functions/data/array-object/flattenObject.js.map +1 -0
- package/dist/functions/data/array-object/groupBy.d.ts +1 -0
- package/dist/functions/data/array-object/groupBy.js +14 -0
- package/dist/functions/data/array-object/groupBy.js.map +1 -0
- package/dist/functions/data/array-object/omit.d.ts +1 -0
- package/dist/functions/data/array-object/omit.js +8 -0
- package/dist/functions/data/array-object/omit.js.map +1 -0
- package/dist/functions/data/array-object/pick.d.ts +1 -0
- package/dist/functions/data/array-object/pick.js +10 -0
- package/dist/functions/data/array-object/pick.js.map +1 -0
- package/dist/functions/data/array-object/shuffle.d.ts +1 -0
- package/dist/functions/data/array-object/shuffle.js +9 -0
- package/dist/functions/data/array-object/shuffle.js.map +1 -0
- package/dist/functions/data/array-object/sortBy.d.ts +1 -0
- package/dist/functions/data/array-object/sortBy.js +13 -0
- package/dist/functions/data/array-object/sortBy.js.map +1 -0
- package/dist/functions/data/array-object/unique.d.ts +10 -0
- package/dist/functions/data/array-object/unique.js +85 -0
- package/dist/functions/data/array-object/unique.js.map +1 -0
- package/dist/functions/data/date/dateRange.d.ts +1 -0
- package/dist/functions/data/date/dateRange.js +18 -0
- package/dist/functions/data/date/dateRange.js.map +1 -0
- package/dist/functions/data/date/formatDate.d.ts +1 -0
- package/dist/functions/data/date/formatDate.js +21 -0
- package/dist/functions/data/date/formatDate.js.map +1 -0
- package/dist/functions/data/date/timeAgo.d.ts +1 -0
- package/dist/functions/data/date/timeAgo.js +49 -0
- package/dist/functions/data/date/timeAgo.js.map +1 -0
- package/dist/functions/data/number/average.d.ts +1 -0
- package/dist/functions/data/number/average.js +8 -0
- package/dist/functions/data/number/average.js.map +1 -0
- package/dist/functions/data/number/clamp.d.ts +1 -0
- package/dist/functions/data/number/clamp.js +7 -0
- package/dist/functions/data/number/clamp.js.map +1 -0
- package/dist/functions/data/number/formatNumber.d.ts +8 -0
- package/dist/functions/data/number/formatNumber.js +16 -0
- package/dist/functions/data/number/formatNumber.js.map +1 -0
- package/dist/functions/data/number/median.d.ts +1 -0
- package/dist/functions/data/number/median.js +14 -0
- package/dist/functions/data/number/median.js.map +1 -0
- package/dist/functions/data/number/percentile.d.ts +1 -0
- package/dist/functions/data/number/percentile.js +18 -0
- package/dist/functions/data/number/percentile.js.map +1 -0
- package/dist/functions/data/number/random.d.ts +4 -0
- package/dist/functions/data/number/random.js +9 -0
- package/dist/functions/data/number/random.js.map +1 -0
- package/dist/functions/data/number/range.d.ts +1 -0
- package/dist/functions/data/number/range.js +18 -0
- package/dist/functions/data/number/range.js.map +1 -0
- package/dist/functions/data/number/sum.d.ts +1 -0
- package/dist/functions/data/number/sum.js +4 -0
- package/dist/functions/data/number/sum.js.map +1 -0
- package/dist/functions/data/randomRegion.d.ts +24 -0
- package/dist/functions/data/randomRegion.js +74 -0
- package/dist/functions/data/randomRegion.js.map +1 -0
- package/dist/functions/data/string/base64.d.ts +5 -0
- package/dist/functions/data/string/base64.js +6 -0
- package/dist/functions/data/string/base64.js.map +1 -0
- package/dist/functions/data/string/capitalize.d.ts +1 -0
- package/dist/functions/data/string/capitalize.js +6 -0
- package/dist/functions/data/string/capitalize.js.map +1 -0
- package/dist/functions/data/string/caseConverter.d.ts +19 -0
- package/dist/functions/data/string/caseConverter.js +94 -0
- package/dist/functions/data/string/caseConverter.js.map +1 -0
- package/dist/functions/data/string/desensitize.d.ts +13 -0
- package/dist/functions/data/string/desensitize.js +107 -0
- package/dist/functions/data/string/desensitize.js.map +1 -0
- package/dist/functions/data/string/htmlEscape.d.ts +20 -0
- package/dist/functions/data/string/htmlEscape.js +80 -0
- package/dist/functions/data/string/htmlEscape.js.map +1 -0
- package/dist/functions/data/string/levenshtein.d.ts +1 -0
- package/dist/functions/data/string/levenshtein.js +27 -0
- package/dist/functions/data/string/levenshtein.js.map +1 -0
- package/dist/functions/data/string/normalize.d.ts +8 -0
- package/dist/functions/data/string/normalize.js +37 -0
- package/dist/functions/data/string/normalize.js.map +1 -0
- package/dist/functions/data/string/pad.d.ts +13 -0
- package/dist/functions/data/string/pad.js +50 -0
- package/dist/functions/data/string/pad.js.map +1 -0
- package/dist/functions/data/string/palindrome.d.ts +3 -0
- package/dist/functions/data/string/palindrome.js +15 -0
- package/dist/functions/data/string/palindrome.js.map +1 -0
- package/dist/functions/data/string/similarity.d.ts +1 -0
- package/dist/functions/data/string/similarity.js +13 -0
- package/dist/functions/data/string/similarity.js.map +1 -0
- package/dist/functions/data/string/template.d.ts +4 -0
- package/dist/functions/data/string/template.js +21 -0
- package/dist/functions/data/string/template.js.map +1 -0
- package/dist/functions/data/string/testRegex.d.ts +20 -0
- package/dist/functions/data/string/testRegex.js +300 -0
- package/dist/functions/data/string/testRegex.js.map +1 -0
- package/dist/functions/data/string/wordCount.d.ts +5 -0
- package/dist/functions/data/string/wordCount.js +11 -0
- package/dist/functions/data/string/wordCount.js.map +1 -0
- package/dist/functions/data/tree/buildTree.d.ts +7 -0
- package/dist/functions/data/tree/buildTree.js +27 -0
- package/dist/functions/data/tree/buildTree.js.map +1 -0
- package/dist/functions/data/tree/filterTree.d.ts +4 -0
- package/dist/functions/data/tree/filterTree.js +21 -0
- package/dist/functions/data/tree/filterTree.js.map +1 -0
- package/dist/functions/data/tree/findNode.d.ts +4 -0
- package/dist/functions/data/tree/findNode.js +21 -0
- package/dist/functions/data/tree/findNode.js.map +1 -0
- package/dist/functions/data/tree/flattenTree.d.ts +6 -0
- package/dist/functions/data/tree/flattenTree.js +21 -0
- package/dist/functions/data/tree/flattenTree.js.map +1 -0
- package/dist/functions/file/walk.d.ts +18 -0
- package/dist/functions/file/walk.js +58 -0
- package/dist/functions/file/walk.js.map +1 -0
- package/dist/functions/integrations/ag-grid/generateLicense.d.ts +7 -0
- package/dist/functions/integrations/ag-grid/generateLicense.js +12 -0
- package/dist/functions/integrations/ag-grid/generateLicense.js.map +1 -0
- package/dist/functions/integrations/uniapp/app-plus/buildAndroidApp.d.ts +30 -0
- package/dist/functions/integrations/uniapp/app-plus/buildAndroidApp.js +884 -0
- package/dist/functions/integrations/uniapp/app-plus/buildAndroidApp.js.map +1 -0
- package/dist/functions/integrations/uniapp/app-plus/buildIOSApp.d.ts +31 -0
- package/dist/functions/integrations/uniapp/app-plus/buildIOSApp.js +900 -0
- package/dist/functions/integrations/uniapp/app-plus/buildIOSApp.js.map +1 -0
- package/dist/functions/integrations/uniapp/build.d.ts +21 -0
- package/dist/functions/integrations/uniapp/build.js +83 -0
- package/dist/functions/integrations/uniapp/build.js.map +1 -0
- package/dist/functions/integrations/uniapp/detectAndroidProjectStructure.d.ts +11 -0
- package/dist/functions/integrations/uniapp/detectAndroidProjectStructure.js +30 -0
- package/dist/functions/integrations/uniapp/detectAndroidProjectStructure.js.map +1 -0
- package/dist/functions/integrations/uniapp/detectProjectType.d.ts +20 -0
- package/dist/functions/integrations/uniapp/detectProjectType.js +68 -0
- package/dist/functions/integrations/uniapp/detectProjectType.js.map +1 -0
- package/dist/functions/integrations/uniapp/parseManifest.d.ts +20 -0
- package/dist/functions/integrations/uniapp/parseManifest.js +51 -0
- package/dist/functions/integrations/uniapp/parseManifest.js.map +1 -0
- package/dist/functions/integrations/uniapp/waitForPages.d.ts +7 -0
- package/dist/functions/integrations/uniapp/waitForPages.js +20 -0
- package/dist/functions/integrations/uniapp/waitForPages.js.map +1 -0
- package/dist/functions/integrations/vue/dynamicMount.d.ts +18 -0
- package/dist/functions/integrations/vue/dynamicMount.js +25 -0
- package/dist/functions/integrations/vue/dynamicMount.js.map +1 -0
- package/dist/functions/integrations/vue/extractColorsFromVueFile.d.ts +3 -0
- package/dist/functions/integrations/vue/extractColorsFromVueFile.js +18 -0
- package/dist/functions/integrations/vue/extractColorsFromVueFile.js.map +1 -0
- package/dist/functions/integrations/vue/extractColorsFromVueSection.d.ts +3 -0
- package/dist/functions/integrations/vue/extractColorsFromVueSection.js +53 -0
- package/dist/functions/integrations/vue/extractColorsFromVueSection.js.map +1 -0
- package/dist/functions/integrations/vue/filterSections.d.ts +2 -0
- package/dist/functions/integrations/vue/filterSections.js +11 -0
- package/dist/functions/integrations/vue/filterSections.js.map +1 -0
- package/dist/functions/integrations/vue/isVNode.d.ts +2 -0
- package/dist/functions/integrations/vue/isVNode.js +6 -0
- package/dist/functions/integrations/vue/isVNode.js.map +1 -0
- package/dist/functions/integrations/vue/isVueComponent.d.ts +2 -0
- package/dist/functions/integrations/vue/isVueComponent.js +6 -0
- package/dist/functions/integrations/vue/isVueComponent.js.map +1 -0
- package/dist/functions/integrations/vue/parseVueFile.d.ts +2 -0
- package/dist/functions/integrations/vue/parseVueFile.js +53 -0
- package/dist/functions/integrations/vue/parseVueFile.js.map +1 -0
- package/dist/functions/integrations/wechat/miniapp/downloadFile.d.ts +6 -0
- package/dist/functions/integrations/wechat/miniapp/downloadFile.js +39 -0
- package/dist/functions/integrations/wechat/miniapp/downloadFile.js.map +1 -0
- package/dist/functions/ios/integrateCameraGallery.d.ts +16 -0
- package/dist/functions/ios/integrateCameraGallery.js +93 -0
- package/dist/functions/ios/integrateCameraGallery.js.map +1 -0
- package/dist/functions/patterns/MyPromise.d.ts +32 -0
- package/dist/functions/patterns/MyPromise.js +254 -0
- package/dist/functions/patterns/MyPromise.js.map +1 -0
- package/dist/functions/patterns/functionBind.d.ts +4 -0
- package/dist/functions/patterns/functionBind.js +33 -0
- package/dist/functions/patterns/functionBind.js.map +1 -0
- package/dist/functions/patterns/myInstanceof.d.ts +5 -0
- package/dist/functions/patterns/myInstanceof.js +56 -0
- package/dist/functions/patterns/myInstanceof.js.map +1 -0
- package/dist/functions/patterns/myNew.d.ts +3 -0
- package/dist/functions/patterns/myNew.js +19 -0
- package/dist/functions/patterns/myNew.js.map +1 -0
- package/dist/functions/platform/android/buildProject.d.ts +13 -0
- package/dist/functions/platform/android/buildProject.js +122 -0
- package/dist/functions/platform/android/buildProject.js.map +1 -0
- package/dist/functions/platform/android/configureAppIcon.d.ts +17 -0
- package/dist/functions/platform/android/configureAppIcon.js +106 -0
- package/dist/functions/platform/android/configureAppIcon.js.map +1 -0
- package/dist/functions/platform/android/configureLaunchScreen.d.ts +21 -0
- package/dist/functions/platform/android/configureLaunchScreen.js +328 -0
- package/dist/functions/platform/android/configureLaunchScreen.js.map +1 -0
- package/dist/functions/platform/android/detectAndroidModules.d.ts +8 -0
- package/dist/functions/platform/android/detectAndroidModules.js +21 -0
- package/dist/functions/platform/android/detectAndroidModules.js.map +1 -0
- package/dist/functions/platform/android/integrateFacebookLogin.d.ts +12 -0
- package/dist/functions/platform/android/integrateFacebookLogin.js +91 -0
- package/dist/functions/platform/android/integrateFacebookLogin.js.map +1 -0
- package/dist/functions/platform/android/integrateGoogleLogin.d.ts +10 -0
- package/dist/functions/platform/android/integrateGoogleLogin.js +199 -0
- package/dist/functions/platform/android/integrateGoogleLogin.js.map +1 -0
- package/dist/functions/platform/android/integrateMiuiLogin.d.ts +13 -0
- package/dist/functions/platform/android/integrateMiuiLogin.js +115 -0
- package/dist/functions/platform/android/integrateMiuiLogin.js.map +1 -0
- package/dist/functions/platform/android/integrateQQLogin.d.ts +12 -0
- package/dist/functions/platform/android/integrateQQLogin.js +130 -0
- package/dist/functions/platform/android/integrateQQLogin.js.map +1 -0
- package/dist/functions/platform/android/integrateShareTrace.d.ts +10 -0
- package/dist/functions/platform/android/integrateShareTrace.js +181 -0
- package/dist/functions/platform/android/integrateShareTrace.js.map +1 -0
- package/dist/functions/platform/android/integrateSinaLogin.d.ts +13 -0
- package/dist/functions/platform/android/integrateSinaLogin.js +85 -0
- package/dist/functions/platform/android/integrateSinaLogin.js.map +1 -0
- package/dist/functions/platform/android/integrateThirdPartyModule.d.ts +46 -0
- package/dist/functions/platform/android/integrateThirdPartyModule.js +251 -0
- package/dist/functions/platform/android/integrateThirdPartyModule.js.map +1 -0
- package/dist/functions/platform/android/integrateUniAppNativePlugin.d.ts +22 -0
- package/dist/functions/platform/android/integrateUniAppNativePlugin.js +631 -0
- package/dist/functions/platform/android/integrateUniAppNativePlugin.js.map +1 -0
- package/dist/functions/platform/android/integrateUniverifyLogin.d.ts +11 -0
- package/dist/functions/platform/android/integrateUniverifyLogin.js +314 -0
- package/dist/functions/platform/android/integrateUniverifyLogin.js.map +1 -0
- package/dist/functions/platform/android/integrateWechatLogin.d.ts +13 -0
- package/dist/functions/platform/android/integrateWechatLogin.js +154 -0
- package/dist/functions/platform/android/integrateWechatLogin.js.map +1 -0
- package/dist/functions/platform/android/integrateWechatShare.d.ts +13 -0
- package/dist/functions/platform/android/integrateWechatShare.js +154 -0
- package/dist/functions/platform/android/integrateWechatShare.js.map +1 -0
- package/dist/functions/platform/android/modifyGradle.d.ts +28 -0
- package/dist/functions/platform/android/modifyGradle.js +119 -0
- package/dist/functions/platform/android/modifyGradle.js.map +1 -0
- package/dist/functions/platform/android/modifyManifest.d.ts +39 -0
- package/dist/functions/platform/android/modifyManifest.js +225 -0
- package/dist/functions/platform/android/modifyManifest.js.map +1 -0
- package/dist/functions/platform/android/permission.d.ts +54 -0
- package/dist/functions/platform/android/permission.js +85 -0
- package/dist/functions/platform/android/permission.js.map +1 -0
- package/dist/functions/platform/ios/configureAppIcon.d.ts +17 -0
- package/dist/functions/platform/ios/configureAppIcon.js +149 -0
- package/dist/functions/platform/ios/configureAppIcon.js.map +1 -0
- package/dist/functions/platform/ios/configureLaunchScreen.d.ts +17 -0
- package/dist/functions/platform/ios/configureLaunchScreen.js +150 -0
- package/dist/functions/platform/ios/configureLaunchScreen.js.map +1 -0
- package/dist/functions/platform/ios/configurePermissions.d.ts +19 -0
- package/dist/functions/platform/ios/configurePermissions.js +120 -0
- package/dist/functions/platform/ios/configurePermissions.js.map +1 -0
- package/dist/functions/platform/ios/integrateNativePlugin.d.ts +35 -0
- package/dist/functions/platform/ios/integrateNativePlugin.js +994 -0
- package/dist/functions/platform/ios/integrateNativePlugin.js.map +1 -0
- package/dist/functions/platform/ios/integrateQQShare.d.ts +14 -0
- package/dist/functions/platform/ios/integrateQQShare.js +132 -0
- package/dist/functions/platform/ios/integrateQQShare.js.map +1 -0
- package/dist/functions/platform/ios/integrateSinaShare.d.ts +16 -0
- package/dist/functions/platform/ios/integrateSinaShare.js +108 -0
- package/dist/functions/platform/ios/integrateSinaShare.js.map +1 -0
- package/dist/functions/platform/ios/integrateThirdPartyModule.d.ts +62 -0
- package/dist/functions/platform/ios/integrateThirdPartyModule.js +883 -0
- package/dist/functions/platform/ios/integrateThirdPartyModule.js.map +1 -0
- package/dist/functions/platform/ios/integrateWechatOauth.d.ts +14 -0
- package/dist/functions/platform/ios/integrateWechatOauth.js +107 -0
- package/dist/functions/platform/ios/integrateWechatOauth.js.map +1 -0
- package/dist/functions/platform/ios/integrateWechatShare.d.ts +14 -0
- package/dist/functions/platform/ios/integrateWechatShare.js +101 -0
- package/dist/functions/platform/ios/integrateWechatShare.js.map +1 -0
- package/dist/functions/platform/ios/modifyInfoPlistKeyValue.d.ts +2 -0
- package/dist/functions/platform/ios/modifyInfoPlistKeyValue.js +45 -0
- package/dist/functions/platform/ios/modifyInfoPlistKeyValue.js.map +1 -0
- package/dist/functions/platform/ios/safelyModifyProjectPbxproj.d.ts +16 -0
- package/dist/functions/platform/ios/safelyModifyProjectPbxproj.js +136 -0
- package/dist/functions/platform/ios/safelyModifyProjectPbxproj.js.map +1 -0
- package/dist/functions/platform/ios/useAltool.d.ts +39 -0
- package/dist/functions/platform/ios/useAltool.js +350 -0
- package/dist/functions/platform/ios/useAltool.js.map +1 -0
- package/dist/functions/style/buildTokens.d.ts +76 -0
- package/dist/functions/style/buildTokens.js +183 -0
- package/dist/functions/style/buildTokens.js.map +1 -0
- package/dist/functions/style/extractCssVariables.d.ts +16 -0
- package/dist/functions/style/extractCssVariables.js +256 -0
- package/dist/functions/style/extractCssVariables.js.map +1 -0
- package/dist/functions/style/generateVariables.d.ts +7 -0
- package/dist/functions/style/generateVariables.js +135 -0
- package/dist/functions/style/generateVariables.js.map +1 -0
- package/dist/functions/style/mixColors.d.ts +1 -0
- package/dist/functions/style/mixColors.js +38 -0
- package/dist/functions/style/mixColors.js.map +1 -0
- package/dist/functions/style/parseDesignTokens.d.ts +10 -0
- package/dist/functions/style/parseDesignTokens.js +216 -0
- package/dist/functions/style/parseDesignTokens.js.map +1 -0
- package/dist/functions/uniapp/app-plus/buildIOSApp.js +36 -0
- package/dist/functions/uniapp/app-plus/buildIOSApp.js.map +1 -1
- package/dist/functions/uniapp/camera/showCamera.d.ts +11 -0
- package/dist/functions/uniapp/camera/showCamera.js +22 -0
- package/dist/functions/uniapp/camera/showCamera.js.map +1 -0
- package/dist/functions/uniapp/customer-service/adapters/openCustomerServiceInMiniapp.d.ts +23 -0
- package/dist/functions/uniapp/customer-service/adapters/openCustomerServiceInMiniapp.js +69 -0
- package/dist/functions/uniapp/customer-service/adapters/openCustomerServiceInMiniapp.js.map +1 -0
- package/dist/functions/uniapp/customer-service/showWxCustomerService.d.ts +28 -0
- package/dist/functions/uniapp/customer-service/showWxCustomerService.js +25 -0
- package/dist/functions/uniapp/customer-service/showWxCustomerService.js.map +1 -0
- package/dist/functions/uniapp/file/adapters/readWriteFileInApp.d.ts +10 -0
- package/dist/functions/uniapp/file/adapters/readWriteFileInApp.js +97 -0
- package/dist/functions/uniapp/file/adapters/readWriteFileInApp.js.map +1 -0
- package/dist/functions/uniapp/file/adapters/readWriteFileInH5.d.ts +30 -0
- package/dist/functions/uniapp/file/adapters/readWriteFileInH5.js +83 -0
- package/dist/functions/uniapp/file/adapters/readWriteFileInH5.js.map +1 -0
- package/dist/functions/uniapp/file/adapters/readWriteFileInMiniapp.d.ts +10 -0
- package/dist/functions/uniapp/file/adapters/readWriteFileInMiniapp.js +97 -0
- package/dist/functions/uniapp/file/adapters/readWriteFileInMiniapp.js.map +1 -0
- package/dist/functions/uniapp/file/showFile.d.ts +35 -0
- package/dist/functions/uniapp/file/showFile.js +66 -0
- package/dist/functions/uniapp/file/showFile.js.map +1 -0
- package/dist/functions/uniapp/image/adapters/chooseImageInApp.d.ts +9 -0
- package/dist/functions/uniapp/image/adapters/chooseImageInApp.js +52 -0
- package/dist/functions/uniapp/image/adapters/chooseImageInApp.js.map +1 -0
- package/dist/functions/uniapp/image/adapters/chooseImageInH5.d.ts +9 -0
- package/dist/functions/uniapp/image/adapters/chooseImageInH5.js +52 -0
- package/dist/functions/uniapp/image/adapters/chooseImageInH5.js.map +1 -0
- package/dist/functions/uniapp/image/adapters/chooseImageInMiniapp.d.ts +9 -0
- package/dist/functions/uniapp/image/adapters/chooseImageInMiniapp.js +52 -0
- package/dist/functions/uniapp/image/adapters/chooseImageInMiniapp.js.map +1 -0
- package/dist/functions/uniapp/image/showImage.d.ts +11 -0
- package/dist/functions/uniapp/image/showImage.js +23 -0
- package/dist/functions/uniapp/image/showImage.js.map +1 -0
- package/dist/functions/uniapp/login/adapters/wechatLoginInApp.d.ts +10 -0
- package/dist/functions/uniapp/login/adapters/wechatLoginInApp.js +49 -0
- package/dist/functions/uniapp/login/adapters/wechatLoginInApp.js.map +1 -0
- package/dist/functions/uniapp/login/adapters/wechatLoginInMiniapp.d.ts +9 -0
- package/dist/functions/uniapp/login/adapters/wechatLoginInMiniapp.js +27 -0
- package/dist/functions/uniapp/login/adapters/wechatLoginInMiniapp.js.map +1 -0
- package/dist/functions/uniapp/login/showLogin.d.ts +13 -0
- package/dist/functions/uniapp/login/showLogin.js +43 -0
- package/dist/functions/uniapp/login/showLogin.js.map +1 -0
- package/dist/functions/uniapp/pay/adapters/wechatPayInApp.d.ts +8 -0
- package/dist/functions/uniapp/pay/adapters/wechatPayInApp.js +36 -0
- package/dist/functions/uniapp/pay/adapters/wechatPayInApp.js.map +1 -0
- package/dist/functions/uniapp/pay/adapters/wechatPayInH5.d.ts +13 -0
- package/dist/functions/uniapp/pay/adapters/wechatPayInH5.js +44 -0
- package/dist/functions/uniapp/pay/adapters/wechatPayInH5.js.map +1 -0
- package/dist/functions/uniapp/pay/adapters/wechatPayInMiniapp.d.ts +8 -0
- package/dist/functions/uniapp/pay/adapters/wechatPayInMiniapp.js +37 -0
- package/dist/functions/uniapp/pay/adapters/wechatPayInMiniapp.js.map +1 -0
- package/dist/functions/uniapp/pay/showPay.d.ts +18 -0
- package/dist/functions/uniapp/pay/showPay.js +60 -0
- package/dist/functions/uniapp/pay/showPay.js.map +1 -0
- package/dist/functions/uniapp/phone/adapters/getPhoneInMiniapp.d.ts +6 -0
- package/dist/functions/uniapp/phone/adapters/getPhoneInMiniapp.js +41 -0
- package/dist/functions/uniapp/phone/adapters/getPhoneInMiniapp.js.map +1 -0
- package/dist/functions/uniapp/phone/showWxPhone.d.ts +8 -0
- package/dist/functions/uniapp/phone/showWxPhone.js +25 -0
- package/dist/functions/uniapp/phone/showWxPhone.js.map +1 -0
- package/dist/functions/uniapp/record/adapters/recordInApp.d.ts +12 -0
- package/dist/functions/uniapp/record/adapters/recordInApp.js +64 -0
- package/dist/functions/uniapp/record/adapters/recordInApp.js.map +1 -0
- package/dist/functions/uniapp/record/adapters/recordInH5.d.ts +21 -0
- package/dist/functions/uniapp/record/adapters/recordInH5.js +82 -0
- package/dist/functions/uniapp/record/adapters/recordInH5.js.map +1 -0
- package/dist/functions/uniapp/record/adapters/recordInMiniapp.d.ts +12 -0
- package/dist/functions/uniapp/record/adapters/recordInMiniapp.js +64 -0
- package/dist/functions/uniapp/record/adapters/recordInMiniapp.js.map +1 -0
- package/dist/functions/uniapp/record/showRecord.d.ts +23 -0
- package/dist/functions/uniapp/record/showRecord.js +95 -0
- package/dist/functions/uniapp/record/showRecord.js.map +1 -0
- package/dist/functions/uniapp/scan-code/adapters/scanCodeInApp.d.ts +9 -0
- package/dist/functions/uniapp/scan-code/adapters/scanCodeInApp.js +30 -0
- package/dist/functions/uniapp/scan-code/adapters/scanCodeInApp.js.map +1 -0
- package/dist/functions/uniapp/scan-code/adapters/scanCodeInMiniapp.d.ts +9 -0
- package/dist/functions/uniapp/scan-code/adapters/scanCodeInMiniapp.js +30 -0
- package/dist/functions/uniapp/scan-code/adapters/scanCodeInMiniapp.js.map +1 -0
- package/dist/functions/uniapp/scan-code/showScanCode.d.ts +12 -0
- package/dist/functions/uniapp/scan-code/showScanCode.js +28 -0
- package/dist/functions/uniapp/scan-code/showScanCode.js.map +1 -0
- package/dist/functions/uniapp/subscribe-message/adapters/wechatSubscribeMessageInMiniapp.d.ts +9 -0
- package/dist/functions/uniapp/subscribe-message/adapters/wechatSubscribeMessageInMiniapp.js +41 -0
- package/dist/functions/uniapp/subscribe-message/adapters/wechatSubscribeMessageInMiniapp.js.map +1 -0
- package/dist/functions/uniapp/subscribe-message/showWxSubscribeMessage.d.ts +11 -0
- package/dist/functions/uniapp/subscribe-message/showWxSubscribeMessage.js +25 -0
- package/dist/functions/uniapp/subscribe-message/showWxSubscribeMessage.js.map +1 -0
- package/dist/functions/uniapp/user-info/wxGetUserInfo.d.ts +43 -0
- package/dist/functions/uniapp/user-info/wxGetUserInfo.js +55 -0
- package/dist/functions/uniapp/user-info/wxGetUserInfo.js.map +1 -0
- package/dist/functions/uniapp/video/adapters/chooseVideoInApp.d.ts +9 -0
- package/dist/functions/uniapp/video/adapters/chooseVideoInApp.js +31 -0
- package/dist/functions/uniapp/video/adapters/chooseVideoInApp.js.map +1 -0
- package/dist/functions/uniapp/video/adapters/chooseVideoInH5.d.ts +9 -0
- package/dist/functions/uniapp/video/adapters/chooseVideoInH5.js +30 -0
- package/dist/functions/uniapp/video/adapters/chooseVideoInH5.js.map +1 -0
- package/dist/functions/uniapp/video/adapters/chooseVideoInMiniapp.d.ts +9 -0
- package/dist/functions/uniapp/video/adapters/chooseVideoInMiniapp.js +31 -0
- package/dist/functions/uniapp/video/adapters/chooseVideoInMiniapp.js.map +1 -0
- package/dist/functions/uniapp/video/showVideo.d.ts +11 -0
- package/dist/functions/uniapp/video/showVideo.js +23 -0
- package/dist/functions/uniapp/video/showVideo.js.map +1 -0
- package/dist/functions/validation/parseJwtPayload.d.ts +7 -0
- package/dist/functions/validation/parseJwtPayload.js +33 -0
- package/dist/functions/validation/parseJwtPayload.js.map +1 -0
- package/dist/functions/validation/validate.d.ts +11 -0
- package/dist/functions/validation/validate.js +44 -0
- package/dist/functions/validation/validate.js.map +1 -0
- package/dist/vue-hooks/browser/useBridgeMessage.d.ts +2 -1
- package/dist/vue-hooks/browser/useBridgeMessage.js +13 -11
- package/dist/vue-hooks/browser/useBridgeMessage.js.map +1 -1
- package/package.json +37 -2
- package/references/blob.d.ts +2 -0
- package/references/device.d.ts +46 -0
- package/references/dom.d.ts +6 -0
- package/references/uniapp.d.ts +221 -8
- package/types/uniapp-ios-build.d.ts +22 -0
- package/types/uniapp.d.ts +298 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type EscapeDirection = 'escape' | 'unescape' | 'both';
|
|
2
|
+
export interface EscapeOptions {
|
|
3
|
+
direction?: EscapeDirection;
|
|
4
|
+
}
|
|
5
|
+
export interface EscapeResult {
|
|
6
|
+
original: string;
|
|
7
|
+
escaped: string;
|
|
8
|
+
unescaped: string;
|
|
9
|
+
direction: EscapeDirection;
|
|
10
|
+
hasHtmlChars: boolean;
|
|
11
|
+
hasHtmlEntities: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function escapeHtml(str: string): string;
|
|
14
|
+
export declare function unescapeHtml(str: string): string;
|
|
15
|
+
export declare function htmlEscape(str: string, options?: EscapeOptions, returnDetails?: boolean): string | EscapeResult;
|
|
16
|
+
export declare function needsEscape(str: string): boolean;
|
|
17
|
+
export declare function hasEntities(str: string): boolean;
|
|
18
|
+
export declare function smartEscape(str: string): string;
|
|
19
|
+
export declare function escape(str: string): string;
|
|
20
|
+
export declare function unescape(str: string): string;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const HTML_ESCAPES = {
|
|
2
|
+
'&': '&',
|
|
3
|
+
'<': '<',
|
|
4
|
+
'>': '>',
|
|
5
|
+
'"': '"',
|
|
6
|
+
"'": '''
|
|
7
|
+
};
|
|
8
|
+
const HTML_UNESCAPES = {
|
|
9
|
+
'&': '&',
|
|
10
|
+
'<': '<',
|
|
11
|
+
'>': '>',
|
|
12
|
+
'"': '"',
|
|
13
|
+
''': "'"
|
|
14
|
+
};
|
|
15
|
+
const HTML_CHARS_REGEX = /[&<>"']/g;
|
|
16
|
+
const HTML_ENTITIES_REGEX = /&(?:amp|lt|gt|quot|#39);/g;
|
|
17
|
+
const HTML_CHARS_TEST_REGEX = /[&<>"']/;
|
|
18
|
+
const HTML_ENTITIES_TEST_REGEX = /&(?:amp|lt|gt|quot|#39);/;
|
|
19
|
+
export function escapeHtml(str) {
|
|
20
|
+
return str.replace(HTML_CHARS_REGEX, (match) => HTML_ESCAPES[match]);
|
|
21
|
+
}
|
|
22
|
+
export function unescapeHtml(str) {
|
|
23
|
+
return str.replace(HTML_ENTITIES_REGEX, (match) => HTML_UNESCAPES[match]);
|
|
24
|
+
}
|
|
25
|
+
export function htmlEscape(str, options = {}, returnDetails = false) {
|
|
26
|
+
const { direction = 'escape' } = options;
|
|
27
|
+
if (!str) {
|
|
28
|
+
if (returnDetails) {
|
|
29
|
+
return {
|
|
30
|
+
original: str,
|
|
31
|
+
escaped: str,
|
|
32
|
+
unescaped: str,
|
|
33
|
+
direction,
|
|
34
|
+
hasHtmlChars: false,
|
|
35
|
+
hasHtmlEntities: false
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return str;
|
|
39
|
+
}
|
|
40
|
+
const escaped = escapeHtml(str);
|
|
41
|
+
const unescaped = unescapeHtml(str);
|
|
42
|
+
const hasHtmlChars = HTML_CHARS_TEST_REGEX.test(str);
|
|
43
|
+
const hasHtmlEntities = HTML_ENTITIES_TEST_REGEX.test(str);
|
|
44
|
+
if (returnDetails) {
|
|
45
|
+
return {
|
|
46
|
+
original: str,
|
|
47
|
+
escaped,
|
|
48
|
+
unescaped,
|
|
49
|
+
direction,
|
|
50
|
+
hasHtmlChars,
|
|
51
|
+
hasHtmlEntities
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
switch (direction) {
|
|
55
|
+
case 'escape':
|
|
56
|
+
return escaped;
|
|
57
|
+
case 'unescape':
|
|
58
|
+
return unescaped;
|
|
59
|
+
case 'both':
|
|
60
|
+
return hasHtmlEntities ? unescaped : escaped;
|
|
61
|
+
default:
|
|
62
|
+
throw new Error(`Invalid escape direction: ${direction}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export function needsEscape(str) {
|
|
66
|
+
return HTML_CHARS_TEST_REGEX.test(str);
|
|
67
|
+
}
|
|
68
|
+
export function hasEntities(str) {
|
|
69
|
+
return HTML_ENTITIES_TEST_REGEX.test(str);
|
|
70
|
+
}
|
|
71
|
+
export function smartEscape(str) {
|
|
72
|
+
return hasEntities(str) ? unescapeHtml(str) : escapeHtml(str);
|
|
73
|
+
}
|
|
74
|
+
export function escape(str) {
|
|
75
|
+
return escapeHtml(str);
|
|
76
|
+
}
|
|
77
|
+
export function unescape(str) {
|
|
78
|
+
return unescapeHtml(str);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=htmlEscape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"htmlEscape.js","sourceRoot":"","sources":["../../../../src/functions/data/string/htmlEscape.ts"],"names":[],"mappings":"AAgBA,MAAM,YAAY,GAA2B;IAC3C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,OAAO;CACb,CAAA;AAGD,MAAM,cAAc,GAA2B;IAC7C,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,QAAQ,EAAE,GAAG;IACb,OAAO,EAAE,GAAG;CACb,CAAA;AAGD,MAAM,gBAAgB,GAAG,UAAU,CAAA;AACnC,MAAM,mBAAmB,GAAG,2BAA2B,CAAA;AACvD,MAAM,qBAAqB,GAAG,SAAS,CAAA;AACvC,MAAM,wBAAwB,GAAG,0BAA0B,CAAA;AAkB3D,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;AACtE,CAAC;AAKD,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;AAC3E,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,GAAW,EACX,UAAyB,EAAE,EAC3B,gBAAyB,KAAK;IAE9B,MAAM,EAAE,SAAS,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAA;IAExC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO;gBACL,QAAQ,EAAE,GAAG;gBACb,OAAO,EAAE,GAAG;gBACZ,SAAS,EAAE,GAAG;gBACd,SAAS;gBACT,YAAY,EAAE,KAAK;gBACnB,eAAe,EAAE,KAAK;aACvB,CAAA;QACH,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IAGD,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;IAC/B,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;IAGnC,MAAM,YAAY,GAAG,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpD,MAAM,eAAe,GAAG,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAE1D,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO;YACL,QAAQ,EAAE,GAAG;YACb,OAAO;YACP,SAAS;YACT,SAAS;YACT,YAAY;YACZ,eAAe;SAChB,CAAA;IACH,CAAC;IAED,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,OAAO,CAAA;QAChB,KAAK,UAAU;YACb,OAAO,SAAS,CAAA;QAClB,KAAK,MAAM;YAET,OAAO,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAA;QAC9C;YACE,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,EAAE,CAAC,CAAA;IAC7D,CAAC;AACH,CAAC;AAKD,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC3C,CAAC;AAGD,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;AAC/D,CAAC;AAGD,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,OAAO,UAAU,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function levenshtein(str1: string, str2: string): number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function levenshtein(str1, str2) {
|
|
2
|
+
if (str1 === str2)
|
|
3
|
+
return 0;
|
|
4
|
+
if (str1.length === 0)
|
|
5
|
+
return str2.length;
|
|
6
|
+
if (str2.length === 0)
|
|
7
|
+
return str1.length;
|
|
8
|
+
const matrix = [];
|
|
9
|
+
for (let i = 0; i <= str2.length; i++) {
|
|
10
|
+
matrix[i] = [i];
|
|
11
|
+
}
|
|
12
|
+
for (let j = 0; j <= str1.length; j++) {
|
|
13
|
+
matrix[0][j] = j;
|
|
14
|
+
}
|
|
15
|
+
for (let i = 1; i <= str2.length; i++) {
|
|
16
|
+
for (let j = 1; j <= str1.length; j++) {
|
|
17
|
+
if (str2.charAt(i - 1) === str1.charAt(j - 1)) {
|
|
18
|
+
matrix[i][j] = matrix[i - 1][j - 1];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j] + 1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return matrix[str2.length][str1.length];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=levenshtein.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levenshtein.js","sourceRoot":"","sources":["../../../../src/functions/data/string/levenshtein.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,IAAY;IACpD,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,CAAC,CAAA;IAC3B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,MAAM,CAAA;IACzC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,MAAM,CAAA;IAEzC,MAAM,MAAM,GAAe,EAAE,CAAA;IAG7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IAClB,CAAC;IAGD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC9C,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;YACrC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CACrB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EACxB,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EACpB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CACrB,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function normalize(str, options = {}) {
|
|
2
|
+
if (!str || typeof str !== 'string')
|
|
3
|
+
return str;
|
|
4
|
+
const { case: caseOption = 'none', trim = true, removeSpecial = false, removeNumbers = false, removePunctuation = false, normalizeWhitespace = true } = options;
|
|
5
|
+
let result = str;
|
|
6
|
+
if (removeSpecial) {
|
|
7
|
+
result = result.replace(/[^\w\s]/g, '');
|
|
8
|
+
}
|
|
9
|
+
if (removeNumbers) {
|
|
10
|
+
result = result.replace(/\d/g, '');
|
|
11
|
+
}
|
|
12
|
+
if (removePunctuation) {
|
|
13
|
+
result = result.replace(/[^\w\s]/g, '');
|
|
14
|
+
}
|
|
15
|
+
if (normalizeWhitespace) {
|
|
16
|
+
result = result.replace(/\s+/g, ' ');
|
|
17
|
+
}
|
|
18
|
+
if (trim) {
|
|
19
|
+
result = result.trim();
|
|
20
|
+
}
|
|
21
|
+
switch (caseOption) {
|
|
22
|
+
case 'lower':
|
|
23
|
+
result = result.toLowerCase();
|
|
24
|
+
break;
|
|
25
|
+
case 'upper':
|
|
26
|
+
result = result.toUpperCase();
|
|
27
|
+
break;
|
|
28
|
+
case 'title':
|
|
29
|
+
result = result.toLowerCase().replace(/\b\w/g, (char) => char.toUpperCase());
|
|
30
|
+
break;
|
|
31
|
+
case 'none':
|
|
32
|
+
default:
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../../../src/functions/data/string/normalize.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,SAAS,CACvB,GAAW,EACX,UAOI,EAAE;IAEN,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAA;IAE/C,MAAM,EACJ,IAAI,EAAE,UAAU,GAAG,MAAM,EACzB,IAAI,GAAG,IAAI,EACX,aAAa,GAAG,KAAK,EACrB,aAAa,GAAG,KAAK,EACrB,iBAAiB,GAAG,KAAK,EACzB,mBAAmB,GAAG,IAAI,EAC3B,GAAG,OAAO,CAAA;IAEX,IAAI,MAAM,GAAG,GAAG,CAAA;IAGhB,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IACzC,CAAC;IAGD,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACpC,CAAC;IAGD,IAAI,iBAAiB,EAAE,CAAC;QACtB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IACzC,CAAC;IAGD,IAAI,mBAAmB,EAAE,CAAC;QACxB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,CAAC;IAGD,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;IAGD,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,OAAO;YACV,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;YAC7B,MAAK;QACP,KAAK,OAAO;YACV,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;YAC7B,MAAK;QACP,KAAK,OAAO;YACV,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;YAC5E,MAAK;QACP,KAAK,MAAM,CAAC;QACZ;YACE,MAAK;IACT,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type PadDirection = 'start' | 'end' | 'both';
|
|
2
|
+
export interface PadOptions {
|
|
3
|
+
direction?: PadDirection;
|
|
4
|
+
padString?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PadResult {
|
|
7
|
+
original: string;
|
|
8
|
+
padded: string;
|
|
9
|
+
paddedLength: number;
|
|
10
|
+
padDirection: PadDirection;
|
|
11
|
+
padCharacter: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function pad(str: string, targetLength: number, options?: PadOptions, returnDetails?: boolean): string | PadResult;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export function pad(str, targetLength, options = {}, returnDetails = false) {
|
|
2
|
+
const { direction = 'end', padString = ' ' } = options;
|
|
3
|
+
if (str.length >= targetLength) {
|
|
4
|
+
if (returnDetails) {
|
|
5
|
+
return {
|
|
6
|
+
original: str,
|
|
7
|
+
padded: str,
|
|
8
|
+
paddedLength: str.length,
|
|
9
|
+
padDirection: direction,
|
|
10
|
+
padCharacter: padString
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return str;
|
|
14
|
+
}
|
|
15
|
+
const padLength = targetLength - str.length;
|
|
16
|
+
let padded;
|
|
17
|
+
switch (direction) {
|
|
18
|
+
case 'start': {
|
|
19
|
+
const pad = padString.repeat(Math.ceil(padLength / padString.length)).slice(0, padLength);
|
|
20
|
+
padded = pad + str;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case 'end': {
|
|
24
|
+
const pad = padString.repeat(Math.ceil(padLength / padString.length)).slice(0, padLength);
|
|
25
|
+
padded = str + pad;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case 'both': {
|
|
29
|
+
const leftPadLength = Math.floor(padLength / 2);
|
|
30
|
+
const rightPadLength = padLength - leftPadLength;
|
|
31
|
+
const leftPad = padString.repeat(Math.ceil(leftPadLength / padString.length)).slice(0, leftPadLength);
|
|
32
|
+
const rightPad = padString.repeat(Math.ceil(rightPadLength / padString.length)).slice(0, rightPadLength);
|
|
33
|
+
padded = leftPad + str + rightPad;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
default:
|
|
37
|
+
throw new Error(`Invalid pad direction: ${direction}`);
|
|
38
|
+
}
|
|
39
|
+
if (returnDetails) {
|
|
40
|
+
return {
|
|
41
|
+
original: str,
|
|
42
|
+
padded,
|
|
43
|
+
paddedLength: padded.length,
|
|
44
|
+
padDirection: direction,
|
|
45
|
+
padCharacter: padString
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return padded;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=pad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pad.js","sourceRoot":"","sources":["../../../../src/functions/data/string/pad.ts"],"names":[],"mappings":"AA4BA,MAAM,UAAU,GAAG,CACjB,GAAW,EACX,YAAoB,EACpB,UAAsB,EAAE,EACxB,gBAAyB,KAAK;IAE9B,MAAM,EAAE,SAAS,GAAG,KAAK,EAAE,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,CAAA;IAGtD,IAAI,GAAG,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;QAC/B,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO;gBACL,QAAQ,EAAE,GAAG;gBACb,MAAM,EAAE,GAAG;gBACX,YAAY,EAAE,GAAG,CAAC,MAAM;gBACxB,YAAY,EAAE,SAAS;gBACvB,YAAY,EAAE,SAAS;aACxB,CAAA;QACH,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,MAAM,SAAS,GAAG,YAAY,GAAG,GAAG,CAAC,MAAM,CAAA;IAC3C,IAAI,MAAc,CAAA;IAElB,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;YACzF,MAAM,GAAG,GAAG,GAAG,GAAG,CAAA;YAClB,MAAK;QACP,CAAC;QACD,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;YACzF,MAAM,GAAG,GAAG,GAAG,GAAG,CAAA;YAClB,MAAK;QACP,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAA;YAC/C,MAAM,cAAc,GAAG,SAAS,GAAG,aAAa,CAAA;YAEhD,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAA;YACrG,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAA;YAExG,MAAM,GAAG,OAAO,GAAG,GAAG,GAAG,QAAQ,CAAA;YACjC,MAAK;QACP,CAAC;QACD;YACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,SAAS,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO;YACL,QAAQ,EAAE,GAAG;YACb,MAAM;YACN,YAAY,EAAE,MAAM,CAAC,MAAM;YAC3B,YAAY,EAAE,SAAS;YACvB,YAAY,EAAE,SAAS;SACxB,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function palindrome(str, options = {}) {
|
|
2
|
+
if (!str || typeof str !== 'string')
|
|
3
|
+
return true;
|
|
4
|
+
const { strict = false } = options;
|
|
5
|
+
if (strict) {
|
|
6
|
+
return str === str.split('').reverse().join('');
|
|
7
|
+
}
|
|
8
|
+
const cleaned = str
|
|
9
|
+
.toLowerCase()
|
|
10
|
+
.replace(/[\s\p{P}]/gu, '');
|
|
11
|
+
if (cleaned.length <= 1)
|
|
12
|
+
return true;
|
|
13
|
+
return cleaned === cleaned.split('').reverse().join('');
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=palindrome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palindrome.js","sourceRoot":"","sources":["../../../../src/functions/data/string/palindrome.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,UAAU,CACxB,GAAW,EACX,UAEI,EAAE;IAEN,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IAEhD,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IAElC,IAAI,MAAM,EAAE,CAAC;QAEX,OAAO,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACjD,CAAC;IAGD,MAAM,OAAO,GAAG,GAAG;SAChB,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAA;IAE7B,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IAEpC,OAAO,OAAO,KAAK,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACzD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function similarity(str1: string, str2: string): number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { levenshtein } from './levenshtein';
|
|
2
|
+
export function similarity(str1, str2) {
|
|
3
|
+
if (str1 === str2)
|
|
4
|
+
return 1;
|
|
5
|
+
if (str1.length === 0 && str2.length === 0)
|
|
6
|
+
return 1;
|
|
7
|
+
if (str1.length === 0 || str2.length === 0)
|
|
8
|
+
return 0;
|
|
9
|
+
const distance = levenshtein(str1, str2);
|
|
10
|
+
const maxLength = Math.max(str1.length, str2.length);
|
|
11
|
+
return 1 - distance / maxLength;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=similarity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"similarity.js","sourceRoot":"","sources":["../../../../src/functions/data/string/similarity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAe3C,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,IAAY;IACnD,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,CAAC,CAAA;IAC3B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAA;IACpD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAA;IAEpD,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACxC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAEpD,OAAO,CAAC,GAAG,QAAQ,GAAG,SAAS,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function template(template, data, options = {}) {
|
|
2
|
+
if (!template || typeof template !== 'string')
|
|
3
|
+
return template;
|
|
4
|
+
const { placeholder = /{{([^}]+)}}/g, defaultValue = '' } = options;
|
|
5
|
+
return template.replace(placeholder, (match, key) => {
|
|
6
|
+
const keys = key.trim().split('.');
|
|
7
|
+
let value = data;
|
|
8
|
+
for (const k of keys) {
|
|
9
|
+
if (value == null)
|
|
10
|
+
return defaultValue;
|
|
11
|
+
if (k === 'length' && Array.isArray(value)) {
|
|
12
|
+
value = value.length;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
value = value[k];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return value != null ? String(value) : defaultValue;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../src/functions/data/string/template.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,QAAQ,CACtB,QAAgB,EAChB,IAAyB,EACzB,UAGI,EAAE;IAEN,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAE9D,MAAM,EAAE,WAAW,GAAG,cAAc,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,OAAO,CAAA;IAEnE,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAClD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAClC,IAAI,KAAK,GAAQ,IAAI,CAAA;QAErB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,KAAK,IAAI,IAAI;gBAAE,OAAO,YAAY,CAAA;YAEtC,IAAI,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3C,KAAK,GAAG,KAAK,CAAC,MAAM,CAAA;YACtB,CAAC;iBAAM,CAAC;gBACN,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;YAClB,CAAC;QACH,CAAC;QAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAA;IACrD,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface VisualizationStep {
|
|
2
|
+
stepNumber: number;
|
|
3
|
+
textPos: number;
|
|
4
|
+
patternPos: number;
|
|
5
|
+
action: string;
|
|
6
|
+
status: 'trying' | 'success' | 'fail' | 'backtrack';
|
|
7
|
+
matched: string;
|
|
8
|
+
explanation: string;
|
|
9
|
+
currentChar?: string;
|
|
10
|
+
currentPattern?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RegexMatchResult {
|
|
13
|
+
hasMatch: boolean;
|
|
14
|
+
matchedText: string;
|
|
15
|
+
matchIndex: number;
|
|
16
|
+
matchEndIndex: number;
|
|
17
|
+
steps: VisualizationStep[];
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function testRegex(pattern: string, text: string): RegexMatchResult;
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
function charMatches(pattern, pos, char) {
|
|
2
|
+
if (pattern[pos] === '\\' && pos + 1 < pattern.length) {
|
|
3
|
+
const next = pattern[pos + 1];
|
|
4
|
+
const escapeMap = {
|
|
5
|
+
'd': [c => /[0-9]/.test(c), '数字 0-9'],
|
|
6
|
+
'D': [c => /[^0-9]/.test(c), '非数字'],
|
|
7
|
+
'w': [c => /[a-zA-Z0-9_]/.test(c), '单词字符 a-zA-Z0-9_'],
|
|
8
|
+
'W': [c => /[^a-zA-Z0-9_]/.test(c), '非单词字符'],
|
|
9
|
+
's': [c => /\s/.test(c), '空白字符'],
|
|
10
|
+
'S': [c => /\S/.test(c), '非空白字符'],
|
|
11
|
+
};
|
|
12
|
+
if (escapeMap[next]) {
|
|
13
|
+
const [matcher, desc] = escapeMap[next];
|
|
14
|
+
return {
|
|
15
|
+
matches: matcher(char),
|
|
16
|
+
patternLen: 2,
|
|
17
|
+
desc: `\\${next} (${desc})`
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
matches: char === next,
|
|
22
|
+
patternLen: 2,
|
|
23
|
+
desc: `\\${next}`
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (pattern[pos] === '[') {
|
|
27
|
+
let end = pos + 1;
|
|
28
|
+
while (end < pattern.length && pattern[end] !== ']') {
|
|
29
|
+
if (pattern[end] === '\\')
|
|
30
|
+
end++;
|
|
31
|
+
end++;
|
|
32
|
+
}
|
|
33
|
+
const charset = pattern.substring(pos, end + 1);
|
|
34
|
+
const isNegated = pattern[pos + 1] === '^';
|
|
35
|
+
const chars = charset.substring(isNegated ? 2 : 1, charset.length - 1);
|
|
36
|
+
let matches = false;
|
|
37
|
+
for (let i = 0; i < chars.length; i++) {
|
|
38
|
+
if (chars[i + 1] === '-' && i + 2 < chars.length) {
|
|
39
|
+
const code = char.charCodeAt(0);
|
|
40
|
+
if (code >= chars.charCodeAt(i) && code <= chars.charCodeAt(i + 2)) {
|
|
41
|
+
matches = true;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
i += 2;
|
|
45
|
+
}
|
|
46
|
+
else if (chars[i] === char) {
|
|
47
|
+
matches = true;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
matches: isNegated ? !matches : matches,
|
|
53
|
+
patternLen: end - pos + 1,
|
|
54
|
+
desc: charset
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (pattern[pos] === '.') {
|
|
58
|
+
return {
|
|
59
|
+
matches: char !== '\n',
|
|
60
|
+
patternLen: 1,
|
|
61
|
+
desc: '. (任意字符)'
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
matches: char === pattern[pos],
|
|
66
|
+
patternLen: 1,
|
|
67
|
+
desc: `'${pattern[pos]}'`
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function getQuantifier(pattern, pos) {
|
|
71
|
+
if (pos >= pattern.length)
|
|
72
|
+
return null;
|
|
73
|
+
const char = pattern[pos];
|
|
74
|
+
if (char === '*')
|
|
75
|
+
return { min: 0, max: Infinity, len: 1 };
|
|
76
|
+
if (char === '+')
|
|
77
|
+
return { min: 1, max: Infinity, len: 1 };
|
|
78
|
+
if (char === '?')
|
|
79
|
+
return { min: 0, max: 1, len: 1 };
|
|
80
|
+
if (char === '{') {
|
|
81
|
+
let end = pos + 1;
|
|
82
|
+
while (end < pattern.length && pattern[end] !== '}')
|
|
83
|
+
end++;
|
|
84
|
+
const nums = pattern.substring(pos + 1, end).split(',');
|
|
85
|
+
const min = parseInt(nums[0]);
|
|
86
|
+
const max = nums[1] ? parseInt(nums[1]) : min;
|
|
87
|
+
return { min, max, len: end - pos + 1 };
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
function matchRecursive(text, textPos, pattern, patternPos, matched, steps, stepNum, maxSteps) {
|
|
92
|
+
if (steps.length >= maxSteps)
|
|
93
|
+
return false;
|
|
94
|
+
if (patternPos >= pattern.length) {
|
|
95
|
+
steps.push({
|
|
96
|
+
stepNumber: stepNum.value++,
|
|
97
|
+
textPos,
|
|
98
|
+
patternPos,
|
|
99
|
+
action: '匹配完成',
|
|
100
|
+
status: 'success',
|
|
101
|
+
matched,
|
|
102
|
+
explanation: `正则表达式已全部匹配完成,匹配结果: "${matched}"`
|
|
103
|
+
});
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
const charMatchResult = charMatches(pattern, patternPos, textPos < text.length ? text[textPos] : '');
|
|
107
|
+
const quantifier = getQuantifier(pattern, patternPos + charMatchResult.patternLen);
|
|
108
|
+
if (quantifier) {
|
|
109
|
+
const { min, max, len } = quantifier;
|
|
110
|
+
const nextPatternPos = patternPos + charMatchResult.patternLen + len;
|
|
111
|
+
const quantSymbol = pattern.substring(patternPos + charMatchResult.patternLen, nextPatternPos);
|
|
112
|
+
steps.push({
|
|
113
|
+
stepNumber: stepNum.value++,
|
|
114
|
+
textPos,
|
|
115
|
+
patternPos,
|
|
116
|
+
action: `处理量词 ${quantSymbol}`,
|
|
117
|
+
status: 'trying',
|
|
118
|
+
matched,
|
|
119
|
+
currentPattern: pattern.substring(patternPos, nextPatternPos),
|
|
120
|
+
explanation: `模式 ${charMatchResult.desc} 后跟量词 ${quantSymbol},要求匹配 ${min} 到 ${max === Infinity ? '无限' : max} 次`
|
|
121
|
+
});
|
|
122
|
+
let count = 0;
|
|
123
|
+
let tempTextPos = textPos;
|
|
124
|
+
const matchedChars = [];
|
|
125
|
+
while (count < max && tempTextPos < text.length) {
|
|
126
|
+
const currentChar = text[tempTextPos];
|
|
127
|
+
const checkResult = charMatches(pattern, patternPos, currentChar);
|
|
128
|
+
if (checkResult.matches) {
|
|
129
|
+
matchedChars.push(currentChar);
|
|
130
|
+
count++;
|
|
131
|
+
tempTextPos++;
|
|
132
|
+
steps.push({
|
|
133
|
+
stepNumber: stepNum.value++,
|
|
134
|
+
textPos: tempTextPos,
|
|
135
|
+
patternPos,
|
|
136
|
+
action: `量词匹配第 ${count} 次`,
|
|
137
|
+
status: 'success',
|
|
138
|
+
matched: matched + matchedChars.join(''),
|
|
139
|
+
currentChar,
|
|
140
|
+
currentPattern: charMatchResult.desc,
|
|
141
|
+
explanation: `字符 "${currentChar}" 符合 ${charMatchResult.desc},量词已匹配 ${count} 次`
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (count < min) {
|
|
149
|
+
steps.push({
|
|
150
|
+
stepNumber: stepNum.value++,
|
|
151
|
+
textPos,
|
|
152
|
+
patternPos,
|
|
153
|
+
action: '量词不满足',
|
|
154
|
+
status: 'fail',
|
|
155
|
+
matched,
|
|
156
|
+
explanation: `量词 ${quantSymbol} 要求至少 ${min} 次,但只匹配了 ${count} 次,回溯`
|
|
157
|
+
});
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
for (let tryCount = count; tryCount >= min; tryCount--) {
|
|
161
|
+
if (tryCount < count) {
|
|
162
|
+
steps.push({
|
|
163
|
+
stepNumber: stepNum.value++,
|
|
164
|
+
textPos: textPos + tryCount,
|
|
165
|
+
patternPos: nextPatternPos,
|
|
166
|
+
action: '回溯',
|
|
167
|
+
status: 'backtrack',
|
|
168
|
+
matched: matched + matchedChars.slice(0, tryCount).join(''),
|
|
169
|
+
explanation: `量词贪婪匹配 ${count} 次后续失败,回溯到 ${tryCount} 次重新尝试`
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
const newMatched = matched + matchedChars.slice(0, tryCount).join('');
|
|
173
|
+
const newTextPos = textPos + tryCount;
|
|
174
|
+
if (matchRecursive(text, newTextPos, pattern, nextPatternPos, newMatched, steps, stepNum, maxSteps)) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
if (textPos >= text.length) {
|
|
182
|
+
steps.push({
|
|
183
|
+
stepNumber: stepNum.value++,
|
|
184
|
+
textPos,
|
|
185
|
+
patternPos,
|
|
186
|
+
action: '文本结束',
|
|
187
|
+
status: 'fail',
|
|
188
|
+
matched,
|
|
189
|
+
explanation: `文本已结束,但正则还未匹配完,失败`
|
|
190
|
+
});
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
const currentChar = text[textPos];
|
|
194
|
+
steps.push({
|
|
195
|
+
stepNumber: stepNum.value++,
|
|
196
|
+
textPos,
|
|
197
|
+
patternPos,
|
|
198
|
+
action: '检查字符',
|
|
199
|
+
status: 'trying',
|
|
200
|
+
matched,
|
|
201
|
+
currentChar,
|
|
202
|
+
currentPattern: charMatchResult.desc,
|
|
203
|
+
explanation: `在文本位置 ${textPos} 检查字符 "${currentChar}" 是否匹配 ${charMatchResult.desc}`
|
|
204
|
+
});
|
|
205
|
+
if (charMatchResult.matches) {
|
|
206
|
+
steps.push({
|
|
207
|
+
stepNumber: stepNum.value++,
|
|
208
|
+
textPos: textPos + 1,
|
|
209
|
+
patternPos: patternPos + charMatchResult.patternLen,
|
|
210
|
+
action: '字符匹配',
|
|
211
|
+
status: 'success',
|
|
212
|
+
matched: matched + currentChar,
|
|
213
|
+
currentChar,
|
|
214
|
+
explanation: `字符 "${currentChar}" 匹配成功`
|
|
215
|
+
});
|
|
216
|
+
return matchRecursive(text, textPos + 1, pattern, patternPos + charMatchResult.patternLen, matched + currentChar, steps, stepNum, maxSteps);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
steps.push({
|
|
220
|
+
stepNumber: stepNum.value++,
|
|
221
|
+
textPos,
|
|
222
|
+
patternPos,
|
|
223
|
+
action: '字符不匹配',
|
|
224
|
+
status: 'fail',
|
|
225
|
+
matched,
|
|
226
|
+
currentChar,
|
|
227
|
+
explanation: `字符 "${currentChar}" 不符合 ${charMatchResult.desc},匹配失败`
|
|
228
|
+
});
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
export function testRegex(pattern, text) {
|
|
234
|
+
const steps = [];
|
|
235
|
+
const stepNum = { value: 0 };
|
|
236
|
+
const maxSteps = 200;
|
|
237
|
+
try {
|
|
238
|
+
steps.push({
|
|
239
|
+
stepNumber: stepNum.value++,
|
|
240
|
+
textPos: 0,
|
|
241
|
+
patternPos: 0,
|
|
242
|
+
action: '开始匹配',
|
|
243
|
+
status: 'trying',
|
|
244
|
+
matched: '',
|
|
245
|
+
explanation: `开始在文本 "${text}" 中搜索模式 /${pattern}/`
|
|
246
|
+
});
|
|
247
|
+
for (let i = 0; i < text.length; i++) {
|
|
248
|
+
steps.push({
|
|
249
|
+
stepNumber: stepNum.value++,
|
|
250
|
+
textPos: i,
|
|
251
|
+
patternPos: 0,
|
|
252
|
+
action: `尝试起始位置 ${i}`,
|
|
253
|
+
status: 'trying',
|
|
254
|
+
matched: '',
|
|
255
|
+
currentChar: text[i],
|
|
256
|
+
explanation: `从文本位置 ${i} (字符 "${text[i]}") 开始尝试匹配`
|
|
257
|
+
});
|
|
258
|
+
if (matchRecursive(text, i, pattern, 0, '', steps, stepNum, maxSteps)) {
|
|
259
|
+
const lastStep = steps[steps.length - 1];
|
|
260
|
+
return {
|
|
261
|
+
hasMatch: true,
|
|
262
|
+
matchedText: lastStep.matched,
|
|
263
|
+
matchIndex: i,
|
|
264
|
+
matchEndIndex: i + lastStep.matched.length,
|
|
265
|
+
steps
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
steps.push({
|
|
269
|
+
stepNumber: stepNum.value++,
|
|
270
|
+
textPos: i,
|
|
271
|
+
patternPos: 0,
|
|
272
|
+
action: '本次尝试失败',
|
|
273
|
+
status: 'fail',
|
|
274
|
+
matched: '',
|
|
275
|
+
explanation: `从位置 ${i} 开始匹配失败,继续尝试下一位置`
|
|
276
|
+
});
|
|
277
|
+
if (steps.length >= maxSteps) {
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
hasMatch: false,
|
|
283
|
+
matchedText: '',
|
|
284
|
+
matchIndex: -1,
|
|
285
|
+
matchEndIndex: -1,
|
|
286
|
+
steps
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
return {
|
|
291
|
+
hasMatch: false,
|
|
292
|
+
matchedText: '',
|
|
293
|
+
matchIndex: -1,
|
|
294
|
+
matchEndIndex: -1,
|
|
295
|
+
steps,
|
|
296
|
+
error: error instanceof Error ? error.message : String(error)
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=testRegex.js.map
|