├── .gitignore
├── GoProject
└── src
│ └── OfflineServer
│ ├── main.go
│ ├── source
│ └── offline_pkg.zip
│ └── templdate.html
├── JXBWebKit.podspec
├── JXBWebKit
├── JSResources.bundle
│ ├── JXBJSBridge.js
│ ├── index.html
│ ├── webView_back@2x.png
│ ├── webView_back@3x.png
│ ├── webView_close@2x.png
│ └── webView_close@3x.png
├── JXBWebViewController.h
├── JXBWebViewController.m
└── Tools
│ ├── CustomUI
│ ├── UIProgressView+WKWebView.h
│ ├── UIProgressView+WKWebView.m
│ ├── WKWebView+AOP.h
│ └── WKWebView+AOP.m
│ ├── Dispatch
│ ├── WKMessageHandlerDispatch.h
│ └── WKMessageHandlerDispatch.m
│ ├── Helper
│ ├── WKAppManager.h
│ ├── WKAppManager.m
│ ├── WKMessageHandlerHelper.h
│ └── WKMessageHandlerHelper.m
│ ├── Interceptor
│ ├── JXBWebViewNetworkInterceptor.h
│ └── JXBWebViewNetworkInterceptor.m
│ ├── MessageHandler
│ ├── WKCallNativeMethodMessageHandler.h
│ ├── WKCallNativeMethodMessageHandler.m
│ └── WKMessageHandlerProtocol.h
│ ├── ReusePool
│ ├── JXBWKWebView.h
│ ├── JXBWKWebView.m
│ ├── JXBWKWebViewPool.h
│ └── JXBWKWebViewPool.m
│ ├── URLProtocol
│ ├── JXBWKCustomProtocol.h
│ ├── JXBWKCustomProtocol.m
│ ├── NSURLProtocol+WebKitSupport.h
│ └── NSURLProtocol+WebKitSupport.m
│ └── WebViewExtension
│ ├── WKWebView+ClearWebCache.h
│ ├── WKWebView+ClearWebCache.m
│ ├── WKWebView+CookiesManager.h
│ ├── WKWebView+CookiesManager.m
│ ├── WKWebView+ExternalNavigationDelegates.h
│ ├── WKWebView+ExternalNavigationDelegates.m
│ ├── WKWebView+SupportProtocol.h
│ ├── WKWebView+SupportProtocol.m
│ ├── WKWebView+SyncUserAgent.h
│ ├── WKWebView+SyncUserAgent.m
│ └── WKWebViewExtension.h
├── JXBWebKitProject
├── JXBWebKitProject.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── JXBWebKitProject.xcscheme
├── JXBWebKitProject.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
├── JXBWebKitProject
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── CustomTwoViewController.h
│ ├── CustomTwoViewController.m
│ ├── CustomViewController.h
│ ├── CustomViewController.m
│ ├── H5EnterModel.h
│ ├── H5EnterModel.m
│ ├── Hybrid
│ │ ├── HybridViewController.h
│ │ ├── HybridViewController.m
│ │ ├── User.h
│ │ └── User.m
│ ├── IneterceptorRequsetHandler.h
│ ├── IneterceptorRequsetHandler.m
│ ├── Info.plist
│ ├── JXBNavigationController.h
│ ├── JXBNavigationController.m
│ ├── Service
│ │ ├── Good
│ │ │ ├── GoodDetailController.h
│ │ │ ├── GoodDetailController.m
│ │ │ ├── GoodListController.h
│ │ │ ├── GoodListController.m
│ │ │ ├── Service_Good.h
│ │ │ ├── Service_Good.m
│ │ │ └── h5.html
│ │ ├── Location
│ │ │ ├── Service_location.h
│ │ │ └── Service_location.m
│ │ ├── Push
│ │ │ ├── Service_push.h
│ │ │ └── Service_push.m
│ │ └── Setting
│ │ │ ├── Service_setting.h
│ │ │ └── Service_setting.m
│ ├── TestWebViewController.h
│ ├── TestWebViewController.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── JXBWebKitProjectTests
│ ├── Info.plist
│ └── JXBWebKitProjectTests.m
├── JXBWebKitProjectUITests
│ ├── Info.plist
│ └── JXBWebKitProjectUITests.m
├── Podfile
├── Podfile.lock
└── Pods
│ ├── Headers
│ ├── Private
│ │ ├── JXBWebKit
│ │ │ ├── JXBWKCustomProtocol.h
│ │ │ ├── JXBWKWebView.h
│ │ │ ├── JXBWKWebViewPool.h
│ │ │ ├── JXBWebViewController.h
│ │ │ ├── NSURLProtocol+WebKitSupport.h
│ │ │ ├── UIProgressView+WKWebView.h
│ │ │ ├── WKAppManager.h
│ │ │ ├── WKCallNativeMethodMessageHandler.h
│ │ │ ├── WKMessageHandlerDispatch.h
│ │ │ ├── WKMessageHandlerHelper.h
│ │ │ ├── WKMessageHandlerProtocol.h
│ │ │ ├── WKWebView+AOP.h
│ │ │ ├── WKWebView+ClearWebCache.h
│ │ │ ├── WKWebView+CookiesManager.h
│ │ │ ├── WKWebView+ExternalNavigationDelegates.h
│ │ │ ├── WKWebView+SupportProtocol.h
│ │ │ ├── WKWebView+SyncUserAgent.h
│ │ │ └── WKWebViewExtension.h
│ │ └── SSZipArchive
│ │ │ ├── SSZipArchive.h
│ │ │ ├── SSZipCommon.h
│ │ │ ├── ZipArchive.h
│ │ │ ├── aes.h
│ │ │ ├── aes_ni.h
│ │ │ ├── aesopt.h
│ │ │ ├── aestab.h
│ │ │ ├── brg_endian.h
│ │ │ ├── brg_types.h
│ │ │ ├── crypt.h
│ │ │ ├── fileenc.h
│ │ │ ├── hmac.h
│ │ │ ├── ioapi.h
│ │ │ ├── ioapi_buf.h
│ │ │ ├── ioapi_mem.h
│ │ │ ├── minishared.h
│ │ │ ├── prng.h
│ │ │ ├── pwd2key.h
│ │ │ ├── sha1.h
│ │ │ ├── unzip.h
│ │ │ └── zip.h
│ └── Public
│ │ ├── JXBWebKit
│ │ ├── JXBWKCustomProtocol.h
│ │ ├── JXBWKWebView.h
│ │ ├── JXBWKWebViewPool.h
│ │ ├── JXBWebViewController.h
│ │ ├── NSURLProtocol+WebKitSupport.h
│ │ ├── UIProgressView+WKWebView.h
│ │ ├── WKAppManager.h
│ │ ├── WKCallNativeMethodMessageHandler.h
│ │ ├── WKMessageHandlerDispatch.h
│ │ ├── WKMessageHandlerHelper.h
│ │ ├── WKMessageHandlerProtocol.h
│ │ ├── WKWebView+AOP.h
│ │ ├── WKWebView+ClearWebCache.h
│ │ ├── WKWebView+CookiesManager.h
│ │ ├── WKWebView+ExternalNavigationDelegates.h
│ │ ├── WKWebView+SupportProtocol.h
│ │ ├── WKWebView+SyncUserAgent.h
│ │ └── WKWebViewExtension.h
│ │ └── SSZipArchive
│ │ ├── SSZipArchive.h
│ │ ├── SSZipCommon.h
│ │ └── ZipArchive.h
│ ├── Local Podspecs
│ └── JXBWebKit.podspec.json
│ ├── Manifest.lock
│ ├── Pods.xcodeproj
│ └── project.pbxproj
│ ├── SSZipArchive
│ ├── LICENSE.txt
│ ├── README.md
│ └── SSZipArchive
│ │ ├── SSZipArchive.h
│ │ ├── SSZipArchive.m
│ │ ├── SSZipCommon.h
│ │ ├── ZipArchive.h
│ │ └── minizip
│ │ ├── aes
│ │ ├── aes.h
│ │ ├── aes_ni.c
│ │ ├── aes_ni.h
│ │ ├── aescrypt.c
│ │ ├── aeskey.c
│ │ ├── aesopt.h
│ │ ├── aestab.c
│ │ ├── aestab.h
│ │ ├── brg_endian.h
│ │ ├── brg_types.h
│ │ ├── fileenc.c
│ │ ├── fileenc.h
│ │ ├── hmac.c
│ │ ├── hmac.h
│ │ ├── prng.c
│ │ ├── prng.h
│ │ ├── pwd2key.c
│ │ ├── pwd2key.h
│ │ ├── sha1.c
│ │ └── sha1.h
│ │ ├── crypt.c
│ │ ├── crypt.h
│ │ ├── ioapi.c
│ │ ├── ioapi.h
│ │ ├── ioapi_buf.c
│ │ ├── ioapi_buf.h
│ │ ├── ioapi_mem.c
│ │ ├── ioapi_mem.h
│ │ ├── minishared.c
│ │ ├── minishared.h
│ │ ├── unzip.c
│ │ ├── unzip.h
│ │ ├── zip.c
│ │ └── zip.h
│ └── Target Support Files
│ ├── JXBWebKit
│ ├── JXBWebKit-dummy.m
│ ├── JXBWebKit-prefix.pch
│ └── JXBWebKit.xcconfig
│ ├── Pods-JXBWebKitProject
│ ├── Pods-JXBWebKitProject-acknowledgements.markdown
│ ├── Pods-JXBWebKitProject-acknowledgements.plist
│ ├── Pods-JXBWebKitProject-dummy.m
│ ├── Pods-JXBWebKitProject-frameworks.sh
│ ├── Pods-JXBWebKitProject-resources-Debug-input-files.xcfilelist
│ ├── Pods-JXBWebKitProject-resources-Debug-output-files.xcfilelist
│ ├── Pods-JXBWebKitProject-resources-Release-input-files.xcfilelist
│ ├── Pods-JXBWebKitProject-resources-Release-output-files.xcfilelist
│ ├── Pods-JXBWebKitProject-resources.sh
│ ├── Pods-JXBWebKitProject.debug.xcconfig
│ └── Pods-JXBWebKitProject.release.xcconfig
│ ├── Pods-JXBWebKitProjectTests
│ ├── Pods-JXBWebKitProjectTests-acknowledgements.markdown
│ ├── Pods-JXBWebKitProjectTests-acknowledgements.plist
│ ├── Pods-JXBWebKitProjectTests-dummy.m
│ ├── Pods-JXBWebKitProjectTests-frameworks.sh
│ ├── Pods-JXBWebKitProjectTests-resources.sh
│ ├── Pods-JXBWebKitProjectTests.debug.xcconfig
│ └── Pods-JXBWebKitProjectTests.release.xcconfig
│ ├── Pods-JXBWebKitProjectUITests
│ ├── Pods-JXBWebKitProjectUITests-acknowledgements.markdown
│ ├── Pods-JXBWebKitProjectUITests-acknowledgements.plist
│ ├── Pods-JXBWebKitProjectUITests-dummy.m
│ ├── Pods-JXBWebKitProjectUITests-frameworks.sh
│ ├── Pods-JXBWebKitProjectUITests-resources.sh
│ ├── Pods-JXBWebKitProjectUITests.debug.xcconfig
│ └── Pods-JXBWebKitProjectUITests.release.xcconfig
│ └── SSZipArchive
│ ├── SSZipArchive-dummy.m
│ ├── SSZipArchive-prefix.pch
│ └── SSZipArchive.xcconfig
├── LICENSE
├── README.md
└── doc_imgs
├── share01.png
└── share02.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 | *.dSYM.zip
29 | *.dSYM
30 |
31 | # CocoaPods
32 | #
33 | # We recommend against adding the Pods directory to your .gitignore. However
34 | # you should judge for yourself, the pros and cons are mentioned at:
35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
36 | #
37 | # Pods/
38 |
39 | # Carthage
40 | #
41 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
42 | # Carthage/Checkouts
43 |
44 | Carthage/Build
45 |
46 | # fastlane
47 | #
48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
49 | # screenshots whenever they are needed.
50 | # For more information about the recommended setup visit:
51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
52 |
53 | fastlane/report.xml
54 | fastlane/Preview.html
55 | fastlane/screenshots/**/*.png
56 | fastlane/test_output
57 |
58 | # Code Injection
59 | #
60 | # After new code Injection tools there's a generated folder /iOSInjectionProject
61 | # https://github.com/johnno1962/injectionforxcode
62 |
63 | iOSInjectionProject/
64 |
--------------------------------------------------------------------------------
/GoProject/src/OfflineServer/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "encoding/json"
5 | "fmt"
6 | "io/ioutil"
7 | "log"
8 | "net/http"
9 | )
10 |
11 | type Person struct {
12 | Name string `json:"name"`
13 | Age string `json:"age"`
14 | HTML string `json:"html"`
15 | }
16 |
17 | func main() {
18 | http.HandleFunc("/api/getperson", getPerson)
19 | http.Handle("/source/", http.StripPrefix("/source/", http.FileServer(http.Dir("source"))))
20 | err := http.ListenAndServe(":9090", nil)
21 | if err != nil {
22 | log.Fatal("ListenAndServer:", err)
23 | }
24 | }
25 |
26 | func getPerson(w http.ResponseWriter, r *http.Request) {
27 | p := Person{Name: "张三", Age: "12", HTML: htmlString()}
28 | jsons, _ := json.Marshal(p)
29 | w.Write([]byte(jsons))
30 | }
31 |
32 | func htmlString() string {
33 | b, err := ioutil.ReadFile("templdate.html")
34 | if err != nil {
35 | fmt.Print(err)
36 | }
37 | str := string(b)
38 | return str
39 | }
40 |
--------------------------------------------------------------------------------
/GoProject/src/OfflineServer/source/offline_pkg.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiubojin/JXBWKWebView/f2576040942744c0bcf299d1f03442643a17bf11/GoProject/src/OfflineServer/source/offline_pkg.zip
--------------------------------------------------------------------------------
/GoProject/src/OfflineServer/templdate.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 模板渲染示例
5 |
6 |
32 |
33 |
34 |
35 |
36 |
37 |
Hello,{{name}}!
38 |
39 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/JXBWebKit.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod spec lint JXBWebKit.podspec' to ensure this is a
3 | # valid spec and to remove all comments including this before submitting the spec.
4 | #
5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
7 | #
8 |
9 | Pod::Spec.new do |s|
10 |
11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
12 | #
13 | # These will help people to find your library, and whilst it
14 | # can feel like a chore to fill in it's definitely to your advantage. The
15 | # summary should be tweet-length, and the description more in depth.
16 | #
17 |
18 | s.name = "JXBWebKit"
19 | s.version = "1.3.0"
20 | s.summary = "JXBWKWebView based on WKWebView"
21 |
22 | # This description is used to generate tags and improve search results.
23 | # * Think: What does it do? Why did you write it? What is the focus?
24 | # * Try to keep it short, snappy and to the point.
25 | # * Write the description between the DESC delimiters below.
26 | # * Finally, don't worry about the indent, CocoaPods strips it!
27 | s.description = "based on WKWebView"
28 |
29 | s.homepage = "https://github.com/xiubojin/JXBWKWebView"
30 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
31 |
32 |
33 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
34 | #
35 | # Licensing your code is important. See http://choosealicense.com for more info.
36 | # CocoaPods will detect a license file if there is a named LICENSE*
37 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
38 | #
39 |
40 | s.license = "MIT"
41 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" }
42 |
43 |
44 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
45 | #
46 | # Specify the authors of the library, with email addresses. Email addresses
47 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
48 | # accepts just a name if you'd rather not provide an email address.
49 | #
50 | # Specify a social_media_url where others can refer to, for example a twitter
51 | # profile URL.
52 | #
53 |
54 | s.author = { "jinxiubo" => "17610158997@163.com" }
55 | # Or just: s.author = "金修博"
56 | # s.authors = { "金修博" => "jinxiubo@58ganji.com" }
57 | # s.social_media_url = "http://twitter.com/金修博"
58 |
59 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
60 | #
61 | # If this Pod runs only on iOS or OS X, then specify the platform and
62 | # the deployment target. You can optionally include the target after the platform.
63 | #
64 |
65 | # s.platform = :ios
66 | # s.platform = :ios, "5.0"
67 |
68 | # When using multiple platforms
69 | s.ios.deployment_target = "8.0"
70 | # s.osx.deployment_target = "10.7"
71 | # s.watchos.deployment_target = "2.0"
72 | # s.tvos.deployment_target = "9.0"
73 |
74 |
75 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
76 | #
77 | # Specify the location from where the source should be retrieved.
78 | # Supports git, hg, bzr, svn and HTTP.
79 | #
80 |
81 | s.source = { :git => "https://github.com/xiubojin/JXBWKWebView.git", :tag => s.version.to_s }
82 |
83 |
84 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
85 | #
86 | # CocoaPods is smart about how it includes source code. For source files
87 | # giving a folder will include any swift, h, m, mm, c & cpp files.
88 | # For header files it will include any header in the folder.
89 | # Not including the public_header_files will make all headers public.
90 | #
91 |
92 | s.source_files = "JXBWebKit/**/*.{h,m}"
93 | s.resource = 'JXBWebKit/*.bundle'
94 | #s.exclude_files = "Classes/Exclude"
95 |
96 | # s.public_header_files = "Classes/**/*.h"
97 |
98 |
99 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
100 | #
101 | # A list of resources included with the Pod. These are copied into the
102 | # target bundle with a build phase script. Anything else will be cleaned.
103 | # You can preserve files from being cleaned, please don't preserve
104 | # non-essential files like tests, examples and documentation.
105 | #
106 |
107 | # s.resource = "icon.png"
108 | # s.resources = "Resources/*.png"
109 |
110 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave"
111 |
112 |
113 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
114 | #
115 | # Link your library with frameworks, or libraries. Libraries do not include
116 | # the lib prefix of their name.
117 | #
118 |
119 | # s.framework = "SomeFramework"
120 | # s.frameworks = "SomeFramework", "AnotherFramework"
121 |
122 | # s.library = "iconv"
123 | # s.libraries = "iconv", "xml2"
124 |
125 |
126 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
127 | #
128 | # If your library depends on compiler flags you can set them in the xcconfig hash
129 | # where they will only apply to your library. If you depend on other Podspecs
130 | # you can include multiple dependencies to ensure it works.
131 |
132 | s.requires_arc = true
133 |
134 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
135 | # s.dependency "JSONKit", "~> 1.4"
136 |
137 | end
138 |
--------------------------------------------------------------------------------
/JXBWebKit/JSResources.bundle/JXBJSBridge.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | window.JXBCallBackList = {};
3 |
4 | window.JXBJSBridge = {
5 | call:call,
6 | };
7 |
8 | String.prototype.hashCode = function() {
9 | var hash = 0;
10 | if (this.length == 0) return hash;
11 | for (var index = 0; index < this.length; index++) {
12 | var charactor = this.charCodeAt(index);
13 | hash = ((hash << 5) - hash) + charactor;
14 | hash = hash & hash;
15 | }
16 | return hash;
17 | };
18 |
19 |
20 |
21 | window.Callback = function(identifier, resultStatus, resultData) {
22 |
23 | callBackDict = window.JXBCallBackList[identifier];
24 |
25 | if (callBackDict) {
26 |
27 | isFinished = true;
28 | if (resultStatus == "success") {
29 | callBackDict.success(resultData);
30 | }
31 | if (resultStatus == "fail") {
32 | callBackDict.fail(resultData);
33 | }
34 | if (resultStatus == "progress") {
35 | isFinished = false;
36 | callBackDict.progress(resultData);
37 | }
38 |
39 | if (isFinished) {
40 | window.JXBCallBackList[identifier] = null;
41 | delete window.JXBCallBackList[identifier];
42 | }
43 | }
44 | }
45 |
46 |
47 | function call(bridgeObjc) {
48 | var dataString = encodeURIComponent(JSON.stringify(bridgeObjc.data));
49 | var timestamp = Date.parse(new Date());
50 | var identifier = (bridgeObjc.target + bridgeObjc.action + dataString + timestamp).hashCode().toString();
51 | window.JXBCallBackList[identifier] = bridgeObjc.callback;
52 | window.webkit.messageHandlers.WKNativeMethodMessage.postMessage({
53 | targetName:bridgeObjc.target,
54 | actionName:bridgeObjc.action,
55 | data:bridgeObjc.data,
56 | identifier:identifier,
57 | });
58 | }
59 |
60 | var JSCallBackMethodManager = {
61 | removeAllCallBacks: function(data){
62 | window.JXBCallBackList = {};
63 | }
64 | };
65 |
--------------------------------------------------------------------------------
/JXBWebKit/JSResources.bundle/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 测试
5 |
6 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/JXBWebKit/JSResources.bundle/webView_back@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiubojin/JXBWKWebView/f2576040942744c0bcf299d1f03442643a17bf11/JXBWebKit/JSResources.bundle/webView_back@2x.png
--------------------------------------------------------------------------------
/JXBWebKit/JSResources.bundle/webView_back@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiubojin/JXBWKWebView/f2576040942744c0bcf299d1f03442643a17bf11/JXBWebKit/JSResources.bundle/webView_back@3x.png
--------------------------------------------------------------------------------
/JXBWebKit/JSResources.bundle/webView_close@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiubojin/JXBWKWebView/f2576040942744c0bcf299d1f03442643a17bf11/JXBWebKit/JSResources.bundle/webView_close@2x.png
--------------------------------------------------------------------------------
/JXBWebKit/JSResources.bundle/webView_close@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiubojin/JXBWKWebView/f2576040942744c0bcf299d1f03442643a17bf11/JXBWebKit/JSResources.bundle/webView_close@3x.png
--------------------------------------------------------------------------------
/JXBWebKit/JXBWebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // JXBWebViewController.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/4/28.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "JXBWKWebView.h"
11 | #import "WKWebViewExtension.h"
12 | #import "JXBWebViewNetworkInterceptor.h"
13 | @class JXBWebViewController;
14 |
15 | #ifndef JXB_REQUIRES_SUPER
16 | #if __has_attribute(objc_requires_super)
17 | #define JXB_REQUIRES_SUPER __attribute__((objc_requires_super))
18 | #else
19 | #define JXB_REQUIRES_SUPER
20 | #endif
21 | #endif
22 |
23 | #pragma mark - MSWebViewControllerDelegate
24 | @protocol JXBWebViewControllerDelegate
25 |
26 | @optional
27 | - (void)webViewControllerWillGoBack:(JXBWebViewController *)webViewController;
28 | - (void)webViewControllerWillGoForward:(JXBWebViewController *)webViewController;
29 | - (void)webViewControllerWillReload:(JXBWebViewController *)webViewController;
30 | - (void)webViewControllerWillStop:(JXBWebViewController *)webViewController;
31 | - (void)webViewControllerDidStartLoad:(JXBWebViewController *)webViewController;
32 | - (void)webViewControllerDidFinishLoad:(JXBWebViewController *)webViewController;
33 | - (void)webViewController:(JXBWebViewController *)webViewController didFailLoadWithError:(NSError *)error;
34 |
35 | @end
36 |
37 | #pragma mark - JXBWebViewController
38 |
39 | @interface JXBWebViewController : UIViewController
40 | @property (nonatomic, strong) JXBWKWebView *webView;
41 | @property (nonatomic, weak) id delegate;
42 | @property (nonatomic, strong) NSArray *cookies;
43 | @property (nonatomic, strong) UIColor *progressTintColor;
44 | @property (nonatomic, strong) UIBarButtonItem *backItem;
45 | @property (nonatomic, strong) UIBarButtonItem *closeItem;
46 | @property (nonatomic, copy) NSURLRequest *request;
47 | @property (nonatomic, copy) NSString *htmlString;
48 | @property (nonatomic, copy) NSURL *fileURL;
49 | @property (nonatomic, assign) BOOL showProgressView;
50 | @property (nonatomic, assign) BOOL allowsBFNavigationGesture;
51 | @property (nonatomic, assign) BOOL isRootController;
52 | @property (nonatomic, readonly, getter=canGoBack) BOOL canGoBack;
53 | @property (nonatomic, readonly, getter=canGoForward) BOOL canGoForward;
54 | @property (nonatomic, readonly, getter=isLoading) BOOL loading;
55 |
56 | //初始化方法栈
57 | - (instancetype)initWithURLString:(NSString *)urlString;
58 | - (instancetype)initWithURL:(NSURL *)URL;
59 | - (instancetype)initWithURLRequest:(NSMutableURLRequest *)request;
60 | - (instancetype)initWithHTMLString:(NSString *)htmlString;
61 | - (instancetype)initWithFileURL:(NSURL *)fileURL;
62 |
63 | - (void)loadRequest:(NSURLRequest *)request;
64 | - (void)loadPostRequest:(NSURLRequest *)request;
65 | - (void)updateNavigationTitle;
66 | - (void)updateNavigationItems;
67 |
68 | //当needInterceptRequest=YES时,该方法用于拦截请求
69 | - (void)interceptRequestWithNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void(^)(WKNavigationActionPolicy))decisionHandler;
70 |
71 | //设置UserAgent
72 | - (void)syncCustomUserAgentWithType:(CustomUserAgentType)type
73 | customUserAgent:(NSString *)customUserAgent;
74 |
75 | //注册拦截的scheme和class
76 | - (void)registerSupportProtocolWithHTTP:(BOOL)supportHTTP
77 | schemes:(NSArray *)schemes
78 | protocolClass:(Class)protocolClass;
79 |
80 | //注销拦截的scheme和class
81 | - (void)unregisterSupportProtocolWithHTTP:(BOOL)supportHTTP
82 | schemes:(NSArray *)schemes
83 | protocolClass:(Class)protocolClass;
84 |
85 | //清除所有缓存
86 | + (void)clearAllWebCache;
87 |
88 | @end
89 |
90 | #pragma mark - JXBWebViewController (SubclassHooks)
91 | //以下方法供子类调用
92 | @interface JXBWebViewController (SubclassHooks)
93 |
94 | //即将后退
95 | - (void)willGoBack JXB_REQUIRES_SUPER;
96 |
97 | //即将前进
98 | - (void)willGoForward JXB_REQUIRES_SUPER;
99 |
100 | //即将刷新
101 | - (void)willReload JXB_REQUIRES_SUPER;
102 |
103 | //即将结束
104 | - (void)willStop JXB_REQUIRES_SUPER;
105 |
106 | //开始加载
107 | - (void)didStartLoad JXB_REQUIRES_SUPER;
108 |
109 | //已经加载完成
110 | - (void)didFinishLoad JXB_REQUIRES_SUPER;
111 |
112 | //加载出错
113 | - (void)didFailLoadWithError:(NSError *)error JXB_REQUIRES_SUPER;
114 |
115 | @end
116 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/CustomUI/UIProgressView+WKWebView.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIProgressView+WKWebView.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/4.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 | @class JXBWebViewController;
11 |
12 | @interface UIProgressView (WKWebView)
13 |
14 | @property(nonatomic, assign) BOOL hiddenWhenWebDidLoad;
15 |
16 | @property(nonatomic, strong) JXBWebViewController *webViewController;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/CustomUI/UIProgressView+WKWebView.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIProgressView+WKWebView.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/4.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "UIProgressView+WKWebView.h"
10 | #import "JXBWebViewController.h"
11 | #import
12 |
13 | @implementation UIProgressView (WKWebView)
14 |
15 | + (void)load {
16 | static dispatch_once_t onceToken;
17 | dispatch_once(&onceToken, ^{
18 | Method originalMethod = class_getInstanceMethod(self, @selector(setProgress:));
19 | Method swizzledMethod = class_getInstanceMethod(self, @selector(hook_setProgress:));
20 | method_exchangeImplementations(originalMethod, swizzledMethod);
21 | originalMethod = class_getInstanceMethod(self, @selector(setProgress:animated:));
22 | swizzledMethod = class_getInstanceMethod(self, @selector(hook_setProgress:animated:));
23 | method_exchangeImplementations(originalMethod, swizzledMethod);
24 | });
25 | }
26 |
27 | - (void)hook_setProgress:(float)progress {
28 | [self hook_setProgress:progress];
29 | [self checkHiddenWhenWebDidLoad];
30 | }
31 |
32 | - (void)hook_setProgress:(float)progress animated:(BOOL)animated {
33 | [self hook_setProgress:progress animated:animated];
34 | [self checkHiddenWhenWebDidLoad];
35 | }
36 |
37 | - (void)checkHiddenWhenWebDidLoad {
38 | if (!self.hiddenWhenWebDidLoad) {
39 | return;
40 | }
41 | float progress = self.progress;
42 | if (progress < 1) {
43 | if (self.hidden) {
44 | self.hidden = NO;
45 | }
46 | } else if (progress >= 1) {
47 | [UIView animateWithDuration:0.35 delay:0.15 options:7 animations:^{
48 | self.alpha = 0.0;
49 | } completion:^(BOOL finished) {
50 | if (finished) {
51 | self.hidden = YES;
52 | self.progress = 0.0;
53 | self.alpha = 1.0;
54 |
55 | //如果vc没被释放
56 | if (self.webViewController) {
57 | [self.webViewController updateNavigationItems];
58 | }
59 | }
60 | }];
61 | }
62 | }
63 |
64 | - (BOOL)hiddenWhenWebDidLoad {
65 | return [objc_getAssociatedObject(self, _cmd) boolValue];
66 | }
67 |
68 | - (void)setHiddenWhenWebDidLoad:(BOOL)hiddenWhenWebDidLoad {
69 | objc_setAssociatedObject(self, @selector(hiddenWhenWebDidLoad), @(hiddenWhenWebDidLoad), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
70 | }
71 |
72 | - (JXBWebViewController *)webViewController {
73 | return objc_getAssociatedObject(self, _cmd);
74 | }
75 |
76 | - (void)setWebViewController:(JXBWebViewController *)webViewController {
77 | objc_setAssociatedObject(self, @selector(webViewController), webViewController, OBJC_ASSOCIATION_ASSIGN);
78 | }
79 |
80 |
81 | @end
82 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/CustomUI/WKWebView+AOP.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+AOP.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/8.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WKWebView (AOP)
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/CustomUI/WKWebView+AOP.m:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+AOP.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/8.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "WKWebView+AOP.h"
10 | #import
11 |
12 |
13 | @implementation WKWebView (AOP)
14 |
15 | + (void)load {
16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0
17 | Class class = [self class];
18 | swizzleMethod(class, @selector(evaluateJavaScript:completionHandler:), @selector(aop_EvaluateJavaScript:completionHandler:));
19 | #endif
20 | }
21 |
22 | - (void)aop_EvaluateJavaScript:(NSString *)javaScriptString completionHandler:(void (^)(id, NSError *))completionHandler{
23 | id strongSelf = self;
24 | [self aop_EvaluateJavaScript:javaScriptString completionHandler:^(id r, NSError *e) {
25 | [strongSelf title];
26 | if (completionHandler) {
27 | completionHandler(r, e);
28 | }
29 | }];
30 | }
31 |
32 | void swizzleMethod(Class class, SEL originalSelector, SEL swizzledSelector) {
33 | Method originalMethod = class_getInstanceMethod(class, originalSelector);
34 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
35 |
36 | BOOL didAddMethod = class_addMethod(class,
37 | originalSelector,
38 | method_getImplementation(swizzledMethod),
39 | method_getTypeEncoding(swizzledMethod));
40 |
41 | if (didAddMethod) {
42 | class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
43 | }else{
44 | method_exchangeImplementations(originalMethod, swizzledMethod);
45 | }
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/Dispatch/WKMessageHandlerDispatch.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKMessageHandlerDispatch.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/7.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface WKMessageHandlerDispatch : NSObject
13 |
14 | //全局唯一访问点
15 | + (instancetype)sharedInstance;
16 |
17 | - (id)performTarget:(NSString *)targetName action:(NSString *)actionName params:(NSDictionary *)params shouldCacheTarget:(BOOL)shouldCacheTarget;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/Dispatch/WKMessageHandlerDispatch.m:
--------------------------------------------------------------------------------
1 | //
2 | // WKMessageHandlerDispatch.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/7.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "WKMessageHandlerDispatch.h"
10 |
11 | @interface WKMessageHandlerDispatch()
12 |
13 | @property (nonatomic, strong) NSMutableDictionary *cachedTarget;
14 |
15 | @end
16 |
17 | @implementation WKMessageHandlerDispatch
18 |
19 | + (instancetype)sharedInstance {
20 | static WKMessageHandlerDispatch *dispatch = nil;
21 | static dispatch_once_t onceToken;
22 |
23 | dispatch_once(&onceToken, ^{
24 | dispatch = [[WKMessageHandlerDispatch alloc] init];
25 | });
26 |
27 | return dispatch;
28 | }
29 |
30 | - (id)performTarget:(NSString *)targetName action:(NSString *)actionName params:(NSDictionary *)params shouldCacheTarget:(BOOL)shouldCacheTarget {
31 |
32 | NSString *targetClassString = [NSString stringWithFormat:@"Service_%@", targetName];
33 | NSString *actionString = [NSString stringWithFormat:@"func_%@:", actionName];
34 | Class targetClass;
35 |
36 | NSObject *target = self.cachedTarget[targetClassString];
37 | if (target == nil) {
38 | targetClass = NSClassFromString(targetClassString);
39 | target = [[targetClass alloc] init];
40 | }
41 |
42 | SEL action = NSSelectorFromString(actionString);
43 |
44 | if (target == nil) {
45 | //没有找到响应对象,此处可以push到404页面或者弹窗.
46 | return nil;
47 | }
48 |
49 | if (shouldCacheTarget) {
50 | self.cachedTarget[targetClassString] = target;
51 | }
52 |
53 | if ([target respondsToSelector:action]) {
54 | return [self safePerformAction:action target:target params:params];
55 | }else{
56 | return nil;
57 | }
58 | }
59 |
60 | - (id)safePerformAction:(SEL)action target:(NSObject *)target params:(NSDictionary *)params {
61 | NSMethodSignature* methodSig = [target methodSignatureForSelector:action];
62 | if(methodSig == nil) {
63 | return nil;
64 | }
65 | const char* retType = [methodSig methodReturnType];
66 |
67 | if (strcmp(retType, @encode(void)) == 0) {
68 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig];
69 | [invocation setArgument:¶ms atIndex:2];
70 | [invocation setSelector:action];
71 | [invocation setTarget:target];
72 | [invocation invoke];
73 | return nil;
74 | }
75 |
76 | if (strcmp(retType, @encode(NSInteger)) == 0) {
77 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig];
78 | [invocation setArgument:¶ms atIndex:2];
79 | [invocation setSelector:action];
80 | [invocation setTarget:target];
81 | [invocation invoke];
82 | NSInteger result = 0;
83 | [invocation getReturnValue:&result];
84 | return @(result);
85 | }
86 |
87 | if (strcmp(retType, @encode(BOOL)) == 0) {
88 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig];
89 | [invocation setArgument:¶ms atIndex:2];
90 | [invocation setSelector:action];
91 | [invocation setTarget:target];
92 | [invocation invoke];
93 | BOOL result = 0;
94 | [invocation getReturnValue:&result];
95 | return @(result);
96 | }
97 |
98 | if (strcmp(retType, @encode(CGFloat)) == 0) {
99 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig];
100 | [invocation setArgument:¶ms atIndex:2];
101 | [invocation setSelector:action];
102 | [invocation setTarget:target];
103 | [invocation invoke];
104 | CGFloat result = 0;
105 | [invocation getReturnValue:&result];
106 | return @(result);
107 | }
108 |
109 | if (strcmp(retType, @encode(NSUInteger)) == 0) {
110 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig];
111 | [invocation setArgument:¶ms atIndex:2];
112 | [invocation setSelector:action];
113 | [invocation setTarget:target];
114 | [invocation invoke];
115 | NSUInteger result = 0;
116 | [invocation getReturnValue:&result];
117 | return @(result);
118 | }
119 |
120 | #pragma clang diagnostic push
121 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
122 | return [target performSelector:action withObject:params];
123 | #pragma clang diagnostic pop
124 | }
125 |
126 | #pragma mark - getters and setters
127 | - (NSMutableDictionary *)cachedTarget {
128 | if (_cachedTarget == nil) {
129 | _cachedTarget = [[NSMutableDictionary alloc] init];
130 | }
131 | return _cachedTarget;
132 | }
133 |
134 | @end
135 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/Helper/WKAppManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppManager.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/7.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface WKAppManager : NSObject
13 |
14 | + (__kindof UINavigationController *)currentNavigationController;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/Helper/WKAppManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppManager.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/7.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "WKAppManager.h"
10 |
11 | FOUNDATION_STATIC_INLINE UIViewController * WKCurrentViewController() {
12 | UIViewController *viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
13 |
14 | while (viewController) {
15 | if ([viewController isKindOfClass:[UITabBarController class]]) {
16 | UITabBarController *tbvc = (UITabBarController*)viewController;
17 | viewController = tbvc.selectedViewController;
18 | } else if ([viewController isKindOfClass:[UINavigationController class]]) {
19 | UINavigationController *nvc = (UINavigationController*)viewController;
20 | viewController = nvc.topViewController;
21 | } else if (viewController.presentedViewController) {
22 | viewController = viewController.presentedViewController;
23 | } else if ([viewController isKindOfClass:[UISplitViewController class]] &&
24 | ((UISplitViewController *)viewController).viewControllers.count > 0) {
25 | UISplitViewController *svc = (UISplitViewController *)viewController;
26 | viewController = svc.viewControllers.lastObject;
27 | } else {
28 | return viewController;
29 | }
30 | }
31 | return viewController;
32 | }
33 |
34 | @implementation WKAppManager
35 |
36 | + (__kindof UINavigationController *)currentNavigationController {
37 | return WKCurrentViewController().navigationController;
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/Helper/WKMessageHandlerHelper.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKMessageHandlerHelper.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/7.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface WKMessageHandlerHelper : NSObject
13 |
14 | + (void)callbackWithResult:(NSString *)result resultData:(NSDictionary *)resultData identifier:(NSString *)identifier message:(WKScriptMessage *)message;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/Helper/WKMessageHandlerHelper.m:
--------------------------------------------------------------------------------
1 | //
2 | // WKMessageHandlerHelper.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/7.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "WKMessageHandlerHelper.h"
10 |
11 | @implementation WKMessageHandlerHelper
12 |
13 | + (void)callbackWithResult:(NSString *)result resultData:(NSDictionary *)resultData identifier:(NSString *)identifier message:(WKScriptMessage *)message {
14 |
15 | NSMutableDictionary *resultDictionary = [[NSMutableDictionary alloc] initWithDictionary:resultData];
16 | resultDictionary[@"result"] = result;
17 |
18 | NSString *resultDataString = [self jsonStringWithData:resultDictionary];
19 |
20 | NSString *callbackString = [NSString stringWithFormat:@"window.Callback('%@', '%@', '%@')", identifier, result, resultDataString];
21 |
22 | if ([[NSThread currentThread] isMainThread]) {
23 | [message.webView evaluateJavaScript:callbackString completionHandler:nil];
24 | } else {
25 | dispatch_async(dispatch_get_main_queue(), ^{
26 | [message.webView evaluateJavaScript:callbackString completionHandler:nil];
27 | });
28 | }
29 | }
30 |
31 | + (NSString *)jsonStringWithData:(NSDictionary *)data {
32 | NSString *messageJSON = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:NULL] encoding:NSUTF8StringEncoding];;
33 |
34 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"];
35 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
36 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\'" withString:@"\\\'"];
37 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];
38 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\r" withString:@"\\r"];
39 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\f" withString:@"\\f"];
40 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\u2028" withString:@"\\u2028"];
41 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\u2029" withString:@"\\u2029"];
42 |
43 | return messageJSON;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/Interceptor/JXBWebViewNetworkInterceptor.h:
--------------------------------------------------------------------------------
1 | //
2 | // JXBWebViewNetworkInterceptor.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2020/10/27.
6 | // Copyright © 2020 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @protocol JXBWebViewNetworkInterceptorDelegate
13 |
14 | - (BOOL)shouldIntercept;
15 |
16 | - (void)webViewNetworkInterceptorWithWebView:(WKWebView *)webView
17 | decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
18 | decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler;
19 |
20 | @end
21 |
22 |
23 | @interface JXBWebViewNetworkInterceptor : NSObject
24 |
25 | @property (nonatomic, assign, readonly) BOOL shouldIntercept;
26 |
27 | + (instancetype)sharedInstance;
28 |
29 | - (void)addDelegate:(id)delegate;
30 | - (void)removeDelegate:(id)delegate;
31 | - (void)handleInterceptorDataWithWebView:(WKWebView *)webView
32 | decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
33 | decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/Interceptor/JXBWebViewNetworkInterceptor.m:
--------------------------------------------------------------------------------
1 | //
2 | // JXBWebViewNetworkInterceptor.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2020/10/27.
6 | // Copyright © 2020 金修博. All rights reserved.
7 | //
8 |
9 | #import "JXBWebViewNetworkInterceptor.h"
10 |
11 | @interface JXBWebViewNetworkInterceptor ()
12 | @property (nonatomic, strong) NSHashTable *delegates;
13 | @end
14 |
15 | @implementation JXBWebViewNetworkInterceptor
16 |
17 | + (instancetype)sharedInstance {
18 | static JXBWebViewNetworkInterceptor *interceptor = nil;
19 | static dispatch_once_t onceToken;
20 | dispatch_once(&onceToken, ^{
21 | interceptor = [[JXBWebViewNetworkInterceptor alloc] init];
22 | });
23 | return interceptor;
24 | }
25 |
26 | - (BOOL)shouldIntercept {
27 | BOOL shouldIntercept = NO;
28 | for (id delegate in self.delegates) {
29 | if (delegate.shouldIntercept) {
30 | shouldIntercept = YES;
31 | break;
32 | }
33 | }
34 | return shouldIntercept;
35 | }
36 |
37 |
38 | - (void)addDelegate:(id) delegate {
39 | [self.delegates addObject:delegate];
40 | }
41 |
42 | - (void)removeDelegate:(id)delegate {
43 | [self.delegates removeObject:delegate];
44 | }
45 |
46 | - (void)handleInterceptorDataWithWebView:(WKWebView *)webView
47 | decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
48 | decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
49 | for (id delegate in self.delegates) {
50 | [delegate webViewNetworkInterceptorWithWebView:webView
51 | decidePolicyForNavigationAction:navigationAction
52 | decisionHandler:decisionHandler];
53 | }
54 | }
55 |
56 | #pragma mark - getter
57 | - (NSHashTable *)delegates {
58 | if (_delegates == nil) {
59 | self.delegates = [NSHashTable weakObjectsHashTable];
60 | }
61 | return _delegates;
62 | }
63 |
64 | @end
65 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/MessageHandler/WKCallNativeMethodMessageHandler.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKCallNativeMethodMessageHandler.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/7.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface WKCallNativeMethodMessageHandler : NSObject
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/MessageHandler/WKCallNativeMethodMessageHandler.m:
--------------------------------------------------------------------------------
1 | //
2 | // WKCallNativeMethodMessageHandler.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/7.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "WKCallNativeMethodMessageHandler.h"
10 | #import "WKMessageHandlerHelper.h"
11 | #import "WKMessageHandlerDispatch.h"
12 |
13 | @implementation WKCallNativeMethodMessageHandler
14 |
15 | #pragma mark - WKScriptMessageHandler
16 | - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
17 | //获取到js脚本传过来的参数
18 | NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithDictionary:message.body];
19 |
20 | //获取callback的identifier
21 | NSString *identifier = params[@"identifier"];
22 |
23 | //success callback
24 | params[@"success"] = ^(NSDictionary *result){
25 | [WKMessageHandlerHelper callbackWithResult:@"success" resultData:result identifier:identifier message:message];
26 | };
27 |
28 | //fail callback
29 | params[@"fail"] = ^(NSDictionary *result){
30 | [WKMessageHandlerHelper callbackWithResult:@"fail" resultData:result identifier:identifier message:message];
31 | };
32 |
33 | //progress callback
34 | params[@"progress"] = ^(NSDictionary *result){
35 | [WKMessageHandlerHelper callbackWithResult:@"progress" resultData:result identifier:identifier message:message];
36 | };
37 |
38 | //other mark
39 | params[@"isFromH5"] = @(YES);
40 | params[@"webview"] = message.webView;
41 |
42 | //把data包裹的数据重新添加到params里,然后将data删除,这样h5和native的target-action取值方式就统一了.
43 | NSDictionary *jsData = params[@"data"];
44 | if (jsData) {
45 | [params removeObjectForKey:@"data"];
46 | [jsData enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSString * _Nonnull value, BOOL * _Nonnull stop) {
47 | [params setValue:value forKey:key];
48 | }];
49 | }
50 |
51 | //target-action
52 | NSString *targetName = params[@"targetName"];
53 | NSString *actionName = params[@"actionName"];
54 |
55 | if ([actionName isKindOfClass:[NSString class]] && actionName.length > 0) {
56 | [[WKMessageHandlerDispatch sharedInstance] performTarget:targetName action:actionName params:params shouldCacheTarget:YES];
57 | }
58 | }
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/MessageHandler/WKMessageHandlerProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKMessageHandlerProtocol.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/20.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol WKMessageHandlerProtocol
12 |
13 | ///JS传给Native的参数
14 | @property (nonatomic, strong) NSDictionary *params;
15 |
16 | /**
17 | Native业务处理成功的回调,result:回调给JS的数据
18 | */
19 | @property (nonatomic, copy) void(^successCallback)(NSDictionary *result);
20 |
21 | /**
22 | Native业务处理失败的回调,result:回调给JS的数据
23 | */
24 | @property (nonatomic, copy) void(^failCallback)(NSDictionary *result);
25 |
26 | /**
27 | Native业务处理的回调,result:回调给JS的数据
28 | */
29 | @property (nonatomic, copy) void(^progressCallback)(NSDictionary *result);
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/ReusePool/JXBWKWebView.h:
--------------------------------------------------------------------------------
1 | //
2 | // MSWKWebView.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/17.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "WKWebViewExtension.h"
11 | #import "JXBWKWebViewPool.h"
12 |
13 | @interface JXBWKWebView : WKWebView
14 |
15 | @property (nonatomic, weak, readwrite) id holderObject;
16 | @property (nonatomic, strong, readonly) NSDate *recycleDate;
17 |
18 | + (instancetype)webView;
19 |
20 | + (WKWebViewConfiguration *)defaultConfiguration;
21 |
22 | #pragma mark - load request
23 | - (void)jxb_loadRequestURLString:(NSString *)urlString;
24 |
25 | - (void)jxb_loadRequestURL:(NSURL *)url;
26 |
27 | - (void)jxb_loadRequestURL:(NSURL *)url cookie:(NSDictionary *)params;
28 |
29 | - (void)jxb_loadRequest:(NSURLRequest *)requset;
30 |
31 | - (void)jxb_loadHTMLTemplate:(NSString *)htmlTemplate;
32 |
33 | #pragma mark - Cache
34 | + (void)jxb_clearAllWebCache;
35 |
36 | #pragma mark - UserAgent
37 | - (void)jxb_syncCustomUserAgentWithType:(CustomUserAgentType)type customUserAgent:(NSString *)customUserAgent;
38 |
39 | #pragma mark - register intercept protocol
40 | + (void)jxb_registerProtocolWithHTTP:(BOOL)supportHTTP
41 | customSchemeArray:(NSArray *)customSchemeArray
42 | urlProtocolClass:(Class)urlProtocolClass;
43 |
44 | + (void)jxb_unregisterProtocolWithHTTP:(BOOL)supportHTTP
45 | customSchemeArray:(NSArray *)customSchemeArray
46 | urlProtocolClass:(Class)urlProtocolClass;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/ReusePool/JXBWKWebViewPool.h:
--------------------------------------------------------------------------------
1 | //
2 | // MSWKWebViewPool.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/17.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 | @class JXBWKWebView;
11 |
12 | #define kWKWebViewReuseUrlString @"kwebkit://reuse-webView"
13 | #define kWKWebViewReuseScheme @"kwebkit"
14 |
15 | @protocol JXBWKWebViewReuseProtocol
16 | - (void)webViewWillReuse;
17 | - (void)webViewEndReuse;
18 | @end
19 |
20 | @interface JXBWKWebViewPool : NSObject
21 |
22 | /**
23 | 是否需要在App启动时提前准备好一个可复用的WebView,默认为YES.
24 | prepare=YES时,可显著优化WKWebView首次启动时间.
25 | prepare=NO时,不会提前初始化一个可复用的WebView.
26 | */
27 | @property(nonatomic, assign) BOOL prepare;
28 |
29 | + (instancetype)sharedInstance;
30 |
31 | - (__kindof JXBWKWebView *)getReusedWebViewForHolder:(id)holder;
32 |
33 | - (void)recycleReusedWebView:(__kindof JXBWKWebView *)webView;
34 |
35 | - (void)cleanReusableViews;
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/ReusePool/JXBWKWebViewPool.m:
--------------------------------------------------------------------------------
1 | //
2 | // MSWKWebViewPool.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/17.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "JXBWKWebViewPool.h"
10 | #import "JXBWKWebView.h"
11 | #import "WKWebViewExtension.h"
12 | #import "JXBWKCustomProtocol.h"
13 | #import "WKCallNativeMethodMessageHandler.h"
14 |
15 | @interface JXBWKWebViewPool()
16 | @property(nonatomic, strong, readwrite) dispatch_semaphore_t lock;
17 | @property(nonatomic, strong, readwrite) NSMutableArray<__kindof JXBWKWebView *> *visiableWebViewSet;
18 | @property(nonatomic, strong, readwrite) NSMutableArray<__kindof JXBWKWebView *> *reusableWebViewSet;
19 | @end
20 |
21 | @implementation JXBWKWebViewPool
22 |
23 | + (void)load {
24 | __block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
25 | [self prepareWebView];
26 | [[NSNotificationCenter defaultCenter] removeObserver:observer];
27 | }];
28 | }
29 |
30 | + (void)prepareWebView {
31 | [[JXBWKWebViewPool sharedInstance] _prepareReuseWebView];
32 | }
33 |
34 | + (instancetype)sharedInstance {
35 | static dispatch_once_t once;
36 | static JXBWKWebViewPool *webViewPool = nil;
37 | dispatch_once(&once,^{
38 | webViewPool = [[JXBWKWebViewPool alloc] init];
39 | });
40 | return webViewPool;
41 | }
42 |
43 | - (instancetype)init{
44 | if(self = [super init]){
45 | _prepare = YES;
46 | _visiableWebViewSet = [NSMutableArray array];
47 | _reusableWebViewSet = [NSMutableArray array];
48 | _lock = dispatch_semaphore_create(1);
49 | [[NSNotificationCenter defaultCenter] addObserver:self
50 | selector:@selector(_clearReusableWebViews) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
51 | }
52 | return self;
53 | }
54 |
55 | #pragma mark - Public Method
56 | - (__kindof JXBWKWebView *)getReusedWebViewForHolder:(id)holder{
57 | if (!holder) {
58 | return nil;
59 | }
60 |
61 | [self _tryCompactWeakHolders];
62 |
63 | JXBWKWebView *webView;
64 |
65 | dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER);
66 |
67 | if (_reusableWebViewSet.count > 0) {
68 | webView = [_reusableWebViewSet firstObject];
69 | NSTimeInterval diff = [NSDate.new timeIntervalSinceDate:webView.recycleDate];
70 | if (diff > 2.f) {
71 | [_reusableWebViewSet removeObject:webView];
72 | [_visiableWebViewSet addObject:webView];
73 | [webView webViewWillReuse];
74 | } else {
75 | webView = [JXBWKWebView webView];
76 | [_visiableWebViewSet addObject:webView];
77 | }
78 | } else {
79 | webView = [JXBWKWebView webView];
80 | [_visiableWebViewSet addObject:webView];
81 | }
82 | webView.holderObject = holder;
83 |
84 | dispatch_semaphore_signal(_lock);
85 |
86 | return webView;
87 | }
88 |
89 | - (void)recycleReusedWebView:(__kindof JXBWKWebView *)webView{
90 | if (!webView) return;
91 |
92 | dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER);
93 |
94 | if ([_visiableWebViewSet containsObject:webView]) {
95 | //将webView重置为初始状态
96 | [webView webViewEndReuse];
97 |
98 | [_visiableWebViewSet removeObject:webView];
99 | [_reusableWebViewSet addObject:webView];
100 | } else {
101 | if (![_reusableWebViewSet containsObject:webView]) {
102 | #if DEBUG
103 | NSLog(@"MSWKWebViewPool没有在任何地方使用这个webView");
104 | #endif
105 | }
106 | }
107 |
108 | dispatch_semaphore_signal(_lock);
109 | }
110 |
111 | - (void)cleanReusableViews{
112 | [self _clearReusableWebViews];
113 | }
114 |
115 | #pragma mark - Private Method
116 | - (void)_tryCompactWeakHolders {
117 | dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER);
118 |
119 | NSMutableSet *shouldreusedWebViewSet = [NSMutableSet set];
120 |
121 | for (JXBWKWebView *webView in _visiableWebViewSet) {
122 | if (!webView.holderObject) {
123 | [shouldreusedWebViewSet addObject:webView];
124 | }
125 | }
126 |
127 | for (JXBWKWebView *webView in shouldreusedWebViewSet) {
128 | [webView webViewEndReuse];
129 |
130 | [_visiableWebViewSet removeObject:webView];
131 | [_reusableWebViewSet addObject:webView];
132 | }
133 |
134 | dispatch_semaphore_signal(_lock);
135 | }
136 |
137 | - (void)_clearReusableWebViews {
138 | [self _tryCompactWeakHolders];
139 |
140 | dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER);
141 | [_reusableWebViewSet removeAllObjects];
142 | dispatch_semaphore_signal(_lock);
143 |
144 | [JXBWKWebView clearAllWebCache];
145 | }
146 |
147 | - (void)_prepareReuseWebView {
148 | if (!_prepare) return;
149 |
150 | __weak typeof(self) weakSelf = self;
151 | dispatch_async(dispatch_get_main_queue(), ^{
152 | JXBWKWebView *webView = [JXBWKWebView webView];
153 | [weakSelf.reusableWebViewSet addObject:webView];
154 | });
155 | }
156 |
157 | #pragma mark - Other
158 | - (void)dealloc {
159 | [[NSNotificationCenter defaultCenter] removeObserver:self];
160 | }
161 |
162 | @end
163 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/URLProtocol/JXBWKCustomProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // MSWKCustomProtocol.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/9.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | __attribute__((objc_subclassing_restricted))
12 | @interface JXBWKCustomProtocol : NSURLProtocol
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/URLProtocol/JXBWKCustomProtocol.m:
--------------------------------------------------------------------------------
1 | //
2 | // MSWKCustomProtocol.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/9.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "JXBWKCustomProtocol.h"
10 | #import "JXBWKWebViewPool.h"
11 | #import
12 |
13 | static NSString* const FilteredNewPostKey = @"FilteredNewPostKey";
14 |
15 | @interface JXBWKCustomProtocol()
16 | @property(nonatomic, strong) NSURLSessionDataTask *dataTask;
17 | @end
18 |
19 | @implementation JXBWKCustomProtocol
20 |
21 | + (BOOL)canInitWithRequest:(NSURLRequest *)request {
22 |
23 | if ([request.URL.scheme isEqualToString:@"post"]) {
24 | return YES;
25 | }
26 |
27 | if ([request.URL.absoluteString caseInsensitiveCompare:kWKWebViewReuseUrlString] == NSOrderedSame) {
28 | return YES;
29 | }
30 |
31 | //如果是已经拦截过的就放行
32 | if ([NSURLProtocol propertyForKey:FilteredNewPostKey inRequest:request]) {
33 | return NO;
34 | }
35 |
36 | return NO;
37 | }
38 |
39 |
40 | + (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request {
41 |
42 | if ([request.URL.scheme isEqualToString:@"post"]) {
43 | //获取oldScheme
44 | NSString *originScheme = request.allHTTPHeaderFields[@"oldScheme"];
45 |
46 | NSMutableString *urlString = [NSMutableString stringWithString:request.URL.absoluteString];
47 |
48 | NSRange schemeRange = [urlString rangeOfString:request.URL.scheme];
49 |
50 | [urlString replaceCharactersInRange:schemeRange withString:originScheme];
51 |
52 | //根据新的urlString生成新的request
53 | NSMutableURLRequest *newRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]];
54 |
55 | //获取bodyParam
56 | NSString *bodyParam = request.allHTTPHeaderFields[@"bodyParam"];
57 | NSData *bodyData =[bodyParam dataUsingEncoding:NSUTF8StringEncoding];
58 | newRequest.HTTPMethod = @"POST";
59 | newRequest.HTTPBody = bodyData;
60 |
61 | //获取cookie
62 | NSString *cookie = request.allHTTPHeaderFields[@"Cookie"];
63 | [newRequest addValue:cookie forHTTPHeaderField:@"Cookie"];
64 |
65 | [NSURLProtocol setProperty:@YES forKey:FilteredNewPostKey inRequest:newRequest];
66 |
67 | return newRequest;
68 | }
69 |
70 |
71 | return request;
72 | }
73 |
74 | - (void)startLoading {
75 | NSURLRequest *request = [[self class] canonicalRequestForRequest:self.request];
76 |
77 | if ([request.URL.absoluteString caseInsensitiveCompare:kWKWebViewReuseUrlString] == NSOrderedSame) {
78 | NSData *responseData = [[self _getWebViewReuseLoadString] dataUsingEncoding:NSUTF8StringEncoding];
79 | [self.client URLProtocol:self didReceiveResponse:[[NSURLResponse alloc]initWithURL:self.request.URL MIMEType:@"text/html" expectedContentLength:responseData.length textEncodingName:@"UTF-8"] cacheStoragePolicy:NSURLCacheStorageNotAllowed];
80 | [self.client URLProtocol:self didLoadData:responseData];
81 | [self.client URLProtocolDidFinishLoading:self];
82 | }else{
83 | NSURLSession *session = [NSURLSession sharedSession];
84 |
85 | NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
86 |
87 | if (!error) {
88 | [[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageAllowed];
89 |
90 | [self.client URLProtocol:self didLoadData:data];
91 |
92 | [[self client] URLProtocolDidFinishLoading:self];
93 | }else{
94 | [self.client URLProtocol:self didFailWithError:error];
95 | }
96 | }];
97 |
98 | [task resume];
99 |
100 | self.dataTask = task;
101 | }
102 | }
103 |
104 | - (void)stopLoading {
105 | [self.dataTask cancel];
106 | }
107 |
108 | - (NSString *)_getWebViewReuseLoadString{
109 | return @"JXBWebKit-Reuse";
110 | }
111 |
112 | @end
113 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/URLProtocol/NSURLProtocol+WebKitSupport.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSURLProtocol+WebKitSupport.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/3.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSURLProtocol (WebKitSupport)
12 |
13 | + (void)wk_registerScheme:(NSString*)scheme;
14 |
15 | + (void)wk_unregisterScheme:(NSString*)scheme;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/URLProtocol/NSURLProtocol+WebKitSupport.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSURLProtocol+WebKitSupport.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/3.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "NSURLProtocol+WebKitSupport.h"
10 | #import
11 |
12 | FOUNDATION_STATIC_INLINE Class ContextControllerClass() {
13 | static Class cls;
14 | if (!cls) {
15 | cls = [[[WKWebView new] valueForKey:[NSString stringWithFormat:@"%@%@%@%@", @"brow", @"singCon",@"textCon", @"troller"]] class];
16 | }
17 | return cls;
18 | }
19 |
20 | FOUNDATION_STATIC_INLINE SEL RegisterSchemeSelector() {
21 | return NSSelectorFromString([NSString stringWithFormat:@"%@%@%@%@%@", @"regi", @"sterSche",@"meForCus", @"tomProto", @"col:"]);
22 | }
23 |
24 | FOUNDATION_STATIC_INLINE SEL UnregisterSchemeSelector() {
25 | return NSSelectorFromString([NSString stringWithFormat:@"%@%@%@%@%@", @"unregi", @"sterSche",@"meForCus", @"tomProto", @"col:"]);
26 | }
27 |
28 | @implementation NSURLProtocol (WebKitSupport)
29 |
30 | + (void)wk_registerScheme:(NSString *)scheme {
31 | Class cls = ContextControllerClass();
32 | SEL sel = RegisterSchemeSelector();
33 | if ([(id)cls respondsToSelector:sel]) {
34 | #pragma clang diagnostic push
35 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
36 | [(id)cls performSelector:sel withObject:scheme];
37 | #pragma clang diagnostic pop
38 | }
39 | }
40 |
41 | + (void)wk_unregisterScheme:(NSString *)scheme {
42 | Class cls = ContextControllerClass();
43 | SEL sel = UnregisterSchemeSelector();
44 | if ([(id)cls respondsToSelector:sel]) {
45 | #pragma clang diagnostic push
46 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
47 | [(id)cls performSelector:sel withObject:scheme];
48 | #pragma clang diagnostic pop
49 | }
50 | }
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/WebViewExtension/WKWebView+ClearWebCache.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+ClearWebCache.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/10.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WKWebView (ClearWebCache)
12 |
13 | + (void)clearAllWebCache;
14 |
15 | - (void)clearBrowseHistory;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/WebViewExtension/WKWebView+ClearWebCache.m:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+ClearWebCache.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/10.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "WKWebView+ClearWebCache.h"
10 |
11 | @implementation WKWebView (ClearWebCache)
12 |
13 | + (void)clearAllWebCache {
14 | if ([[NSProcessInfo processInfo] operatingSystemVersion].majorVersion > 9){
15 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
16 | if (@available(iOS 9.0, *)) {
17 | NSSet *websiteDataTypes = [NSSet setWithArray:@[
18 | WKWebsiteDataTypeMemoryCache,
19 | WKWebsiteDataTypeSessionStorage,
20 | WKWebsiteDataTypeDiskCache,
21 | WKWebsiteDataTypeOfflineWebApplicationCache,
22 | WKWebsiteDataTypeCookies,
23 | WKWebsiteDataTypeLocalStorage,
24 | WKWebsiteDataTypeIndexedDBDatabases,
25 | WKWebsiteDataTypeWebSQLDatabases
26 | ]];
27 |
28 | NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0];
29 | [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes
30 | modifiedSince:dateFrom
31 | completionHandler:^{
32 | NSLog(@"WKWebView (ClearWebCache) Clear All Cache Done");
33 | }];
34 | }
35 | #endif
36 | } else {
37 | // iOS8
38 | NSSet *websiteDataTypes = [NSSet setWithArray:@[
39 | @"WKWebsiteDataTypeCookies",
40 | @"WKWebsiteDataTypeLocalStorage",
41 | @"WKWebsiteDataTypeIndexedDBDatabases",
42 | @"WKWebsiteDataTypeWebSQLDatabases"
43 | ]];
44 | for (NSString *type in websiteDataTypes) {
45 | clearWebViewCacheFolderByType(type);
46 | }
47 | }
48 | }
49 |
50 | FOUNDATION_STATIC_INLINE void clearWebViewCacheFolderByType(NSString *cacheType) {
51 |
52 | static dispatch_once_t once;
53 | static NSDictionary *cachePathMap = nil;
54 |
55 | dispatch_once(&once,
56 | ^{
57 | NSString *bundleId = [NSBundle mainBundle].infoDictionary[(NSString *)kCFBundleIdentifierKey];
58 | NSString *libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject];
59 | NSString *storageFileBasePath = [libraryPath stringByAppendingPathComponent:
60 | [NSString stringWithFormat:@"WebKit/%@/WebsiteData/", bundleId]];
61 |
62 | cachePathMap = @{@"WKWebsiteDataTypeCookies":
63 | [libraryPath stringByAppendingPathComponent:@"Cookies/Cookies.binarycookies"],
64 | @"WKWebsiteDataTypeLocalStorage":
65 | [storageFileBasePath stringByAppendingPathComponent:@"LocalStorage"],
66 | @"WKWebsiteDataTypeIndexedDBDatabases":
67 | [storageFileBasePath stringByAppendingPathComponent:@"IndexedDB"],
68 | @"WKWebsiteDataTypeWebSQLDatabases":
69 | [storageFileBasePath stringByAppendingPathComponent:@"WebSQL"]
70 | };
71 | });
72 |
73 | NSString *filePath = cachePathMap[cacheType];
74 | if (filePath && filePath.length > 0) {
75 | if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
76 | NSError *error = nil;
77 | [[NSFileManager defaultManager] removeItemAtPath:filePath error:&error];
78 | if (error) {
79 | NSLog(@"removed file fail: %@ ,error %@", [filePath lastPathComponent], error);
80 | }
81 | }
82 | }
83 | }
84 |
85 | - (void)clearBrowseHistory {
86 | SEL sel = NSSelectorFromString([NSString stringWithFormat:@"%@%@%@%@", @"_re", @"moveA",@"llIte", @"ms"]);
87 | if([self.backForwardList respondsToSelector:sel]){
88 | #pragma clang diagnostic push
89 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
90 | [self.backForwardList performSelector:sel];
91 | #pragma clang diagnostic pop
92 | }
93 | }
94 |
95 | @end
96 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/WebViewExtension/WKWebView+CookiesManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+CookiesManager.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/10.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WKWebView (CookiesManager)
12 |
13 | - (void)writeCookie:(NSArray *)cookies completion:(dispatch_block_t)completion;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/WebViewExtension/WKWebView+CookiesManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+CookiesManager.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/10.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "WKWebView+CookiesManager.h"
10 |
11 |
12 | @implementation WKWebView (CookiesManager)
13 |
14 | - (void)writeCookie:(NSArray *)cookies completion:(dispatch_block_t)completion{
15 | if (cookies.count == 0) {
16 | completion();
17 | return;
18 | }
19 | if (@available(iOS 11.0, *)) {
20 | WKHTTPCookieStore *cookieStore = self.configuration.websiteDataStore.httpCookieStore;
21 | //添加新的cookie
22 | [cookies enumerateObjectsUsingBlock:^(NSHTTPCookie * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
23 | [cookieStore setCookie:obj completionHandler:^{
24 | if (idx == cookies.count - 1) {
25 | completion();
26 | }
27 | }];
28 | }];
29 | }else{
30 | [cookies enumerateObjectsUsingBlock:^(NSHTTPCookie * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
31 | [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:obj];
32 | }];
33 | [self reload];
34 | completion();
35 | }
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/WebViewExtension/WKWebView+ExternalNavigationDelegates.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+ExternalNavigationDelegates.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/17.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface WKWebView (ExternalNavigationDelegates)
13 | @property(nonatomic, weak) id mainNavigationDelegate;
14 |
15 | - (void)useExternalNavigationDelegate;
16 | - (void)unUseExternalNavigationDelegate;
17 | - (void)addExternalNavigationDelegate:(id)delegate;
18 | - (void)removeExternalNavigationDelegate:(id)delegate;
19 | - (BOOL)containsExternalNavigationDelegate:(id)delegate;
20 | - (void)clearExternalNavigationDelegates;
21 | @end
22 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/WebViewExtension/WKWebView+SupportProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+SupportProtocol.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/7/31.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WKWebView (SupportProtocol)
12 |
13 | /**
14 | 注册支持拦截的scheme
15 |
16 | @param supportHTTP 是否支持拦截HTTP(s)
17 | @param customSchemeArray 其他scheme
18 | */
19 | + (void)registerSupportProtocolWithHTTP:(BOOL)supportHTTP customSchemeArray:(NSArray *)customSchemeArray;
20 |
21 | /**
22 | 注销之前注册拦截的scheme
23 |
24 | @param supportHTTP 是否注销拦截HTTP(s)
25 | @param customSchemeArray 其他scheme
26 | */
27 | + (void)unregisterSupportProtocolWithHTTP:(BOOL)supportHTTP customSchemeArray:(NSArray *)customSchemeArray;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/WebViewExtension/WKWebView+SupportProtocol.m:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+SupportProtocol.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/7/31.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "WKWebView+SupportProtocol.h"
10 | #import "NSURLProtocol+WebKitSupport.h"
11 |
12 | @implementation WKWebView (SupportProtocol)
13 |
14 | + (void)registerSupportProtocolWithHTTP:(BOOL)supportHTTP customSchemeArray:(NSArray *)customSchemeArray {
15 |
16 | if (!supportHTTP && [customSchemeArray count] <= 0) {
17 | return;
18 | }
19 |
20 | if (supportHTTP) {
21 | [NSURLProtocol wk_registerScheme:@"http"];
22 | [NSURLProtocol wk_registerScheme:@"https"];
23 | }
24 |
25 | for (NSString *scheme in customSchemeArray) {
26 | [NSURLProtocol wk_registerScheme:scheme];
27 | }
28 | }
29 |
30 | + (void)unregisterSupportProtocolWithHTTP:(BOOL)supportHTTP customSchemeArray:(NSArray *)customSchemeArray {
31 |
32 | if (!supportHTTP && [customSchemeArray count] <= 0) {
33 | return;
34 | }
35 |
36 | if (supportHTTP) {
37 | [NSURLProtocol wk_unregisterScheme:@"http"];
38 | [NSURLProtocol wk_unregisterScheme:@"https"];
39 | }
40 |
41 | for (NSString *scheme in customSchemeArray) {
42 | [NSURLProtocol wk_unregisterScheme:scheme];
43 | }
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/WebViewExtension/WKWebView+SyncUserAgent.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+SyncConfigUA.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/23.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef NS_ENUM (NSInteger, CustomUserAgentType){
12 | CustomUserAgentTypeReplace, //替换所有UA
13 | CustomUserAgentTypeAppend, //在原UA后面追加字符串
14 | };
15 |
16 |
17 | @interface WKWebView (SyncUserAgent)
18 |
19 | /**
20 | * 设置UserAgent
21 | *
22 | * @param type replace or append original UA
23 | * @param customUserAgent customUserAgent
24 | */
25 | - (void)syncCustomUserAgentWithType:(CustomUserAgentType)type
26 | customUserAgent:(NSString *)customUserAgent;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/WebViewExtension/WKWebView+SyncUserAgent.m:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebView+SyncConfigUA.m
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/23.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "WKWebView+SyncUserAgent.h"
10 |
11 | @implementation WKWebView (SyncUserAgent)
12 |
13 | - (void)syncCustomUserAgentWithType:(CustomUserAgentType)type
14 | customUserAgent:(NSString *)customUserAgent {
15 |
16 | if (!customUserAgent || customUserAgent.length <= 0) {
17 | return;
18 | }
19 |
20 | if(type == CustomUserAgentTypeReplace){
21 | if (@available(iOS 9.0, *)) {
22 | self.customUserAgent = customUserAgent;
23 | }
24 | }else if (type == CustomUserAgentTypeAppend){
25 | [self evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id userAgent, NSError * _Nullable error) {
26 | if ([userAgent isKindOfClass:[NSString class]]) {
27 | NSString *newUserAgent = [NSString stringWithFormat:@"%@-%@", userAgent, customUserAgent];
28 | if (@available(iOS 9.0, *)) {
29 | self.customUserAgent = newUserAgent;
30 | }
31 | }
32 | }];
33 | }else{
34 | NSLog(@"WKWebView (SyncConfigUA) config with invalid type :%@", @(type));
35 | }
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/JXBWebKit/Tools/WebViewExtension/WKWebViewExtension.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebViewExtension.h
3 | // JXBWebKit
4 | //
5 | // Created by jinxiubo on 2018/5/10.
6 | // Copyright © 2018年 jinxiubo. All rights reserved.
7 | //
8 |
9 | #import "WKWebView+ClearWebCache.h"
10 | #import "WKWebView+CookiesManager.h"
11 | #import "WKWebView+SyncUserAgent.h"
12 | #import "WKWebView+ExternalNavigationDelegates.h"
13 | #import "WKWebView+SupportProtocol.h"
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject.xcodeproj/xcshareddata/xcschemes/JXBWebKitProject.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
75 |
77 |
83 |
84 |
85 |
86 |
87 |
88 |
94 |
96 |
102 |
103 |
104 |
105 |
107 |
108 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 |
24 | - (void)applicationWillResignActive:(UIApplication *)application {
25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
27 | }
28 |
29 |
30 | - (void)applicationDidEnterBackground:(UIApplication *)application {
31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 |
36 | - (void)applicationWillEnterForeground:(UIApplication *)application {
37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
38 | }
39 |
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
43 | }
44 |
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/CustomTwoViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CustomTwoViewController.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2020/5/18.
6 | // Copyright © 2020 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface CustomTwoViewController : UIViewController
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/CustomTwoViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CustomTwoViewController.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2020/5/18.
6 | // Copyright © 2020 金修博. All rights reserved.
7 | //
8 |
9 | #import "CustomTwoViewController.h"
10 | #import
11 |
12 | @interface CustomTwoViewController ()
13 | @property (nonatomic, strong) WKWebView *webView ;
14 |
15 | @end
16 |
17 | @implementation CustomTwoViewController
18 |
19 | - (void)viewDidLayoutSubviews {
20 | [super viewDidLayoutSubviews];
21 |
22 | self.webView.frame = self.view.frame;
23 | }
24 |
25 | - (void)viewDidLoad {
26 | [super viewDidLoad];
27 | self.view.backgroundColor = [UIColor whiteColor];
28 |
29 | NSLog(@"start");
30 | WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero];
31 | NSLog(@"end");
32 | self.webView = webView;
33 | webView.UIDelegate = self;
34 | webView.navigationDelegate = self;
35 | [self.view addSubview:webView];
36 |
37 | NSURL *url = [NSURL URLWithString:@"https://www.baidu.com"];
38 | NSURLRequest *request = [NSURLRequest requestWithURL:url];
39 | [webView loadRequest:request];
40 | }
41 |
42 | - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
43 | decisionHandler(WKNavigationActionPolicyAllow);
44 | }
45 | @end
46 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/CustomViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CustomViewController.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2020/5/17.
6 | // Copyright © 2020 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface CustomViewController : UIViewController
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/CustomViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CustomViewController.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2020/5/17.
6 | // Copyright © 2020 金修博. All rights reserved.
7 | //
8 |
9 | #import "CustomViewController.h"
10 | #import
11 |
12 | @interface CustomViewController ()
13 | @property (nonatomic, strong) WKWebView *webView ;
14 | @end
15 |
16 | @implementation CustomViewController
17 |
18 | - (void)viewDidLayoutSubviews {
19 | [super viewDidLayoutSubviews];
20 |
21 | self.webView.frame = self.view.frame;
22 | }
23 |
24 | - (void)viewDidLoad {
25 | [super viewDidLoad];
26 | self.view.backgroundColor = [UIColor whiteColor];
27 |
28 | NSLog(@"start");
29 | WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero];
30 | NSLog(@"end");
31 | self.webView = webView;
32 | webView.UIDelegate = self;
33 | webView.navigationDelegate = self;
34 | [self.view addSubview:webView];
35 |
36 | NSURL *url = [NSURL URLWithString:@"https://www.baidu.com"];
37 | NSURLRequest *request = [NSURLRequest requestWithURL:url];
38 | [webView loadRequest:request];
39 | }
40 |
41 | - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
42 | decisionHandler(WKNavigationActionPolicyAllow);
43 | }
44 |
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/H5EnterModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // H5EnterModel.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface H5EnterModel : NSObject
12 |
13 | @property(nonatomic, copy) NSString *title;
14 | @property(nonatomic, copy) NSString *detailTitle;
15 | @property(nonatomic, copy) NSString *url;
16 | @property(nonatomic, copy) NSDictionary *cookie;
17 | @property(nonatomic, assign) NSInteger type;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/H5EnterModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // H5EnterModel.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "H5EnterModel.h"
10 |
11 | @implementation H5EnterModel
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Hybrid/HybridViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // HybridViewController.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface HybridViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Hybrid/HybridViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // HybridViewController.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "HybridViewController.h"
10 |
11 | @interface HybridViewController ()
12 |
13 | @end
14 |
15 | @implementation HybridViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 | }
21 |
22 | - (void)didReceiveMemoryWarning {
23 | [super didReceiveMemoryWarning];
24 | // Dispose of any resources that can be recreated.
25 | }
26 |
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Hybrid/User.h:
--------------------------------------------------------------------------------
1 | //
2 | // User.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface User : NSObject
12 |
13 | @property(nonatomic, copy) NSString *name;
14 | @property(nonatomic, copy) NSString *age;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Hybrid/User.m:
--------------------------------------------------------------------------------
1 | //
2 | // User.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "User.h"
10 |
11 | @implementation User
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/IneterceptorRequsetHandler.h:
--------------------------------------------------------------------------------
1 | //
2 | // IneterceptorRequsetHandler.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2020/10/27.
6 | // Copyright © 2020 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface IneterceptorRequsetHandler : NSObject
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/IneterceptorRequsetHandler.m:
--------------------------------------------------------------------------------
1 | //
2 | // IneterceptorRequsetHandler.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2020/10/27.
6 | // Copyright © 2020 金修博. All rights reserved.
7 | //
8 |
9 | #import "IneterceptorRequsetHandler.h"
10 |
11 | @implementation IneterceptorRequsetHandler
12 |
13 | - (BOOL)shouldIntercept {
14 | return YES;
15 | }
16 |
17 | - (void)webViewNetworkInterceptorWithWebView:(WKWebView *)webView
18 | decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
19 | decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
20 |
21 | NSLog(@"webView = %@", webView);
22 |
23 | NSLog(@"navigationAction.request = %@", navigationAction.request);
24 |
25 | decisionHandler(WKNavigationActionPolicyAllow);
26 | }
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | NSAppTransportSecurity
24 |
25 | NSAllowsArbitraryLoads
26 |
27 |
28 | UILaunchStoryboardName
29 | LaunchScreen
30 | UIMainStoryboardFile
31 | Main
32 | UIRequiredDeviceCapabilities
33 |
34 | armv7
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UISupportedInterfaceOrientations~ipad
43 |
44 | UIInterfaceOrientationPortrait
45 | UIInterfaceOrientationPortraitUpsideDown
46 | UIInterfaceOrientationLandscapeLeft
47 | UIInterfaceOrientationLandscapeRight
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/JXBNavigationController.h:
--------------------------------------------------------------------------------
1 | //
2 | // JXBNavigationController.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface JXBNavigationController : UINavigationController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/JXBNavigationController.m:
--------------------------------------------------------------------------------
1 | //
2 | // JXBNavigationController.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "JXBNavigationController.h"
10 | #import
11 |
12 | @interface JXBNavigationController ()
13 |
14 | @end
15 |
16 | @implementation JXBNavigationController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 |
21 | __weak JXBNavigationController *weakSelf = self;
22 | if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
23 | self.interactivePopGestureRecognizer.delegate = weakSelf;
24 | self.delegate = weakSelf;
25 | }
26 | }
27 |
28 | - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
29 |
30 | if ( [self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
31 | self.interactivePopGestureRecognizer.enabled = NO;
32 | }
33 |
34 | [super pushViewController:viewController animated:animated];
35 | }
36 |
37 | - (NSArray *)popToRootViewControllerAnimated:(BOOL)animated {
38 | if ( [self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
39 | self.interactivePopGestureRecognizer.enabled = NO;
40 | }
41 |
42 | return [super popToRootViewControllerAnimated:animated];
43 | }
44 |
45 | - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated {
46 | if( [self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
47 | self.interactivePopGestureRecognizer.enabled = NO;
48 | }
49 |
50 | return [super popToViewController:viewController animated:animated];
51 | }
52 |
53 | #pragma mark UINavigationControllerDelegate
54 | - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animate {
55 | if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
56 | self.interactivePopGestureRecognizer.enabled = YES;
57 | }
58 | }
59 |
60 |
61 | @end
62 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Good/GoodDetailController.h:
--------------------------------------------------------------------------------
1 | //
2 | // GoodDetailController.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/4.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface GoodDetailController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Good/GoodDetailController.m:
--------------------------------------------------------------------------------
1 | //
2 | // GoodDetailController.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/4.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "GoodDetailController.h"
10 |
11 | @interface GoodDetailController ()
12 |
13 | @end
14 |
15 | @implementation GoodDetailController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 | self.title = @"商品详情";
21 |
22 | self.view.backgroundColor = [UIColor purpleColor];
23 | }
24 |
25 | - (void)didReceiveMemoryWarning {
26 | [super didReceiveMemoryWarning];
27 | // Dispose of any resources that can be recreated.
28 |
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Good/GoodListController.h:
--------------------------------------------------------------------------------
1 | //
2 | // GoodListController.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/4.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface GoodListController : UIViewController
13 | @property (nonatomic, strong) NSDictionary *params;
14 | @property (nonatomic, copy) void(^successCallback)(NSDictionary *result);
15 | @property (nonatomic, copy) void(^failCallback)(NSDictionary *result);
16 | @property (nonatomic, copy) void(^progressCallback)(NSDictionary *result);
17 | @end
18 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Good/GoodListController.m:
--------------------------------------------------------------------------------
1 | //
2 | // GoodListController.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/4.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "GoodListController.h"
10 |
11 | @interface GoodListController ()
12 | @property (nonatomic, strong) UIButton *btnSuccess;
13 | @property (nonatomic, strong) UIButton *btnFail;
14 | @property (nonatomic, strong) UIButton *btnProgress;
15 | @end
16 |
17 | @implementation GoodListController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 |
22 | self.view.backgroundColor = [UIColor whiteColor];
23 |
24 | self.title = @"商品列表";
25 |
26 | self.btnFail = [UIButton buttonWithType:UIButtonTypeSystem];
27 | self.btnFail.frame = CGRectMake(0, 0, 100, 50);
28 | self.btnFail.center = self.view.center;
29 | [self.btnFail addTarget:self action:@selector(btnFailClick:) forControlEvents:UIControlEventTouchUpInside];
30 | [self.btnFail setTitle:@"fail" forState:UIControlStateNormal];
31 |
32 | self.btnSuccess = [UIButton buttonWithType:UIButtonTypeSystem];
33 | self.btnSuccess.frame = CGRectMake(CGRectGetMinX(self.btnFail.frame), CGRectGetMinY(self.btnFail.frame)-100, 100, 50);
34 | [self.btnSuccess addTarget:self action:@selector(btnSuccessClick:) forControlEvents:UIControlEventTouchUpInside];
35 | [self.btnSuccess setTitle:@"success" forState:UIControlStateNormal];
36 |
37 | self.btnProgress = [UIButton buttonWithType:UIButtonTypeSystem];
38 | self.btnProgress.frame = CGRectMake(CGRectGetMinX(self.btnFail.frame), CGRectGetMinY(self.btnFail.frame)+100, 100, 50);
39 | [self.btnProgress addTarget:self action:@selector(btnProgressClick:) forControlEvents:UIControlEventTouchUpInside];
40 | [self.btnProgress setTitle:@"progress" forState:UIControlStateNormal];
41 |
42 | [self.view addSubview:self.btnSuccess];
43 | [self.view addSubview:self.btnFail];
44 | [self.view addSubview:self.btnProgress];
45 | }
46 |
47 | #pragma mark - event response
48 | - (void)btnSuccessClick:(UIButton *)button {
49 | if (self.successCallback) {
50 | self.successCallback(@{
51 | @"value":@"success result from GoodListController",
52 | @"receivedData":self.params
53 | });
54 | }
55 | [self.navigationController popViewControllerAnimated:YES];
56 | }
57 |
58 | - (void)btnFailClick:(UIButton *)button {
59 | if (self.failCallback) {
60 | self.failCallback(@{
61 | @"value":@"fail result data from GoodDetailController",
62 | @"receivedData":self.params
63 | });
64 | }
65 | [self.navigationController popViewControllerAnimated:YES];
66 | }
67 |
68 | - (void)btnProgressClick:(UIButton *)button {
69 | if (self.progressCallback) {
70 | self.progressCallback(@{
71 | @"value":@"60%...",
72 | @"receivedData":self.params
73 | });
74 | }
75 | [self.navigationController popViewControllerAnimated:YES];
76 | }
77 |
78 |
79 | - (void)didReceiveMemoryWarning {
80 | [super didReceiveMemoryWarning];
81 | // Dispose of any resources that can be recreated.
82 | }
83 |
84 | @end
85 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Good/Service_Good.h:
--------------------------------------------------------------------------------
1 | //
2 | // Service_Good.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/4.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Service_Good : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Good/Service_Good.m:
--------------------------------------------------------------------------------
1 | //
2 | // Service_Good.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/4.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "Service_Good.h"
10 | #import "GoodListController.h"
11 | #import "GoodDetailController.h"
12 | #import
13 |
14 | @implementation Service_Good
15 |
16 | - (void)func_list:(NSDictionary *)params {
17 | GoodListController *vc = [[GoodListController alloc] init];
18 | vc.params = @{@"key1":@"value1", @"key2": @"value2"};
19 | vc.successCallback = params[@"success"];
20 | vc.failCallback = params[@"fail"];
21 | vc.progressCallback = params[@"progress"];
22 | [WKAppManager.currentNavigationController pushViewController:vc animated:YES];
23 | }
24 |
25 | - (void)func_detail:(NSDictionary *)params {
26 | GoodDetailController *vc = [[GoodDetailController alloc] init];
27 | [WKAppManager.currentNavigationController pushViewController:vc animated:YES];
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Good/h5.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 测试
5 |
6 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Location/Service_location.h:
--------------------------------------------------------------------------------
1 | //
2 | // Service_location.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Service_location : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Location/Service_location.m:
--------------------------------------------------------------------------------
1 | //
2 | // Service_location.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "Service_location.h"
10 |
11 | @implementation Service_location
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Push/Service_push.h:
--------------------------------------------------------------------------------
1 | //
2 | // Service_push.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Service_push : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Push/Service_push.m:
--------------------------------------------------------------------------------
1 | //
2 | // Service_push.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "Service_push.h"
10 | #import
11 |
12 | NSString * const kServicePushRegisterPushAuthority = @"kServicePushRegisterPushAuthority";
13 |
14 | @implementation Service_push
15 |
16 | //获取推送权限状态
17 | - (void)func_getAuthorityState:(NSDictionary *)param {
18 | BOOL isOpen = NO;
19 |
20 | //iOS8.0以上
21 | UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
22 | if (setting.types != UIUserNotificationTypeNone) {
23 | isOpen = YES;
24 | }
25 |
26 | void(^successCallback)(NSDictionary *result) = param[@"success"];
27 |
28 | NSDictionary *resultDict = @{@"isOpen":@(isOpen)};
29 |
30 | successCallback(resultDict);
31 | }
32 |
33 | //获取推送权限
34 | - (void)func_getAuthority:(NSDictionary *)param {
35 | [self getAuthorityFromUser];
36 | }
37 |
38 | //延迟授权
39 | - (void)getAuthorityFromUser {
40 | BOOL isOpen = NO;
41 |
42 | //iOS8.0以上
43 | UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
44 | if (setting.types != UIUserNotificationTypeNone) {
45 | isOpen = YES;
46 | }
47 |
48 | if(isOpen) return;
49 |
50 |
51 | UIAlertController *alertController = [UIAlertController
52 | alertControllerWithTitle:@"获取推送权限提醒"
53 | message:@"我们想要访问您的推送权限以提供更好的服务,请在接下来的系统授权弹窗中点击\"确定\"按钮."
54 | preferredStyle:UIAlertControllerStyleAlert];
55 |
56 | UIAlertAction* denyAction = [UIAlertAction
57 | actionWithTitle:@"不"
58 | style:UIAlertActionStyleDefault
59 | handler:^(UIAlertAction * action)
60 | {
61 | [alertController dismissViewControllerAnimated:YES completion:nil];
62 |
63 | }];
64 |
65 | UIAlertAction* allowAction = [UIAlertAction
66 | actionWithTitle:@"好的"
67 | style:UIAlertActionStyleDestructive
68 | handler:^(UIAlertAction * action) {
69 | [alertController dismissViewControllerAnimated:NO completion:nil];
70 |
71 | dispatch_async(dispatch_get_main_queue(), ^{
72 | [[NSNotificationCenter defaultCenter] postNotificationName:kServicePushRegisterPushAuthority object:nil];
73 | });
74 |
75 | }];
76 |
77 | [alertController addAction:denyAction];
78 | [alertController addAction:allowAction];
79 |
80 | [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController animated:YES completion:nil];
81 | }
82 |
83 | - (void)func_openSystemNotifiPage:(NSDictionary *)param {
84 |
85 | if (@available(iOS 10.0, *)) {
86 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
87 | }else{
88 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"//prefs:root=NOTIFICATIONS_ID"]];
89 | }
90 | }
91 |
92 | @end
93 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Setting/Service_setting.h:
--------------------------------------------------------------------------------
1 | //
2 | // Service_setting.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Service_setting : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/Service/Setting/Service_setting.m:
--------------------------------------------------------------------------------
1 | //
2 | // Service_setting.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "Service_setting.h"
10 | #import
11 |
12 | @interface Service_setting()
13 | @property(nonatomic, copy) NSString *cacheFilePath;
14 | @end
15 |
16 | @implementation Service_setting
17 |
18 | //获取缓存大小
19 | - (void)func_getCacheSize:(NSDictionary *)param {
20 | NSFileManager *manager = [NSFileManager defaultManager];
21 | CGFloat size = 0;
22 | if ([manager fileExistsAtPath:self.cacheFilePath]) {
23 | // 目录下的文件计算大小
24 | NSArray *childrenFile = [manager subpathsAtPath:self.cacheFilePath];
25 | for (NSString *fileName in childrenFile) {
26 | NSString *absolutePath = [self.cacheFilePath stringByAppendingPathComponent:fileName];
27 | size += [manager attributesOfItemAtPath:absolutePath error:nil].fileSize;
28 | }
29 | }
30 |
31 | // 将大小转化为M,size单位b,转,KB,MB除以两次1024
32 | CGFloat sizeResult = size / 1024.0 / 1024.0;
33 | NSString *sizeStr = [NSString stringWithFormat:@"%.2fM",sizeResult];
34 |
35 | void(^successCallback)(NSDictionary *result) = param[@"success"];
36 |
37 | NSDictionary *resultDict = @{@"size":sizeStr};
38 |
39 | successCallback(resultDict);
40 | }
41 |
42 | //清除缓存
43 | - (void)func_clearCache:(NSDictionary *)param {
44 | NSFileManager *fileManager = [NSFileManager defaultManager];
45 |
46 | if ([fileManager fileExistsAtPath:self.cacheFilePath]) {
47 | NSArray *childrenFiles = [fileManager subpathsAtPath:self.cacheFilePath];
48 | for (NSString *fileName in childrenFiles) {
49 | // 拼接路径
50 | NSString *absolutePath = [self.cacheFilePath stringByAppendingPathComponent:fileName];
51 |
52 | // 将文件删除
53 | [fileManager removeItemAtPath:absolutePath error:nil];
54 | }
55 | }
56 |
57 | void(^successCallback)(NSDictionary *result) = param[@"success"];
58 |
59 | successCallback(nil);
60 | }
61 |
62 | //缓存文件路径
63 | - (NSString *)cacheFilePath {
64 | if (!_cacheFilePath) {
65 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask,YES);
66 | _cacheFilePath = [paths lastObject];
67 | }
68 |
69 | return _cacheFilePath;
70 | }
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/TestWebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // TestWebViewController.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/9/4.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "JXBWebViewController.h"
10 |
11 | @interface TestWebViewController : JXBWebViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/TestWebViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // TestWebViewController.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/9/4.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import "TestWebViewController.h"
10 | #import "IneterceptorRequsetHandler.h"
11 |
12 | @interface TestWebViewController ()
13 | @property (nonatomic, strong) IneterceptorRequsetHandler *handler;
14 | @end
15 |
16 | @implementation TestWebViewController
17 |
18 | - (instancetype)init {
19 | if (self = [super init]) {
20 | //进度条颜色
21 | self.progressTintColor = [UIColor blackColor];
22 | //创建拦截器
23 | self.handler = [IneterceptorRequsetHandler new];
24 | }
25 | return self;
26 | }
27 |
28 |
29 |
30 | - (void)viewDidLoad {
31 | [super viewDidLoad];
32 |
33 | NSLog(@"Test.webView = %@", self.webView);
34 |
35 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Warning" style:0 target:self action:@selector(warningAcition)];
36 |
37 | [[JXBWebViewNetworkInterceptor sharedInstance] addDelegate:self.handler];
38 | }
39 |
40 | - (void)didReceiveMemoryWarning {
41 | [super didReceiveMemoryWarning];
42 | // Dispose of any resources that can be recreated.
43 | }
44 |
45 | - (void)warningAcition {
46 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object:nil];
47 | }
48 |
49 | - (void)dealloc {
50 | [[JXBWebViewNetworkInterceptor sharedInstance] removeDelegate:self.handler];
51 | }
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProject/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // JXBWebKitProject
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProjectTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProjectTests/JXBWebKitProjectTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // JXBWebKitProjectTests.m
3 | // JXBWebKitProjectTests
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface JXBWebKitProjectTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation JXBWebKitProjectTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProjectUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/JXBWebKitProject/JXBWebKitProjectUITests/JXBWebKitProjectUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // JXBWebKitProjectUITests.m
3 | // JXBWebKitProjectUITests
4 | //
5 | // Created by 金修博 on 2018/8/3.
6 | // Copyright © 2018年 金修博. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface JXBWebKitProjectUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation JXBWebKitProjectUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment the next line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | target 'JXBWebKitProject' do
5 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
6 | # use_frameworks!
7 |
8 | # Pods for JXBWebKitProject
9 | pod 'JXBWebKit', :path => '../'
10 | pod 'SSZipArchive'
11 |
12 | target 'JXBWebKitProjectTests' do
13 | inherit! :search_paths
14 | # Pods for testing
15 | end
16 |
17 | target 'JXBWebKitProjectUITests' do
18 | inherit! :search_paths
19 | # Pods for testing
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - JXBWebKit (1.1.1)
3 | - SSZipArchive (2.1.3)
4 |
5 | DEPENDENCIES:
6 | - JXBWebKit (from `../`)
7 | - SSZipArchive
8 |
9 | SPEC REPOS:
10 | https://github.com/cocoapods/specs.git:
11 | - SSZipArchive
12 |
13 | EXTERNAL SOURCES:
14 | JXBWebKit:
15 | :path: "../"
16 |
17 | SPEC CHECKSUMS:
18 | JXBWebKit: f9459910a5fce771f971e176ec6fe9f4acb2f333
19 | SSZipArchive: 51a800ebb77f95a8329b6ced1faaff394b47f509
20 |
21 | PODFILE CHECKSUM: 014222f5e4df3e46bc3ab47fd0420c0d1625f354
22 |
23 | COCOAPODS: 1.7.5
24 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/JXBWKCustomProtocol.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/URLProtocol/JXBWKCustomProtocol.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/JXBWKWebView.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/ReusePool/JXBWKWebView.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/JXBWKWebViewPool.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/ReusePool/JXBWKWebViewPool.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/JXBWebViewController.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/JXBWebViewController.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/NSURLProtocol+WebKitSupport.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/URLProtocol/NSURLProtocol+WebKitSupport.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/UIProgressView+WKWebView.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/CustomUI/UIProgressView+WKWebView.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKAppManager.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/Helper/WKAppManager.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKCallNativeMethodMessageHandler.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/MessageHandler/WKCallNativeMethodMessageHandler.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKMessageHandlerDispatch.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/Dispatch/WKMessageHandlerDispatch.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKMessageHandlerHelper.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/Helper/WKMessageHandlerHelper.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKMessageHandlerProtocol.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/MessageHandler/WKMessageHandlerProtocol.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKWebView+AOP.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/CustomUI/WKWebView+AOP.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKWebView+ClearWebCache.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebView+ClearWebCache.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKWebView+CookiesManager.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebView+CookiesManager.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKWebView+ExternalNavigationDelegates.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebView+ExternalNavigationDelegates.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKWebView+SupportProtocol.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebView+SupportProtocol.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKWebView+SyncUserAgent.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebView+SyncUserAgent.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/JXBWebKit/WKWebViewExtension.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebViewExtension.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/SSZipArchive.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/SSZipArchive.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/SSZipCommon.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/SSZipCommon.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/ZipArchive.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/ZipArchive.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/aes.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/aes.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/aes_ni.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/aes_ni.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/aesopt.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/aesopt.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/aestab.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/aestab.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/brg_endian.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/brg_endian.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/brg_types.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/brg_types.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/crypt.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/crypt.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/fileenc.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/fileenc.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/hmac.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/hmac.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/ioapi.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/ioapi.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/ioapi_buf.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/ioapi_buf.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/ioapi_mem.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/ioapi_mem.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/minishared.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/minishared.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/prng.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/prng.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/pwd2key.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/pwd2key.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/sha1.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/aes/sha1.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/unzip.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/unzip.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Private/SSZipArchive/zip.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/minizip/zip.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/JXBWKCustomProtocol.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/URLProtocol/JXBWKCustomProtocol.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/JXBWKWebView.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/ReusePool/JXBWKWebView.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/JXBWKWebViewPool.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/ReusePool/JXBWKWebViewPool.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/JXBWebViewController.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/JXBWebViewController.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/NSURLProtocol+WebKitSupport.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/URLProtocol/NSURLProtocol+WebKitSupport.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/UIProgressView+WKWebView.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/CustomUI/UIProgressView+WKWebView.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKAppManager.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/Helper/WKAppManager.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKCallNativeMethodMessageHandler.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/MessageHandler/WKCallNativeMethodMessageHandler.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKMessageHandlerDispatch.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/Dispatch/WKMessageHandlerDispatch.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKMessageHandlerHelper.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/Helper/WKMessageHandlerHelper.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKMessageHandlerProtocol.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/MessageHandler/WKMessageHandlerProtocol.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKWebView+AOP.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/CustomUI/WKWebView+AOP.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKWebView+ClearWebCache.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebView+ClearWebCache.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKWebView+CookiesManager.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebView+CookiesManager.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKWebView+ExternalNavigationDelegates.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebView+ExternalNavigationDelegates.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKWebView+SupportProtocol.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebView+SupportProtocol.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKWebView+SyncUserAgent.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebView+SyncUserAgent.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/JXBWebKit/WKWebViewExtension.h:
--------------------------------------------------------------------------------
1 | ../../../../../JXBWebKit/Tools/WebViewExtension/WKWebViewExtension.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/SSZipArchive/SSZipArchive.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/SSZipArchive.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/SSZipArchive/SSZipCommon.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/SSZipCommon.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Headers/Public/SSZipArchive/ZipArchive.h:
--------------------------------------------------------------------------------
1 | ../../../SSZipArchive/SSZipArchive/ZipArchive.h
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Local Podspecs/JXBWebKit.podspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "JXBWebKit",
3 | "version": "1.1.1",
4 | "summary": "JXBWKWebView based on WKWebView",
5 | "description": "based on WKWebView",
6 | "homepage": "https://github.com/xiubojin/JXBWKWebView",
7 | "license": "MIT",
8 | "authors": {
9 | "jinxiubo": "17610158997@163.com"
10 | },
11 | "platforms": {
12 | "ios": "8.0"
13 | },
14 | "source": {
15 | "git": "https://github.com/xiubojin/JXBWKWebView.git",
16 | "tag": "1.1.1"
17 | },
18 | "source_files": "JXBWebKit/**/*.{h,m}",
19 | "resources": "JXBWebKit/*.bundle",
20 | "requires_arc": true
21 | }
22 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - JXBWebKit (1.1.1)
3 | - SSZipArchive (2.1.3)
4 |
5 | DEPENDENCIES:
6 | - JXBWebKit (from `../`)
7 | - SSZipArchive
8 |
9 | SPEC REPOS:
10 | https://github.com/cocoapods/specs.git:
11 | - SSZipArchive
12 |
13 | EXTERNAL SOURCES:
14 | JXBWebKit:
15 | :path: "../"
16 |
17 | SPEC CHECKSUMS:
18 | JXBWebKit: f9459910a5fce771f971e176ec6fe9f4acb2f333
19 | SSZipArchive: 51a800ebb77f95a8329b6ced1faaff394b47f509
20 |
21 | PODFILE CHECKSUM: 014222f5e4df3e46bc3ab47fd0420c0d1625f354
22 |
23 | COCOAPODS: 1.7.5
24 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010-2015, Sam Soffes, http://soff.es
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/README.md:
--------------------------------------------------------------------------------
1 |
2 | [](https://travis-ci.org/ZipArchive/ZipArchive)
3 |
4 | # SSZipArchive
5 |
6 | ZipArchive is a simple utility class for zipping and unzipping files on iOS, macOS and tvOS.
7 |
8 | - Unzip zip files;
9 | - Unzip password protected zip files;
10 | - Unzip AES encrypted zip files;
11 | - Create zip files;
12 | - Create password protected zip files;
13 | - Create AES encrypted zip files;
14 | - Choose compression level;
15 | - Append to existing zip files;
16 | - Zip-up NSData instances. (with a filename)
17 |
18 | ## Installation and Setup
19 |
20 | *The main release branch is configured to support Objective C and Swift 3+.*
21 |
22 | SSZipArchive works on Xcode 7-9 and above, iOS 8-11 and above.
23 |
24 | ### CocoaPods
25 | In your Podfile:
26 | `pod 'SSZipArchive'`
27 |
28 | ### Carthage
29 | In your Cartfile:
30 | `github "ZipArchive/ZipArchive"`
31 |
32 | ### Manual
33 |
34 | 1. Add the `SSZipArchive` and `minizip` folders to your project.
35 | 2. Add the `libz` library to your target
36 |
37 | SSZipArchive requires ARC.
38 |
39 | ## Usage
40 |
41 | ### Objective-C
42 |
43 | ```objective-c
44 | // Create
45 | [SSZipArchive createZipFileAtPath:zipPath withContentsOfDirectory:sampleDataPath];
46 |
47 | // Unzip
48 | [SSZipArchive unzipFileAtPath:zipPath toDestination:unzipPath];
49 | ```
50 |
51 | ### Swift
52 |
53 | ```swift
54 | // Create
55 | SSZipArchive.createZipFileAtPath(zipPath, withContentsOfDirectory: sampleDataPath)
56 |
57 | // Unzip
58 | SSZipArchive.unzipFileAtPath(zipPath, toDestination: unzipPath)
59 | ```
60 |
61 | ## License
62 |
63 | SSZipArchive is protected under the [MIT license](https://github.com/samsoffes/ssziparchive/raw/master/LICENSE) and our slightly modified version of [Minizip](https://github.com/nmoinvaz/minizip) 1.2 is licensed under the [Zlib license](http://www.zlib.net/zlib_license.html).
64 |
65 | ## Acknowledgments
66 |
67 | * Big thanks to [aish](http://code.google.com/p/ziparchive) for creating [ZipArchive](http://code.google.com/p/ziparchive). The project that inspired SSZipArchive.
68 | * Thank you [@soffes](https://github.com/soffes) for the actual name of SSZipArchive.
69 | * Thank you [@randomsequence](https://github.com/randomsequence) for implementing the creation support tech.
70 | * Thank you [@johnezang](https://github.com/johnezang) for all his amazing help along the way.
71 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/SSZipCommon.h:
--------------------------------------------------------------------------------
1 | #ifndef SSZipCommon
2 | #define SSZipCommon
3 |
4 | /* unz_global_info structure contain global data about the ZIPfile
5 | These data comes from the end of central dir */
6 | typedef struct unz_global_info64_s
7 | {
8 | uint64_t number_entry; /* total number of entries in the central dir on this disk */
9 | uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
10 | uint16_t size_comment; /* size of the global comment of the zipfile */
11 | } unz_global_info64;
12 |
13 | typedef struct unz_global_info_s
14 | {
15 | uint32_t number_entry; /* total number of entries in the central dir on this disk */
16 | uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
17 | uint16_t size_comment; /* size of the global comment of the zipfile */
18 | } unz_global_info;
19 |
20 | /* unz_file_info contain information about a file in the zipfile */
21 | /* https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT */
22 | typedef struct unz_file_info64_s
23 | {
24 | uint16_t version; /* version made by 2 bytes */
25 | uint16_t version_needed; /* version needed to extract 2 bytes */
26 | uint16_t flag; /* general purpose bit flag 2 bytes */
27 | uint16_t compression_method; /* compression method 2 bytes */
28 | uint32_t dos_date; /* last mod file date in Dos fmt 4 bytes */
29 | uint32_t crc; /* crc-32 4 bytes */
30 | uint64_t compressed_size; /* compressed size 8 bytes */
31 | uint64_t uncompressed_size; /* uncompressed size 8 bytes */
32 | uint16_t size_filename; /* filename length 2 bytes */
33 | uint16_t size_file_extra; /* extra field length 2 bytes */
34 | uint16_t size_file_comment; /* file comment length 2 bytes */
35 |
36 | uint32_t disk_num_start; /* disk number start 4 bytes */
37 | uint16_t internal_fa; /* internal file attributes 2 bytes */
38 | uint32_t external_fa; /* external file attributes 4 bytes */
39 |
40 | uint64_t disk_offset;
41 |
42 | uint16_t size_file_extra_internal;
43 | } unz_file_info64;
44 |
45 | typedef struct unz_file_info_s
46 | {
47 | uint16_t version; /* version made by 2 bytes */
48 | uint16_t version_needed; /* version needed to extract 2 bytes */
49 | uint16_t flag; /* general purpose bit flag 2 bytes */
50 | uint16_t compression_method; /* compression method 2 bytes */
51 | uint32_t dos_date; /* last mod file date in Dos fmt 4 bytes */
52 | uint32_t crc; /* crc-32 4 bytes */
53 | uint32_t compressed_size; /* compressed size 4 bytes */
54 | uint32_t uncompressed_size; /* uncompressed size 4 bytes */
55 | uint16_t size_filename; /* filename length 2 bytes */
56 | uint16_t size_file_extra; /* extra field length 2 bytes */
57 | uint16_t size_file_comment; /* file comment length 2 bytes */
58 |
59 | uint16_t disk_num_start; /* disk number start 2 bytes */
60 | uint16_t internal_fa; /* internal file attributes 2 bytes */
61 | uint32_t external_fa; /* external file attributes 4 bytes */
62 |
63 | uint64_t disk_offset;
64 | } unz_file_info;
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/ZipArchive.h:
--------------------------------------------------------------------------------
1 | //
2 | // ZipArchive.h
3 | // ZipArchive
4 | //
5 | // Created by Serhii Mumriak on 12/1/15.
6 | // Copyright © 2015 smumryak. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for ZipArchive.
12 | FOUNDATION_EXPORT double ZipArchiveVersionNumber;
13 |
14 | //! Project version string for ZipArchive.
15 | FOUNDATION_EXPORT const unsigned char ZipArchiveVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 | #import "SSZipArchive.h"
20 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/aes/aes_ni.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
3 |
4 | The redistribution and use of this software (with or without changes)
5 | is allowed without the payment of fees or royalties provided that:
6 |
7 | source code distributions include the above copyright notice, this
8 | list of conditions and the following disclaimer;
9 |
10 | binary distributions include the above copyright notice, this list
11 | of conditions and the following disclaimer in their documentation.
12 |
13 | This software is provided 'as is' with no explicit or implied warranties
14 | in respect of its operation, including, but not limited to, correctness
15 | and fitness for purpose.
16 | ---------------------------------------------------------------------------
17 | Issue Date: 13/11/2013
18 | */
19 |
20 | #ifndef AES_NI_H
21 | #define AES_NI_H
22 |
23 | #define USE_AES_CONTEXT
24 |
25 | #include "aesopt.h"
26 |
27 | #if defined( USE_INTEL_AES_IF_PRESENT )
28 |
29 | /* map names in C code to make them internal ('name' -> 'aes_name_i') */
30 | #define aes_xi(x) aes_ ## x ## _i
31 |
32 | /* map names here to provide the external API ('name' -> 'aes_name') */
33 | #define aes_ni(x) aes_ ## x
34 |
35 | AES_RETURN aes_ni(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1]);
36 | AES_RETURN aes_ni(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1]);
37 | AES_RETURN aes_ni(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1]);
38 |
39 | AES_RETURN aes_ni(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1]);
40 | AES_RETURN aes_ni(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1]);
41 | AES_RETURN aes_ni(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1]);
42 |
43 | AES_RETURN aes_ni(encrypt)(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]);
44 | AES_RETURN aes_ni(decrypt)(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]);
45 |
46 | AES_RETURN aes_xi(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1]);
47 | AES_RETURN aes_xi(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1]);
48 | AES_RETURN aes_xi(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1]);
49 |
50 | AES_RETURN aes_xi(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1]);
51 | AES_RETURN aes_xi(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1]);
52 | AES_RETURN aes_xi(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1]);
53 |
54 | AES_RETURN aes_xi(encrypt)(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]);
55 | AES_RETURN aes_xi(decrypt)(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]);
56 |
57 | #endif
58 |
59 | #endif
60 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/aes/fileenc.c:
--------------------------------------------------------------------------------
1 | /*
2 | ---------------------------------------------------------------------------
3 | Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK.
4 | All rights reserved.
5 |
6 | LICENSE TERMS
7 |
8 | The free distribution and use of this software in both source and binary
9 | form is allowed (with or without changes) provided that:
10 |
11 | 1. distributions of this source code include the above copyright
12 | notice, this list of conditions and the following disclaimer;
13 |
14 | 2. distributions in binary form include the above copyright
15 | notice, this list of conditions and the following disclaimer
16 | in the documentation and/or other associated materials;
17 |
18 | 3. the copyright holder's name is not used to endorse products
19 | built using this software without specific written permission.
20 |
21 | ALTERNATIVELY, provided that this notice is retained in full, this product
22 | may be distributed under the terms of the GNU General Public License (GPL),
23 | in which case the provisions of the GPL apply INSTEAD OF those given above.
24 |
25 | DISCLAIMER
26 |
27 | This software is provided 'as is' with no explicit or implied warranties
28 | in respect of its properties, including, but not limited to, correctness
29 | and/or fitness for purpose.
30 | -------------------------------------------------------------------------
31 | Issue Date: 24/01/2003
32 |
33 | This file implements password based file encryption and authentication
34 | using AES in CTR mode, HMAC-SHA1 authentication and RFC2898 password
35 | based key derivation.
36 |
37 | */
38 |
39 | #include
40 |
41 | #include "fileenc.h"
42 |
43 | #if defined(__cplusplus)
44 | extern "C"
45 | {
46 | #endif
47 |
48 | /* subroutine for data encryption/decryption */
49 | /* this could be speeded up a lot by aligning */
50 | /* buffers and using 32 bit operations */
51 |
52 | static void encr_data(unsigned char data[], unsigned long d_len, fcrypt_ctx cx[1])
53 | {
54 | unsigned int i = 0, pos = cx->encr_pos;
55 |
56 | while (i < d_len)
57 | {
58 | if (pos == AES_BLOCK_SIZE)
59 | {
60 | unsigned int j = 0;
61 | /* increment encryption nonce */
62 | while (j < 8 && !++cx->nonce[j])
63 | ++j;
64 | /* encrypt the nonce to form next xor buffer */
65 | aes_encrypt(cx->nonce, cx->encr_bfr, cx->encr_ctx);
66 | pos = 0;
67 | }
68 |
69 | data[i++] ^= cx->encr_bfr[pos++];
70 | }
71 |
72 | cx->encr_pos = pos;
73 | }
74 |
75 | int fcrypt_init(
76 | int mode, /* the mode to be used (input) */
77 | const unsigned char pwd[], /* the user specified password (input) */
78 | unsigned int pwd_len, /* the length of the password (input) */
79 | const unsigned char salt[], /* the salt (input) */
80 | #ifdef PASSWORD_VERIFIER
81 | unsigned char pwd_ver[PWD_VER_LENGTH], /* 2 byte password verifier (output) */
82 | #endif
83 | fcrypt_ctx cx[1]) /* the file encryption context (output) */
84 | { unsigned char kbuf[2 * MAX_KEY_LENGTH + PWD_VER_LENGTH];
85 |
86 | if (pwd_len > MAX_PWD_LENGTH)
87 | return PASSWORD_TOO_LONG;
88 |
89 | if (mode < 1 || mode > 3)
90 | return BAD_MODE;
91 |
92 | cx->mode = mode;
93 | cx->pwd_len = pwd_len;
94 |
95 | /* derive the encryption and authentication keys and the password verifier */
96 | derive_key(pwd, pwd_len, salt, SALT_LENGTH(mode), KEYING_ITERATIONS,
97 | kbuf, 2 * KEY_LENGTH(mode) + PWD_VER_LENGTH);
98 |
99 | /* initialise the encryption nonce and buffer pos */
100 | cx->encr_pos = AES_BLOCK_SIZE;
101 | /* if we need a random component in the encryption */
102 | /* nonce, this is where it would have to be set */
103 | memset(cx->nonce, 0, AES_BLOCK_SIZE * sizeof(unsigned char));
104 |
105 | /* initialise for encryption using key 1 */
106 | aes_encrypt_key(kbuf, KEY_LENGTH(mode), cx->encr_ctx);
107 |
108 | /* initialise for authentication using key 2 */
109 | hmac_sha_begin(HMAC_SHA1, cx->auth_ctx);
110 | hmac_sha_key(kbuf + KEY_LENGTH(mode), KEY_LENGTH(mode), cx->auth_ctx);
111 |
112 | #ifdef PASSWORD_VERIFIER
113 | memcpy(pwd_ver, kbuf + 2 * KEY_LENGTH(mode), PWD_VER_LENGTH);
114 | #endif
115 |
116 | return GOOD_RETURN;
117 | }
118 |
119 | /* perform 'in place' encryption and authentication */
120 |
121 | void fcrypt_encrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1])
122 | {
123 | encr_data(data, data_len, cx);
124 | hmac_sha_data(data, data_len, cx->auth_ctx);
125 | }
126 |
127 | /* perform 'in place' authentication and decryption */
128 |
129 | void fcrypt_decrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1])
130 | {
131 | hmac_sha_data(data, data_len, cx->auth_ctx);
132 | encr_data(data, data_len, cx);
133 | }
134 |
135 | /* close encryption/decryption and return the MAC value */
136 |
137 | int fcrypt_end(unsigned char mac[], fcrypt_ctx cx[1])
138 | {
139 | hmac_sha_end(mac, MAC_LENGTH(cx->mode), cx->auth_ctx);
140 | return MAC_LENGTH(cx->mode); /* return MAC length in bytes */
141 | }
142 |
143 | #if defined(__cplusplus)
144 | }
145 | #endif
146 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/aes/fileenc.h:
--------------------------------------------------------------------------------
1 | /*
2 | ---------------------------------------------------------------------------
3 | Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK.
4 | All rights reserved.
5 |
6 | LICENSE TERMS
7 |
8 | The free distribution and use of this software in both source and binary
9 | form is allowed (with or without changes) provided that:
10 |
11 | 1. distributions of this source code include the above copyright
12 | notice, this list of conditions and the following disclaimer;
13 |
14 | 2. distributions in binary form include the above copyright
15 | notice, this list of conditions and the following disclaimer
16 | in the documentation and/or other associated materials;
17 |
18 | 3. the copyright holder's name is not used to endorse products
19 | built using this software without specific written permission.
20 |
21 | ALTERNATIVELY, provided that this notice is retained in full, this product
22 | may be distributed under the terms of the GNU General Public License (GPL),
23 | in which case the provisions of the GPL apply INSTEAD OF those given above.
24 |
25 | DISCLAIMER
26 |
27 | This software is provided 'as is' with no explicit or implied warranties
28 | in respect of its properties, including, but not limited to, correctness
29 | and/or fitness for purpose.
30 | ---------------------------------------------------------------------------
31 | Issue Date: 24/01/2003
32 |
33 | This file contains the header file for fileenc.c, which implements password
34 | based file encryption and authentication using AES in CTR mode, HMAC-SHA1
35 | authentication and RFC2898 password based key derivation.
36 | */
37 |
38 | #ifndef _FENC_H
39 | #define _FENC_H
40 |
41 | #include "aes.h"
42 | #include "hmac.h"
43 | #include "pwd2key.h"
44 |
45 | #define PASSWORD_VERIFIER
46 |
47 | #define MAX_KEY_LENGTH 32
48 | #define MAX_PWD_LENGTH 128
49 | #define MAX_SALT_LENGTH 16
50 | #define KEYING_ITERATIONS 1000
51 |
52 | #ifdef PASSWORD_VERIFIER
53 | #define PWD_VER_LENGTH 2
54 | #else
55 | #define PWD_VER_LENGTH 0
56 | #endif
57 |
58 | #define GOOD_RETURN 0
59 | #define PASSWORD_TOO_LONG -100
60 | #define BAD_MODE -101
61 |
62 | /*
63 | Field lengths (in bytes) versus File Encryption Mode (0 < mode < 4)
64 |
65 | Mode Key Salt MAC Overhead
66 | 1 16 8 10 18
67 | 2 24 12 10 22
68 | 3 32 16 10 26
69 |
70 | The following macros assume that the mode value is correct.
71 | */
72 |
73 | #define KEY_LENGTH(mode) (8 * (mode & 3) + 8)
74 | #define SALT_LENGTH(mode) (4 * (mode & 3) + 4)
75 | #define MAC_LENGTH(mode) (10)
76 |
77 | /* the context for file encryption */
78 |
79 | #if defined(__cplusplus)
80 | extern "C"
81 | {
82 | #endif
83 |
84 | typedef struct
85 | { unsigned char nonce[AES_BLOCK_SIZE]; /* the CTR nonce */
86 | unsigned char encr_bfr[AES_BLOCK_SIZE]; /* encrypt buffer */
87 | aes_encrypt_ctx encr_ctx[1]; /* encryption context */
88 | hmac_ctx auth_ctx[1]; /* authentication context */
89 | unsigned int encr_pos; /* block position (enc) */
90 | unsigned int pwd_len; /* password length */
91 | unsigned int mode; /* File encryption mode */
92 | } fcrypt_ctx;
93 |
94 | /* initialise file encryption or decryption */
95 |
96 | int fcrypt_init(
97 | int mode, /* the mode to be used (input) */
98 | const unsigned char pwd[], /* the user specified password (input) */
99 | unsigned int pwd_len, /* the length of the password (input) */
100 | const unsigned char salt[], /* the salt (input) */
101 | #ifdef PASSWORD_VERIFIER
102 | unsigned char pwd_ver[PWD_VER_LENGTH], /* 2 byte password verifier (output) */
103 | #endif
104 | fcrypt_ctx cx[1]); /* the file encryption context (output) */
105 |
106 | /* perform 'in place' encryption or decryption and authentication */
107 |
108 | void fcrypt_encrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1]);
109 | void fcrypt_decrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1]);
110 |
111 | /* close encryption/decryption and return the MAC value */
112 | /* the return value is the length of the MAC */
113 |
114 | int fcrypt_end(unsigned char mac[], /* the MAC value (output) */
115 | fcrypt_ctx cx[1]); /* the context (input) */
116 |
117 | #if defined(__cplusplus)
118 | }
119 | #endif
120 |
121 | #endif
122 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/aes/hmac.h:
--------------------------------------------------------------------------------
1 | /*
2 | ---------------------------------------------------------------------------
3 | Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
4 |
5 | The redistribution and use of this software (with or without changes)
6 | is allowed without the payment of fees or royalties provided that:
7 |
8 | source code distributions include the above copyright notice, this
9 | list of conditions and the following disclaimer;
10 |
11 | binary distributions include the above copyright notice, this list
12 | of conditions and the following disclaimer in their documentation.
13 |
14 | This software is provided 'as is' with no explicit or implied warranties
15 | in respect of its operation, including, but not limited to, correctness
16 | and fitness for purpose.
17 | ---------------------------------------------------------------------------
18 | Issue Date: 20/12/2007
19 |
20 | This is an implementation of HMAC, the FIPS standard keyed hash function
21 | */
22 |
23 | #ifndef _HMAC2_H
24 | #define _HMAC2_H
25 |
26 | #include
27 | #include
28 |
29 | #if defined(__cplusplus)
30 | extern "C"
31 | {
32 | #endif
33 |
34 | #include "sha1.h"
35 |
36 | #if defined(SHA_224) || defined(SHA_256) || defined(SHA_384) || defined(SHA_512)
37 | #define HMAC_MAX_OUTPUT_SIZE SHA2_MAX_DIGEST_SIZE
38 | #define HMAC_MAX_BLOCK_SIZE SHA2_MAX_BLOCK_SIZE
39 | #else
40 | #define HMAC_MAX_OUTPUT_SIZE SHA1_DIGEST_SIZE
41 | #define HMAC_MAX_BLOCK_SIZE SHA1_BLOCK_SIZE
42 | #endif
43 |
44 | #define HMAC_IN_DATA 0xffffffff
45 |
46 | enum hmac_hash
47 | {
48 | #ifdef SHA_1
49 | HMAC_SHA1,
50 | #endif
51 | #ifdef SHA_224
52 | HMAC_SHA224,
53 | #endif
54 | #ifdef SHA_256
55 | HMAC_SHA256,
56 | #endif
57 | #ifdef SHA_384
58 | HMAC_SHA384,
59 | #endif
60 | #ifdef SHA_512
61 | HMAC_SHA512,
62 | HMAC_SHA512_256,
63 | HMAC_SHA512_224,
64 | HMAC_SHA512_192,
65 | HMAC_SHA512_128
66 | #endif
67 | };
68 |
69 | typedef VOID_RETURN hf_begin(void*);
70 | typedef VOID_RETURN hf_hash(const void*, unsigned long len, void*);
71 | typedef VOID_RETURN hf_end(void*, void*);
72 |
73 | typedef struct
74 | { hf_begin *f_begin;
75 | hf_hash *f_hash;
76 | hf_end *f_end;
77 | unsigned char key[HMAC_MAX_BLOCK_SIZE];
78 | union
79 | {
80 | #ifdef SHA_1
81 | sha1_ctx u_sha1;
82 | #endif
83 | #ifdef SHA_224
84 | sha224_ctx u_sha224;
85 | #endif
86 | #ifdef SHA_256
87 | sha256_ctx u_sha256;
88 | #endif
89 | #ifdef SHA_384
90 | sha384_ctx u_sha384;
91 | #endif
92 | #ifdef SHA_512
93 | sha512_ctx u_sha512;
94 | #endif
95 | } sha_ctx[1];
96 | unsigned long input_len;
97 | unsigned long output_len;
98 | unsigned long klen;
99 | } hmac_ctx;
100 |
101 | /* returns the length of hash digest for the hash used */
102 | /* mac_len must not be greater than this */
103 | int hmac_sha_begin(enum hmac_hash hash, hmac_ctx cx[1]);
104 |
105 | int hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1]);
106 |
107 | void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1]);
108 |
109 | void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1]);
110 |
111 | void hmac_sha(enum hmac_hash hash, const unsigned char key[], unsigned long key_len,
112 | const unsigned char data[], unsigned long data_len,
113 | unsigned char mac[], unsigned long mac_len);
114 |
115 | #if defined(__cplusplus)
116 | }
117 | #endif
118 |
119 | #endif
120 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/aes/prng.h:
--------------------------------------------------------------------------------
1 | /*
2 | ---------------------------------------------------------------------------
3 | Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK.
4 | All rights reserved.
5 |
6 | LICENSE TERMS
7 |
8 | The free distribution and use of this software in both source and binary
9 | form is allowed (with or without changes) provided that:
10 |
11 | 1. distributions of this source code include the above copyright
12 | notice, this list of conditions and the following disclaimer;
13 |
14 | 2. distributions in binary form include the above copyright
15 | notice, this list of conditions and the following disclaimer
16 | in the documentation and/or other associated materials;
17 |
18 | 3. the copyright holder's name is not used to endorse products
19 | built using this software without specific written permission.
20 |
21 | ALTERNATIVELY, provided that this notice is retained in full, this product
22 | may be distributed under the terms of the GNU General Public License (GPL),
23 | in which case the provisions of the GPL apply INSTEAD OF those given above.
24 |
25 | DISCLAIMER
26 |
27 | This software is provided 'as is' with no explicit or implied warranties
28 | in respect of its properties, including, but not limited to, correctness
29 | and/or fitness for purpose.
30 | ---------------------------------------------------------------------------
31 | Issue Date: 24/01/2003
32 |
33 | This is the header file for an implementation of a random data pool based on
34 | the use of an external entropy function (inspired by Peter Gutmann's work).
35 | */
36 |
37 | #ifndef _PRNG_H
38 | #define _PRNG_H
39 |
40 | #include "sha1.h"
41 |
42 | #define PRNG_POOL_LEN 256 /* minimum random pool size */
43 | #define PRNG_MIN_MIX 20 /* min initial pool mixing iterations */
44 |
45 | /* ensure that pool length is a multiple of the SHA1 digest size */
46 |
47 | #define PRNG_POOL_SIZE (SHA1_DIGEST_SIZE * (1 + (PRNG_POOL_LEN - 1) / SHA1_DIGEST_SIZE))
48 |
49 | #if defined(__cplusplus)
50 | extern "C"
51 | {
52 | #endif
53 |
54 | /* A function for providing entropy is a parameter in the prng_init() */
55 | /* call. This function has the following form and returns a maximum */
56 | /* of 'len' bytes of pseudo random data in the buffer 'buf'. It can */
57 | /* return less than 'len' bytes but will be repeatedly called for more */
58 | /* data in this case. */
59 |
60 | typedef int (*prng_entropy_fn)(unsigned char buf[], unsigned int len);
61 |
62 | typedef struct
63 | { unsigned char rbuf[PRNG_POOL_SIZE]; /* the random pool */
64 | unsigned char obuf[PRNG_POOL_SIZE]; /* pool output buffer */
65 | unsigned int pos; /* output buffer position */
66 | prng_entropy_fn entropy; /* entropy function pointer */
67 | } prng_ctx;
68 |
69 | /* initialise the random stream generator */
70 | void prng_init(prng_entropy_fn fun, prng_ctx ctx[1]);
71 |
72 | /* obtain random bytes from the generator */
73 | void prng_rand(unsigned char data[], unsigned int data_len, prng_ctx ctx[1]);
74 |
75 | /* close the random stream generator */
76 | void prng_end(prng_ctx ctx[1]);
77 |
78 | #if defined(__cplusplus)
79 | }
80 | #endif
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/aes/pwd2key.h:
--------------------------------------------------------------------------------
1 | /*
2 | ---------------------------------------------------------------------------
3 | Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
4 |
5 | The redistribution and use of this software (with or without changes)
6 | is allowed without the payment of fees or royalties provided that:
7 |
8 | source code distributions include the above copyright notice, this
9 | list of conditions and the following disclaimer;
10 |
11 | binary distributions include the above copyright notice, this list
12 | of conditions and the following disclaimer in their documentation.
13 |
14 | This software is provided 'as is' with no explicit or implied warranties
15 | in respect of its operation, including, but not limited to, correctness
16 | and fitness for purpose.
17 | ---------------------------------------------------------------------------
18 | Issue Date: 20/12/2007
19 |
20 | This is an implementation of RFC2898, which specifies key derivation from
21 | a password and a salt value.
22 | */
23 |
24 | #ifndef PWD2KEY_H
25 | #define PWD2KEY_H
26 |
27 | #if defined(__cplusplus)
28 | extern "C"
29 | {
30 | #endif
31 |
32 | void derive_key(
33 | const unsigned char pwd[], /* the PASSWORD, and */
34 | unsigned int pwd_len, /* its length */
35 | const unsigned char salt[], /* the SALT and its */
36 | unsigned int salt_len, /* length */
37 | unsigned int iter, /* the number of iterations */
38 | unsigned char key[], /* space for the output key */
39 | unsigned int key_len); /* and its required length */
40 |
41 | #if defined(__cplusplus)
42 | }
43 | #endif
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/aes/sha1.h:
--------------------------------------------------------------------------------
1 | /*
2 | ---------------------------------------------------------------------------
3 | Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
4 |
5 | The redistribution and use of this software (with or without changes)
6 | is allowed without the payment of fees or royalties provided that:
7 |
8 | source code distributions include the above copyright notice, this
9 | list of conditions and the following disclaimer;
10 |
11 | binary distributions include the above copyright notice, this list
12 | of conditions and the following disclaimer in their documentation.
13 |
14 | This software is provided 'as is' with no explicit or implied warranties
15 | in respect of its operation, including, but not limited to, correctness
16 | and fitness for purpose.
17 | ---------------------------------------------------------------------------
18 | Issue Date: 20/12/2007
19 | */
20 |
21 | #ifndef _SHA1_H
22 | #define _SHA1_H
23 |
24 | #define SHA_1
25 |
26 | /* define for bit or byte oriented SHA */
27 | #if 1
28 | # define SHA1_BITS 0 /* byte oriented */
29 | #else
30 | # define SHA1_BITS 1 /* bit oriented */
31 | #endif
32 |
33 | #include
34 | #include "brg_types.h"
35 |
36 | #define SHA1_BLOCK_SIZE 64
37 | #define SHA1_DIGEST_SIZE 20
38 |
39 | #if defined(__cplusplus)
40 | extern "C"
41 | {
42 | #endif
43 |
44 | /* type to hold the SHA256 context */
45 |
46 | typedef struct
47 | { uint32_t count[2];
48 | uint32_t hash[SHA1_DIGEST_SIZE >> 2];
49 | uint32_t wbuf[SHA1_BLOCK_SIZE >> 2];
50 | } sha1_ctx;
51 |
52 | /* Note that these prototypes are the same for both bit and */
53 | /* byte oriented implementations. However the length fields */
54 | /* are in bytes or bits as appropriate for the version used */
55 | /* and bit sequences are input as arrays of bytes in which */
56 | /* bit sequences run from the most to the least significant */
57 | /* end of each byte. The value 'len' in sha1_hash for the */
58 | /* byte oriented version of SHA1 is limited to 2^29 bytes, */
59 | /* but multiple calls will handle longer data blocks. */
60 |
61 | VOID_RETURN sha1_compile(sha1_ctx ctx[1]);
62 |
63 | VOID_RETURN sha1_begin(sha1_ctx ctx[1]);
64 | VOID_RETURN sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1]);
65 | VOID_RETURN sha1_end(unsigned char hval[], sha1_ctx ctx[1]);
66 | VOID_RETURN sha1(unsigned char hval[], const unsigned char data[], unsigned long len);
67 |
68 | #if defined(__cplusplus)
69 | }
70 | #endif
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/crypt.c:
--------------------------------------------------------------------------------
1 | /* crypt.c -- base code for traditional PKWARE encryption
2 | Version 1.2.0, September 16th, 2017
3 |
4 | Copyright (C) 2012-2017 Nathan Moinvaziri
5 | https://github.com/nmoinvaz/minizip
6 | Copyright (C) 1998-2005 Gilles Vollant
7 | Modifications for Info-ZIP crypting
8 | http://www.winimage.com/zLibDll/minizip.html
9 | Copyright (C) 2003 Terry Thorsen
10 |
11 | This code is a modified version of crypting code in Info-ZIP distribution
12 |
13 | Copyright (C) 1990-2000 Info-ZIP. All rights reserved.
14 |
15 | This program is distributed under the terms of the same license as zlib.
16 | See the accompanying LICENSE file for the full text of the license.
17 |
18 | This encryption code is a direct transcription of the algorithm from
19 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This
20 | file (appnote.txt) is distributed with the PKZIP program (even in the
21 | version without encryption capabilities).
22 |
23 | If you don't need crypting in your application, just define symbols
24 | NOCRYPT and NOUNCRYPT.
25 | */
26 |
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | #ifdef _WIN32
33 | # include
34 | # include
35 | #else
36 | # include
37 | # include
38 | # include
39 | #endif
40 |
41 | #include "zlib.h"
42 |
43 | #include "crypt.h"
44 |
45 | /***************************************************************************/
46 |
47 | #define CRC32(c, b) ((*(pcrc_32_tab+(((uint32_t)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
48 |
49 | /***************************************************************************/
50 |
51 | uint8_t decrypt_byte(uint32_t *pkeys)
52 | {
53 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
54 | * unpredictable manner on 16-bit systems; not a problem
55 | * with any known compiler so far, though */
56 |
57 | temp = ((uint32_t)(*(pkeys+2)) & 0xffff) | 2;
58 | return (uint8_t)(((temp * (temp ^ 1)) >> 8) & 0xff);
59 | }
60 |
61 | uint8_t update_keys(uint32_t *pkeys, const z_crc_t *pcrc_32_tab, int32_t c)
62 | {
63 | (*(pkeys+0)) = (uint32_t)CRC32((*(pkeys+0)), c);
64 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
65 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
66 | {
67 | register int32_t keyshift = (int32_t)((*(pkeys + 1)) >> 24);
68 | (*(pkeys+2)) = (uint32_t)CRC32((*(pkeys+2)), keyshift);
69 | }
70 | return c;
71 | }
72 |
73 | void init_keys(const char *passwd, uint32_t *pkeys, const z_crc_t *pcrc_32_tab)
74 | {
75 | *(pkeys+0) = 305419896L;
76 | *(pkeys+1) = 591751049L;
77 | *(pkeys+2) = 878082192L;
78 | while (*passwd != 0)
79 | {
80 | update_keys(pkeys, pcrc_32_tab, *passwd);
81 | passwd += 1;
82 | }
83 | }
84 |
85 | /***************************************************************************/
86 |
87 | int cryptrand(unsigned char *buf, unsigned int len)
88 | {
89 | #ifdef _WIN32
90 | HCRYPTPROV provider;
91 | unsigned __int64 pentium_tsc[1];
92 | int rlen = 0;
93 | int result = 0;
94 |
95 |
96 | if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
97 | {
98 | result = CryptGenRandom(provider, len, buf);
99 | CryptReleaseContext(provider, 0);
100 | if (result)
101 | return len;
102 | }
103 |
104 | for (rlen = 0; rlen < (int)len; ++rlen)
105 | {
106 | if (rlen % 8 == 0)
107 | QueryPerformanceCounter((LARGE_INTEGER *)pentium_tsc);
108 | buf[rlen] = ((unsigned char*)pentium_tsc)[rlen % 8];
109 | }
110 |
111 | return rlen;
112 | #else
113 | arc4random_buf(buf, len);
114 | return len;
115 | #endif
116 | }
117 |
118 | int crypthead(const char *passwd, uint8_t *buf, int buf_size, uint32_t *pkeys,
119 | const z_crc_t *pcrc_32_tab, uint8_t verify1, uint8_t verify2)
120 | {
121 | uint8_t n = 0; /* index in random header */
122 | uint8_t header[RAND_HEAD_LEN-2]; /* random header */
123 | uint16_t t = 0; /* temporary */
124 |
125 | if (buf_size < RAND_HEAD_LEN)
126 | return 0;
127 |
128 | init_keys(passwd, pkeys, pcrc_32_tab);
129 |
130 | /* First generate RAND_HEAD_LEN-2 random bytes. */
131 | cryptrand(header, RAND_HEAD_LEN-2);
132 |
133 | /* Encrypt random header (last two bytes is high word of crc) */
134 | init_keys(passwd, pkeys, pcrc_32_tab);
135 |
136 | for (n = 0; n < RAND_HEAD_LEN-2; n++)
137 | buf[n] = (uint8_t)zencode(pkeys, pcrc_32_tab, header[n], t);
138 |
139 | buf[n++] = (uint8_t)zencode(pkeys, pcrc_32_tab, verify1, t);
140 | buf[n++] = (uint8_t)zencode(pkeys, pcrc_32_tab, verify2, t);
141 | return n;
142 | }
143 |
144 | /***************************************************************************/
145 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/crypt.h:
--------------------------------------------------------------------------------
1 | /* crypt.h -- base code for traditional PKWARE encryption
2 | Version 1.2.0, September 16th, 2017
3 |
4 | Copyright (C) 2012-2017 Nathan Moinvaziri
5 | https://github.com/nmoinvaz/minizip
6 | Copyright (C) 1998-2005 Gilles Vollant
7 | Modifications for Info-ZIP crypting
8 | http://www.winimage.com/zLibDll/minizip.html
9 | Copyright (C) 2003 Terry Thorsen
10 |
11 | This code is a modified version of crypting code in Info-ZIP distribution
12 |
13 | Copyright (C) 1990-2000 Info-ZIP. All rights reserved.
14 |
15 | This program is distributed under the terms of the same license as zlib.
16 | See the accompanying LICENSE file for the full text of the license.
17 | */
18 |
19 | #ifndef _MINICRYPT_H
20 | #define _MINICRYPT_H
21 |
22 | #if ZLIB_VERNUM < 0x1270
23 | typedef unsigned long z_crc_t;
24 | #endif
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | #define RAND_HEAD_LEN 12
31 |
32 | /***************************************************************************/
33 |
34 | #define zdecode(pkeys,pcrc_32_tab,c) \
35 | (update_keys(pkeys,pcrc_32_tab, c ^= decrypt_byte(pkeys)))
36 |
37 | #define zencode(pkeys,pcrc_32_tab,c,t) \
38 | (t = decrypt_byte(pkeys), update_keys(pkeys,pcrc_32_tab,c), t^(c))
39 |
40 | /***************************************************************************/
41 |
42 | /* Return the next byte in the pseudo-random sequence */
43 | uint8_t decrypt_byte(uint32_t *pkeys);
44 |
45 | /* Update the encryption keys with the next byte of plain text */
46 | uint8_t update_keys(uint32_t *pkeys, const z_crc_t *pcrc_32_tab, int32_t c);
47 |
48 | /* Initialize the encryption keys and the random header according to the given password. */
49 | void init_keys(const char *passwd, uint32_t *pkeys, const z_crc_t *pcrc_32_tab);
50 |
51 | /* Generate cryptographically secure random numbers */
52 | int cryptrand(unsigned char *buf, unsigned int len);
53 |
54 | /* Create encryption header */
55 | int crypthead(const char *passwd, uint8_t *buf, int buf_size, uint32_t *pkeys,
56 | const z_crc_t *pcrc_32_tab, uint8_t verify1, uint8_t verify2);
57 |
58 | /***************************************************************************/
59 |
60 | #ifdef __cplusplus
61 | }
62 | #endif
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/ioapi_buf.h:
--------------------------------------------------------------------------------
1 | /* ioapi_buf.h -- IO base function header for compress/uncompress .zip
2 | files using zlib + zip or unzip API
3 |
4 | This version of ioapi is designed to buffer IO.
5 |
6 | Copyright (C) 2012-2017 Nathan Moinvaziri
7 | https://github.com/nmoinvaz/minizip
8 |
9 | This program is distributed under the terms of the same license as zlib.
10 | See the accompanying LICENSE file for the full text of the license.
11 | */
12 |
13 | #ifndef _IOAPI_BUF_H
14 | #define _IOAPI_BUF_H
15 |
16 | #include
17 | #include
18 | #include
19 |
20 | #include "zlib.h"
21 | #include "ioapi.h"
22 |
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 | voidpf ZCALLBACK fopen_buf_func(voidpf opaque, const char* filename, int mode);
28 | voidpf ZCALLBACK fopen64_buf_func(voidpf opaque, const void* filename, int mode);
29 | voidpf ZCALLBACK fopendisk_buf_func(voidpf opaque, voidpf stream_cd, uint32_t number_disk, int mode);
30 | voidpf ZCALLBACK fopendisk64_buf_func(voidpf opaque, voidpf stream_cd, uint32_t number_disk, int mode);
31 | uint32_t ZCALLBACK fread_buf_func(voidpf opaque, voidpf stream, void* buf, uint32_t size);
32 | uint32_t ZCALLBACK fwrite_buf_func(voidpf opaque, voidpf stream, const void* buf, uint32_t size);
33 | long ZCALLBACK ftell_buf_func(voidpf opaque, voidpf stream);
34 | uint64_t ZCALLBACK ftell64_buf_func(voidpf opaque, voidpf stream);
35 | long ZCALLBACK fseek_buf_func(voidpf opaque, voidpf stream, uint32_t offset, int origin);
36 | long ZCALLBACK fseek64_buf_func(voidpf opaque, voidpf stream, uint64_t offset, int origin);
37 | int ZCALLBACK fclose_buf_func(voidpf opaque,voidpf stream);
38 | int ZCALLBACK ferror_buf_func(voidpf opaque,voidpf stream);
39 |
40 | typedef struct ourbuffer_s {
41 | zlib_filefunc_def filefunc;
42 | zlib_filefunc64_def filefunc64;
43 | } ourbuffer_t;
44 |
45 | void fill_buffer_filefunc(zlib_filefunc_def* pzlib_filefunc_def, ourbuffer_t *ourbuf);
46 | void fill_buffer_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def, ourbuffer_t *ourbuf);
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/ioapi_mem.h:
--------------------------------------------------------------------------------
1 | /* ioapi_mem.h -- IO base function header for compress/uncompress .zip
2 | files using zlib + zip or unzip API
3 |
4 | This version of ioapi is designed to access memory rather than files.
5 | We do use a region of memory to put data in to and take it out of.
6 |
7 | Copyright (C) 2012-2017 Nathan Moinvaziri (https://github.com/nmoinvaz/minizip)
8 | (C) 2003 Justin Fletcher
9 | (C) 1998-2003 Gilles Vollant
10 |
11 | This program is distributed under the terms of the same license as zlib.
12 | See the accompanying LICENSE file for the full text of the license.
13 | */
14 |
15 | #ifndef _IOAPI_MEM_H
16 | #define _IOAPI_MEM_H
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "zlib.h"
23 | #include "ioapi.h"
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | voidpf ZCALLBACK fopen_mem_func(voidpf opaque, const char* filename, int mode);
30 | voidpf ZCALLBACK fopendisk_mem_func(voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
31 | uint32_t ZCALLBACK fread_mem_func(voidpf opaque, voidpf stream, void* buf, uint32_t size);
32 | uint32_t ZCALLBACK fwrite_mem_func(voidpf opaque, voidpf stream, const void* buf, uint32_t size);
33 | long ZCALLBACK ftell_mem_func(voidpf opaque, voidpf stream);
34 | long ZCALLBACK fseek_mem_func(voidpf opaque, voidpf stream, uint32_t offset, int origin);
35 | int ZCALLBACK fclose_mem_func(voidpf opaque, voidpf stream);
36 | int ZCALLBACK ferror_mem_func(voidpf opaque, voidpf stream);
37 |
38 | typedef struct ourmemory_s {
39 | char *base; /* Base of the region of memory we're using */
40 | uint32_t size; /* Size of the region of memory we're using */
41 | uint32_t limit; /* Furthest we've written */
42 | uint32_t cur_offset; /* Current offset in the area */
43 | int grow; /* Growable memory buffer */
44 | } ourmemory_t;
45 |
46 | void fill_memory_filefunc(zlib_filefunc_def* pzlib_filefunc_def, ourmemory_t *ourmem);
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/SSZipArchive/SSZipArchive/minizip/minishared.h:
--------------------------------------------------------------------------------
1 | #ifndef _MINISHARED_H
2 | #define _MINISHARED_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | #ifdef _WIN32
9 | # define MKDIR(d) _mkdir(d)
10 | # define CHDIR(d) _chdir(d)
11 | #else
12 | # define MKDIR(d) mkdir(d, 0775)
13 | # define CHDIR(d) chdir(d)
14 | #endif
15 |
16 | /***************************************************************************/
17 |
18 | /* Get a file's date and time in dos format */
19 | uint32_t get_file_date(const char *path, uint32_t *dos_date);
20 |
21 | /* Sets a file's date and time in dos format */
22 | void change_file_date(const char *path, uint32_t dos_date);
23 |
24 | /* Convert dos date/time format to struct tm */
25 | int dosdate_to_tm(uint64_t dos_date, struct tm *ptm);
26 |
27 | /* Convert dos date/time format to time_t */
28 | time_t dosdate_to_time_t(uint64_t dos_date);
29 |
30 | /* Convert struct tm to dos date/time format */
31 | uint32_t tm_to_dosdate(const struct tm *ptm);
32 |
33 | /* Create a directory and all subdirectories */
34 | int makedir(const char *newdir);
35 |
36 | /* Check to see if a file exists */
37 | int check_file_exists(const char *path);
38 |
39 | /* Check to see if a file is over 4GB and needs ZIP64 extension */
40 | int is_large_file(const char *path);
41 |
42 | /* Print a 64-bit number for compatibility */
43 | void display_zpos64(uint64_t n, int size_char);
44 |
45 | /***************************************************************************/
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif /* _MINISHARED_H */
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/JXBWebKit/JXBWebKit-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_JXBWebKit : NSObject
3 | @end
4 | @implementation PodsDummy_JXBWebKit
5 | @end
6 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/JXBWebKit/JXBWebKit-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/JXBWebKit/JXBWebKit.xcconfig:
--------------------------------------------------------------------------------
1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/JXBWebKit
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/JXBWebKit" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/JXBWebKit"
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../..
8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
9 | SKIP_INSTALL = YES
10 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## JXBWebKit
5 |
6 | MIT License
7 |
8 | Copyright (c) 2018
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 |
18 | The above copyright notice and this permission notice shall be included in
19 | all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 | THE SOFTWARE.
28 |
29 |
30 | ## SSZipArchive
31 |
32 | Copyright (c) 2010-2015, Sam Soffes, http://soff.es
33 |
34 | Permission is hereby granted, free of charge, to any person obtaining
35 | a copy of this software and associated documentation files (the
36 | "Software"), to deal in the Software without restriction, including
37 | without limitation the rights to use, copy, modify, merge, publish,
38 | distribute, sublicense, and/or sell copies of the Software, and to
39 | permit persons to whom the Software is furnished to do so, subject to
40 | the following conditions:
41 |
42 | The above copyright notice and this permission notice shall be
43 | included in all copies or substantial portions of the Software.
44 |
45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
46 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
49 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
50 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
51 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
52 |
53 | Generated by CocoaPods - https://cocoapods.org
54 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | MIT License
18 |
19 | Copyright (c) 2018
20 |
21 | Permission is hereby granted, free of charge, to any person obtaining a copy
22 | of this software and associated documentation files (the "Software"), to deal
23 | in the Software without restriction, including without limitation the rights
24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25 | copies of the Software, and to permit persons to whom the Software is
26 | furnished to do so, subject to the following conditions:
27 |
28 |
29 | The above copyright notice and this permission notice shall be included in
30 | all copies or substantial portions of the Software.
31 |
32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
38 | THE SOFTWARE.
39 |
40 | License
41 | MIT
42 | Title
43 | JXBWebKit
44 | Type
45 | PSGroupSpecifier
46 |
47 |
48 | FooterText
49 | Copyright (c) 2010-2015, Sam Soffes, http://soff.es
50 |
51 | Permission is hereby granted, free of charge, to any person obtaining
52 | a copy of this software and associated documentation files (the
53 | "Software"), to deal in the Software without restriction, including
54 | without limitation the rights to use, copy, modify, merge, publish,
55 | distribute, sublicense, and/or sell copies of the Software, and to
56 | permit persons to whom the Software is furnished to do so, subject to
57 | the following conditions:
58 |
59 | The above copyright notice and this permission notice shall be
60 | included in all copies or substantial portions of the Software.
61 |
62 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
63 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
64 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
65 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
66 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
67 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
68 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
69 |
70 | License
71 | MIT
72 | Title
73 | SSZipArchive
74 | Type
75 | PSGroupSpecifier
76 |
77 |
78 | FooterText
79 | Generated by CocoaPods - https://cocoapods.org
80 | Title
81 |
82 | Type
83 | PSGroupSpecifier
84 |
85 |
86 | StringsTable
87 | Acknowledgements
88 | Title
89 | Acknowledgements
90 |
91 |
92 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_JXBWebKitProject : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_JXBWebKitProject
5 | @end
6 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject-resources-Debug-input-files.xcfilelist:
--------------------------------------------------------------------------------
1 | ${PODS_ROOT}/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject-resources.sh
2 | ${PODS_ROOT}/../../JXBWebKit/JSResources.bundle
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject-resources-Debug-output-files.xcfilelist:
--------------------------------------------------------------------------------
1 | ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/JSResources.bundle
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject-resources-Release-input-files.xcfilelist:
--------------------------------------------------------------------------------
1 | ${PODS_ROOT}/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject-resources.sh
2 | ${PODS_ROOT}/../../JXBWebKit/JSResources.bundle
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject-resources-Release-output-files.xcfilelist:
--------------------------------------------------------------------------------
1 | ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/JSResources.bundle
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject.debug.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/JXBWebKit" "${PODS_ROOT}/Headers/Public/SSZipArchive"
3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/JXBWebKit" "${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive"
4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"JXBWebKit" -l"SSZipArchive" -l"z"
5 | PODS_BUILD_DIR = ${BUILD_DIR}
6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
7 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
8 | PODS_ROOT = ${SRCROOT}/Pods
9 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProject/Pods-JXBWebKitProject.release.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/JXBWebKit" "${PODS_ROOT}/Headers/Public/SSZipArchive"
3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/JXBWebKit" "${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive"
4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"JXBWebKit" -l"SSZipArchive" -l"z"
5 | PODS_BUILD_DIR = ${BUILD_DIR}
6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
7 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
8 | PODS_ROOT = ${SRCROOT}/Pods
9 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProjectTests/Pods-JXBWebKitProjectTests-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 | Generated by CocoaPods - https://cocoapods.org
4 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProjectTests/Pods-JXBWebKitProjectTests-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Generated by CocoaPods - https://cocoapods.org
18 | Title
19 |
20 | Type
21 | PSGroupSpecifier
22 |
23 |
24 | StringsTable
25 | Acknowledgements
26 | Title
27 | Acknowledgements
28 |
29 |
30 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProjectTests/Pods-JXBWebKitProjectTests-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_JXBWebKitProjectTests : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_JXBWebKitProjectTests
5 | @end
6 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProjectTests/Pods-JXBWebKitProjectTests.debug.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/JXBWebKit" "${PODS_ROOT}/Headers/Public/SSZipArchive"
3 | OTHER_LDFLAGS = $(inherited) -l"z"
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
7 | PODS_ROOT = ${SRCROOT}/Pods
8 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProjectTests/Pods-JXBWebKitProjectTests.release.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/JXBWebKit" "${PODS_ROOT}/Headers/Public/SSZipArchive"
3 | OTHER_LDFLAGS = $(inherited) -l"z"
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
7 | PODS_ROOT = ${SRCROOT}/Pods
8 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProjectUITests/Pods-JXBWebKitProjectUITests-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 | Generated by CocoaPods - https://cocoapods.org
4 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProjectUITests/Pods-JXBWebKitProjectUITests-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Generated by CocoaPods - https://cocoapods.org
18 | Title
19 |
20 | Type
21 | PSGroupSpecifier
22 |
23 |
24 | StringsTable
25 | Acknowledgements
26 | Title
27 | Acknowledgements
28 |
29 |
30 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProjectUITests/Pods-JXBWebKitProjectUITests-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_JXBWebKitProjectUITests : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_JXBWebKitProjectUITests
5 | @end
6 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProjectUITests/Pods-JXBWebKitProjectUITests.debug.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/JXBWebKit" "${PODS_ROOT}/Headers/Public/SSZipArchive"
3 | OTHER_LDFLAGS = $(inherited) -l"z"
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
7 | PODS_ROOT = ${SRCROOT}/Pods
8 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/Pods-JXBWebKitProjectUITests/Pods-JXBWebKitProjectUITests.release.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/JXBWebKit" "${PODS_ROOT}/Headers/Public/SSZipArchive"
3 | OTHER_LDFLAGS = $(inherited) -l"z"
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
7 | PODS_ROOT = ${SRCROOT}/Pods
8 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/SSZipArchive/SSZipArchive-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_SSZipArchive : NSObject
3 | @end
4 | @implementation PodsDummy_SSZipArchive
5 | @end
6 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/SSZipArchive/SSZipArchive-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/JXBWebKitProject/Pods/Target Support Files/SSZipArchive/SSZipArchive.xcconfig:
--------------------------------------------------------------------------------
1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SSZipArchive" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SSZipArchive"
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/SSZipArchive
8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
9 | SKIP_INSTALL = YES
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 如果你有好的想法,欢迎`Issue`或贡献代码!
2 |
3 | 如果你在使用该库的过程中遇到任何问题,可以通过我的邮箱或`Issue`联系到我。
4 |
5 |
6 | ## 使用CocoaPods安装
7 |
8 | ```
9 | pod 'JXBWebKit', '~> 1.3.0'
10 | ```
11 |
12 |
13 |
14 | ## 手动安装
15 |
16 | 拖动`JXBWebKit`文件夹到你的项目.
17 |
18 | 注意`Copy`选项需要选择`"Copy items into destination group's folder" and select "Create groups for any folders".`
19 |
20 |
21 |
22 | ## 示例
23 |
24 | 打开`JXBWebKitProject`直接执行项目。
25 |
26 |
27 |
28 | ## 使用方法
29 |
30 | 1.可以直接使用`JXBWebViewController`实例对象打开远程和本地的`HTML`.
31 |
32 | 2.可以从`JXBWebViewController`派生出一个子类,使用该子类实例打开远程和本地的`HTML`.
33 |
34 | 3.还可以从`JXBWKWebViewPool`获取一个可复用的`WebView`,使用该`WebView`打开远程和本地的`HTML`.
35 |
36 |
37 |
38 | ## 提供的功能
39 |
40 | 1.`WebView`适配不通机型.
41 |
42 | 2.`UI`支持(进度条、进度条颜色、back&close按钮).
43 |
44 | 3.支持拦截URL.
45 |
46 | 4.通过`JSBridge`和`Web`进行交互,实测任何场景的交互操作都可满足!比如
47 |
48 | - 打开`naive`任意页面.
49 | - 获取`native`定位、推送、相册、相机等权限.
50 | - 获取`native`数据。
51 | - 调用`native`的任意`API`。
52 | - 其他
53 |
54 | 5.对子类提供`WebView`父类的`hook`操作.
55 |
56 | 6.支持`WKWebView`的复用,通过复用优化启动性能以及内存占用.
57 |
58 | 7.支持各种自定义浏览器的`UserAgent`.
59 |
60 | 8.支持拦截`WebView`的网络请求.
61 |
62 | 9.支持操作`Cookie`.
63 |
64 | 10.`demo`中提供了让业务`H5`页面秒开的方案(`HTML`模板渲染 & 静态资源离线包).
65 |
66 | - 现在市面上绝大部分新闻类APP使用的都是HTML模板渲染方案.
67 | - 除了资讯类页面外其他业务场景的H5都可使用离线包方案.
68 |
69 |
70 |
71 | ## 注意
72 |
73 | 关于上述第10条中提到的H5秒开方案需要`server`进行配合,因此在这里我使用`Go`语言进行后台开发,`server`提供了两个`API`:
74 |
75 | 1.一个普通的`get`请求,`client`通过获取响应数据中的`html`渲染模板进行渲染。
76 |
77 | 2.一个下载服务器离线包资源的接口。
78 |
79 | 当然,要想看这个功能的具体实现效果,需要在本地配置`Go`的开发环境,详见如下步骤:
80 |
81 | 1.使用`brew install go`安装golang.
82 |
83 | 2.环境配置
84 |
85 | (1)使用`cd ~`切换到根目录.
86 |
87 | (2)使用`ls -all`查看所有文件,看有没有`.bash_profile`文件.
88 |
89 | (3)没有就创建一个`touch .bash_profile`
90 |
91 | 使用`vim`打开`.bash_profile`进行编辑,`i`进行编辑,编辑完成后`:wq`退出,编辑内容如下:
92 |
93 | ````
94 | export GOPATH=/Users//Documents/go
95 | export GOBIN=$GOPATH/bin
96 | export PATH=$PATH:$GOBIN
97 | ````
98 |
99 | (4)切换到`Documents`文件夹,创建`go`文件夹,再在`go`文件夹下分别创建`bin`、`src`文件夹,`src`就是以后存放项目的文件夹.
100 |
101 | (5)在终端输入`go env`命令查看配置是否正确,`GOBIN`有值表示配置没问题.
102 |
103 | (6)在本工程内搜索文件夹`GoProject > src > OfflineServer`,将`OfflineServer`文件夹拷贝至`Documents > go > src`目录下.
104 |
105 | (7)切换至`Documents > go > src`
106 |
107 | (8)`go build`编译项目.
108 |
109 | (9)`go run main.go`运行项目.
110 |
111 | (10)不再需要开启`server`服务可以`control+c`退出.
112 |
113 |
114 |
115 | ## 整体架构
116 |
117 | 
118 |
119 |
120 |
121 | ## 关于JSBridge的实现原理
122 |
123 | ### 图解
124 |
125 | 
126 |
127 |
128 |
129 | ### JS调用Native
130 |
131 | 示例代码大家可以通过两种方式获取到,如下:
132 |
133 | (1)找到当前工程目录,再找到`GoProject -> src -> OfflineServer -> source`,在`source`文件下有个压缩文件`offline_pkg.zip`,将该文件拷贝至别处解压,找到`resource`目录下的`offline.js`文件,里面就有示例代码,比如:
134 |
135 | 获取`native`的推送权限状态
136 |
137 | ```objective-c
138 | function getPushAuthState() {
139 | window.JXBJSBridge.call({
140 | target : "push",
141 | action : "getAuthorityState",
142 | data : {
143 | "id" : "123456789",
144 | "name" : "zhangsan"
145 | },
146 | callback : {
147 | success : function(result){document.getElementById('message').innerHTML = result;},
148 | fail : function(result){document.getElementById('message').innerHTML = result;},
149 | progress : function(result){document.getElementById('message').innerHTML = result;},
150 | }
151 | });
152 | }
153 | ```
154 |
155 | (2)在当前工程目录下有个`JSResources.bundle`文件,显示包内容,里面有个`index.html`,同样也有示例代码。
156 |
157 |
158 |
159 | ### Object-C代码如何写?
160 |
161 | 与`JS`约定好参数,`target、action、data、callback`等。
162 |
163 | `target`:对应原生的目标类,格式为`Service_target`。
164 |
165 | `action`:对应目标类的目标方法,格式为`func_action:`。
166 |
167 | `data`:`JS`传给`Native`的数据。
168 |
169 | `callback`:`Native`处理完业务后回调给`JS`的结果。
170 |
171 | 示例:
172 |
173 | ```objective-c
174 | //获取推送权限状态
175 | - (void)func_getAuthorityState:(NSDictionary *)param {
176 | //获取id
177 | NSString *ID = param[@"id"];
178 | //获取name
179 | NSString *name = param[@"name"];
180 |
181 | BOOL isOpen = NO;
182 | UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
183 | if (setting.types != UIUserNotificationTypeNone) {
184 | isOpen = YES;
185 | }
186 | void(^successCallback)(NSDictionary *result) = param[@"success"];
187 | NSDictionary *resultDict = @{@"isOpen":@(isOpen)};
188 | successCallback(resultDict);
189 | }
190 | ```
191 |
192 | ### 如何与Android统一调用方式
193 |
194 | 当前库加载的注入脚本是`JXBJSBridge.js`,当`WebView`加载`HTML`时会在`window`上挂一个`call`方法,此时`call`方法相当于一个全局方法,供`JS`调用,这个脚本文件同样可以提供给`Android`使用,达到调用方式统一的目的。
195 |
--------------------------------------------------------------------------------
/doc_imgs/share01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiubojin/JXBWKWebView/f2576040942744c0bcf299d1f03442643a17bf11/doc_imgs/share01.png
--------------------------------------------------------------------------------
/doc_imgs/share02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiubojin/JXBWKWebView/f2576040942744c0bcf299d1f03442643a17bf11/doc_imgs/share02.png
--------------------------------------------------------------------------------