@matiks/rn-stroke-text 0.0.1

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.
Files changed (62) hide show
  1. package/NitroRnStrokeText.podspec +31 -0
  2. package/README.md +38 -0
  3. package/android/CMakeLists.txt +29 -0
  4. package/android/build.gradle +138 -0
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/rnstroketext/FontUtil.kt +48 -0
  10. package/android/src/main/java/com/margelo/nitro/rnstroketext/HybridMatiksStrokeText.kt +80 -0
  11. package/android/src/main/java/com/margelo/nitro/rnstroketext/NitroRnStrokeTextPackage.kt +28 -0
  12. package/android/src/main/java/com/margelo/nitro/rnstroketext/StrokeTextView.kt +348 -0
  13. package/ios/Bridge.h +8 -0
  14. package/ios/HybridMatiksStrokeText.swift +97 -0
  15. package/ios/StrokeTextView.swift +174 -0
  16. package/ios/StrokedTextLabel.swift +62 -0
  17. package/lib/index.d.ts +10 -0
  18. package/lib/index.js +23 -0
  19. package/lib/specs/Stroke.nitro.d.ts +23 -0
  20. package/lib/specs/Stroke.nitro.js +1 -0
  21. package/nitro.json +24 -0
  22. package/nitrogen/generated/.gitattributes +1 -0
  23. package/nitrogen/generated/android/NitroRnStrokeText+autolinking.cmake +83 -0
  24. package/nitrogen/generated/android/NitroRnStrokeText+autolinking.gradle +27 -0
  25. package/nitrogen/generated/android/NitroRnStrokeTextOnLoad.cpp +46 -0
  26. package/nitrogen/generated/android/NitroRnStrokeTextOnLoad.hpp +25 -0
  27. package/nitrogen/generated/android/c++/JDimensions.hpp +61 -0
  28. package/nitrogen/generated/android/c++/JHybridMatiksStrokeTextSpec.cpp +156 -0
  29. package/nitrogen/generated/android/c++/JHybridMatiksStrokeTextSpec.hpp +85 -0
  30. package/nitrogen/generated/android/c++/JTextAlign.hpp +61 -0
  31. package/nitrogen/generated/android/c++/views/JHybridMatiksStrokeTextStateUpdater.cpp +92 -0
  32. package/nitrogen/generated/android/c++/views/JHybridMatiksStrokeTextStateUpdater.hpp +49 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/Dimensions.kt +41 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/HybridMatiksStrokeTextSpec.kt +115 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/NitroRnStrokeTextOnLoad.kt +35 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/TextAlign.kt +24 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/views/HybridMatiksStrokeTextManager.kt +56 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnstroketext/views/HybridMatiksStrokeTextStateUpdater.kt +23 -0
  39. package/nitrogen/generated/ios/NitroRnStrokeText+autolinking.rb +60 -0
  40. package/nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Bridge.cpp +33 -0
  41. package/nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Bridge.hpp +119 -0
  42. package/nitrogen/generated/ios/NitroRnStrokeText-Swift-Cxx-Umbrella.hpp +51 -0
  43. package/nitrogen/generated/ios/NitroRnStrokeTextAutolinking.mm +33 -0
  44. package/nitrogen/generated/ios/NitroRnStrokeTextAutolinking.swift +25 -0
  45. package/nitrogen/generated/ios/c++/HybridMatiksStrokeTextSpecSwift.cpp +11 -0
  46. package/nitrogen/generated/ios/c++/HybridMatiksStrokeTextSpecSwift.hpp +157 -0
  47. package/nitrogen/generated/ios/c++/views/HybridMatiksStrokeTextComponent.mm +147 -0
  48. package/nitrogen/generated/ios/swift/Dimensions.swift +35 -0
  49. package/nitrogen/generated/ios/swift/HybridMatiksStrokeTextSpec.swift +65 -0
  50. package/nitrogen/generated/ios/swift/HybridMatiksStrokeTextSpec_cxx.swift +341 -0
  51. package/nitrogen/generated/ios/swift/TextAlign.swift +44 -0
  52. package/nitrogen/generated/shared/c++/Dimensions.hpp +87 -0
  53. package/nitrogen/generated/shared/c++/HybridMatiksStrokeTextSpec.cpp +41 -0
  54. package/nitrogen/generated/shared/c++/HybridMatiksStrokeTextSpec.hpp +87 -0
  55. package/nitrogen/generated/shared/c++/TextAlign.hpp +80 -0
  56. package/nitrogen/generated/shared/c++/views/HybridMatiksStrokeTextComponent.cpp +196 -0
  57. package/nitrogen/generated/shared/c++/views/HybridMatiksStrokeTextComponent.hpp +118 -0
  58. package/nitrogen/generated/shared/json/MatiksStrokeTextConfig.json +19 -0
  59. package/package.json +107 -0
  60. package/react-native.config.js +16 -0
  61. package/src/index.tsx +44 -0
  62. package/src/specs/Stroke.nitro.ts +34 -0
@@ -0,0 +1,196 @@
1
+ ///
2
+ /// HybridMatiksStrokeTextComponent.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridMatiksStrokeTextComponent.hpp"
9
+
10
+ #include <string>
11
+ #include <exception>
12
+ #include <utility>
13
+ #include <NitroModules/NitroDefines.hpp>
14
+ #include <NitroModules/JSIConverter.hpp>
15
+ #include <NitroModules/PropNameIDCache.hpp>
16
+ #include <react/renderer/core/RawValue.h>
17
+ #include <react/renderer/core/ShadowNode.h>
18
+ #include <react/renderer/core/ComponentDescriptor.h>
19
+ #include <react/renderer/components/view/ViewProps.h>
20
+
21
+ namespace margelo::nitro::rnstroketext::views {
22
+
23
+ extern const char HybridMatiksStrokeTextComponentName[] = "MatiksStrokeText";
24
+
25
+ HybridMatiksStrokeTextProps::HybridMatiksStrokeTextProps(const react::PropsParserContext& context,
26
+ const HybridMatiksStrokeTextProps& sourceProps,
27
+ const react::RawProps& rawProps):
28
+ react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
29
+ width([&]() -> CachedProp<std::optional<double>> {
30
+ try {
31
+ const react::RawValue* rawValue = rawProps.at("width", nullptr, nullptr);
32
+ if (rawValue == nullptr) return sourceProps.width;
33
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
34
+ return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.width);
35
+ } catch (const std::exception& exc) {
36
+ throw std::runtime_error(std::string("MatiksStrokeText.width: ") + exc.what());
37
+ }
38
+ }()),
39
+ text([&]() -> CachedProp<std::string> {
40
+ try {
41
+ const react::RawValue* rawValue = rawProps.at("text", nullptr, nullptr);
42
+ if (rawValue == nullptr) return sourceProps.text;
43
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
44
+ return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.text);
45
+ } catch (const std::exception& exc) {
46
+ throw std::runtime_error(std::string("MatiksStrokeText.text: ") + exc.what());
47
+ }
48
+ }()),
49
+ fontSize([&]() -> CachedProp<std::optional<double>> {
50
+ try {
51
+ const react::RawValue* rawValue = rawProps.at("fontSize", nullptr, nullptr);
52
+ if (rawValue == nullptr) return sourceProps.fontSize;
53
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
54
+ return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.fontSize);
55
+ } catch (const std::exception& exc) {
56
+ throw std::runtime_error(std::string("MatiksStrokeText.fontSize: ") + exc.what());
57
+ }
58
+ }()),
59
+ color([&]() -> CachedProp<std::optional<std::string>> {
60
+ try {
61
+ const react::RawValue* rawValue = rawProps.at("color", nullptr, nullptr);
62
+ if (rawValue == nullptr) return sourceProps.color;
63
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
64
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.color);
65
+ } catch (const std::exception& exc) {
66
+ throw std::runtime_error(std::string("MatiksStrokeText.color: ") + exc.what());
67
+ }
68
+ }()),
69
+ strokeColor([&]() -> CachedProp<std::optional<std::string>> {
70
+ try {
71
+ const react::RawValue* rawValue = rawProps.at("strokeColor", nullptr, nullptr);
72
+ if (rawValue == nullptr) return sourceProps.strokeColor;
73
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
74
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.strokeColor);
75
+ } catch (const std::exception& exc) {
76
+ throw std::runtime_error(std::string("MatiksStrokeText.strokeColor: ") + exc.what());
77
+ }
78
+ }()),
79
+ strokeWidth([&]() -> CachedProp<std::optional<double>> {
80
+ try {
81
+ const react::RawValue* rawValue = rawProps.at("strokeWidth", nullptr, nullptr);
82
+ if (rawValue == nullptr) return sourceProps.strokeWidth;
83
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
84
+ return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.strokeWidth);
85
+ } catch (const std::exception& exc) {
86
+ throw std::runtime_error(std::string("MatiksStrokeText.strokeWidth: ") + exc.what());
87
+ }
88
+ }()),
89
+ fontFamily([&]() -> CachedProp<std::optional<std::string>> {
90
+ try {
91
+ const react::RawValue* rawValue = rawProps.at("fontFamily", nullptr, nullptr);
92
+ if (rawValue == nullptr) return sourceProps.fontFamily;
93
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
94
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.fontFamily);
95
+ } catch (const std::exception& exc) {
96
+ throw std::runtime_error(std::string("MatiksStrokeText.fontFamily: ") + exc.what());
97
+ }
98
+ }()),
99
+ align([&]() -> CachedProp<std::optional<TextAlign>> {
100
+ try {
101
+ const react::RawValue* rawValue = rawProps.at("align", nullptr, nullptr);
102
+ if (rawValue == nullptr) return sourceProps.align;
103
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
104
+ return CachedProp<std::optional<TextAlign>>::fromRawValue(*runtime, value, sourceProps.align);
105
+ } catch (const std::exception& exc) {
106
+ throw std::runtime_error(std::string("MatiksStrokeText.align: ") + exc.what());
107
+ }
108
+ }()),
109
+ numberOfLines([&]() -> CachedProp<std::optional<double>> {
110
+ try {
111
+ const react::RawValue* rawValue = rawProps.at("numberOfLines", nullptr, nullptr);
112
+ if (rawValue == nullptr) return sourceProps.numberOfLines;
113
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
114
+ return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.numberOfLines);
115
+ } catch (const std::exception& exc) {
116
+ throw std::runtime_error(std::string("MatiksStrokeText.numberOfLines: ") + exc.what());
117
+ }
118
+ }()),
119
+ ellipsis([&]() -> CachedProp<std::optional<bool>> {
120
+ try {
121
+ const react::RawValue* rawValue = rawProps.at("ellipsis", nullptr, nullptr);
122
+ if (rawValue == nullptr) return sourceProps.ellipsis;
123
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
124
+ return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.ellipsis);
125
+ } catch (const std::exception& exc) {
126
+ throw std::runtime_error(std::string("MatiksStrokeText.ellipsis: ") + exc.what());
127
+ }
128
+ }()),
129
+ hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridMatiksStrokeTextSpec>& /* ref */)>>> {
130
+ try {
131
+ const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
132
+ if (rawValue == nullptr) return sourceProps.hybridRef;
133
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
134
+ return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridMatiksStrokeTextSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
135
+ } catch (const std::exception& exc) {
136
+ throw std::runtime_error(std::string("MatiksStrokeText.hybridRef: ") + exc.what());
137
+ }
138
+ }()) { }
139
+
140
+ HybridMatiksStrokeTextProps::HybridMatiksStrokeTextProps(const HybridMatiksStrokeTextProps& other):
141
+ react::ViewProps(),
142
+ width(other.width),
143
+ text(other.text),
144
+ fontSize(other.fontSize),
145
+ color(other.color),
146
+ strokeColor(other.strokeColor),
147
+ strokeWidth(other.strokeWidth),
148
+ fontFamily(other.fontFamily),
149
+ align(other.align),
150
+ numberOfLines(other.numberOfLines),
151
+ ellipsis(other.ellipsis),
152
+ hybridRef(other.hybridRef) { }
153
+
154
+ bool HybridMatiksStrokeTextProps::filterObjectKeys(const std::string& propName) {
155
+ switch (hashString(propName)) {
156
+ case hashString("width"): return true;
157
+ case hashString("text"): return true;
158
+ case hashString("fontSize"): return true;
159
+ case hashString("color"): return true;
160
+ case hashString("strokeColor"): return true;
161
+ case hashString("strokeWidth"): return true;
162
+ case hashString("fontFamily"): return true;
163
+ case hashString("align"): return true;
164
+ case hashString("numberOfLines"): return true;
165
+ case hashString("ellipsis"): return true;
166
+ case hashString("hybridRef"): return true;
167
+ default: return false;
168
+ }
169
+ }
170
+
171
+ HybridMatiksStrokeTextComponentDescriptor::HybridMatiksStrokeTextComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
172
+ : ConcreteComponentDescriptor(parameters,
173
+ react::RawPropsParser(/* enableJsiParser */ true)) {}
174
+
175
+ std::shared_ptr<const react::Props> HybridMatiksStrokeTextComponentDescriptor::cloneProps(const react::PropsParserContext& context,
176
+ const std::shared_ptr<const react::Props>& props,
177
+ react::RawProps rawProps) const {
178
+ // 1. Prepare raw props parser
179
+ rawProps.parse(rawPropsParser_);
180
+ // 2. Copy props with Nitro's cached copy constructor
181
+ return HybridMatiksStrokeTextShadowNode::Props(context, /* & */ rawProps, props);
182
+ }
183
+
184
+ #ifdef ANDROID
185
+ void HybridMatiksStrokeTextComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
186
+ // This is called immediately after `ShadowNode` is created, cloned or in progress.
187
+ // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
188
+ auto& concreteShadowNode = dynamic_cast<HybridMatiksStrokeTextShadowNode&>(shadowNode);
189
+ const HybridMatiksStrokeTextProps& props = concreteShadowNode.getConcreteProps();
190
+ HybridMatiksStrokeTextState state;
191
+ state.setProps(props);
192
+ concreteShadowNode.setStateData(std::move(state));
193
+ }
194
+ #endif
195
+
196
+ } // namespace margelo::nitro::rnstroketext::views
@@ -0,0 +1,118 @@
1
+ ///
2
+ /// HybridMatiksStrokeTextComponent.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <optional>
11
+ #include <NitroModules/NitroDefines.hpp>
12
+ #include <NitroModules/NitroHash.hpp>
13
+ #include <NitroModules/CachedProp.hpp>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <react/renderer/components/view/ViewProps.h>
18
+
19
+ #include <optional>
20
+ #include <string>
21
+ #include "TextAlign.hpp"
22
+ #include <memory>
23
+ #include "HybridMatiksStrokeTextSpec.hpp"
24
+ #include <functional>
25
+
26
+ namespace margelo::nitro::rnstroketext::views {
27
+
28
+ using namespace facebook;
29
+
30
+ /**
31
+ * The name of the actual native View.
32
+ */
33
+ extern const char HybridMatiksStrokeTextComponentName[];
34
+
35
+ /**
36
+ * Props for the "MatiksStrokeText" View.
37
+ */
38
+ class HybridMatiksStrokeTextProps final: public react::ViewProps {
39
+ public:
40
+ HybridMatiksStrokeTextProps() = default;
41
+ HybridMatiksStrokeTextProps(const HybridMatiksStrokeTextProps&);
42
+ HybridMatiksStrokeTextProps(const react::PropsParserContext& context,
43
+ const HybridMatiksStrokeTextProps& sourceProps,
44
+ const react::RawProps& rawProps);
45
+
46
+ public:
47
+ CachedProp<std::optional<double>> width;
48
+ CachedProp<std::string> text;
49
+ CachedProp<std::optional<double>> fontSize;
50
+ CachedProp<std::optional<std::string>> color;
51
+ CachedProp<std::optional<std::string>> strokeColor;
52
+ CachedProp<std::optional<double>> strokeWidth;
53
+ CachedProp<std::optional<std::string>> fontFamily;
54
+ CachedProp<std::optional<TextAlign>> align;
55
+ CachedProp<std::optional<double>> numberOfLines;
56
+ CachedProp<std::optional<bool>> ellipsis;
57
+ CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridMatiksStrokeTextSpec>& /* ref */)>>> hybridRef;
58
+
59
+ private:
60
+ static bool filterObjectKeys(const std::string& propName);
61
+ };
62
+
63
+ /**
64
+ * State for the "MatiksStrokeText" View.
65
+ */
66
+ class HybridMatiksStrokeTextState final {
67
+ public:
68
+ HybridMatiksStrokeTextState() = default;
69
+
70
+ public:
71
+ void setProps(const HybridMatiksStrokeTextProps& props) { _props.emplace(props); }
72
+ const std::optional<HybridMatiksStrokeTextProps>& getProps() const { return _props; }
73
+
74
+ public:
75
+ #ifdef ANDROID
76
+ HybridMatiksStrokeTextState(const HybridMatiksStrokeTextState& /* previousState */, folly::dynamic /* data */) {}
77
+ folly::dynamic getDynamic() const {
78
+ throw std::runtime_error("HybridMatiksStrokeTextState does not support folly!");
79
+ }
80
+ react::MapBuffer getMapBuffer() const {
81
+ throw std::runtime_error("HybridMatiksStrokeTextState does not support MapBuffer!");
82
+ };
83
+ #endif
84
+
85
+ private:
86
+ std::optional<HybridMatiksStrokeTextProps> _props;
87
+ };
88
+
89
+ /**
90
+ * The Shadow Node for the "MatiksStrokeText" View.
91
+ */
92
+ using HybridMatiksStrokeTextShadowNode = react::ConcreteViewShadowNode<HybridMatiksStrokeTextComponentName /* "HybridMatiksStrokeText" */,
93
+ HybridMatiksStrokeTextProps /* custom props */,
94
+ react::ViewEventEmitter /* default */,
95
+ HybridMatiksStrokeTextState /* custom state */>;
96
+
97
+ /**
98
+ * The Component Descriptor for the "MatiksStrokeText" View.
99
+ */
100
+ class HybridMatiksStrokeTextComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridMatiksStrokeTextShadowNode> {
101
+ public:
102
+ HybridMatiksStrokeTextComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
103
+
104
+ public:
105
+ /**
106
+ * A faster path for cloning props - reuses the caching logic from `HybridMatiksStrokeTextProps`.
107
+ */
108
+ std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
109
+ const std::shared_ptr<const react::Props>& props,
110
+ react::RawProps rawProps) const override;
111
+ #ifdef ANDROID
112
+ void adopt(react::ShadowNode& shadowNode) const override;
113
+ #endif
114
+ };
115
+
116
+ /* The actual view for "MatiksStrokeText" needs to be implemented in platform-specific code. */
117
+
118
+ } // namespace margelo::nitro::rnstroketext::views
@@ -0,0 +1,19 @@
1
+ {
2
+ "uiViewClassName": "MatiksStrokeText",
3
+ "supportsRawText": false,
4
+ "bubblingEventTypes": {},
5
+ "directEventTypes": {},
6
+ "validAttributes": {
7
+ "width": true,
8
+ "text": true,
9
+ "fontSize": true,
10
+ "color": true,
11
+ "strokeColor": true,
12
+ "strokeWidth": true,
13
+ "fontFamily": true,
14
+ "align": true,
15
+ "numberOfLines": true,
16
+ "ellipsis": true,
17
+ "hybridRef": true
18
+ }
19
+ }
package/package.json ADDED
@@ -0,0 +1,107 @@
1
+ {
2
+ "name": "@matiks/rn-stroke-text",
3
+ "version": "0.0.1",
4
+ "description": "rn-stroke-text",
5
+ "main": "lib/index",
6
+ "module": "lib/index",
7
+ "types": "lib/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "react-native.config.js",
13
+ "lib",
14
+ "nitrogen",
15
+ "android/build.gradle",
16
+ "android/gradle.properties",
17
+ "android/fix-prefab.gradle",
18
+ "android/CMakeLists.txt",
19
+ "android/src",
20
+ "ios/**/*.h",
21
+ "ios/**/*.m",
22
+ "ios/**/*.mm",
23
+ "ios/**/*.cpp",
24
+ "ios/**/*.swift",
25
+ "app.plugin.js",
26
+ "nitro.json",
27
+ "*.podspec",
28
+ "README.md"
29
+ ],
30
+ "scripts": {
31
+ "typecheck": "tsc --noEmit",
32
+ "clean": "rm -rf android/build node_modules/**/android/build lib",
33
+ "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
34
+ "lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
35
+ "typescript": "tsc",
36
+ "specs": "tsc --noEmit false && nitrogen --logLevel=\"debug\""
37
+ },
38
+ "keywords": [
39
+ "react-native",
40
+ "nitro"
41
+ ],
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/mrousavy/nitro.git"
45
+ },
46
+ "author": "Marc Rousavy <me@mrousavy.com> (https://github.com/mrousavy)",
47
+ "license": "MIT",
48
+ "bugs": {
49
+ "url": "https://github.com/mrousavy/nitro/issues"
50
+ },
51
+ "homepage": "https://github.com/mrousavy/nitro#readme",
52
+ "publishConfig": {
53
+ "registry": "https://registry.npmjs.org/"
54
+ },
55
+ "devDependencies": {
56
+ "@react-native/eslint-config": "0.82.0",
57
+ "@types/react": "^19.1.03",
58
+ "eslint": "^8.57.0",
59
+ "eslint-config-prettier": "^9.1.0",
60
+ "eslint-plugin-prettier": "^5.2.1",
61
+ "nitrogen": "*",
62
+ "prettier": "^3.3.3",
63
+ "react": "19.1.1",
64
+ "react-native": "0.82.0",
65
+ "react-native-nitro-modules": "*",
66
+ "typescript": "^5.8.3"
67
+ },
68
+ "peerDependencies": {
69
+ "react": "*",
70
+ "react-native": "*",
71
+ "react-native-nitro-modules": "*"
72
+ },
73
+ "eslintConfig": {
74
+ "root": true,
75
+ "extends": [
76
+ "@react-native",
77
+ "prettier"
78
+ ],
79
+ "plugins": [
80
+ "prettier"
81
+ ],
82
+ "rules": {
83
+ "prettier/prettier": [
84
+ "warn",
85
+ {
86
+ "quoteProps": "consistent",
87
+ "singleQuote": true,
88
+ "tabWidth": 2,
89
+ "trailingComma": "es5",
90
+ "useTabs": false
91
+ }
92
+ ]
93
+ }
94
+ },
95
+ "eslintIgnore": [
96
+ "node_modules/",
97
+ "lib/"
98
+ ],
99
+ "prettier": {
100
+ "quoteProps": "consistent",
101
+ "singleQuote": true,
102
+ "tabWidth": 2,
103
+ "trailingComma": "es5",
104
+ "useTabs": false,
105
+ "semi": false
106
+ }
107
+ }
@@ -0,0 +1,16 @@
1
+ // https://github.com/react-native-community/cli/blob/main/docs/dependencies.md
2
+
3
+ module.exports = {
4
+ dependency: {
5
+ platforms: {
6
+ /**
7
+ * @type {import('@react-native-community/cli-types').IOSDependencyParams}
8
+ */
9
+ ios: {},
10
+ /**
11
+ * @type {import('@react-native-community/cli-types').AndroidDependencyParams}
12
+ */
13
+ android: {},
14
+ },
15
+ },
16
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,44 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import { callback, getHostComponent } from "react-native-nitro-modules";
3
+ import MatiksKeyboardViewConfig from "../nitrogen/generated/shared/json/MatiksStrokeTextConfig.json";
4
+ import { type MatiksStrokeText, type MatiksStrokeTextMethods, type MatiksStrokeTextProps } from "./specs/Stroke.nitro";
5
+
6
+ const StrokeTextViewComponent = getHostComponent<MatiksStrokeTextProps, MatiksStrokeTextMethods>(
7
+ 'MatiksStrokeText',
8
+ () => MatiksKeyboardViewConfig
9
+ )
10
+
11
+ interface StrokeTextViewProps extends MatiksStrokeTextProps {
12
+ styles?: {
13
+ width?: number,
14
+ height?: number
15
+ }
16
+ }
17
+
18
+ const StrokeTextView = ({ styles, ...props }: StrokeTextViewProps) => {
19
+ const ref = useRef<MatiksStrokeText | null>(null);
20
+ const [size, setSize] = useState({ width: 0, height: 0 });
21
+
22
+ useEffect(() => {
23
+ if (!ref.current) return;
24
+
25
+ const result = ref.current.measureDimensions();
26
+ setSize(result);
27
+ }, [
28
+ props.fontFamily,
29
+ props.fontSize,
30
+ props.text,
31
+ ]);
32
+
33
+ return (
34
+ <StrokeTextViewComponent
35
+ {...props}
36
+ style={[{ width: size.width, height: size.height }, styles]}
37
+ hybridRef={callback((_ref) => {
38
+ ref.current = _ref;
39
+ })}
40
+ />
41
+ );
42
+ };
43
+
44
+ export default React.memo(StrokeTextView)
@@ -0,0 +1,34 @@
1
+ type TextAlign = "center" | "left" | "right"
2
+ import type {
3
+ HybridView,
4
+ HybridViewMethods,
5
+ HybridViewProps,
6
+ } from 'react-native-nitro-modules';
7
+
8
+ export interface MatiksStrokeTextProps extends HybridViewProps {
9
+ width?: number;
10
+ text: string;
11
+ fontSize?: number;
12
+ color?: string;
13
+ strokeColor?: string;
14
+ strokeWidth?: number;
15
+ fontFamily?: string;
16
+ align?: TextAlign;
17
+ numberOfLines?: number;
18
+ ellipsis?: boolean;
19
+ }
20
+
21
+
22
+ export interface Dimensions {
23
+ width: number;
24
+ height: number;
25
+ }
26
+
27
+ export interface MatiksStrokeTextMethods extends HybridViewMethods {
28
+ measureDimensions(): Dimensions;
29
+ }
30
+
31
+ export type MatiksStrokeText = HybridView<
32
+ MatiksStrokeTextProps,
33
+ MatiksStrokeTextMethods
34
+ >