@react-native-kakao/map 2.2.7 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +5 -38
- package/RNCKakaoMap.podspec +16 -52
- package/android/build.gradle +12 -107
- package/android/consumer-rules.pro +2 -0
- package/android/src/main/AndroidManifest.xml +3 -1
- package/android/src/main/java/net/mjstudio/rnkakao/map/CameraOptions.kt +61 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/KakaoMapModule.kt +131 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/KakaoMapView.kt +1257 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/MapCameraCommands.kt +306 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/MapDimScreen.kt +431 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/MapGui.kt +899 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/MapImageLoader.kt +232 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/MapLabels.kt +1572 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/MapOptions.kt +360 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/MapRoutes.kt +805 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/MapShapes.kt +1096 -0
- package/android/src/main/java/net/mjstudio/rnkakao/map/MapUtilities.kt +495 -0
- package/expo-module.config.json +5 -0
- package/ios/CameraOptions.swift +41 -0
- package/ios/KakaoMapModule.swift +204 -0
- package/ios/KakaoMapView.swift +1018 -0
- package/ios/MapCameraCommands.swift +451 -0
- package/ios/MapDimScreen.swift +463 -0
- package/ios/MapGui.swift +1099 -0
- package/ios/MapImageLoader.swift +177 -0
- package/ios/MapLabels.swift +1676 -0
- package/ios/MapOptions.swift +374 -0
- package/ios/MapRoutes.swift +903 -0
- package/ios/MapShapes.swift +1294 -0
- package/ios/MapUnits.swift +20 -0
- package/ios/MapUtilities.swift +365 -0
- package/lib/commonjs/index.js +180 -29
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +18 -0
- package/lib/commonjs/index.web.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types-assets.js +2 -0
- package/lib/commonjs/types-assets.js.map +1 -0
- package/lib/commonjs/types-camera.js +6 -0
- package/lib/commonjs/types-camera.js.map +1 -0
- package/lib/commonjs/types-dim.js +6 -0
- package/lib/commonjs/types-dim.js.map +1 -0
- package/lib/commonjs/types-gui.js +6 -0
- package/lib/commonjs/types-gui.js.map +1 -0
- package/lib/commonjs/types-labels.js +6 -0
- package/lib/commonjs/types-labels.js.map +1 -0
- package/lib/commonjs/types-routes.js +6 -0
- package/lib/commonjs/types-routes.js.map +1 -0
- package/lib/commonjs/types-shapes.js +6 -0
- package/lib/commonjs/types-shapes.js.map +1 -0
- package/lib/commonjs/types-utilities.js +6 -0
- package/lib/commonjs/types-utilities.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/index.js +180 -22
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +13 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/module/types-assets.js +2 -0
- package/lib/module/types-assets.js.map +1 -0
- package/lib/module/types-camera.js +4 -0
- package/lib/module/types-camera.js.map +1 -0
- package/lib/module/types-dim.js +4 -0
- package/lib/module/types-dim.js.map +1 -0
- package/lib/module/types-gui.js +4 -0
- package/lib/module/types-gui.js.map +1 -0
- package/lib/module/types-labels.js +4 -0
- package/lib/module/types-labels.js.map +1 -0
- package/lib/module/types-routes.js +4 -0
- package/lib/module/types-routes.js.map +1 -0
- package/lib/module/types-shapes.js +4 -0
- package/lib/module/types-shapes.js.map +1 -0
- package/lib/module/types-utilities.js +4 -0
- package/lib/module/types-utilities.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/src/index.d.ts +59 -9
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types-assets.d.ts +9 -0
- package/lib/typescript/src/types-assets.d.ts.map +1 -0
- package/lib/typescript/src/types-camera.d.ts +123 -0
- package/lib/typescript/src/types-camera.d.ts.map +1 -0
- package/lib/typescript/src/types-dim.d.ts +54 -0
- package/lib/typescript/src/types-dim.d.ts.map +1 -0
- package/lib/typescript/src/types-gui.d.ts +189 -0
- package/lib/typescript/src/types-gui.d.ts.map +1 -0
- package/lib/typescript/src/types-labels.d.ts +246 -0
- package/lib/typescript/src/types-labels.d.ts.map +1 -0
- package/lib/typescript/src/types-routes.d.ts +162 -0
- package/lib/typescript/src/types-routes.d.ts.map +1 -0
- package/lib/typescript/src/types-shapes.d.ts +253 -0
- package/lib/typescript/src/types-shapes.d.ts.map +1 -0
- package/lib/typescript/src/types-utilities.d.ts +130 -0
- package/lib/typescript/src/types-utilities.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +222 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +24 -77
- package/src/index.tsx +322 -0
- package/src/index.web.tsx +46 -0
- package/src/types-assets.ts +8 -0
- package/src/types-camera.ts +97 -0
- package/src/types-dim.ts +54 -0
- package/src/types-gui.ts +171 -0
- package/src/types-labels.ts +207 -0
- package/src/types-routes.ts +118 -0
- package/src/types-shapes.ts +244 -0
- package/src/types-utilities.ts +115 -0
- package/src/types.ts +223 -0
- package/android/gradle.properties +0 -1
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/net/mjstudio/rnkakao/map/RNCKakaoMapModule.kt +0 -25
- package/android/src/main/java/net/mjstudio/rnkakao/map/RNCKakaoMapPackage.kt +0 -35
- package/android/src/newarch/KakaoMapSpec.kt +0 -7
- package/android/src/oldarch/KakaoMapSpec.kt +0 -14
- package/ios/Component/Map/RNCKakaoMapView.h +0 -23
- package/ios/Component/Map/RNCKakaoMapView.mm +0 -209
- package/ios/Component/Map/RNCKakaoMapViewManager.mm +0 -19
- package/ios/NativeModule/RNCKakaoMap.h +0 -7
- package/ios/NativeModule/RNCKakaoMap.mm +0 -19
- package/ios/NativeModule/RNCKakaoMapManager.swift +0 -7
- package/ios/Util/Util.h +0 -97
- package/lib/commonjs/component/KakaoMapView.js +0 -54
- package/lib/commonjs/component/KakaoMapView.js.map +0 -1
- package/lib/commonjs/spec/NativeKakaoMap.js +0 -9
- package/lib/commonjs/spec/NativeKakaoMap.js.map +0 -1
- package/lib/commonjs/spec/RNCKakaoMapViewNativeComponent.js +0 -15
- package/lib/commonjs/spec/RNCKakaoMapViewNativeComponent.js.map +0 -1
- package/lib/commonjs/type/type.js +0 -2
- package/lib/commonjs/type/type.js.map +0 -1
- package/lib/commonjs/util/Const.js +0 -14
- package/lib/commonjs/util/Const.js.map +0 -1
- package/lib/commonjs/util/Util.js +0 -15
- package/lib/commonjs/util/Util.js.map +0 -1
- package/lib/module/component/KakaoMapView.js +0 -48
- package/lib/module/component/KakaoMapView.js.map +0 -1
- package/lib/module/spec/NativeKakaoMap.js +0 -3
- package/lib/module/spec/NativeKakaoMap.js.map +0 -1
- package/lib/module/spec/RNCKakaoMapViewNativeComponent.js +0 -10
- package/lib/module/spec/RNCKakaoMapViewNativeComponent.js.map +0 -1
- package/lib/module/type/type.js +0 -2
- package/lib/module/type/type.js.map +0 -1
- package/lib/module/util/Const.js +0 -8
- package/lib/module/util/Const.js.map +0 -1
- package/lib/module/util/Util.js +0 -9
- package/lib/module/util/Util.js.map +0 -1
- package/lib/typescript/src/component/KakaoMapView.d.ts +0 -25
- package/lib/typescript/src/component/KakaoMapView.d.ts.map +0 -1
- package/lib/typescript/src/spec/NativeKakaoMap.d.ts +0 -7
- package/lib/typescript/src/spec/NativeKakaoMap.d.ts.map +0 -1
- package/lib/typescript/src/spec/RNCKakaoMapViewNativeComponent.d.ts +0 -32
- package/lib/typescript/src/spec/RNCKakaoMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/type/type.d.ts +0 -8
- package/lib/typescript/src/type/type.d.ts.map +0 -1
- package/lib/typescript/src/util/Const.d.ts +0 -8
- package/lib/typescript/src/util/Const.d.ts.map +0 -1
- package/lib/typescript/src/util/Util.d.ts +0 -3
- package/lib/typescript/src/util/Util.d.ts.map +0 -1
- package/src/component/KakaoMapView.tsx +0 -82
- package/src/index.ts +0 -43
- package/src/spec/NativeKakaoMap.ts +0 -8
- package/src/spec/RNCKakaoMapViewNativeComponent.ts +0 -38
- package/src/type/type.ts +0 -7
- package/src/util/Const.ts +0 -7
- package/src/util/Util.ts +0 -11
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
private let mapImageLoadError = "ERR_KAKAO_MAP_IMAGE_LOAD"
|
|
5
|
+
private let supportedMapImageSchemes = Set([
|
|
6
|
+
"asset", "content", "data", "file", "http", "https"
|
|
7
|
+
])
|
|
8
|
+
|
|
9
|
+
final class MapImageLoadException: Exception {
|
|
10
|
+
init(_ message: String) {
|
|
11
|
+
super.init(name: "KakaoMapImageError", description: message, code: mapImageLoadError)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
final class MapImageLoadToken {
|
|
16
|
+
fileprivate let id: UUID
|
|
17
|
+
private let lock = NSLock()
|
|
18
|
+
private var cancellation: (() -> Void)?
|
|
19
|
+
private var isFinished = false
|
|
20
|
+
|
|
21
|
+
fileprivate init(id: UUID = UUID(), cancellation: @escaping () -> Void) {
|
|
22
|
+
self.id = id
|
|
23
|
+
self.cancellation = cancellation
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
func cancel() {
|
|
27
|
+
lock.lock()
|
|
28
|
+
guard !isFinished else {
|
|
29
|
+
lock.unlock()
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
isFinished = true
|
|
33
|
+
let cancellation = cancellation
|
|
34
|
+
self.cancellation = nil
|
|
35
|
+
lock.unlock()
|
|
36
|
+
cancellation?()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@discardableResult
|
|
40
|
+
fileprivate func finish() -> Bool {
|
|
41
|
+
lock.lock()
|
|
42
|
+
guard !isFinished else {
|
|
43
|
+
lock.unlock()
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
isFinished = true
|
|
47
|
+
cancellation = nil
|
|
48
|
+
lock.unlock()
|
|
49
|
+
return true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
final class MapImageLoader {
|
|
54
|
+
private struct Request {
|
|
55
|
+
let token: MapImageLoadToken
|
|
56
|
+
let completion: (Result<UIImage, Error>) -> Void
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private let imageLoader: EXImageLoaderInterface?
|
|
60
|
+
private let cache = NSCache<NSURL, UIImage>()
|
|
61
|
+
private var requests: [UUID: Request] = [:]
|
|
62
|
+
private var isDisposed = false
|
|
63
|
+
|
|
64
|
+
init(appContext: AppContext?) {
|
|
65
|
+
imageLoader = appContext?.imageLoader
|
|
66
|
+
cache.countLimit = 64
|
|
67
|
+
cache.totalCostLimit = 16 * 1024 * 1024
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@discardableResult
|
|
71
|
+
func load(
|
|
72
|
+
_ uri: String,
|
|
73
|
+
completion: @escaping (Result<UIImage, Error>) -> Void
|
|
74
|
+
) -> MapImageLoadToken {
|
|
75
|
+
dispatchPrecondition(condition: .onQueue(.main))
|
|
76
|
+
let requestId = UUID()
|
|
77
|
+
let token = MapImageLoadToken(id: requestId) { [weak self] in
|
|
78
|
+
if Thread.isMainThread {
|
|
79
|
+
self?.cancel(requestId)
|
|
80
|
+
} else {
|
|
81
|
+
DispatchQueue.main.async { [weak self] in
|
|
82
|
+
self?.cancel(requestId)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
guard !isDisposed else {
|
|
88
|
+
fail(token, completion: completion, message: "The map image loader was destroyed.")
|
|
89
|
+
return token
|
|
90
|
+
}
|
|
91
|
+
requests[token.id] = Request(token: token, completion: completion)
|
|
92
|
+
guard let url = URL(string: uri), let scheme = url.scheme?.lowercased(),
|
|
93
|
+
supportedMapImageSchemes.contains(scheme)
|
|
94
|
+
else {
|
|
95
|
+
reject(token.id, message: "Image URI must use a supported scheme.")
|
|
96
|
+
return token
|
|
97
|
+
}
|
|
98
|
+
guard let imageLoader else {
|
|
99
|
+
reject(token.id, message: "The Expo image loader is unavailable.")
|
|
100
|
+
return token
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let key = url as NSURL
|
|
104
|
+
if let image = cache.object(forKey: key) {
|
|
105
|
+
DispatchQueue.main.async { [weak self] in
|
|
106
|
+
self?.finish(token.id, result: .success(image))
|
|
107
|
+
}
|
|
108
|
+
return token
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
imageLoader.loadImage(for: url) { [weak self] error, image in
|
|
112
|
+
DispatchQueue.main.async { [weak self] in
|
|
113
|
+
guard let self, !self.isDisposed else { return }
|
|
114
|
+
if let image {
|
|
115
|
+
finish(token.id, result: .success(image), cacheKey: key)
|
|
116
|
+
} else {
|
|
117
|
+
finish(
|
|
118
|
+
token.id,
|
|
119
|
+
result: .failure(MapImageLoadException(error?
|
|
120
|
+
.localizedDescription ?? "Could not decode the map image."))
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return token
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
func dispose() {
|
|
129
|
+
dispatchPrecondition(condition: .onQueue(.main))
|
|
130
|
+
guard !isDisposed else { return }
|
|
131
|
+
isDisposed = true
|
|
132
|
+
let currentRequests = requests.values
|
|
133
|
+
requests.removeAll()
|
|
134
|
+
currentRequests.forEach { $0.token.finish() }
|
|
135
|
+
cache.removeAllObjects()
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private func cancel(_ id: UUID) {
|
|
139
|
+
requests.removeValue(forKey: id)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private func finish(
|
|
143
|
+
_ id: UUID,
|
|
144
|
+
result: Result<UIImage, Error>,
|
|
145
|
+
cacheKey: NSURL? = nil
|
|
146
|
+
) {
|
|
147
|
+
guard !isDisposed, let request = requests.removeValue(forKey: id) else { return }
|
|
148
|
+
guard request.token.finish() else { return }
|
|
149
|
+
if case let .success(image) = result, let cacheKey {
|
|
150
|
+
cache.setObject(image, forKey: cacheKey, cost: imageCost(image))
|
|
151
|
+
}
|
|
152
|
+
request.completion(result)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private func reject(_ id: UUID, message: String) {
|
|
156
|
+
DispatchQueue.main.async { [weak self] in
|
|
157
|
+
self?.finish(id, result: .failure(MapImageLoadException(message)))
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private func fail(
|
|
162
|
+
_ token: MapImageLoadToken,
|
|
163
|
+
completion: @escaping (Result<UIImage, Error>) -> Void,
|
|
164
|
+
message: String
|
|
165
|
+
) {
|
|
166
|
+
DispatchQueue.main.async {
|
|
167
|
+
if token.finish() {
|
|
168
|
+
completion(.failure(MapImageLoadException(message)))
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private func imageCost(_ image: UIImage) -> Int {
|
|
175
|
+
guard let cgImage = image.cgImage else { return 0 }
|
|
176
|
+
return cgImage.bytesPerRow * cgImage.height
|
|
177
|
+
}
|