zcw-shared 2.1.0 → 2.8.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/README.md +17 -180
- package/dist/constants/apiErrorCodes.d.ts +17 -0
- package/dist/constants/apiErrorCodes.js +26 -0
- package/dist/constants/apiErrorCodes.js.map +1 -0
- package/dist/constants/authStorage.d.ts +4 -0
- package/dist/constants/authStorage.js +5 -0
- package/dist/constants/authStorage.js.map +1 -0
- package/dist/functions/android/integrateThirdPartyModule.d.ts +5 -0
- package/dist/functions/android/integrateThirdPartyModule.js +70 -0
- package/dist/functions/android/integrateThirdPartyModule.js.map +1 -1
- package/dist/functions/android/integrateUniPushAndroid.d.ts +23 -0
- package/dist/functions/android/integrateUniPushAndroid.js +266 -0
- package/dist/functions/android/integrateUniPushAndroid.js.map +1 -0
- package/dist/functions/api/auth.d.ts +14 -0
- package/dist/functions/api/auth.js +109 -0
- package/dist/functions/api/auth.js.map +1 -0
- package/dist/functions/api/schemas/auth.schema.d.ts +363 -0
- package/dist/functions/api/schemas/auth.schema.js +39 -0
- package/dist/functions/api/schemas/auth.schema.js.map +1 -0
- package/dist/functions/api/schemas/video.schema.d.ts +391 -0
- package/dist/functions/api/schemas/video.schema.js +55 -0
- package/dist/functions/api/schemas/video.schema.js.map +1 -0
- package/dist/functions/api/video.d.ts +62 -0
- package/dist/functions/api/video.js +243 -0
- package/dist/functions/api/video.js.map +1 -0
- package/dist/functions/browser/isElectron.d.ts +5 -0
- package/dist/functions/browser/isElectron.js +4 -0
- package/dist/functions/browser/isElectron.js.map +1 -0
- package/dist/functions/dom/isTextTruncated.d.ts +4 -0
- package/dist/functions/dom/isTextTruncated.js +16 -0
- package/dist/functions/dom/isTextTruncated.js.map +1 -0
- package/dist/functions/dom/localFileInput.d.ts +14 -0
- package/dist/functions/dom/localFileInput.js +27 -0
- package/dist/functions/dom/localFileInput.js.map +1 -0
- package/dist/functions/file/getIconfontNameByExtension.js +53 -56
- package/dist/functions/file/getIconfontNameByExtension.js.map +1 -1
- package/dist/functions/im/formatImChatConversationListTime.d.ts +1 -0
- package/dist/functions/im/formatImChatConversationListTime.js +19 -0
- package/dist/functions/im/formatImChatConversationListTime.js.map +1 -0
- package/dist/functions/im/parseImMentionSegments.d.ts +15 -0
- package/dist/functions/im/parseImMentionSegments.js +56 -0
- package/dist/functions/im/parseImMentionSegments.js.map +1 -0
- package/dist/functions/image/getImageDimensions.js +15 -5
- package/dist/functions/image/getImageDimensions.js.map +1 -1
- package/dist/functions/ios/integrateThirdPartyModule.d.ts +9 -1
- package/dist/functions/ios/integrateThirdPartyModule.js +112 -2
- package/dist/functions/ios/integrateThirdPartyModule.js.map +1 -1
- package/dist/functions/ios/integrateUniPushIOS.d.ts +18 -0
- package/dist/functions/ios/integrateUniPushIOS.js +200 -0
- package/dist/functions/ios/integrateUniPushIOS.js.map +1 -0
- package/dist/functions/oss/uploadViaSignedPut.d.ts +35 -0
- package/dist/functions/oss/uploadViaSignedPut.js +86 -0
- package/dist/functions/oss/uploadViaSignedPut.js.map +1 -0
- package/dist/functions/storage/useDexieShortcuts.d.ts +28 -0
- package/dist/functions/storage/useDexieShortcuts.js +54 -0
- package/dist/functions/storage/useDexieShortcuts.js.map +1 -0
- package/dist/functions/storage/useLocalStorage.js +11 -12
- package/dist/functions/storage/useLocalStorage.js.map +1 -1
- package/dist/functions/storage/useSessionStorage.js +11 -12
- package/dist/functions/storage/useSessionStorage.js.map +1 -1
- package/dist/functions/storage/useStorageWithIndexedDB.js +4 -5
- package/dist/functions/storage/useStorageWithIndexedDB.js.map +1 -1
- package/dist/functions/uniapp/app-plus/buildAndroidApp.js +38 -0
- package/dist/functions/uniapp/app-plus/buildAndroidApp.js.map +1 -1
- package/dist/functions/uniapp/app-plus/buildIOSApp.js +38 -0
- package/dist/functions/uniapp/app-plus/buildIOSApp.js.map +1 -1
- package/dist/schemas/auth.schema.d.ts +4 -4
- package/dist/vue-hooks/browser/useBridgeMessage.js +7 -8
- package/dist/vue-hooks/browser/useBridgeMessage.js.map +1 -1
- package/dist/vue-hooks/dom/useAppendToBody.d.ts +25 -0
- package/dist/vue-hooks/dom/useAppendToBody.js +31 -0
- package/dist/vue-hooks/dom/useAppendToBody.js.map +1 -0
- package/dist/vue-hooks/dom/useDraggable.d.ts +8 -3
- package/dist/vue-hooks/dom/useDraggable.js +57 -19
- package/dist/vue-hooks/dom/useDraggable.js.map +1 -1
- package/package.json +35 -1
- package/references/dom.d.ts +8 -3
- package/types/address.d.ts +38 -0
- package/types/im-api.d.ts +142 -0
- package/types/im-chat.d.ts +90 -0
- package/types/im-message-display.d.ts +89 -0
- package/types/notification.d.ts +37 -0
- package/types/oss.d.ts +26 -0
- package/types/page-config.d.ts +14 -0
- package/types/payment.d.ts +21 -0
- package/types/performance.d.ts +12 -0
- package/types/rbac.d.ts +24 -0
- package/types/report.d.ts +29 -0
- package/types/review.d.ts +13 -0
- package/types/uniapp-android-build.d.ts +31 -0
- package/types/uniapp-ios-build.d.ts +26 -0
- package/types/user.d.ts +2 -1
- package/dist/functions/async/sleep.d.ts +0 -5
- package/dist/functions/async/sleep.js +0 -6
- package/dist/functions/async/sleep.js.map +0 -1
- package/dist/functions/async/timeout.d.ts +0 -6
- package/dist/functions/async/timeout.js +0 -12
- package/dist/functions/async/timeout.js.map +0 -1
- package/dist/functions/browser/computePosition.d.ts +0 -6
- package/dist/functions/browser/computePosition.js +0 -49
- package/dist/functions/browser/computePosition.js.map +0 -1
- package/dist/functions/browser/createSharedKeyboardCenter.d.ts +0 -18
- package/dist/functions/browser/createSharedKeyboardCenter.js +0 -58
- package/dist/functions/browser/createSharedKeyboardCenter.js.map +0 -1
- package/dist/functions/browser/createThrottledEventListener.d.ts +0 -11
- package/dist/functions/browser/createThrottledEventListener.js +0 -51
- package/dist/functions/browser/createThrottledEventListener.js.map +0 -1
- package/dist/functions/browser/demonstrateResourceLoading.d.ts +0 -32
- package/dist/functions/browser/demonstrateResourceLoading.js +0 -169
- package/dist/functions/browser/demonstrateResourceLoading.js.map +0 -1
- package/dist/functions/browser/detectOverflow.d.ts +0 -12
- package/dist/functions/browser/detectOverflow.js +0 -17
- package/dist/functions/browser/detectOverflow.js.map +0 -1
- package/dist/functions/browser/getAlignment.d.ts +0 -2
- package/dist/functions/browser/getAlignment.js +0 -5
- package/dist/functions/browser/getAlignment.js.map +0 -1
- package/dist/functions/browser/getBasePlacement.d.ts +0 -2
- package/dist/functions/browser/getBasePlacement.js +0 -4
- package/dist/functions/browser/getBasePlacement.js.map +0 -1
- package/dist/functions/browser/getCrossAxisFlip.d.ts +0 -2
- package/dist/functions/browser/getCrossAxisFlip.js +0 -11
- package/dist/functions/browser/getCrossAxisFlip.js.map +0 -1
- package/dist/functions/browser/getElementRect.d.ts +0 -3
- package/dist/functions/browser/getElementRect.js +0 -14
- package/dist/functions/browser/getElementRect.js.map +0 -1
- package/dist/functions/browser/getFlipPlacements.d.ts +0 -2
- package/dist/functions/browser/getFlipPlacements.js +0 -13
- package/dist/functions/browser/getFlipPlacements.js.map +0 -1
- package/dist/functions/browser/getMainAxisFlip.d.ts +0 -2
- package/dist/functions/browser/getMainAxisFlip.js +0 -17
- package/dist/functions/browser/getMainAxisFlip.js.map +0 -1
- package/dist/functions/browser/getRelativePosition.d.ts +0 -3
- package/dist/functions/browser/getRelativePosition.js +0 -14
- package/dist/functions/browser/getRelativePosition.js.map +0 -1
- package/dist/functions/browser/getViewportRect.d.ts +0 -7
- package/dist/functions/browser/getViewportRect.js +0 -15
- package/dist/functions/browser/getViewportRect.js.map +0 -1
- package/dist/functions/browser/isValidPlacement.d.ts +0 -2
- package/dist/functions/browser/isValidPlacement.js +0 -16
- package/dist/functions/browser/isValidPlacement.js.map +0 -1
- package/dist/functions/browser/pickFile.d.ts +0 -15
- package/dist/functions/browser/pickFile.js +0 -48
- package/dist/functions/browser/pickFile.js.map +0 -1
- package/dist/functions/build/generateExports.d.ts +0 -26
- package/dist/functions/build/generateExports.js +0 -34
- package/dist/functions/build/generateExports.js.map +0 -1
- package/dist/functions/core/diff/diff.d.ts +0 -25
- package/dist/functions/core/diff/diff.js +0 -316
- package/dist/functions/core/diff/diff.js.map +0 -1
- package/dist/functions/core/diff/vueDiff.d.ts +0 -38
- package/dist/functions/core/diff/vueDiff.js +0 -333
- package/dist/functions/core/diff/vueDiff.js.map +0 -1
- package/dist/functions/core/generator/generatorUtils.d.ts +0 -16
- package/dist/functions/core/generator/generatorUtils.js +0 -139
- package/dist/functions/core/generator/generatorUtils.js.map +0 -1
- package/dist/functions/core/type/isType.d.ts +0 -11
- package/dist/functions/core/type/isType.js +0 -30
- package/dist/functions/core/type/isType.js.map +0 -1
- package/dist/functions/data/array-object/chunk.d.ts +0 -1
- package/dist/functions/data/array-object/chunk.js +0 -11
- package/dist/functions/data/array-object/chunk.js.map +0 -1
- package/dist/functions/data/array-object/deepClone.d.ts +0 -12
- package/dist/functions/data/array-object/deepClone.js +0 -131
- package/dist/functions/data/array-object/deepClone.js.map +0 -1
- package/dist/functions/data/array-object/evolve.d.ts +0 -3
- package/dist/functions/data/array-object/evolve.js +0 -15
- package/dist/functions/data/array-object/evolve.js.map +0 -1
- package/dist/functions/data/array-object/flatten.d.ts +0 -7
- package/dist/functions/data/array-object/flatten.js +0 -60
- package/dist/functions/data/array-object/flatten.js.map +0 -1
- package/dist/functions/data/array-object/flattenObject.d.ts +0 -5
- package/dist/functions/data/array-object/flattenObject.js +0 -102
- package/dist/functions/data/array-object/flattenObject.js.map +0 -1
- package/dist/functions/data/array-object/groupBy.d.ts +0 -1
- package/dist/functions/data/array-object/groupBy.js +0 -14
- package/dist/functions/data/array-object/groupBy.js.map +0 -1
- package/dist/functions/data/array-object/omit.d.ts +0 -1
- package/dist/functions/data/array-object/omit.js +0 -8
- package/dist/functions/data/array-object/omit.js.map +0 -1
- package/dist/functions/data/array-object/pick.d.ts +0 -1
- package/dist/functions/data/array-object/pick.js +0 -10
- package/dist/functions/data/array-object/pick.js.map +0 -1
- package/dist/functions/data/array-object/shuffle.d.ts +0 -1
- package/dist/functions/data/array-object/shuffle.js +0 -9
- package/dist/functions/data/array-object/shuffle.js.map +0 -1
- package/dist/functions/data/array-object/sortBy.d.ts +0 -1
- package/dist/functions/data/array-object/sortBy.js +0 -13
- package/dist/functions/data/array-object/sortBy.js.map +0 -1
- package/dist/functions/data/array-object/unique.d.ts +0 -10
- package/dist/functions/data/array-object/unique.js +0 -85
- package/dist/functions/data/array-object/unique.js.map +0 -1
- package/dist/functions/data/date/dateRange.d.ts +0 -1
- package/dist/functions/data/date/dateRange.js +0 -18
- package/dist/functions/data/date/dateRange.js.map +0 -1
- package/dist/functions/data/date/formatDate.d.ts +0 -1
- package/dist/functions/data/date/formatDate.js +0 -21
- package/dist/functions/data/date/formatDate.js.map +0 -1
- package/dist/functions/data/date/timeAgo.d.ts +0 -1
- package/dist/functions/data/date/timeAgo.js +0 -49
- package/dist/functions/data/date/timeAgo.js.map +0 -1
- package/dist/functions/data/number/average.d.ts +0 -1
- package/dist/functions/data/number/average.js +0 -8
- package/dist/functions/data/number/average.js.map +0 -1
- package/dist/functions/data/number/clamp.d.ts +0 -1
- package/dist/functions/data/number/clamp.js +0 -7
- package/dist/functions/data/number/clamp.js.map +0 -1
- package/dist/functions/data/number/formatNumber.d.ts +0 -8
- package/dist/functions/data/number/formatNumber.js +0 -16
- package/dist/functions/data/number/formatNumber.js.map +0 -1
- package/dist/functions/data/number/median.d.ts +0 -1
- package/dist/functions/data/number/median.js +0 -14
- package/dist/functions/data/number/median.js.map +0 -1
- package/dist/functions/data/number/percentile.d.ts +0 -1
- package/dist/functions/data/number/percentile.js +0 -18
- package/dist/functions/data/number/percentile.js.map +0 -1
- package/dist/functions/data/number/random.d.ts +0 -4
- package/dist/functions/data/number/random.js +0 -9
- package/dist/functions/data/number/random.js.map +0 -1
- package/dist/functions/data/number/range.d.ts +0 -1
- package/dist/functions/data/number/range.js +0 -18
- package/dist/functions/data/number/range.js.map +0 -1
- package/dist/functions/data/number/sum.d.ts +0 -1
- package/dist/functions/data/number/sum.js +0 -4
- package/dist/functions/data/number/sum.js.map +0 -1
- package/dist/functions/data/randomRegion.d.ts +0 -24
- package/dist/functions/data/randomRegion.js +0 -74
- package/dist/functions/data/randomRegion.js.map +0 -1
- package/dist/functions/data/string/base64.d.ts +0 -5
- package/dist/functions/data/string/base64.js +0 -6
- package/dist/functions/data/string/base64.js.map +0 -1
- package/dist/functions/data/string/capitalize.d.ts +0 -1
- package/dist/functions/data/string/capitalize.js +0 -6
- package/dist/functions/data/string/capitalize.js.map +0 -1
- package/dist/functions/data/string/caseConverter.d.ts +0 -19
- package/dist/functions/data/string/caseConverter.js +0 -94
- package/dist/functions/data/string/caseConverter.js.map +0 -1
- package/dist/functions/data/string/desensitize.d.ts +0 -13
- package/dist/functions/data/string/desensitize.js +0 -107
- package/dist/functions/data/string/desensitize.js.map +0 -1
- package/dist/functions/data/string/htmlEscape.d.ts +0 -20
- package/dist/functions/data/string/htmlEscape.js +0 -80
- package/dist/functions/data/string/htmlEscape.js.map +0 -1
- package/dist/functions/data/string/levenshtein.d.ts +0 -1
- package/dist/functions/data/string/levenshtein.js +0 -27
- package/dist/functions/data/string/levenshtein.js.map +0 -1
- package/dist/functions/data/string/normalize.d.ts +0 -8
- package/dist/functions/data/string/normalize.js +0 -37
- package/dist/functions/data/string/normalize.js.map +0 -1
- package/dist/functions/data/string/pad.d.ts +0 -13
- package/dist/functions/data/string/pad.js +0 -50
- package/dist/functions/data/string/pad.js.map +0 -1
- package/dist/functions/data/string/palindrome.d.ts +0 -3
- package/dist/functions/data/string/palindrome.js +0 -15
- package/dist/functions/data/string/palindrome.js.map +0 -1
- package/dist/functions/data/string/similarity.d.ts +0 -1
- package/dist/functions/data/string/similarity.js +0 -13
- package/dist/functions/data/string/similarity.js.map +0 -1
- package/dist/functions/data/string/template.d.ts +0 -4
- package/dist/functions/data/string/template.js +0 -21
- package/dist/functions/data/string/template.js.map +0 -1
- package/dist/functions/data/string/testRegex.d.ts +0 -20
- package/dist/functions/data/string/testRegex.js +0 -300
- package/dist/functions/data/string/testRegex.js.map +0 -1
- package/dist/functions/data/string/wordCount.d.ts +0 -5
- package/dist/functions/data/string/wordCount.js +0 -11
- package/dist/functions/data/string/wordCount.js.map +0 -1
- package/dist/functions/data/tree/buildTree.d.ts +0 -7
- package/dist/functions/data/tree/buildTree.js +0 -27
- package/dist/functions/data/tree/buildTree.js.map +0 -1
- package/dist/functions/data/tree/filterTree.d.ts +0 -4
- package/dist/functions/data/tree/filterTree.js +0 -21
- package/dist/functions/data/tree/filterTree.js.map +0 -1
- package/dist/functions/data/tree/findNode.d.ts +0 -4
- package/dist/functions/data/tree/findNode.js +0 -21
- package/dist/functions/data/tree/findNode.js.map +0 -1
- package/dist/functions/data/tree/flattenTree.d.ts +0 -6
- package/dist/functions/data/tree/flattenTree.js +0 -21
- package/dist/functions/data/tree/flattenTree.js.map +0 -1
- package/dist/functions/file/walk.d.ts +0 -18
- package/dist/functions/file/walk.js +0 -58
- package/dist/functions/file/walk.js.map +0 -1
- package/dist/functions/hybrid/detectBridgeEnvironment.d.ts +0 -11
- package/dist/functions/hybrid/detectBridgeEnvironment.js +0 -26
- package/dist/functions/hybrid/detectBridgeEnvironment.js.map +0 -1
- package/dist/functions/integrations/ag-grid/generateLicense.d.ts +0 -7
- package/dist/functions/integrations/ag-grid/generateLicense.js +0 -12
- package/dist/functions/integrations/ag-grid/generateLicense.js.map +0 -1
- package/dist/functions/integrations/uniapp/app-plus/buildAndroidApp.d.ts +0 -30
- package/dist/functions/integrations/uniapp/app-plus/buildAndroidApp.js +0 -884
- package/dist/functions/integrations/uniapp/app-plus/buildAndroidApp.js.map +0 -1
- package/dist/functions/integrations/uniapp/app-plus/buildIOSApp.d.ts +0 -31
- package/dist/functions/integrations/uniapp/app-plus/buildIOSApp.js +0 -900
- package/dist/functions/integrations/uniapp/app-plus/buildIOSApp.js.map +0 -1
- package/dist/functions/integrations/uniapp/build.d.ts +0 -21
- package/dist/functions/integrations/uniapp/build.js +0 -83
- package/dist/functions/integrations/uniapp/build.js.map +0 -1
- package/dist/functions/integrations/uniapp/detectAndroidProjectStructure.d.ts +0 -11
- package/dist/functions/integrations/uniapp/detectAndroidProjectStructure.js +0 -30
- package/dist/functions/integrations/uniapp/detectAndroidProjectStructure.js.map +0 -1
- package/dist/functions/integrations/uniapp/detectProjectType.d.ts +0 -20
- package/dist/functions/integrations/uniapp/detectProjectType.js +0 -68
- package/dist/functions/integrations/uniapp/detectProjectType.js.map +0 -1
- package/dist/functions/integrations/uniapp/parseManifest.d.ts +0 -20
- package/dist/functions/integrations/uniapp/parseManifest.js +0 -51
- package/dist/functions/integrations/uniapp/parseManifest.js.map +0 -1
- package/dist/functions/integrations/uniapp/waitForPages.d.ts +0 -7
- package/dist/functions/integrations/uniapp/waitForPages.js +0 -20
- package/dist/functions/integrations/uniapp/waitForPages.js.map +0 -1
- package/dist/functions/integrations/vue/dynamicMount.d.ts +0 -18
- package/dist/functions/integrations/vue/dynamicMount.js +0 -25
- package/dist/functions/integrations/vue/dynamicMount.js.map +0 -1
- package/dist/functions/integrations/vue/extractColorsFromVueFile.d.ts +0 -3
- package/dist/functions/integrations/vue/extractColorsFromVueFile.js +0 -18
- package/dist/functions/integrations/vue/extractColorsFromVueFile.js.map +0 -1
- package/dist/functions/integrations/vue/extractColorsFromVueSection.d.ts +0 -3
- package/dist/functions/integrations/vue/extractColorsFromVueSection.js +0 -53
- package/dist/functions/integrations/vue/extractColorsFromVueSection.js.map +0 -1
- package/dist/functions/integrations/vue/filterSections.d.ts +0 -2
- package/dist/functions/integrations/vue/filterSections.js +0 -11
- package/dist/functions/integrations/vue/filterSections.js.map +0 -1
- package/dist/functions/integrations/vue/isVNode.d.ts +0 -2
- package/dist/functions/integrations/vue/isVNode.js +0 -6
- package/dist/functions/integrations/vue/isVNode.js.map +0 -1
- package/dist/functions/integrations/vue/isVueComponent.d.ts +0 -2
- package/dist/functions/integrations/vue/isVueComponent.js +0 -6
- package/dist/functions/integrations/vue/isVueComponent.js.map +0 -1
- package/dist/functions/integrations/vue/parseVueFile.d.ts +0 -2
- package/dist/functions/integrations/vue/parseVueFile.js +0 -53
- package/dist/functions/integrations/vue/parseVueFile.js.map +0 -1
- package/dist/functions/integrations/wechat/miniapp/downloadFile.d.ts +0 -6
- package/dist/functions/integrations/wechat/miniapp/downloadFile.js +0 -39
- package/dist/functions/integrations/wechat/miniapp/downloadFile.js.map +0 -1
- package/dist/functions/patterns/MyPromise.d.ts +0 -32
- package/dist/functions/patterns/MyPromise.js +0 -254
- package/dist/functions/patterns/MyPromise.js.map +0 -1
- package/dist/functions/patterns/functionBind.d.ts +0 -4
- package/dist/functions/patterns/functionBind.js +0 -33
- package/dist/functions/patterns/functionBind.js.map +0 -1
- package/dist/functions/patterns/myInstanceof.d.ts +0 -5
- package/dist/functions/patterns/myInstanceof.js +0 -56
- package/dist/functions/patterns/myInstanceof.js.map +0 -1
- package/dist/functions/patterns/myNew.d.ts +0 -3
- package/dist/functions/patterns/myNew.js +0 -19
- package/dist/functions/patterns/myNew.js.map +0 -1
- package/dist/functions/platform/android/buildProject.d.ts +0 -13
- package/dist/functions/platform/android/buildProject.js +0 -122
- package/dist/functions/platform/android/buildProject.js.map +0 -1
- package/dist/functions/platform/android/configureAppIcon.d.ts +0 -17
- package/dist/functions/platform/android/configureAppIcon.js +0 -106
- package/dist/functions/platform/android/configureAppIcon.js.map +0 -1
- package/dist/functions/platform/android/configureLaunchScreen.d.ts +0 -21
- package/dist/functions/platform/android/configureLaunchScreen.js +0 -328
- package/dist/functions/platform/android/configureLaunchScreen.js.map +0 -1
- package/dist/functions/platform/android/detectAndroidModules.d.ts +0 -8
- package/dist/functions/platform/android/detectAndroidModules.js +0 -21
- package/dist/functions/platform/android/detectAndroidModules.js.map +0 -1
- package/dist/functions/platform/android/integrateFacebookLogin.d.ts +0 -12
- package/dist/functions/platform/android/integrateFacebookLogin.js +0 -91
- package/dist/functions/platform/android/integrateFacebookLogin.js.map +0 -1
- package/dist/functions/platform/android/integrateGoogleLogin.d.ts +0 -10
- package/dist/functions/platform/android/integrateGoogleLogin.js +0 -199
- package/dist/functions/platform/android/integrateGoogleLogin.js.map +0 -1
- package/dist/functions/platform/android/integrateMiuiLogin.d.ts +0 -13
- package/dist/functions/platform/android/integrateMiuiLogin.js +0 -115
- package/dist/functions/platform/android/integrateMiuiLogin.js.map +0 -1
- package/dist/functions/platform/android/integrateQQLogin.d.ts +0 -12
- package/dist/functions/platform/android/integrateQQLogin.js +0 -130
- package/dist/functions/platform/android/integrateQQLogin.js.map +0 -1
- package/dist/functions/platform/android/integrateShareTrace.d.ts +0 -10
- package/dist/functions/platform/android/integrateShareTrace.js +0 -181
- package/dist/functions/platform/android/integrateShareTrace.js.map +0 -1
- package/dist/functions/platform/android/integrateSinaLogin.d.ts +0 -13
- package/dist/functions/platform/android/integrateSinaLogin.js +0 -85
- package/dist/functions/platform/android/integrateSinaLogin.js.map +0 -1
- package/dist/functions/platform/android/integrateThirdPartyModule.d.ts +0 -46
- package/dist/functions/platform/android/integrateThirdPartyModule.js +0 -251
- package/dist/functions/platform/android/integrateThirdPartyModule.js.map +0 -1
- package/dist/functions/platform/android/integrateUniAppNativePlugin.d.ts +0 -22
- package/dist/functions/platform/android/integrateUniAppNativePlugin.js +0 -631
- package/dist/functions/platform/android/integrateUniAppNativePlugin.js.map +0 -1
- package/dist/functions/platform/android/integrateUniverifyLogin.d.ts +0 -11
- package/dist/functions/platform/android/integrateUniverifyLogin.js +0 -314
- package/dist/functions/platform/android/integrateUniverifyLogin.js.map +0 -1
- package/dist/functions/platform/android/integrateWechatLogin.d.ts +0 -13
- package/dist/functions/platform/android/integrateWechatLogin.js +0 -154
- package/dist/functions/platform/android/integrateWechatLogin.js.map +0 -1
- package/dist/functions/platform/android/integrateWechatShare.d.ts +0 -13
- package/dist/functions/platform/android/integrateWechatShare.js +0 -154
- package/dist/functions/platform/android/integrateWechatShare.js.map +0 -1
- package/dist/functions/platform/android/modifyGradle.d.ts +0 -28
- package/dist/functions/platform/android/modifyGradle.js +0 -119
- package/dist/functions/platform/android/modifyGradle.js.map +0 -1
- package/dist/functions/platform/android/modifyManifest.d.ts +0 -39
- package/dist/functions/platform/android/modifyManifest.js +0 -225
- package/dist/functions/platform/android/modifyManifest.js.map +0 -1
- package/dist/functions/platform/android/permission.d.ts +0 -54
- package/dist/functions/platform/android/permission.js +0 -85
- package/dist/functions/platform/android/permission.js.map +0 -1
- package/dist/functions/platform/ios/configureAppIcon.d.ts +0 -17
- package/dist/functions/platform/ios/configureAppIcon.js +0 -149
- package/dist/functions/platform/ios/configureAppIcon.js.map +0 -1
- package/dist/functions/platform/ios/configureLaunchScreen.d.ts +0 -17
- package/dist/functions/platform/ios/configureLaunchScreen.js +0 -150
- package/dist/functions/platform/ios/configureLaunchScreen.js.map +0 -1
- package/dist/functions/platform/ios/configurePermissions.d.ts +0 -19
- package/dist/functions/platform/ios/configurePermissions.js +0 -120
- package/dist/functions/platform/ios/configurePermissions.js.map +0 -1
- package/dist/functions/platform/ios/integrateNativePlugin.d.ts +0 -35
- package/dist/functions/platform/ios/integrateNativePlugin.js +0 -994
- package/dist/functions/platform/ios/integrateNativePlugin.js.map +0 -1
- package/dist/functions/platform/ios/integrateQQShare.d.ts +0 -14
- package/dist/functions/platform/ios/integrateQQShare.js +0 -132
- package/dist/functions/platform/ios/integrateQQShare.js.map +0 -1
- package/dist/functions/platform/ios/integrateSinaShare.d.ts +0 -16
- package/dist/functions/platform/ios/integrateSinaShare.js +0 -108
- package/dist/functions/platform/ios/integrateSinaShare.js.map +0 -1
- package/dist/functions/platform/ios/integrateThirdPartyModule.d.ts +0 -62
- package/dist/functions/platform/ios/integrateThirdPartyModule.js +0 -883
- package/dist/functions/platform/ios/integrateThirdPartyModule.js.map +0 -1
- package/dist/functions/platform/ios/integrateWechatOauth.d.ts +0 -14
- package/dist/functions/platform/ios/integrateWechatOauth.js +0 -107
- package/dist/functions/platform/ios/integrateWechatOauth.js.map +0 -1
- package/dist/functions/platform/ios/integrateWechatShare.d.ts +0 -14
- package/dist/functions/platform/ios/integrateWechatShare.js +0 -101
- package/dist/functions/platform/ios/integrateWechatShare.js.map +0 -1
- package/dist/functions/platform/ios/modifyInfoPlistKeyValue.d.ts +0 -2
- package/dist/functions/platform/ios/modifyInfoPlistKeyValue.js +0 -45
- package/dist/functions/platform/ios/modifyInfoPlistKeyValue.js.map +0 -1
- package/dist/functions/platform/ios/safelyModifyProjectPbxproj.d.ts +0 -16
- package/dist/functions/platform/ios/safelyModifyProjectPbxproj.js +0 -136
- package/dist/functions/platform/ios/safelyModifyProjectPbxproj.js.map +0 -1
- package/dist/functions/platform/ios/useAltool.d.ts +0 -39
- package/dist/functions/platform/ios/useAltool.js +0 -350
- package/dist/functions/platform/ios/useAltool.js.map +0 -1
- package/dist/functions/style/buildTokens.d.ts +0 -76
- package/dist/functions/style/buildTokens.js +0 -183
- package/dist/functions/style/buildTokens.js.map +0 -1
- package/dist/functions/style/extractCssVariables.d.ts +0 -16
- package/dist/functions/style/extractCssVariables.js +0 -256
- package/dist/functions/style/extractCssVariables.js.map +0 -1
- package/dist/functions/style/generateVariables.d.ts +0 -7
- package/dist/functions/style/generateVariables.js +0 -135
- package/dist/functions/style/generateVariables.js.map +0 -1
- package/dist/functions/style/mixColors.d.ts +0 -1
- package/dist/functions/style/mixColors.js +0 -38
- package/dist/functions/style/mixColors.js.map +0 -1
- package/dist/functions/style/parseDesignTokens.d.ts +0 -10
- package/dist/functions/style/parseDesignTokens.js +0 -216
- package/dist/functions/style/parseDesignTokens.js.map +0 -1
- package/dist/functions/uniapp/app-plus/buildAndroidPlugin.d.ts +0 -3
- package/dist/functions/uniapp/app-plus/buildAndroidPlugin.js +0 -509
- package/dist/functions/uniapp/app-plus/buildAndroidPlugin.js.map +0 -1
- package/dist/functions/uniapp/app-plus/buildIOSPlugin.d.ts +0 -3
- package/dist/functions/uniapp/app-plus/buildIOSPlugin.js +0 -406
- package/dist/functions/uniapp/app-plus/buildIOSPlugin.js.map +0 -1
- package/dist/functions/validation/parseJwtPayload.d.ts +0 -7
- package/dist/functions/validation/parseJwtPayload.js +0 -33
- package/dist/functions/validation/parseJwtPayload.js.map +0 -1
- package/dist/functions/validation/validate.d.ts +0 -11
- package/dist/functions/validation/validate.js +0 -44
- package/dist/functions/validation/validate.js.map +0 -1
|
@@ -1,994 +0,0 @@
|
|
|
1
|
-
import { addFileToXcodeProject, addFileToEmbedFrameworks, } from "./integrateThirdPartyModule";
|
|
2
|
-
async function extractPlugin(pluginPath, extractDir, deps) {
|
|
3
|
-
try {
|
|
4
|
-
if (deps.existsSync(pluginPath)) {
|
|
5
|
-
const stat = deps.statSync(pluginPath);
|
|
6
|
-
if (stat.isDirectory()) {
|
|
7
|
-
deps.log?.("插件是目录,直接使用");
|
|
8
|
-
return {
|
|
9
|
-
success: true,
|
|
10
|
-
extractedPath: pluginPath,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
if (pluginPath.endsWith(".zip")) {
|
|
15
|
-
const pluginName = deps.basename(pluginPath, ".zip");
|
|
16
|
-
const targetDir = deps.join(extractDir, pluginName);
|
|
17
|
-
if (deps.existsSync(targetDir)) {
|
|
18
|
-
deps.log?.(`插件已解压过,使用现有目录: ${targetDir}`);
|
|
19
|
-
return {
|
|
20
|
-
success: true,
|
|
21
|
-
extractedPath: targetDir,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
if (!deps.existsSync(extractDir)) {
|
|
25
|
-
deps.mkdirSync(extractDir, { recursive: true });
|
|
26
|
-
}
|
|
27
|
-
deps.log?.(`开始解压插件: ${pluginPath}`);
|
|
28
|
-
deps.log?.(`解压到目录: ${extractDir}`);
|
|
29
|
-
return new Promise((resolve) => {
|
|
30
|
-
let resolved = false;
|
|
31
|
-
let timeoutId;
|
|
32
|
-
const child = deps.exec(`unzip -q "${pluginPath}" -d "${extractDir}"`, (error, stdout, stderr) => {
|
|
33
|
-
if (resolved)
|
|
34
|
-
return;
|
|
35
|
-
resolved = true;
|
|
36
|
-
if (timeoutId !== undefined) {
|
|
37
|
-
deps.clearTimeout(timeoutId);
|
|
38
|
-
}
|
|
39
|
-
if (error) {
|
|
40
|
-
deps.log?.(`解压失败: ${error.message}`);
|
|
41
|
-
if (stderr)
|
|
42
|
-
deps.log?.(`错误输出: ${stderr}`);
|
|
43
|
-
resolve({
|
|
44
|
-
success: false,
|
|
45
|
-
error: `解压插件失败: ${error.message}`,
|
|
46
|
-
});
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
deps.log?.("解压完成,查找解压后的目录...");
|
|
50
|
-
const files = deps.readdirSync(extractDir);
|
|
51
|
-
if (files.length === 0) {
|
|
52
|
-
deps.log?.("解压后未找到任何文件");
|
|
53
|
-
resolve({
|
|
54
|
-
success: false,
|
|
55
|
-
error: "解压后未找到插件文件",
|
|
56
|
-
});
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const extractedPath = deps.join(extractDir, files[0]);
|
|
60
|
-
deps.log?.(`找到解压后的目录: ${extractedPath}`);
|
|
61
|
-
resolve({
|
|
62
|
-
success: true,
|
|
63
|
-
extractedPath,
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
timeoutId = deps.setTimeout(() => {
|
|
67
|
-
if (resolved)
|
|
68
|
-
return;
|
|
69
|
-
resolved = true;
|
|
70
|
-
child.kill();
|
|
71
|
-
deps.log?.("解压超时(30秒)");
|
|
72
|
-
resolve({
|
|
73
|
-
success: false,
|
|
74
|
-
error: "解压插件超时",
|
|
75
|
-
});
|
|
76
|
-
}, 30000);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
success: false,
|
|
81
|
-
error: `不支持的插件格式: ${pluginPath}`,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
return {
|
|
86
|
-
success: false,
|
|
87
|
-
error: `解压插件异常: ${error instanceof Error ? error.message : String(error)}`,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function readPluginPackageJson(pluginDir, deps) {
|
|
92
|
-
try {
|
|
93
|
-
const packageJsonPath = deps.join(pluginDir, "package.json");
|
|
94
|
-
if (!deps.existsSync(packageJsonPath)) {
|
|
95
|
-
return {
|
|
96
|
-
success: false,
|
|
97
|
-
error: `插件 package.json 不存在: ${packageJsonPath}`,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const content = deps.readFileSync(packageJsonPath, "utf8");
|
|
101
|
-
const packageJson = deps.parse(content);
|
|
102
|
-
return {
|
|
103
|
-
success: true,
|
|
104
|
-
packageJson,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
return {
|
|
109
|
-
success: false,
|
|
110
|
-
error: `读取插件 package.json 失败: ${error instanceof Error ? error.message : String(error)}`,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function extractIOSPluginConfig(packageJson) {
|
|
115
|
-
try {
|
|
116
|
-
const iosConfig = packageJson._dp_nativeplugin?.ios;
|
|
117
|
-
if (!iosConfig) {
|
|
118
|
-
return {
|
|
119
|
-
success: false,
|
|
120
|
-
error: "package.json 中未找到 _dp_nativeplugin.ios 配置",
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
const plugins = iosConfig.plugins;
|
|
124
|
-
if (!plugins || !Array.isArray(plugins) || plugins.length === 0) {
|
|
125
|
-
return {
|
|
126
|
-
success: false,
|
|
127
|
-
error: "package.json 中未找到有效的 plugins 配置",
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
const pluginItems = [];
|
|
131
|
-
for (const plugin of plugins) {
|
|
132
|
-
if (plugin.type && plugin.name && plugin.class) {
|
|
133
|
-
pluginItems.push({
|
|
134
|
-
type: plugin.type,
|
|
135
|
-
name: plugin.name,
|
|
136
|
-
class: plugin.class,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (pluginItems.length === 0) {
|
|
141
|
-
return {
|
|
142
|
-
success: false,
|
|
143
|
-
error: "package.json 中未找到有效的插件配置",
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
const hooksClass = iosConfig.hooksClass || "";
|
|
147
|
-
const frameworks = iosConfig.frameworks || [];
|
|
148
|
-
const embedFrameworks = iosConfig.embedFrameworks || [];
|
|
149
|
-
const resources = iosConfig.resources || [];
|
|
150
|
-
const privacies = iosConfig.privacies || [];
|
|
151
|
-
let parameters = undefined;
|
|
152
|
-
if (iosConfig.parameters && typeof iosConfig.parameters === "object") {
|
|
153
|
-
parameters = {};
|
|
154
|
-
for (const [paramName, paramConfig] of Object.entries(iosConfig.parameters)) {
|
|
155
|
-
if (paramConfig &&
|
|
156
|
-
typeof paramConfig === "object" &&
|
|
157
|
-
"key" in paramConfig) {
|
|
158
|
-
parameters[paramName] = {
|
|
159
|
-
key: paramConfig.key,
|
|
160
|
-
des: paramConfig.des || "",
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
success: true,
|
|
167
|
-
plugins: pluginItems,
|
|
168
|
-
hooksClass,
|
|
169
|
-
frameworks,
|
|
170
|
-
embedFrameworks,
|
|
171
|
-
resources,
|
|
172
|
-
privacies,
|
|
173
|
-
parameters,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
catch (error) {
|
|
177
|
-
return {
|
|
178
|
-
success: false,
|
|
179
|
-
error: `提取插件配置失败: ${error instanceof Error ? error.message : String(error)}`,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function addPluginToInfoPlist(xmlDoc, pluginItems, hooksClass) {
|
|
184
|
-
const dictElement = xmlDoc.getElementsByTagName("dict")[0];
|
|
185
|
-
if (!dictElement)
|
|
186
|
-
return false;
|
|
187
|
-
let unipluginsKey = null;
|
|
188
|
-
let unipluginsArray = null;
|
|
189
|
-
const childNodes = Array.from(dictElement.childNodes || []).filter((node) => node.nodeType === 1);
|
|
190
|
-
for (let i = 0; i < childNodes.length; i++) {
|
|
191
|
-
const node = childNodes[i];
|
|
192
|
-
if (node.nodeName === "key" && node.textContent === "dcloud_uniplugins") {
|
|
193
|
-
unipluginsKey = node;
|
|
194
|
-
if (i + 1 < childNodes.length && childNodes[i + 1].nodeName === "array") {
|
|
195
|
-
unipluginsArray = childNodes[i + 1];
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if (!unipluginsArray) {
|
|
201
|
-
if (!unipluginsKey) {
|
|
202
|
-
unipluginsKey = xmlDoc.createElement("key");
|
|
203
|
-
unipluginsKey.textContent = "dcloud_uniplugins";
|
|
204
|
-
dictElement.appendChild(unipluginsKey);
|
|
205
|
-
}
|
|
206
|
-
unipluginsArray = xmlDoc.createElement("array");
|
|
207
|
-
dictElement.appendChild(unipluginsArray);
|
|
208
|
-
}
|
|
209
|
-
const pluginDict = xmlDoc.createElement("dict");
|
|
210
|
-
const hooksClassKey = xmlDoc.createElement("key");
|
|
211
|
-
hooksClassKey.textContent = "hooksClass";
|
|
212
|
-
const hooksClassValue = xmlDoc.createElement("string");
|
|
213
|
-
hooksClassValue.textContent = hooksClass;
|
|
214
|
-
pluginDict.appendChild(hooksClassKey);
|
|
215
|
-
pluginDict.appendChild(hooksClassValue);
|
|
216
|
-
const pluginsKey = xmlDoc.createElement("key");
|
|
217
|
-
pluginsKey.textContent = "plugins";
|
|
218
|
-
const pluginsArray = xmlDoc.createElement("array");
|
|
219
|
-
for (const plugin of pluginItems) {
|
|
220
|
-
const itemDict = xmlDoc.createElement("dict");
|
|
221
|
-
const typeKey = xmlDoc.createElement("key");
|
|
222
|
-
typeKey.textContent = "type";
|
|
223
|
-
const typeValue = xmlDoc.createElement("string");
|
|
224
|
-
typeValue.textContent = plugin.type;
|
|
225
|
-
itemDict.appendChild(typeKey);
|
|
226
|
-
itemDict.appendChild(typeValue);
|
|
227
|
-
const nameKey = xmlDoc.createElement("key");
|
|
228
|
-
nameKey.textContent = "name";
|
|
229
|
-
const nameValue = xmlDoc.createElement("string");
|
|
230
|
-
nameValue.textContent = plugin.name;
|
|
231
|
-
itemDict.appendChild(nameKey);
|
|
232
|
-
itemDict.appendChild(nameValue);
|
|
233
|
-
const classKey = xmlDoc.createElement("key");
|
|
234
|
-
classKey.textContent = "class";
|
|
235
|
-
const classValue = xmlDoc.createElement("string");
|
|
236
|
-
classValue.textContent = plugin.class;
|
|
237
|
-
itemDict.appendChild(classKey);
|
|
238
|
-
itemDict.appendChild(classValue);
|
|
239
|
-
pluginsArray.appendChild(itemDict);
|
|
240
|
-
}
|
|
241
|
-
pluginDict.appendChild(pluginsKey);
|
|
242
|
-
pluginDict.appendChild(pluginsArray);
|
|
243
|
-
unipluginsArray.appendChild(pluginDict);
|
|
244
|
-
return true;
|
|
245
|
-
}
|
|
246
|
-
function addPluginParametersToInfoPlist(xmlDoc, parameters, parameterValues) {
|
|
247
|
-
const dictElement = xmlDoc.getElementsByTagName("dict")[0];
|
|
248
|
-
if (!dictElement)
|
|
249
|
-
return false;
|
|
250
|
-
for (const [paramName, paramConfig] of Object.entries(parameters)) {
|
|
251
|
-
const value = parameterValues[paramName];
|
|
252
|
-
if (!value)
|
|
253
|
-
continue;
|
|
254
|
-
const key = paramConfig.key;
|
|
255
|
-
const keys = key.split(":");
|
|
256
|
-
if (keys.length === 1) {
|
|
257
|
-
const keyElement = xmlDoc.createElement("key");
|
|
258
|
-
keyElement.textContent = keys[0];
|
|
259
|
-
const valueElement = xmlDoc.createElement("string");
|
|
260
|
-
valueElement.textContent = value;
|
|
261
|
-
dictElement.appendChild(keyElement);
|
|
262
|
-
dictElement.appendChild(valueElement);
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
const parentKey = keys[0];
|
|
266
|
-
const childKey = keys[1];
|
|
267
|
-
let parentDict = null;
|
|
268
|
-
const childNodes = Array.from(dictElement.childNodes || []).filter((node) => node.nodeType === 1);
|
|
269
|
-
for (let i = 0; i < childNodes.length; i++) {
|
|
270
|
-
const node = childNodes[i];
|
|
271
|
-
if (node.nodeName === "key" && node.textContent === parentKey) {
|
|
272
|
-
if (i + 1 < childNodes.length &&
|
|
273
|
-
childNodes[i + 1].nodeName === "dict") {
|
|
274
|
-
parentDict = childNodes[i + 1];
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (!parentDict) {
|
|
280
|
-
const parentKeyElement = xmlDoc.createElement("key");
|
|
281
|
-
parentKeyElement.textContent = parentKey;
|
|
282
|
-
parentDict = xmlDoc.createElement("dict");
|
|
283
|
-
dictElement.appendChild(parentKeyElement);
|
|
284
|
-
dictElement.appendChild(parentDict);
|
|
285
|
-
}
|
|
286
|
-
const childKeyElement = xmlDoc.createElement("key");
|
|
287
|
-
childKeyElement.textContent = childKey;
|
|
288
|
-
const childValueElement = xmlDoc.createElement("string");
|
|
289
|
-
childValueElement.textContent = value;
|
|
290
|
-
parentDict.appendChild(childKeyElement);
|
|
291
|
-
parentDict.appendChild(childValueElement);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return true;
|
|
295
|
-
}
|
|
296
|
-
function addPrivaciesToInfoPlist(xmlDoc, privacies) {
|
|
297
|
-
const dictElement = xmlDoc.getElementsByTagName("dict")[0];
|
|
298
|
-
if (!dictElement)
|
|
299
|
-
return false;
|
|
300
|
-
for (const privacy of privacies) {
|
|
301
|
-
const keyElements = xmlDoc.getElementsByTagName("key");
|
|
302
|
-
let found = false;
|
|
303
|
-
for (let i = 0; i < keyElements.length; i++) {
|
|
304
|
-
const keyElement = keyElements[i];
|
|
305
|
-
if (keyElement.textContent === privacy) {
|
|
306
|
-
found = true;
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
if (!found) {
|
|
311
|
-
const keyElement = xmlDoc.createElement("key");
|
|
312
|
-
keyElement.textContent = privacy;
|
|
313
|
-
const valueElement = xmlDoc.createElement("string");
|
|
314
|
-
valueElement.textContent = "应用需要使用此功能";
|
|
315
|
-
dictElement.appendChild(keyElement);
|
|
316
|
-
dictElement.appendChild(valueElement);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return true;
|
|
320
|
-
}
|
|
321
|
-
function findFilesRecursive(dir, extensions, deps, depth = 0) {
|
|
322
|
-
const result = [];
|
|
323
|
-
const maxDepth = 10;
|
|
324
|
-
if (!deps.existsSync(dir)) {
|
|
325
|
-
return result;
|
|
326
|
-
}
|
|
327
|
-
const bundleExtensions = [".framework", ".xcframework", ".app", ".bundle"];
|
|
328
|
-
if (depth > maxDepth) {
|
|
329
|
-
return result;
|
|
330
|
-
}
|
|
331
|
-
try {
|
|
332
|
-
const files = deps.readdirSync(dir);
|
|
333
|
-
for (const file of files) {
|
|
334
|
-
const filePath = deps.join(dir, file);
|
|
335
|
-
try {
|
|
336
|
-
const stat = deps.statSync(filePath);
|
|
337
|
-
if (stat.isDirectory()) {
|
|
338
|
-
let matchesExtension = false;
|
|
339
|
-
let isBundle = false;
|
|
340
|
-
for (const ext of extensions) {
|
|
341
|
-
if (file.endsWith(ext)) {
|
|
342
|
-
matchesExtension = true;
|
|
343
|
-
isBundle = bundleExtensions.includes(ext);
|
|
344
|
-
result.push(filePath);
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
if (!matchesExtension || !isBundle) {
|
|
349
|
-
if (!matchesExtension) {
|
|
350
|
-
result.push(...findFilesRecursive(filePath, extensions, deps, depth + 1));
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
for (const ext of extensions) {
|
|
356
|
-
if (file.endsWith(ext)) {
|
|
357
|
-
result.push(filePath);
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
catch (error) {
|
|
364
|
-
continue;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
catch (error) {
|
|
369
|
-
}
|
|
370
|
-
return result;
|
|
371
|
-
}
|
|
372
|
-
async function copyFrameworkUsingArchive(sourcePath, targetPath, deps, logFn) {
|
|
373
|
-
const log = (msg) => {
|
|
374
|
-
const message = `[copyFramework] ${msg}`;
|
|
375
|
-
if (logFn)
|
|
376
|
-
logFn(message);
|
|
377
|
-
};
|
|
378
|
-
try {
|
|
379
|
-
log(`开始复制 framework: ${deps.basename(sourcePath)}`);
|
|
380
|
-
log(` 源路径: ${sourcePath}`);
|
|
381
|
-
log(` 目标路径: ${targetPath}`);
|
|
382
|
-
const targetDir = deps.dirname(targetPath);
|
|
383
|
-
const tempDir = deps.join(targetDir, ".temp_framework_copy");
|
|
384
|
-
log(` 临时目录: ${tempDir}`);
|
|
385
|
-
if (deps.existsSync(tempDir)) {
|
|
386
|
-
log(` 清理已存在的临时目录...`);
|
|
387
|
-
await new Promise((resolve) => {
|
|
388
|
-
deps.exec(`rm -rf "${tempDir}"`, (error) => {
|
|
389
|
-
if (error) {
|
|
390
|
-
log(` 警告: 清理临时目录失败: ${error.message}`);
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
log(` 临时目录已清理`);
|
|
394
|
-
}
|
|
395
|
-
resolve();
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
if (!deps.existsSync(tempDir)) {
|
|
400
|
-
log(` 创建临时目录...`);
|
|
401
|
-
deps.mkdirSync(tempDir, { recursive: true });
|
|
402
|
-
}
|
|
403
|
-
const frameworkName = deps.basename(sourcePath);
|
|
404
|
-
const archiveName = `${frameworkName}.tar.gz`;
|
|
405
|
-
const archivePath = deps.join(tempDir, archiveName);
|
|
406
|
-
log(` 压缩文件路径: ${archivePath}`);
|
|
407
|
-
const sourceDir = deps.dirname(sourcePath);
|
|
408
|
-
const sourceName = deps.basename(sourcePath);
|
|
409
|
-
log(` 开始压缩: ${sourceDir}/${sourceName} -> ${archivePath}`);
|
|
410
|
-
return new Promise((resolve) => {
|
|
411
|
-
const startTime = Date.now();
|
|
412
|
-
deps.exec(`cd "${sourceDir}" && tar -czf "${archivePath}" "${sourceName}"`, (error, stdout, stderr) => {
|
|
413
|
-
const compressTime = Date.now() - startTime;
|
|
414
|
-
log(` 压缩完成 (耗时: ${compressTime}ms)`);
|
|
415
|
-
if (error) {
|
|
416
|
-
log(` 压缩失败: ${error.message}`);
|
|
417
|
-
if (stderr)
|
|
418
|
-
log(` stderr: ${stderr}`);
|
|
419
|
-
resolve({
|
|
420
|
-
success: false,
|
|
421
|
-
error: `压缩 framework 失败: ${error.message}`,
|
|
422
|
-
});
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
const targetArchivePath = deps.join(targetDir, archiveName);
|
|
426
|
-
log(` 开始复制压缩文件: ${archivePath} -> ${targetArchivePath}`);
|
|
427
|
-
const copyStartTime = Date.now();
|
|
428
|
-
try {
|
|
429
|
-
deps.copyFileSync(archivePath, targetArchivePath);
|
|
430
|
-
const copyTime = Date.now() - copyStartTime;
|
|
431
|
-
log(` 复制压缩文件完成 (耗时: ${copyTime}ms)`);
|
|
432
|
-
}
|
|
433
|
-
catch (copyError) {
|
|
434
|
-
log(` 复制压缩文件失败: ${copyError.message || String(copyError)}`);
|
|
435
|
-
resolve({
|
|
436
|
-
success: false,
|
|
437
|
-
error: `复制压缩文件失败: ${copyError.message || String(copyError)}`,
|
|
438
|
-
});
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
log(` 开始解压: ${targetArchivePath} -> ${targetDir}`);
|
|
442
|
-
const extractStartTime = Date.now();
|
|
443
|
-
deps.exec(`cd "${targetDir}" && tar -xzf "${targetArchivePath}" && rm -f "${targetArchivePath}"`, (extractError, extractStdout, extractStderr) => {
|
|
444
|
-
const extractTime = Date.now() - extractStartTime;
|
|
445
|
-
log(` 解压完成 (耗时: ${extractTime}ms)`);
|
|
446
|
-
try {
|
|
447
|
-
if (deps.existsSync(archivePath)) {
|
|
448
|
-
deps.exec(`rm -f "${archivePath}"`, () => { });
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
catch { }
|
|
452
|
-
if (extractError) {
|
|
453
|
-
log(` 解压失败: ${extractError.message}`);
|
|
454
|
-
if (extractStderr)
|
|
455
|
-
log(` stderr: ${extractStderr}`);
|
|
456
|
-
resolve({
|
|
457
|
-
success: false,
|
|
458
|
-
error: `解压 framework 失败: ${extractError.message}`,
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
else {
|
|
462
|
-
const totalTime = Date.now() - startTime;
|
|
463
|
-
log(` framework 复制成功 (总耗时: ${totalTime}ms)`);
|
|
464
|
-
resolve({ success: true });
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
catch (error) {
|
|
471
|
-
log(` 复制 framework 异常: ${error.message || String(error)}`);
|
|
472
|
-
return {
|
|
473
|
-
success: false,
|
|
474
|
-
error: `复制 framework 失败: ${error.message || String(error)}`,
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
export async function integrateNativePluginIOS(projectPath, projectName, pluginPath, deps, parameters) {
|
|
479
|
-
try {
|
|
480
|
-
deps.log?.(`开始集成 UniApp 原生插件: ${pluginPath}`);
|
|
481
|
-
deps.log?.("步骤 1: 解压插件");
|
|
482
|
-
const tempDir = deps.join(projectPath, ".temp");
|
|
483
|
-
if (deps.existsSync(tempDir)) {
|
|
484
|
-
deps.log?.("清理已存在的临时目录...");
|
|
485
|
-
await new Promise((resolve) => {
|
|
486
|
-
deps.exec(`rm -rf "${tempDir}"`, (error) => {
|
|
487
|
-
if (error) {
|
|
488
|
-
deps.log?.(`警告: 清理临时目录失败: ${error.message}`);
|
|
489
|
-
}
|
|
490
|
-
else {
|
|
491
|
-
deps.log?.("临时目录已清理");
|
|
492
|
-
}
|
|
493
|
-
resolve();
|
|
494
|
-
});
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
if (!deps.existsSync(tempDir)) {
|
|
498
|
-
deps.mkdirSync(tempDir, { recursive: true });
|
|
499
|
-
deps.log?.("已创建临时目录");
|
|
500
|
-
}
|
|
501
|
-
const extractResult = await extractPlugin(pluginPath, tempDir, {
|
|
502
|
-
existsSync: deps.existsSync,
|
|
503
|
-
readdirSync: deps.readdirSync,
|
|
504
|
-
statSync: deps.statSync,
|
|
505
|
-
join: deps.join,
|
|
506
|
-
exec: deps.exec,
|
|
507
|
-
basename: deps.basename,
|
|
508
|
-
dirname: deps.dirname,
|
|
509
|
-
mkdirSync: deps.mkdirSync,
|
|
510
|
-
log: deps.log,
|
|
511
|
-
setTimeout: deps.setTimeout,
|
|
512
|
-
clearTimeout: deps.clearTimeout,
|
|
513
|
-
});
|
|
514
|
-
if (!extractResult.success) {
|
|
515
|
-
return {
|
|
516
|
-
success: false,
|
|
517
|
-
error: extractResult.error,
|
|
518
|
-
logs: [],
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
const pluginDir = extractResult.extractedPath;
|
|
522
|
-
deps.log?.(`插件已解压到: ${pluginDir}`);
|
|
523
|
-
deps.log?.("步骤 2: 读取插件配置");
|
|
524
|
-
const packageJsonResult = readPluginPackageJson(pluginDir, {
|
|
525
|
-
existsSync: deps.existsSync,
|
|
526
|
-
readFileSync: deps.readFileSync,
|
|
527
|
-
join: deps.join,
|
|
528
|
-
parse: deps.parse,
|
|
529
|
-
});
|
|
530
|
-
if (!packageJsonResult.success) {
|
|
531
|
-
return {
|
|
532
|
-
success: false,
|
|
533
|
-
error: packageJsonResult.error,
|
|
534
|
-
logs: [],
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
const packageJson = packageJsonResult.packageJson;
|
|
538
|
-
deps.log?.(`插件名称: ${packageJson.name}`);
|
|
539
|
-
deps.log?.(`插件 ID: ${packageJson.id}`);
|
|
540
|
-
deps.log?.(`插件版本: ${packageJson.version}`);
|
|
541
|
-
deps.log?.("步骤 3: 提取 iOS 插件配置");
|
|
542
|
-
const configResult = extractIOSPluginConfig(packageJson);
|
|
543
|
-
if (!configResult.success) {
|
|
544
|
-
return {
|
|
545
|
-
success: false,
|
|
546
|
-
error: configResult.error,
|
|
547
|
-
logs: [],
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
const { plugins: pluginItems, hooksClass, frameworks, embedFrameworks, resources, privacies, parameters: pluginParameters, } = configResult;
|
|
551
|
-
deps.log?.(`找到 ${pluginItems.length} 个插件`);
|
|
552
|
-
if (hooksClass) {
|
|
553
|
-
deps.log?.(`Hooks 类: ${hooksClass}`);
|
|
554
|
-
}
|
|
555
|
-
deps.log?.("步骤 4: 复制插件文件");
|
|
556
|
-
const iosDir = deps.join(pluginDir, "ios");
|
|
557
|
-
deps.log?.(` iosDir: ${iosDir}`);
|
|
558
|
-
deps.log?.(` iosDir 存在: ${deps.existsSync(iosDir)}`);
|
|
559
|
-
if (!deps.existsSync(iosDir)) {
|
|
560
|
-
return {
|
|
561
|
-
success: false,
|
|
562
|
-
error: `插件 ios 目录不存在: ${iosDir}`,
|
|
563
|
-
logs: [],
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
deps.log?.("步骤 4.1: 查找静态库 (.a)");
|
|
567
|
-
const findLibStartTime = Date.now();
|
|
568
|
-
const staticLibs = findFilesRecursive(iosDir, [".a"], deps);
|
|
569
|
-
const findLibTime = Date.now() - findLibStartTime;
|
|
570
|
-
deps.log?.(` 找到 ${staticLibs.length} 个静态库 (查找耗时: ${findLibTime}ms)`);
|
|
571
|
-
const libsDir = deps.join(projectPath, "libs");
|
|
572
|
-
if (!deps.existsSync(libsDir)) {
|
|
573
|
-
deps.mkdirSync(libsDir, { recursive: true });
|
|
574
|
-
}
|
|
575
|
-
for (const libPath of staticLibs) {
|
|
576
|
-
const libName = deps.basename(libPath);
|
|
577
|
-
const targetPath = deps.join(libsDir, libName);
|
|
578
|
-
deps.copyFileSync(libPath, targetPath);
|
|
579
|
-
deps.log?.(`已复制静态库: ${libName}`);
|
|
580
|
-
}
|
|
581
|
-
deps.log?.("步骤 4.2: 查找 framework");
|
|
582
|
-
deps.log?.(` 搜索目录: ${iosDir}`);
|
|
583
|
-
const findFrameworkStartTime = Date.now();
|
|
584
|
-
const allFrameworks = findFilesRecursive(iosDir, [".framework"], deps);
|
|
585
|
-
const findFrameworkTime = Date.now() - findFrameworkStartTime;
|
|
586
|
-
deps.log?.(`找到 ${allFrameworks.length} 个 framework (查找耗时: ${findFrameworkTime}ms)`);
|
|
587
|
-
const frameworksDir = deps.join(projectPath, "Frameworks");
|
|
588
|
-
if (!deps.existsSync(frameworksDir)) {
|
|
589
|
-
deps.mkdirSync(frameworksDir, { recursive: true });
|
|
590
|
-
}
|
|
591
|
-
for (const frameworkPath of allFrameworks) {
|
|
592
|
-
const frameworkName = deps.basename(frameworkPath);
|
|
593
|
-
deps.log?.(`开始复制 framework: ${frameworkName}`);
|
|
594
|
-
const targetPath = deps.join(frameworksDir, frameworkName);
|
|
595
|
-
const copyResult = await copyFrameworkUsingArchive(frameworkPath, targetPath, {
|
|
596
|
-
existsSync: deps.existsSync,
|
|
597
|
-
readdirSync: deps.readdirSync,
|
|
598
|
-
join: deps.join,
|
|
599
|
-
dirname: deps.dirname,
|
|
600
|
-
exec: deps.exec,
|
|
601
|
-
basename: deps.basename,
|
|
602
|
-
mkdirSync: deps.mkdirSync,
|
|
603
|
-
copyFileSync: deps.copyFileSync,
|
|
604
|
-
}, deps.log);
|
|
605
|
-
if (copyResult.success) {
|
|
606
|
-
deps.log?.(`已复制 framework: ${frameworkName}`);
|
|
607
|
-
}
|
|
608
|
-
else {
|
|
609
|
-
deps.log?.(`警告: 复制 framework 失败 (${frameworkName}): ${copyResult.error}`);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
deps.log?.("步骤 4.4: 查找 xcframework");
|
|
613
|
-
const findXcframeworkStartTime = Date.now();
|
|
614
|
-
const xcframeworks = findFilesRecursive(iosDir, [".xcframework"], deps);
|
|
615
|
-
const findXcframeworkTime = Date.now() - findXcframeworkStartTime;
|
|
616
|
-
deps.log?.(` 找到 ${xcframeworks.length} 个 xcframework (查找耗时: ${findXcframeworkTime}ms)`);
|
|
617
|
-
for (const xcframeworkPath of xcframeworks) {
|
|
618
|
-
const xcframeworkName = deps.basename(xcframeworkPath);
|
|
619
|
-
const targetPath = deps.join(frameworksDir, xcframeworkName);
|
|
620
|
-
deps.log?.(`开始复制 xcframework: ${xcframeworkName}`);
|
|
621
|
-
const copyResult = await copyFrameworkUsingArchive(xcframeworkPath, targetPath, {
|
|
622
|
-
existsSync: deps.existsSync,
|
|
623
|
-
readdirSync: deps.readdirSync,
|
|
624
|
-
join: deps.join,
|
|
625
|
-
dirname: deps.dirname,
|
|
626
|
-
exec: deps.exec,
|
|
627
|
-
basename: deps.basename,
|
|
628
|
-
mkdirSync: deps.mkdirSync,
|
|
629
|
-
copyFileSync: deps.copyFileSync,
|
|
630
|
-
}, deps.log);
|
|
631
|
-
if (copyResult.success) {
|
|
632
|
-
deps.log?.(`已复制 xcframework: ${xcframeworkName}`);
|
|
633
|
-
}
|
|
634
|
-
else {
|
|
635
|
-
deps.log?.(`警告: 复制 xcframework 失败 (${xcframeworkName}): ${copyResult.error}`);
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
deps.log?.("步骤 4.5: 复制资源文件");
|
|
639
|
-
if (resources && resources.length > 0) {
|
|
640
|
-
const resourcesTargetDir = deps.join(projectPath, projectName, "Resources");
|
|
641
|
-
if (!deps.existsSync(resourcesTargetDir)) {
|
|
642
|
-
deps.mkdirSync(resourcesTargetDir, { recursive: true });
|
|
643
|
-
}
|
|
644
|
-
for (const resourcePath of resources) {
|
|
645
|
-
const sourcePath = deps.join(iosDir, resourcePath);
|
|
646
|
-
if (deps.existsSync(sourcePath)) {
|
|
647
|
-
const resourceName = deps.basename(resourcePath);
|
|
648
|
-
const targetPath = deps.join(resourcesTargetDir, resourceName);
|
|
649
|
-
const stat = deps.statSync(sourcePath);
|
|
650
|
-
if (stat.isDirectory()) {
|
|
651
|
-
await deps.cp(sourcePath, targetPath, {
|
|
652
|
-
recursive: true,
|
|
653
|
-
force: true,
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
else {
|
|
657
|
-
deps.copyFileSync(sourcePath, targetPath);
|
|
658
|
-
}
|
|
659
|
-
deps.log?.(`已复制资源文件: ${resourceName}`);
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
662
|
-
deps.log?.(`警告: 资源文件不存在: ${sourcePath}`);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
deps.log?.("步骤 4.6: 查找头文件 (.h)");
|
|
667
|
-
const findHeaderStartTime = Date.now();
|
|
668
|
-
const headers = findFilesRecursive(iosDir, [".h"], deps);
|
|
669
|
-
const findHeaderTime = Date.now() - findHeaderStartTime;
|
|
670
|
-
deps.log?.(` 找到 ${headers.length} 个头文件 (查找耗时: ${findHeaderTime}ms)`);
|
|
671
|
-
const headersDir = deps.join(projectPath, projectName, "NativePlugins");
|
|
672
|
-
if (headers.length > 0) {
|
|
673
|
-
if (!deps.existsSync(headersDir)) {
|
|
674
|
-
deps.mkdirSync(headersDir, { recursive: true });
|
|
675
|
-
}
|
|
676
|
-
for (const headerPath of headers) {
|
|
677
|
-
const headerName = deps.basename(headerPath);
|
|
678
|
-
const targetPath = deps.join(headersDir, headerName);
|
|
679
|
-
deps.copyFileSync(headerPath, targetPath);
|
|
680
|
-
deps.log?.(`已复制头文件: ${headerName}`);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
deps.log?.("步骤 5: 修改 Info.plist");
|
|
684
|
-
const infoPlistPath = deps.join(projectPath, projectName, `${projectName}-Info.plist`);
|
|
685
|
-
if (deps.existsSync(infoPlistPath)) {
|
|
686
|
-
try {
|
|
687
|
-
const xmlContent = deps.readFileSync(infoPlistPath, "utf8");
|
|
688
|
-
const parser = new deps.xmlParser();
|
|
689
|
-
const xmlDoc = parser.parseFromString(xmlContent, "text/xml");
|
|
690
|
-
addPluginToInfoPlist(xmlDoc, pluginItems, hooksClass || "");
|
|
691
|
-
deps.log?.("已添加插件信息到 dcloud_uniplugins");
|
|
692
|
-
if (privacies && privacies.length > 0) {
|
|
693
|
-
addPrivaciesToInfoPlist(xmlDoc, privacies);
|
|
694
|
-
deps.log?.(`已添加 ${privacies.length} 个隐私权限描述`);
|
|
695
|
-
}
|
|
696
|
-
if (pluginParameters && parameters) {
|
|
697
|
-
addPluginParametersToInfoPlist(xmlDoc, pluginParameters, parameters);
|
|
698
|
-
deps.log?.("已添加插件参数配置");
|
|
699
|
-
}
|
|
700
|
-
const serializer = new deps.xmlSerializer();
|
|
701
|
-
const newXmlContent = serializer.serializeToString(xmlDoc);
|
|
702
|
-
deps.writeFileSync(infoPlistPath, newXmlContent, "utf8");
|
|
703
|
-
deps.log?.("Info.plist 修改完成");
|
|
704
|
-
}
|
|
705
|
-
catch (error) {
|
|
706
|
-
deps.log?.(`修改 Info.plist 失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
deps.log?.("步骤 6: 添加文件到 Xcode 项目");
|
|
710
|
-
const projectFiles = deps
|
|
711
|
-
.readdirSync(projectPath)
|
|
712
|
-
.filter((file) => file.endsWith(".xcodeproj"));
|
|
713
|
-
if (projectFiles.length === 0) {
|
|
714
|
-
deps.log?.("警告: 未找到 .xcodeproj 文件,跳过 Xcode 项目配置");
|
|
715
|
-
}
|
|
716
|
-
else {
|
|
717
|
-
const projectFile = projectFiles[0];
|
|
718
|
-
const projectPbxprojPath = deps.join(projectPath, projectFile, "project.pbxproj");
|
|
719
|
-
for (const libPath of staticLibs) {
|
|
720
|
-
const libName = deps.basename(libPath);
|
|
721
|
-
const relativePath = `libs/${libName}`;
|
|
722
|
-
const addResult = addFileToXcodeProject(projectPbxprojPath, relativePath, "staticLibrary", {
|
|
723
|
-
existsSync: deps.existsSync,
|
|
724
|
-
readFileSync: deps.readFileSync,
|
|
725
|
-
writeFileSync: deps.writeFileSync,
|
|
726
|
-
});
|
|
727
|
-
if (addResult.success) {
|
|
728
|
-
deps.log?.(`已添加到 Xcode 项目: ${libName}`);
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
deps.log?.(`警告: 添加到 Xcode 项目失败: ${addResult.error}`);
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
const embedFrameworkNames = new Set((embedFrameworks || []).map((name) => {
|
|
735
|
-
return name.endsWith(".framework") ? name : `${name}.framework`;
|
|
736
|
-
}));
|
|
737
|
-
const frameworksToEmbed = [];
|
|
738
|
-
const frameworksToLink = [];
|
|
739
|
-
for (const frameworkPath of allFrameworks) {
|
|
740
|
-
const frameworkName = deps.basename(frameworkPath);
|
|
741
|
-
if (embedFrameworkNames.has(frameworkName)) {
|
|
742
|
-
frameworksToEmbed.push(frameworkPath);
|
|
743
|
-
}
|
|
744
|
-
else {
|
|
745
|
-
frameworksToLink.push(frameworkPath);
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
if (frameworksToEmbed.length > 0) {
|
|
749
|
-
deps.log?.(`步骤 6.2.1: 添加 ${frameworksToEmbed.length} 个 framework 到 Link Binary With Libraries 和 Embed Frameworks`);
|
|
750
|
-
for (const frameworkPath of frameworksToEmbed) {
|
|
751
|
-
const frameworkName = deps.basename(frameworkPath);
|
|
752
|
-
const relativePath = `Frameworks/${frameworkName}`;
|
|
753
|
-
const linkResult = addFileToXcodeProject(projectPbxprojPath, relativePath, "framework", {
|
|
754
|
-
existsSync: deps.existsSync,
|
|
755
|
-
readFileSync: deps.readFileSync,
|
|
756
|
-
writeFileSync: deps.writeFileSync,
|
|
757
|
-
});
|
|
758
|
-
if (!linkResult.success) {
|
|
759
|
-
deps.log?.(`警告: 添加到 Link Binary With Libraries 失败: ${linkResult.error}`);
|
|
760
|
-
}
|
|
761
|
-
const embedResult = addFileToEmbedFrameworks(projectPbxprojPath, relativePath, {
|
|
762
|
-
existsSync: deps.existsSync,
|
|
763
|
-
readFileSync: deps.readFileSync,
|
|
764
|
-
writeFileSync: deps.writeFileSync,
|
|
765
|
-
});
|
|
766
|
-
if (embedResult.success) {
|
|
767
|
-
deps.log?.(`已添加到 Embed Frameworks: ${frameworkName}`);
|
|
768
|
-
}
|
|
769
|
-
else {
|
|
770
|
-
deps.log?.(`警告: 添加到 Embed Frameworks 失败: ${embedResult.error}`);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
if (frameworksToLink.length > 0) {
|
|
775
|
-
deps.log?.(`步骤 6.2.2: 添加 ${frameworksToLink.length} 个 framework 到 Link Binary With Libraries`);
|
|
776
|
-
for (const frameworkPath of frameworksToLink) {
|
|
777
|
-
const frameworkName = deps.basename(frameworkPath);
|
|
778
|
-
const relativePath = `Frameworks/${frameworkName}`;
|
|
779
|
-
const addResult = addFileToXcodeProject(projectPbxprojPath, relativePath, "framework", {
|
|
780
|
-
existsSync: deps.existsSync,
|
|
781
|
-
readFileSync: deps.readFileSync,
|
|
782
|
-
writeFileSync: deps.writeFileSync,
|
|
783
|
-
});
|
|
784
|
-
if (addResult.success) {
|
|
785
|
-
deps.log?.(`已添加到 Link Binary With Libraries: ${frameworkName}`);
|
|
786
|
-
}
|
|
787
|
-
else {
|
|
788
|
-
deps.log?.(`警告: 添加到 Link Binary With Libraries 失败: ${addResult.error}`);
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
for (const xcframeworkPath of xcframeworks) {
|
|
793
|
-
const xcframeworkName = deps.basename(xcframeworkPath);
|
|
794
|
-
const relativePath = `Frameworks/${xcframeworkName}`;
|
|
795
|
-
const addResult = addFileToXcodeProject(projectPbxprojPath, relativePath, "framework", {
|
|
796
|
-
existsSync: deps.existsSync,
|
|
797
|
-
readFileSync: deps.readFileSync,
|
|
798
|
-
writeFileSync: deps.writeFileSync,
|
|
799
|
-
});
|
|
800
|
-
if (addResult.success) {
|
|
801
|
-
deps.log?.(`已添加到 Xcode 项目: ${xcframeworkName}`);
|
|
802
|
-
}
|
|
803
|
-
else {
|
|
804
|
-
deps.log?.(`警告: 添加到 Xcode 项目失败: ${addResult.error}`);
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
if (resources && resources.length > 0) {
|
|
808
|
-
for (const resourcePath of resources) {
|
|
809
|
-
const resourceName = deps.basename(resourcePath);
|
|
810
|
-
const relativePath = `${projectName}/Resources/${resourceName}`;
|
|
811
|
-
const addResult = addFileToXcodeProject(projectPbxprojPath, relativePath, "bundle", {
|
|
812
|
-
existsSync: deps.existsSync,
|
|
813
|
-
readFileSync: deps.readFileSync,
|
|
814
|
-
writeFileSync: deps.writeFileSync,
|
|
815
|
-
});
|
|
816
|
-
if (addResult.success) {
|
|
817
|
-
deps.log?.(`已添加资源到 Xcode 项目: ${resourceName}`);
|
|
818
|
-
}
|
|
819
|
-
else {
|
|
820
|
-
deps.log?.(`警告: 添加资源到 Xcode 项目失败: ${addResult.error}`);
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
if (frameworks && frameworks.length > 0) {
|
|
825
|
-
deps.log?.("注意: 系统库需要手动在 Xcode 中添加到 Link Binary With Libraries:");
|
|
826
|
-
for (const framework of frameworks) {
|
|
827
|
-
deps.log?.(` - ${framework}`);
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
deps.log?.("步骤 6.8: 检查插件依赖");
|
|
831
|
-
const pluginFrameworkDir = deps.join(pluginDir, "ios");
|
|
832
|
-
if (deps.existsSync(pluginFrameworkDir)) {
|
|
833
|
-
try {
|
|
834
|
-
const frameworkFiles = findFilesRecursive(pluginFrameworkDir, [".m", ".mm", ".swift"], deps);
|
|
835
|
-
let hasSVGKitImport = false;
|
|
836
|
-
for (const file of frameworkFiles) {
|
|
837
|
-
try {
|
|
838
|
-
const content = deps.readFileSync(file, "utf8");
|
|
839
|
-
if (content.includes("SVGKit") || content.includes("SVGKImage")) {
|
|
840
|
-
hasSVGKitImport = true;
|
|
841
|
-
break;
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
catch {
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
if (hasSVGKitImport) {
|
|
848
|
-
deps.log?.("⚠️ 警告: 插件使用了 SVGKit 库,但主项目中可能未包含该库");
|
|
849
|
-
deps.log?.(" 解决方案 1: 在主项目中使用 CocoaPods 安装 SVGKit");
|
|
850
|
-
deps.log?.(' 1. 在主项目根目录创建 Podfile,添加: pod "SVGKit", "~> 3.0"');
|
|
851
|
-
deps.log?.(" 2. 运行: pod install");
|
|
852
|
-
deps.log?.(" 3. 使用 .xcworkspace 打开项目");
|
|
853
|
-
deps.log?.(" 解决方案 2: 手动下载 SVGKit.framework 并添加到项目中");
|
|
854
|
-
deps.log?.(" 解决方案 3: 如果不需要 SVG 支持,可以移除插件中的 SVG 相关代码");
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
catch (error) {
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
if (allFrameworks.length > 0 ||
|
|
861
|
-
xcframeworks.length > 0) {
|
|
862
|
-
deps.log?.("步骤 6.7: 更新 FRAMEWORK_SEARCH_PATHS");
|
|
863
|
-
try {
|
|
864
|
-
let content = deps.readFileSync(projectPbxprojPath, "utf8");
|
|
865
|
-
const frameworksSearchPath = '"$(PROJECT_DIR)/Frameworks"';
|
|
866
|
-
let modified = false;
|
|
867
|
-
const frameworkSearchPathsRegex = /(FRAMEWORK_SEARCH_PATHS\s*=\s*\()([\s\S]*?)(\t+\);)/g;
|
|
868
|
-
const matches = [];
|
|
869
|
-
let match;
|
|
870
|
-
while ((match = frameworkSearchPathsRegex.exec(content)) !== null) {
|
|
871
|
-
matches.push({
|
|
872
|
-
full: match[0],
|
|
873
|
-
start: match[1],
|
|
874
|
-
middle: match[2],
|
|
875
|
-
end: match[3],
|
|
876
|
-
index: match.index
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
for (let i = matches.length - 1; i >= 0; i--) {
|
|
880
|
-
const m = matches[i];
|
|
881
|
-
const currentPaths = m.middle.trim();
|
|
882
|
-
if (!currentPaths.includes("Frameworks") &&
|
|
883
|
-
!currentPaths.includes(frameworksSearchPath)) {
|
|
884
|
-
const indent = m.end.match(/^\t+/)?.[0] || '\t\t\t\t';
|
|
885
|
-
const newPathEntry = `${indent}${frameworksSearchPath},\n`;
|
|
886
|
-
const newMiddle = currentPaths
|
|
887
|
-
? `${currentPaths}\n${newPathEntry}`
|
|
888
|
-
: newPathEntry;
|
|
889
|
-
const newContent = `${m.start}${newMiddle}${m.end}`;
|
|
890
|
-
const before = content.substring(0, m.index);
|
|
891
|
-
const after = content.substring(m.index + m.full.length);
|
|
892
|
-
content = before + newContent + after;
|
|
893
|
-
modified = true;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
if (modified) {
|
|
897
|
-
deps.writeFileSync(projectPbxprojPath, content, "utf8");
|
|
898
|
-
deps.log?.(`已添加 Frameworks 目录到所有 FRAMEWORK_SEARCH_PATHS 配置`);
|
|
899
|
-
}
|
|
900
|
-
else {
|
|
901
|
-
deps.log?.(`所有 FRAMEWORK_SEARCH_PATHS 已包含 Frameworks 目录`);
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
catch (error) {
|
|
905
|
-
deps.log?.(`警告: 更新 FRAMEWORK_SEARCH_PATHS 失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
deps.log?.("步骤 7: 清理临时文件");
|
|
910
|
-
try {
|
|
911
|
-
deps.log?.(` 检查临时目录: ${tempDir}`);
|
|
912
|
-
if (deps.existsSync(tempDir)) {
|
|
913
|
-
deps.log?.(` 开始清理临时目录: ${tempDir}`);
|
|
914
|
-
await new Promise((resolve) => {
|
|
915
|
-
const timeout = deps.setTimeout(() => {
|
|
916
|
-
deps.log?.(`警告: 清理临时目录超时: ${tempDir}`);
|
|
917
|
-
resolve();
|
|
918
|
-
}, 5000);
|
|
919
|
-
deps.exec(`rm -rf "${tempDir}"`, (error) => {
|
|
920
|
-
deps.clearTimeout(timeout);
|
|
921
|
-
if (error) {
|
|
922
|
-
deps.log?.(`警告: 清理临时目录失败: ${tempDir} (${error.message})`);
|
|
923
|
-
}
|
|
924
|
-
else {
|
|
925
|
-
deps.log?.(`✓ 已清理临时目录: ${tempDir}`);
|
|
926
|
-
}
|
|
927
|
-
resolve();
|
|
928
|
-
});
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
else {
|
|
932
|
-
deps.log?.(` 临时目录不存在,跳过清理: ${tempDir}`);
|
|
933
|
-
}
|
|
934
|
-
const frameworksDir = deps.join(projectPath, "Frameworks");
|
|
935
|
-
const frameworkTempDir = deps.join(frameworksDir, ".temp_framework_copy");
|
|
936
|
-
deps.log?.(` 检查 framework 临时目录: ${frameworkTempDir}`);
|
|
937
|
-
if (deps.existsSync(frameworkTempDir)) {
|
|
938
|
-
deps.log?.(` 开始清理 framework 临时目录: ${frameworkTempDir}`);
|
|
939
|
-
await new Promise((resolve) => {
|
|
940
|
-
const timeout = deps.setTimeout(() => {
|
|
941
|
-
deps.log?.(`警告: 清理 framework 临时目录超时: ${frameworkTempDir}`);
|
|
942
|
-
resolve();
|
|
943
|
-
}, 5000);
|
|
944
|
-
deps.exec(`rm -rf "${frameworkTempDir}"`, (error) => {
|
|
945
|
-
deps.clearTimeout(timeout);
|
|
946
|
-
if (error) {
|
|
947
|
-
deps.log?.(`警告: 清理 framework 临时目录失败: ${frameworkTempDir} (${error.message})`);
|
|
948
|
-
}
|
|
949
|
-
else {
|
|
950
|
-
deps.log?.(`✓ 已清理 framework 临时目录: ${frameworkTempDir}`);
|
|
951
|
-
}
|
|
952
|
-
resolve();
|
|
953
|
-
});
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
else {
|
|
957
|
-
deps.log?.(` framework 临时目录不存在,跳过清理: ${frameworkTempDir}`);
|
|
958
|
-
}
|
|
959
|
-
deps.log?.("✓ 清理临时文件完成");
|
|
960
|
-
}
|
|
961
|
-
catch (cleanupError) {
|
|
962
|
-
deps.log?.(`警告: 清理临时文件时出错: ${cleanupError instanceof Error
|
|
963
|
-
? cleanupError.message
|
|
964
|
-
: String(cleanupError)}`);
|
|
965
|
-
}
|
|
966
|
-
deps.log?.("原生插件集成完成");
|
|
967
|
-
return {
|
|
968
|
-
success: true,
|
|
969
|
-
message: "原生插件集成成功",
|
|
970
|
-
logs: [],
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
catch (error) {
|
|
974
|
-
deps.log?.(`原生插件集成异常: ${error instanceof Error ? error.message : String(error)}`);
|
|
975
|
-
try {
|
|
976
|
-
const tempDir = deps.join(projectPath, ".temp");
|
|
977
|
-
if (deps.existsSync(tempDir)) {
|
|
978
|
-
deps.exec(`rm -rf "${tempDir}"`, () => { });
|
|
979
|
-
}
|
|
980
|
-
const frameworksDir = deps.join(projectPath, "Frameworks");
|
|
981
|
-
const frameworkTempDir = deps.join(frameworksDir, ".temp_framework_copy");
|
|
982
|
-
if (deps.existsSync(frameworkTempDir)) {
|
|
983
|
-
deps.exec(`rm -rf "${frameworkTempDir}"`, () => { });
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
catch { }
|
|
987
|
-
return {
|
|
988
|
-
success: false,
|
|
989
|
-
error: `原生插件集成异常: ${error instanceof Error ? error.message : String(error)}`,
|
|
990
|
-
logs: [],
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
//# sourceMappingURL=integrateNativePlugin.js.map
|