@react-native-ohos/react-native-svg 15.12.1-rc.1 → 15.12.1-rc.11
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/LICENSE +21 -21
- package/README.OpenSource +10 -10
- package/README.md +13 -13
- package/css/package.json +5 -5
- package/harmony/svg/BuildProfile.ets +16 -16
- package/harmony/svg/build-profile.json5 +9 -9
- package/harmony/svg/hvigorfile.ts +1 -1
- package/harmony/svg/index.ets +6 -6
- package/harmony/svg/oh-package.json5 +13 -13
- package/harmony/svg/src/main/cpp/CMakeLists.txt +6 -1
- package/harmony/svg/src/main/cpp/SVGPackage.h +14 -0
- package/harmony/svg/src/main/cpp/SvgArkUINode.cpp +3 -0
- package/harmony/svg/src/main/cpp/SvgArkUINode.h +15 -9
- package/harmony/svg/src/main/cpp/SvgFilter.cpp +505 -505
- package/harmony/svg/src/main/cpp/SvgFilter.h +112 -112
- package/harmony/svg/src/main/cpp/SvgForeignObjectNode.cpp +86 -0
- package/harmony/svg/src/main/cpp/SvgForeignObjectNode.h +81 -0
- package/harmony/svg/src/main/cpp/SvgForeignObjectNodeDelegate.h +30 -0
- package/harmony/svg/src/main/cpp/SvgForeignProps.h +39 -0
- package/harmony/svg/src/main/cpp/SvgGradient.cpp +1 -0
- package/harmony/svg/src/main/cpp/SvgGroup.cpp +8 -1
- package/harmony/svg/src/main/cpp/SvgNode.cpp +109 -3
- package/harmony/svg/src/main/cpp/SvgNode.h +43 -13
- package/harmony/svg/src/main/cpp/SvgViewManager.cpp +3 -0
- package/harmony/svg/src/main/cpp/SvgViewManager.h +2 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.cpp +40 -40
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.h +48 -48
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.cpp +33 -33
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.h +48 -48
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.cpp +39 -39
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.h +55 -55
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.cpp +33 -33
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.h +49 -49
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.cpp +34 -34
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.h +48 -48
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.cpp +35 -35
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.h +45 -45
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.cpp +198 -198
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.h +48 -48
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGForeignObjectComponentInstance.cpp +93 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGForeignObjectComponentInstance.h +55 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.h +8 -4
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.cpp +4 -1
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.cpp +38 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.h +11 -2
- package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.cpp +69 -10
- package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.cpp +54 -26
- package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.h +6 -10
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeBlendJSIBinder.h +26 -26
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeColorMatrixJSIBinder.h +26 -26
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeCompositeJSIBinder.h +30 -30
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeFloodJSIBinder.h +26 -26
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeGaussianBlurJSIBinder.h +26 -26
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeOffsetJSIBinder.h +26 -26
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFilterJSIBinder.h +44 -44
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.cpp +977 -977
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.h +1280 -1280
- package/harmony/svg/src/main/cpp/properties/Dimension.h +14 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.cpp +30 -1
- package/harmony/svg/src/main/cpp/utils/DynamicUtils.h +55 -55
- package/harmony/svg/src/main/cpp/utils/FilterManager.h +190 -190
- package/harmony/svg/src/main/ets/RNSVGImageModule.ts +21 -21
- package/harmony/svg/src/main/ets/RNSVGRenderableModule.ts +16 -16
- package/harmony/svg/src/main/ets/RNSVGSvgViewModule.ts +18 -18
- package/harmony/svg/src/main/ets/SvgPackage.ts +57 -57
- package/harmony/svg/src/main/module.json5 +7 -7
- package/harmony/svg/src/main/resources/base/element/string.json +8 -8
- package/harmony/svg/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/svg/src/main/resources/zh_CN/element/string.json +8 -8
- package/harmony/svg/ts.ts +7 -7
- package/harmony/svg.har +0 -0
- package/lib/commonjs/css/index.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/css/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/package.json +53 -54
- package/src/css/index.tsx +19 -19
- package/src/index.tsx +2 -2
- package/tsconfig.json +11 -11
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Use of this source code is governed by a MIT license that can be
|
|
4
4
|
* found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
#ifndef RNSVG_GROUP_COMPONENT_INSTANCE_H
|
|
7
|
+
#define RNSVG_GROUP_COMPONENT_INSTANCE_H
|
|
7
8
|
#pragma once
|
|
8
9
|
|
|
9
10
|
#include "RNSVGBaseComponentInstance.h"
|
|
@@ -15,13 +16,16 @@ namespace svg {
|
|
|
15
16
|
class RNSVGGroupComponentInstance : public RNSVGBaseComponentInstance<facebook::react::RNSVGGroupShadowNode> {
|
|
16
17
|
public:
|
|
17
18
|
explicit RNSVGGroupComponentInstance(Context context);
|
|
18
|
-
|
|
19
|
+
std::shared_ptr<SvgGroup> getNode(){
|
|
20
|
+
return m_svgGroup;
|
|
21
|
+
}
|
|
19
22
|
protected:
|
|
20
23
|
void UpdateElementProps() override;
|
|
21
|
-
|
|
24
|
+
|
|
22
25
|
private:
|
|
23
26
|
std::shared_ptr<SvgGroup> m_svgGroup = std::make_shared<SvgGroup>();
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
} // namespace svg
|
|
27
|
-
} // namespace rnoh
|
|
30
|
+
} // namespace rnoh
|
|
31
|
+
#endif // RNSVG_GROUP_COMPONENT_INSTANCE_H
|
|
@@ -77,7 +77,10 @@ std::string RNSVGImageComponentInstance::FindLocalCacheByUri(std::string const &
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// 查找缓存目录
|
|
80
|
-
auto
|
|
80
|
+
auto basePtr = shared_from_this();
|
|
81
|
+
auto thisPtr = std::static_pointer_cast<RNSVGImageComponentInstance>(basePtr);
|
|
82
|
+
auto cacheDir = arkTsTurboModule->getImageSourceResolver()->resolveImageSources(thisPtr, uri);
|
|
83
|
+
|
|
81
84
|
if (!cacheDir.empty()) {
|
|
82
85
|
return cacheDir; // 如果找到缓存文件,返回缓存路径
|
|
83
86
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#include "RNSVGSvgViewComponentInstance.h"
|
|
8
8
|
#include "utils/DynamicUtils.h"
|
|
9
9
|
#include <glog/logging.h>
|
|
10
|
+
#include "RNSVGGroupComponentInstance.h"
|
|
10
11
|
|
|
11
12
|
namespace rnoh {
|
|
12
13
|
namespace svg {
|
|
@@ -21,6 +22,7 @@ RNSVGSvgViewComponentInstance::RNSVGSvgViewComponentInstance(Context context)
|
|
|
21
22
|
|
|
22
23
|
RNSVGSvgViewComponentInstance::~RNSVGSvgViewComponentInstance() {
|
|
23
24
|
SvgViewManager::getInstance().onDropView(CppComponentInstance::getTag());
|
|
25
|
+
noSvgComponentIndex = 0;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
void RNSVGSvgViewComponentInstance::onFinalizeUpdates() {
|
|
@@ -45,9 +47,45 @@ void RNSVGSvgViewComponentInstance::onFinalizeUpdates() {
|
|
|
45
47
|
getLocalRootArkUINode().markDirty();
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
void RNSVGSvgViewComponentInstance::onDrawForeignImage(ForeignProps foreignProps) {
|
|
51
|
+
if (foreignProps.foreignPixelMap) {
|
|
52
|
+
DLOG(INFO) << "[svgForeignNode] RNSVGSvgViewComponentInstance OH_PixelmapNative is not null, position:{ x:" << foreignProps.x.Value()
|
|
53
|
+
<< ",y:" << foreignProps.y.Value() << "},width:" << foreignProps.width.Value() << ";height:" << foreignProps.height.Value();
|
|
54
|
+
m_svgArkUINode.SetForeignObject(foreignProps);
|
|
55
|
+
m_svgArkUINode.markDirty();
|
|
56
|
+
} else {
|
|
57
|
+
DLOG(INFO) << "RNSVGSvgViewComponentInstance OH_PixelmapNative is null";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
48
60
|
void RNSVGSvgViewComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance,
|
|
49
61
|
std::size_t index) {
|
|
50
62
|
CppComponentInstance::onChildInserted(childComponentInstance, index);
|
|
63
|
+
if (childComponentInstance->getComponentName() == "RNSVGGroup") {
|
|
64
|
+
auto childInstance = childComponentInstance->getChildren();
|
|
65
|
+
for (ComponentInstance::Shared c : childInstance) {
|
|
66
|
+
if (c->getComponentName().find("SVG") == std::string::npos) {
|
|
67
|
+
NativeNodeApi::getInstance()->insertChildAt(m_svgArkUINode.getArkUINodeHandle(),
|
|
68
|
+
c->getLocalRootArkUINode().getArkUINodeHandle(), noSvgComponentIndex);
|
|
69
|
+
noSvgComponentIndex++;
|
|
70
|
+
}
|
|
71
|
+
auto groupChildInstance = c->getChildren();
|
|
72
|
+
for (ComponentInstance::Shared c1 : groupChildInstance) {
|
|
73
|
+
if (c1->getComponentName() == "RNSVGForeignObject") {
|
|
74
|
+
auto m_foreignComponentInstance =
|
|
75
|
+
std::dynamic_pointer_cast<RNSVGForeignObjectComponentInstance>(c1);
|
|
76
|
+
if (m_foreignComponentInstance) {
|
|
77
|
+
auto groupInstance =
|
|
78
|
+
std::dynamic_pointer_cast<RNSVGGroupComponentInstance>(c1->getParent().lock());
|
|
79
|
+
m_svgArkUINode.SetGroupNode(groupInstance->getNode());
|
|
80
|
+
m_svgArkUINode.AddChild(m_foreignComponentInstance->getLocalRootArkUINode());
|
|
81
|
+
m_foreignComponentInstance->getLocalRootArkUINode().SetForeignNodeDelegate(this);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
51
89
|
OnChildInsertCommon(std::dynamic_pointer_cast<SvgHost>(childComponentInstance));
|
|
52
90
|
}
|
|
53
91
|
|
|
@@ -12,18 +12,26 @@
|
|
|
12
12
|
#include <react/renderer/components/react_native_svg/ShadowNodes.h>
|
|
13
13
|
#include "SvgViewManager.h"
|
|
14
14
|
#include "SvgSvg.h"
|
|
15
|
+
#include "RNSVGForeignObjectComponentInstance.h"
|
|
16
|
+
|
|
17
|
+
namespace rnoh {
|
|
18
|
+
namespace svg {
|
|
19
|
+
class RNSVGGroupComponentInstance;
|
|
20
|
+
} // namespace svg
|
|
21
|
+
} // namespace rnoh
|
|
22
|
+
|
|
15
23
|
|
|
16
24
|
namespace rnoh {
|
|
17
25
|
namespace svg {
|
|
18
26
|
|
|
19
27
|
class RNSVGSvgViewComponentInstance : public CppComponentInstance<facebook::react::RNSVGSvgViewShadowNode>,
|
|
20
|
-
public SvgHost {
|
|
28
|
+
public SvgHost , public SvgForeignObjectNodeDelegate {
|
|
21
29
|
public:
|
|
22
30
|
explicit RNSVGSvgViewComponentInstance(Context context);
|
|
23
31
|
~RNSVGSvgViewComponentInstance();
|
|
24
32
|
|
|
25
33
|
void onFinalizeUpdates() override;
|
|
26
|
-
|
|
34
|
+
void onDrawForeignImage(ForeignProps foreignProps) override;
|
|
27
35
|
// get SvgNode from childComponentInstance and set it to root_
|
|
28
36
|
void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override;
|
|
29
37
|
|
|
@@ -41,6 +49,7 @@ public:
|
|
|
41
49
|
private:
|
|
42
50
|
SvgArkUINode m_svgArkUINode;
|
|
43
51
|
std::shared_ptr<SvgSvg> m_svgSvg = std::make_shared<SvgSvg>();
|
|
52
|
+
int noSvgComponentIndex {0}; // 非svg添加的index(适配js侧view包裹会拆解子元素成平级)
|
|
44
53
|
};
|
|
45
54
|
|
|
46
55
|
} // namespace svg
|
|
@@ -44,9 +44,30 @@ void ResponseCallback(void *usrCtx, Rcp_Response *response, uint32_t errCode) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
void HttpTaskProcessor::createParentPath(const fs::path &filePath) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
fs::
|
|
47
|
+
try {
|
|
48
|
+
fs::path parentPath = filePath.parent_path();
|
|
49
|
+
if (!parentPath.empty() && !fs::exists(parentPath)) {
|
|
50
|
+
// 检查路径的有效性
|
|
51
|
+
if (parentPath.is_relative()) {
|
|
52
|
+
LOG(ERROR) << "[SVGImage] Invalid parent path (relative path): " << parentPath;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// 尝试创建目录,并捕获可能的异常
|
|
56
|
+
auto result = fs::create_directories(parentPath);
|
|
57
|
+
if (result) {
|
|
58
|
+
LOG(INFO) << "[SVGImage] Successfully created parent directories: " << parentPath;
|
|
59
|
+
} else {
|
|
60
|
+
LOG(ERROR) << "[SVGImage] Failed to create parent directories: " << parentPath;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} catch (const fs::filesystem_error& e) {
|
|
64
|
+
LOG(ERROR) << "[SVGImage] Filesystem error in createParentPath: " << e.what()
|
|
65
|
+
<< " for path: " << filePath;
|
|
66
|
+
} catch (const std::exception& e) {
|
|
67
|
+
LOG(ERROR) << "[SVGImage] Standard exception in createParentPath: " << e.what()
|
|
68
|
+
<< " for path: " << filePath;
|
|
69
|
+
} catch (...) {
|
|
70
|
+
LOG(ERROR) << "[SVGImage] Unknown exception in createParentPath for path: " << filePath;
|
|
50
71
|
}
|
|
51
72
|
}
|
|
52
73
|
|
|
@@ -54,14 +75,52 @@ size_t HttpTaskProcessor::saveImage(const char *buffer, uint32_t length) {
|
|
|
54
75
|
size_t status = 0;
|
|
55
76
|
if (filePath_ == "")
|
|
56
77
|
return status;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
78
|
+
|
|
79
|
+
// 验证输入参数
|
|
80
|
+
if (buffer == nullptr || length == 0) {
|
|
81
|
+
LOG(ERROR) << "[SVGImage] Invalid buffer or length in saveImage";
|
|
82
|
+
return status;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
// 先创建父目录
|
|
87
|
+
createParentPath(filePath_);
|
|
88
|
+
|
|
89
|
+
// 验证文件路径的合理性
|
|
90
|
+
fs::path filePath(filePath_);
|
|
91
|
+
if (filePath.has_filename()) {
|
|
92
|
+
LOG(INFO) << "[SVGImage] Attempting to save image to: " << filePath_;
|
|
93
|
+
} else {
|
|
94
|
+
LOG(ERROR) << "[SVGImage] Invalid file path (no filename): " << filePath_;
|
|
95
|
+
return status;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 打开文件进行写入
|
|
99
|
+
fp_ = fopen(filePath_.c_str(), "w");
|
|
100
|
+
if (fp_) {
|
|
101
|
+
status = fwrite(buffer, sizeof(char), length, fp_);
|
|
102
|
+
fclose(fp_);
|
|
103
|
+
|
|
104
|
+
if (status == length) {
|
|
105
|
+
LOG(INFO) << "[SVGImage] Successfully saved image: " << filePath_
|
|
106
|
+
<< " (size: " << length << " bytes)";
|
|
107
|
+
} else {
|
|
108
|
+
LOG(ERROR) << "[SVGImage] Partial write error. Expected: " << length
|
|
109
|
+
<< ", wrote: " << status;
|
|
110
|
+
status = 0; // 返回0表示失败
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
LOG(ERROR) << "[SVGImage] Failed to open file for writing: " << filePath_
|
|
114
|
+
<< " (errno: " << errno << ")";
|
|
115
|
+
}
|
|
116
|
+
} catch (const std::exception& e) {
|
|
117
|
+
LOG(ERROR) << "[SVGImage] Exception in saveImage: " << e.what();
|
|
118
|
+
status = 0;
|
|
119
|
+
} catch (...) {
|
|
120
|
+
LOG(ERROR) << "[SVGImage] Unknown exception in saveImage";
|
|
121
|
+
status = 0;
|
|
64
122
|
}
|
|
123
|
+
|
|
65
124
|
return status;
|
|
66
125
|
}
|
|
67
126
|
|
|
@@ -10,46 +10,60 @@
|
|
|
10
10
|
namespace rnoh {
|
|
11
11
|
namespace svg {
|
|
12
12
|
|
|
13
|
-
std::string ImageSourceResolver::resolveImageSources(ImageSourceUpdateListener
|
|
13
|
+
std::string ImageSourceResolver::resolveImageSources(std::shared_ptr<ImageSourceUpdateListener> listener, std::string uri) {
|
|
14
14
|
// 判断是否还在下载中
|
|
15
15
|
if (m_pendingSet.find(uri) != m_pendingSet.end()) {
|
|
16
|
-
removeListener(
|
|
17
|
-
addListenerForURI(uri,
|
|
16
|
+
removeListener(listener);
|
|
17
|
+
addListenerForURI(uri, listener);
|
|
18
18
|
return "";
|
|
19
19
|
}
|
|
20
20
|
// 生成图像的哈希缓存文件名
|
|
21
|
-
auto hashedFileName = StringUtils::
|
|
21
|
+
auto hashedFileName = StringUtils::generateHash(uri);
|
|
22
22
|
|
|
23
23
|
bool exist = remoteImageSourceMap_.get(hashedFileName);
|
|
24
24
|
if (exist) {
|
|
25
25
|
auto cacheUri = "file://" + fileCacheDir_ + hashedFileName;
|
|
26
26
|
return cacheUri;
|
|
27
27
|
}
|
|
28
|
-
removeListener(
|
|
29
|
-
addListenerForURI(uri,
|
|
28
|
+
removeListener(listener);
|
|
29
|
+
addListenerForURI(uri, listener);
|
|
30
30
|
return "";
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
void ImageSourceResolver::addListenerForURI(const std::string &uri, ImageSourceUpdateListener
|
|
33
|
+
void ImageSourceResolver::addListenerForURI(const std::string &uri, std::shared_ptr<ImageSourceUpdateListener> listener) {
|
|
34
34
|
listener->observedUri = uri;
|
|
35
35
|
auto it = m_uriListenersMap.find(uri);
|
|
36
36
|
if (it == m_uriListenersMap.end()) {
|
|
37
|
-
m_uriListenersMap.emplace(uri, std::
|
|
37
|
+
m_uriListenersMap.emplace(uri, std::vector<std::weak_ptr<ImageSourceUpdateListener>>{listener});
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
auto alreadyThere = std::find_if(it->second.begin(), it->second.end(),[&listener]
|
|
42
|
+
(const std::weak_ptr<ImageSourceUpdateListener> &wk )
|
|
43
|
+
{
|
|
44
|
+
auto sp = wk.lock();
|
|
45
|
+
return sp == listener;
|
|
46
|
+
|
|
47
|
+
});
|
|
48
|
+
if (alreadyThere != it->second.end())
|
|
49
|
+
{
|
|
41
50
|
return;
|
|
42
51
|
}
|
|
43
52
|
it->second.push_back(listener);
|
|
44
53
|
}
|
|
45
54
|
|
|
46
|
-
void ImageSourceResolver::removeListenerForURI(const std::string &uri, ImageSourceUpdateListener
|
|
55
|
+
void ImageSourceResolver::removeListenerForURI(const std::string &uri, std::shared_ptr<ImageSourceUpdateListener> listener) {
|
|
47
56
|
auto it = m_uriListenersMap.find(uri);
|
|
48
57
|
if (it == m_uriListenersMap.end()) {
|
|
49
58
|
return;
|
|
50
59
|
}
|
|
51
60
|
auto &listeners = it->second;
|
|
52
|
-
auto listenerPos = std::
|
|
61
|
+
auto listenerPos = std::find_if(listeners.begin(), listeners.end(), [&listener](const std::weak_ptr<ImageSourceUpdateListener> &wk)
|
|
62
|
+
{
|
|
63
|
+
auto sp = wk.lock();
|
|
64
|
+
return sp == listener;
|
|
65
|
+
|
|
66
|
+
});
|
|
53
67
|
if (listenerPos != listeners.end()) {
|
|
54
68
|
listeners.erase(listenerPos);
|
|
55
69
|
if (listeners.empty()) {
|
|
@@ -58,7 +72,7 @@ void ImageSourceResolver::removeListenerForURI(const std::string &uri, ImageSour
|
|
|
58
72
|
}
|
|
59
73
|
}
|
|
60
74
|
|
|
61
|
-
void ImageSourceResolver::removeListener(ImageSourceUpdateListener
|
|
75
|
+
void ImageSourceResolver::removeListener(std::shared_ptr<ImageSourceUpdateListener> listener) {
|
|
62
76
|
if (!listener->observedUri.empty()) {
|
|
63
77
|
removeListenerForURI(listener->observedUri, listener);
|
|
64
78
|
}
|
|
@@ -70,7 +84,7 @@ void ImageSourceResolver::imageDownloadComplete(std::string uri, std::string fil
|
|
|
70
84
|
m_pendingSet.erase(uri);
|
|
71
85
|
}
|
|
72
86
|
// 生成图像的哈希缓存文件名
|
|
73
|
-
auto hashedFileName = StringUtils::
|
|
87
|
+
auto hashedFileName = StringUtils::generateHash(uri);
|
|
74
88
|
DLOG(INFO) << "[SVGImage] remoteImageSourceMap PUT: " << hashedFileName;
|
|
75
89
|
remoteImageSourceMap_.put(hashedFileName, true);
|
|
76
90
|
auto it = m_uriListenersMap.find(uri);
|
|
@@ -80,25 +94,39 @@ void ImageSourceResolver::imageDownloadComplete(std::string uri, std::string fil
|
|
|
80
94
|
|
|
81
95
|
auto &listeners = it->second;
|
|
82
96
|
for (auto listener : listeners) {
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
|
|
98
|
+
if (auto weaklistener = listener.lock())
|
|
99
|
+
{
|
|
100
|
+
weaklistener->onImageSourceCacheUpdate(fileUri);
|
|
101
|
+
removeListenerForURI(uri, weaklistener);
|
|
102
|
+
}
|
|
103
|
+
|
|
85
104
|
}
|
|
86
105
|
}
|
|
87
106
|
|
|
88
107
|
void ImageSourceResolver::imageDownloadFail(std::string uri) {
|
|
89
|
-
|
|
90
|
-
if (pend != m_pendingSet.end()) {
|
|
91
|
-
m_pendingSet.erase(uri);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
auto it = m_uriListenersMap.find(uri);
|
|
95
|
-
if (it == m_uriListenersMap.end()) {
|
|
108
|
+
if (uri.empty()) {
|
|
96
109
|
return;
|
|
97
110
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
111
|
+
if (!m_pendingSet.empty()) {
|
|
112
|
+
auto pend = m_pendingSet.find(uri);
|
|
113
|
+
if (pend != m_pendingSet.end()) {
|
|
114
|
+
m_pendingSet.erase(uri);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!m_uriListenersMap.empty()) {
|
|
118
|
+
auto it = m_uriListenersMap.find(uri);
|
|
119
|
+
if (it == m_uriListenersMap.end()) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
auto &listeners = it->second;
|
|
123
|
+
for (auto listener : listeners) {
|
|
124
|
+
auto weaklistener = listener.lock();
|
|
125
|
+
if (weaklistener) {
|
|
126
|
+
weaklistener->onImageSourceCacheDownloadFileFail();
|
|
127
|
+
removeListenerForURI(uri, weaklistener);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
102
130
|
}
|
|
103
131
|
}
|
|
104
132
|
|
|
@@ -45,11 +45,7 @@ public:
|
|
|
45
45
|
: m_imageSourceResolver(ImageSourceResolver) {}
|
|
46
46
|
|
|
47
47
|
// 注销监听器
|
|
48
|
-
~ImageSourceUpdateListener()
|
|
49
|
-
if (!m_imageSourceResolver) {
|
|
50
|
-
m_imageSourceResolver->removeListener(this);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
48
|
+
~ImageSourceUpdateListener() = default;
|
|
53
49
|
|
|
54
50
|
// 监听图像缓存更新
|
|
55
51
|
virtual void onImageSourceCacheUpdate(std::string imageUri) = 0;
|
|
@@ -62,16 +58,16 @@ public:
|
|
|
62
58
|
};
|
|
63
59
|
|
|
64
60
|
// 解析图像源的缓存路径
|
|
65
|
-
std::string resolveImageSources(ImageSourceUpdateListener
|
|
61
|
+
std::string resolveImageSources(std::shared_ptr<ImageSourceUpdateListener> listener, std::string uri);
|
|
66
62
|
|
|
67
63
|
// 为URI添加监听器
|
|
68
|
-
void addListenerForURI(const std::string &uri, ImageSourceUpdateListener
|
|
64
|
+
void addListenerForURI(const std::string &uri, std::shared_ptr<ImageSourceUpdateListener> listener);
|
|
69
65
|
|
|
70
66
|
// 从URI移除监听器
|
|
71
|
-
void removeListenerForURI(const std::string &uri, ImageSourceUpdateListener
|
|
67
|
+
void removeListenerForURI(const std::string &uri, std::shared_ptr<ImageSourceUpdateListener> listener);
|
|
72
68
|
|
|
73
69
|
// 从解析器中移除监听器
|
|
74
|
-
void removeListener(ImageSourceUpdateListener
|
|
70
|
+
void removeListener(std::shared_ptr<ImageSourceUpdateListener> listener);
|
|
75
71
|
|
|
76
72
|
// 下载完成后更新图像缓存
|
|
77
73
|
void imageDownloadComplete(std::string uri, std::string fileUri);
|
|
@@ -87,7 +83,7 @@ public:
|
|
|
87
83
|
|
|
88
84
|
private:
|
|
89
85
|
// 存储URI与对应的监听器(支持多个监听器)
|
|
90
|
-
std::unordered_map<std::string, std::vector<ImageSourceUpdateListener
|
|
86
|
+
std::unordered_map<std::string, std::vector<std::weak_ptr<ImageSourceUpdateListener>>> m_uriListenersMap;
|
|
91
87
|
|
|
92
88
|
// 存储正在下载的图像URI集合
|
|
93
89
|
std::unordered_set<std::string> m_pendingSet;
|
package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeBlendJSIBinder.h
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
// This file was generated.
|
|
4
|
-
|
|
5
|
-
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
6
|
-
|
|
7
|
-
namespace rnoh {
|
|
8
|
-
class RNSVGFeBlendJSIBinder : public ViewComponentJSIBinder {
|
|
9
|
-
protected:
|
|
10
|
-
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
11
|
-
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
12
|
-
object.setProperty(rt, "name", true);
|
|
13
|
-
object.setProperty(rt, "x", true);
|
|
14
|
-
object.setProperty(rt, "y", true);
|
|
15
|
-
object.setProperty(rt, "width", true);
|
|
16
|
-
object.setProperty(rt, "height", true);
|
|
17
|
-
object.setProperty(rt, "result", true);
|
|
18
|
-
object.setProperty(rt, "in1", true);
|
|
19
|
-
object.setProperty(rt, "in2", true);
|
|
20
|
-
object.setProperty(rt, "mode", true);
|
|
21
|
-
object.setProperty(rt, "pointerEvents", true);
|
|
22
|
-
|
|
23
|
-
return object;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
} // namespace rnoh
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
// This file was generated.
|
|
4
|
+
|
|
5
|
+
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
6
|
+
|
|
7
|
+
namespace rnoh {
|
|
8
|
+
class RNSVGFeBlendJSIBinder : public ViewComponentJSIBinder {
|
|
9
|
+
protected:
|
|
10
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
11
|
+
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
12
|
+
object.setProperty(rt, "name", true);
|
|
13
|
+
object.setProperty(rt, "x", true);
|
|
14
|
+
object.setProperty(rt, "y", true);
|
|
15
|
+
object.setProperty(rt, "width", true);
|
|
16
|
+
object.setProperty(rt, "height", true);
|
|
17
|
+
object.setProperty(rt, "result", true);
|
|
18
|
+
object.setProperty(rt, "in1", true);
|
|
19
|
+
object.setProperty(rt, "in2", true);
|
|
20
|
+
object.setProperty(rt, "mode", true);
|
|
21
|
+
object.setProperty(rt, "pointerEvents", true);
|
|
22
|
+
|
|
23
|
+
return object;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
} // namespace rnoh
|
package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeColorMatrixJSIBinder.h
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
// This file was generated.
|
|
4
|
-
|
|
5
|
-
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
6
|
-
|
|
7
|
-
namespace rnoh {
|
|
8
|
-
class RNSVGFeColorMatrixJSIBinder : public ViewComponentJSIBinder {
|
|
9
|
-
protected:
|
|
10
|
-
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
11
|
-
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
12
|
-
object.setProperty(rt, "name", true);
|
|
13
|
-
object.setProperty(rt, "x", true);
|
|
14
|
-
object.setProperty(rt, "y", true);
|
|
15
|
-
object.setProperty(rt, "width", true);
|
|
16
|
-
object.setProperty(rt, "height", true);
|
|
17
|
-
object.setProperty(rt, "result", true);
|
|
18
|
-
object.setProperty(rt, "in1", true);
|
|
19
|
-
object.setProperty(rt, "type", true);
|
|
20
|
-
object.setProperty(rt, "values", true);
|
|
21
|
-
object.setProperty(rt, "pointerEvents", true);
|
|
22
|
-
|
|
23
|
-
return object;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
} // namespace rnoh
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
// This file was generated.
|
|
4
|
+
|
|
5
|
+
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
6
|
+
|
|
7
|
+
namespace rnoh {
|
|
8
|
+
class RNSVGFeColorMatrixJSIBinder : public ViewComponentJSIBinder {
|
|
9
|
+
protected:
|
|
10
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
11
|
+
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
12
|
+
object.setProperty(rt, "name", true);
|
|
13
|
+
object.setProperty(rt, "x", true);
|
|
14
|
+
object.setProperty(rt, "y", true);
|
|
15
|
+
object.setProperty(rt, "width", true);
|
|
16
|
+
object.setProperty(rt, "height", true);
|
|
17
|
+
object.setProperty(rt, "result", true);
|
|
18
|
+
object.setProperty(rt, "in1", true);
|
|
19
|
+
object.setProperty(rt, "type", true);
|
|
20
|
+
object.setProperty(rt, "values", true);
|
|
21
|
+
object.setProperty(rt, "pointerEvents", true);
|
|
22
|
+
|
|
23
|
+
return object;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
} // namespace rnoh
|
package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeCompositeJSIBinder.h
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
// This file was generated.
|
|
4
|
-
|
|
5
|
-
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
6
|
-
|
|
7
|
-
namespace rnoh {
|
|
8
|
-
class RNSVGFeCompositeJSIBinder : public ViewComponentJSIBinder {
|
|
9
|
-
protected:
|
|
10
|
-
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
11
|
-
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
12
|
-
object.setProperty(rt, "name", true);
|
|
13
|
-
object.setProperty(rt, "x", true);
|
|
14
|
-
object.setProperty(rt, "y", true);
|
|
15
|
-
object.setProperty(rt, "width", true);
|
|
16
|
-
object.setProperty(rt, "height", true);
|
|
17
|
-
object.setProperty(rt, "result", true);
|
|
18
|
-
object.setProperty(rt, "in1", true);
|
|
19
|
-
object.setProperty(rt, "in2", true);
|
|
20
|
-
object.setProperty(rt, "operator1", true);
|
|
21
|
-
object.setProperty(rt, "k1", true);
|
|
22
|
-
object.setProperty(rt, "k2", true);
|
|
23
|
-
object.setProperty(rt, "k3", true);
|
|
24
|
-
object.setProperty(rt, "k4", true);
|
|
25
|
-
object.setProperty(rt, "pointerEvents", true);
|
|
26
|
-
|
|
27
|
-
return object;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
} // namespace rnoh
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
// This file was generated.
|
|
4
|
+
|
|
5
|
+
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
6
|
+
|
|
7
|
+
namespace rnoh {
|
|
8
|
+
class RNSVGFeCompositeJSIBinder : public ViewComponentJSIBinder {
|
|
9
|
+
protected:
|
|
10
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
11
|
+
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
12
|
+
object.setProperty(rt, "name", true);
|
|
13
|
+
object.setProperty(rt, "x", true);
|
|
14
|
+
object.setProperty(rt, "y", true);
|
|
15
|
+
object.setProperty(rt, "width", true);
|
|
16
|
+
object.setProperty(rt, "height", true);
|
|
17
|
+
object.setProperty(rt, "result", true);
|
|
18
|
+
object.setProperty(rt, "in1", true);
|
|
19
|
+
object.setProperty(rt, "in2", true);
|
|
20
|
+
object.setProperty(rt, "operator1", true);
|
|
21
|
+
object.setProperty(rt, "k1", true);
|
|
22
|
+
object.setProperty(rt, "k2", true);
|
|
23
|
+
object.setProperty(rt, "k3", true);
|
|
24
|
+
object.setProperty(rt, "k4", true);
|
|
25
|
+
object.setProperty(rt, "pointerEvents", true);
|
|
26
|
+
|
|
27
|
+
return object;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
} // namespace rnoh
|
package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeFloodJSIBinder.h
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
// This file was generated.
|
|
4
|
-
|
|
5
|
-
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
6
|
-
|
|
7
|
-
namespace rnoh {
|
|
8
|
-
class RNSVGFeFloodJSIBinder : public ViewComponentJSIBinder {
|
|
9
|
-
protected:
|
|
10
|
-
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
11
|
-
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
12
|
-
object.setProperty(rt, "name", true);
|
|
13
|
-
object.setProperty(rt, "x", true);
|
|
14
|
-
object.setProperty(rt, "y", true);
|
|
15
|
-
object.setProperty(rt, "width", true);
|
|
16
|
-
object.setProperty(rt, "height", true);
|
|
17
|
-
object.setProperty(rt, "result", true);
|
|
18
|
-
object.setProperty(rt, "in1", true);
|
|
19
|
-
object.setProperty(rt, "floodColor", true);
|
|
20
|
-
object.setProperty(rt, "floodOpacity", true);
|
|
21
|
-
object.setProperty(rt, "pointerEvents", true);
|
|
22
|
-
|
|
23
|
-
return object;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
} // namespace rnoh
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
// This file was generated.
|
|
4
|
+
|
|
5
|
+
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
6
|
+
|
|
7
|
+
namespace rnoh {
|
|
8
|
+
class RNSVGFeFloodJSIBinder : public ViewComponentJSIBinder {
|
|
9
|
+
protected:
|
|
10
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
11
|
+
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
12
|
+
object.setProperty(rt, "name", true);
|
|
13
|
+
object.setProperty(rt, "x", true);
|
|
14
|
+
object.setProperty(rt, "y", true);
|
|
15
|
+
object.setProperty(rt, "width", true);
|
|
16
|
+
object.setProperty(rt, "height", true);
|
|
17
|
+
object.setProperty(rt, "result", true);
|
|
18
|
+
object.setProperty(rt, "in1", true);
|
|
19
|
+
object.setProperty(rt, "floodColor", true);
|
|
20
|
+
object.setProperty(rt, "floodOpacity", true);
|
|
21
|
+
object.setProperty(rt, "pointerEvents", true);
|
|
22
|
+
|
|
23
|
+
return object;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
} // namespace rnoh
|