@nayan-ui/engine 0.0.0-stage → 1.0.0-beta.3

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 (189) hide show
  1. package/LICENSE +21 -0
  2. package/NayanEngine.podspec +28 -0
  3. package/README.md +210 -2
  4. package/lib/module/assets/AssetBytesCache.js +76 -0
  5. package/lib/module/assets/AssetCache.js +19 -0
  6. package/lib/module/assets/AssetLoader.js +52 -0
  7. package/lib/module/assets/CacheGeneration.js +7 -0
  8. package/lib/module/assets/IndexedDbCache.web.js +149 -0
  9. package/lib/module/assets/ProceduralCache.js +222 -0
  10. package/lib/module/assets/font.js +136 -0
  11. package/lib/module/assets/loft.js +142 -0
  12. package/lib/module/assets/model.js +74 -0
  13. package/lib/module/assets/modelling.js +254 -0
  14. package/lib/module/assets/shape.js +926 -0
  15. package/lib/module/assets/source.js +58 -0
  16. package/lib/module/assets/source.web.js +22 -0
  17. package/lib/module/assets/storage.js +4 -0
  18. package/lib/module/assets/storage.shared.js +36 -0
  19. package/lib/module/assets/storage.web.js +37 -0
  20. package/lib/module/assets/surface.js +47 -0
  21. package/lib/module/assets/texture.js +66 -0
  22. package/lib/module/drawing/DrawingCanvas.js +38 -0
  23. package/lib/module/drawing/DrawingCanvas.web.js +206 -0
  24. package/lib/module/drawing/DrawingDocument.js +256 -0
  25. package/lib/module/drawing/types.js +4 -0
  26. package/lib/module/globals.d.ts +12 -0
  27. package/lib/module/index.js +36 -0
  28. package/lib/module/input/Joystick.js +84 -0
  29. package/lib/module/input/Joystick.web.js +93 -0
  30. package/lib/module/input/keyboard.js +250 -0
  31. package/lib/module/media/audio-worklet.js +34 -0
  32. package/lib/module/media/audio.js +94 -0
  33. package/lib/module/media/haptics.js +82 -0
  34. package/lib/module/media/output.web.js +66 -0
  35. package/lib/module/native/BrowserEngine.js +551 -0
  36. package/lib/module/native/EngineBridge.js +4 -0
  37. package/lib/module/native/NativeNayanEngine.js +7 -0
  38. package/lib/module/native/NativeNayanEngine.web.js +62 -0
  39. package/lib/module/native/prepare.js +7 -0
  40. package/lib/module/native/prepare.web.js +17 -0
  41. package/lib/module/native/spec/NativeNayanEngine.js +17 -0
  42. package/lib/module/package.json +1 -0
  43. package/lib/module/render/GameView.js +249 -0
  44. package/lib/module/render/camera.js +34 -0
  45. package/lib/module/render/host.js +39 -0
  46. package/lib/module/render/host.web.js +104 -0
  47. package/lib/module/render/meshes.js +159 -0
  48. package/lib/module/render/quality.js +112 -0
  49. package/lib/module/render/responder.js +4 -0
  50. package/lib/module/render/responder.web.js +97 -0
  51. package/lib/module/render/touch.js +185 -0
  52. package/lib/module/types.js +30 -0
  53. package/lib/module/world/Scoreboard.js +143 -0
  54. package/lib/module/world/TransformBatch.js +126 -0
  55. package/lib/module/world/World.js +690 -0
  56. package/lib/module/world/desc.js +186 -0
  57. package/lib/module/world/effects.js +451 -0
  58. package/lib/module/world/quat.js +86 -0
  59. package/lib/module/world/types.js +4 -0
  60. package/lib/typescript/package.json +1 -0
  61. package/lib/typescript/src/assets/AssetBytesCache.d.ts +7 -0
  62. package/lib/typescript/src/assets/AssetCache.d.ts +9 -0
  63. package/lib/typescript/src/assets/AssetLoader.d.ts +11 -0
  64. package/lib/typescript/src/assets/CacheGeneration.d.ts +3 -0
  65. package/lib/typescript/src/assets/IndexedDbCache.web.d.ts +20 -0
  66. package/lib/typescript/src/assets/ProceduralCache.d.ts +33 -0
  67. package/lib/typescript/src/assets/font.d.ts +53 -0
  68. package/lib/typescript/src/assets/loft.d.ts +31 -0
  69. package/lib/typescript/src/assets/model.d.ts +48 -0
  70. package/lib/typescript/src/assets/modelling.d.ts +157 -0
  71. package/lib/typescript/src/assets/shape.d.ts +203 -0
  72. package/lib/typescript/src/assets/source.d.ts +10 -0
  73. package/lib/typescript/src/assets/source.web.d.ts +8 -0
  74. package/lib/typescript/src/assets/storage.d.ts +2 -0
  75. package/lib/typescript/src/assets/storage.shared.d.ts +7 -0
  76. package/lib/typescript/src/assets/storage.web.d.ts +7 -0
  77. package/lib/typescript/src/assets/surface.d.ts +17 -0
  78. package/lib/typescript/src/assets/texture.d.ts +30 -0
  79. package/lib/typescript/src/drawing/DrawingCanvas.d.ts +5 -0
  80. package/lib/typescript/src/drawing/DrawingCanvas.web.d.ts +4 -0
  81. package/lib/typescript/src/drawing/DrawingDocument.d.ts +210 -0
  82. package/lib/typescript/src/drawing/types.d.ts +12 -0
  83. package/lib/typescript/src/index.d.ts +42 -0
  84. package/lib/typescript/src/input/Joystick.d.ts +20 -0
  85. package/lib/typescript/src/input/Joystick.web.d.ts +13 -0
  86. package/lib/typescript/src/input/keyboard.d.ts +17 -0
  87. package/lib/typescript/src/media/audio.d.ts +46 -0
  88. package/lib/typescript/src/media/haptics.d.ts +22 -0
  89. package/lib/typescript/src/media/output.web.d.ts +4 -0
  90. package/lib/typescript/src/native/BrowserEngine.d.ts +8 -0
  91. package/lib/typescript/src/native/EngineBridge.d.ts +22 -0
  92. package/lib/typescript/src/native/NativeNayanEngine.d.ts +5 -0
  93. package/lib/typescript/src/native/NativeNayanEngine.web.d.ts +10 -0
  94. package/lib/typescript/src/native/prepare.d.ts +3 -0
  95. package/lib/typescript/src/native/prepare.web.d.ts +2 -0
  96. package/lib/typescript/src/native/spec/NativeNayanEngine.d.ts +182 -0
  97. package/lib/typescript/src/render/GameView.d.ts +95 -0
  98. package/lib/typescript/src/render/camera.d.ts +6 -0
  99. package/lib/typescript/src/render/host.d.ts +29 -0
  100. package/lib/typescript/src/render/host.web.d.ts +16 -0
  101. package/lib/typescript/src/render/meshes.d.ts +45 -0
  102. package/lib/typescript/src/render/quality.d.ts +46 -0
  103. package/lib/typescript/src/render/responder.d.ts +2 -0
  104. package/lib/typescript/src/render/responder.web.d.ts +40 -0
  105. package/lib/typescript/src/render/touch.d.ts +26 -0
  106. package/lib/typescript/src/types.d.ts +72 -0
  107. package/lib/typescript/src/world/Scoreboard.d.ts +65 -0
  108. package/lib/typescript/src/world/TransformBatch.d.ts +39 -0
  109. package/lib/typescript/src/world/World.d.ts +199 -0
  110. package/lib/typescript/src/world/desc.d.ts +17 -0
  111. package/lib/typescript/src/world/effects.d.ts +156 -0
  112. package/lib/typescript/src/world/quat.d.ts +31 -0
  113. package/lib/typescript/src/world/types.d.ts +233 -0
  114. package/lib/web/audio-worklet.js +29 -0
  115. package/lib/web/engine_core_bg.wasm +0 -0
  116. package/lib/web/index.js +7974 -0
  117. package/lib/web/types/src/assets/AssetBytesCache.d.ts +6 -0
  118. package/lib/web/types/src/assets/AssetCache.d.ts +8 -0
  119. package/lib/web/types/src/assets/AssetLoader.d.ts +10 -0
  120. package/lib/web/types/src/assets/CacheGeneration.d.ts +2 -0
  121. package/lib/web/types/src/assets/IndexedDbCache.d.ts +19 -0
  122. package/lib/web/types/src/assets/ProceduralCache.d.ts +32 -0
  123. package/lib/web/types/src/assets/font.d.ts +52 -0
  124. package/lib/web/types/src/assets/loft.d.ts +30 -0
  125. package/lib/web/types/src/assets/model.d.ts +47 -0
  126. package/lib/web/types/src/assets/modelling.d.ts +156 -0
  127. package/lib/web/types/src/assets/shape.d.ts +202 -0
  128. package/lib/web/types/src/assets/source.d.ts +7 -0
  129. package/lib/web/types/src/assets/storage.d.ts +6 -0
  130. package/lib/web/types/src/assets/storage.shared.d.ts +6 -0
  131. package/lib/web/types/src/assets/surface.d.ts +16 -0
  132. package/lib/web/types/src/assets/texture.d.ts +29 -0
  133. package/lib/web/types/src/drawing/DrawingCanvas.d.ts +3 -0
  134. package/lib/web/types/src/drawing/DrawingDocument.d.ts +209 -0
  135. package/lib/web/types/src/drawing/types.d.ts +11 -0
  136. package/lib/web/types/src/index.d.ts +41 -0
  137. package/lib/web/types/src/input/Joystick.d.ts +12 -0
  138. package/lib/web/types/src/input/keyboard.d.ts +16 -0
  139. package/lib/web/types/src/media/audio.d.ts +45 -0
  140. package/lib/web/types/src/media/haptics.d.ts +21 -0
  141. package/lib/web/types/src/media/output.d.ts +3 -0
  142. package/lib/web/types/src/native/BrowserEngine.d.ts +7 -0
  143. package/lib/web/types/src/native/EngineBridge.d.ts +21 -0
  144. package/lib/web/types/src/native/NativeNayanEngine.d.ts +9 -0
  145. package/lib/web/types/src/native/prepare.d.ts +1 -0
  146. package/lib/web/types/src/native/spec/NativeNayanEngine.d.ts +181 -0
  147. package/lib/web/types/src/render/GameView.d.ts +94 -0
  148. package/lib/web/types/src/render/camera.d.ts +5 -0
  149. package/lib/web/types/src/render/host.d.ts +15 -0
  150. package/lib/web/types/src/render/meshes.d.ts +44 -0
  151. package/lib/web/types/src/render/quality.d.ts +45 -0
  152. package/lib/web/types/src/render/responder.d.ts +39 -0
  153. package/lib/web/types/src/render/touch.d.ts +25 -0
  154. package/lib/web/types/src/types.d.ts +71 -0
  155. package/lib/web/types/src/world/Scoreboard.d.ts +64 -0
  156. package/lib/web/types/src/world/TransformBatch.d.ts +38 -0
  157. package/lib/web/types/src/world/World.d.ts +198 -0
  158. package/lib/web/types/src/world/desc.d.ts +16 -0
  159. package/lib/web/types/src/world/effects.d.ts +155 -0
  160. package/lib/web/types/src/world/quat.d.ts +30 -0
  161. package/lib/web/types/src/world/types.d.ts +232 -0
  162. package/native/android/CMakeLists.txt +34 -0
  163. package/native/android/NayanEngineSpec.h +15 -0
  164. package/native/android/build.gradle +26 -0
  165. package/native/android/codegen/CMakeLists.txt +3 -0
  166. package/native/android/proguard-rules.pro +2 -0
  167. package/native/android/src/main/java/com/nayanui/engine/EngineSurfaceView.java +234 -0
  168. package/native/android/src/main/java/com/nayanui/engine/EngineSurfaceViewManager.java +45 -0
  169. package/native/android/src/main/java/com/nayanui/engine/NayanEnginePackage.java +24 -0
  170. package/native/core/build/EngineCore.xcframework/Info.plist +43 -0
  171. package/native/core/build/EngineCore.xcframework/ios-arm64/libengine_core.a +0 -0
  172. package/native/core/build/EngineCore.xcframework/ios-arm64-simulator/libengine_core.a +0 -0
  173. package/native/core/build/android/arm64-v8a/libengine_core.a +0 -0
  174. package/native/core/build/android/armeabi-v7a/libengine_core.a +0 -0
  175. package/native/core/build/android/x86/libengine_core.a +0 -0
  176. package/native/core/build/android/x86_64/libengine_core.a +0 -0
  177. package/native/core/include/drawing-licenses.txt +58 -0
  178. package/native/core/include/engine_core.h +322 -0
  179. package/native/cpp/NayanEngineModule.cpp +827 -0
  180. package/native/cpp/NayanEngineModule.h +144 -0
  181. package/native/cpp/generated/NayanEngineSpecJSI.cpp +2 -0
  182. package/native/cpp/generated/NayanEngineSpecJSI.h +921 -0
  183. package/native/ios/NayanEngineProvider.h +5 -0
  184. package/native/ios/NayanEngineProvider.mm +21 -0
  185. package/native/ios/NayanEngineSurface.mm +223 -0
  186. package/native/scripts/check-package.mjs +39 -0
  187. package/package.json +162 -4
  188. package/react-native.config.js +18 -0
  189. package/src/native/spec/NativeNayanEngine.ts +226 -0
@@ -0,0 +1,234 @@
1
+ package com.nayanui.engine;
2
+
3
+ import android.content.Context;
4
+ import java.nio.charset.StandardCharsets;
5
+ import com.facebook.react.bridge.Arguments;
6
+ import com.facebook.react.bridge.ReactContext;
7
+ import com.facebook.react.bridge.WritableMap;
8
+ import com.facebook.react.uimanager.UIManagerHelper;
9
+ import com.facebook.react.uimanager.events.Event;
10
+ import com.facebook.react.uimanager.events.EventDispatcher;
11
+ import android.graphics.SurfaceTexture;
12
+ import android.view.Surface;
13
+ import android.view.MotionEvent;
14
+ import android.view.ScaleGestureDetector;
15
+ import android.view.Choreographer;
16
+ import android.view.TextureView;
17
+
18
+ /**
19
+ * A surface the Rust renderer draws into (Vulkan, or OpenGL ES when Vulkan isn't usable). A
20
+ * TextureView keeps the last frame in the view tree during navigation's removal animation, even
21
+ * after React stops rendering. JS refers to it by `surfaceId`.
22
+ */
23
+ public class EngineSurfaceView extends TextureView implements TextureView.SurfaceTextureListener, Choreographer.FrameCallback {
24
+ private int surfaceId = -1;
25
+ private Surface surface;
26
+ private int width;
27
+ private int height;
28
+ private int drawingId = -1;
29
+ private int drawingMode;
30
+ private int drawingBackground = 0xffffff;
31
+ private boolean drawingTick;
32
+ private long lastDrawingEvent;
33
+ private int drawingPointer = -1;
34
+ private boolean pencil;
35
+ private float lastX, lastY;
36
+ private final float density;
37
+ private final ScaleGestureDetector scaleDetector;
38
+
39
+ public EngineSurfaceView(Context context) {
40
+ super(context);
41
+ setSurfaceTextureListener(this);
42
+ density = context.getResources().getDisplayMetrics().density;
43
+ scaleDetector = new ScaleGestureDetector(context, new ScaleGestureDetector.SimpleOnScaleGestureListener() {
44
+ @Override public boolean onScale(ScaleGestureDetector detector) {
45
+ nativeDrawingTransform(drawingId, 0, 0, detector.getScaleFactor());
46
+ return true;
47
+ }
48
+ });
49
+ }
50
+
51
+ public void setSurfaceId(int id) {
52
+ if (id == surfaceId) {
53
+ return;
54
+ }
55
+ if (surfaceId >= 0) {
56
+ nativeDetach(surfaceId);
57
+ }
58
+ surfaceId = id;
59
+ attach();
60
+ }
61
+
62
+ /**
63
+ * Stops the renderer, but leaves the texture visible until navigation removes the view. Hiding it
64
+ * here would replace the game's last frame with an empty screen during the exit animation.
65
+ */
66
+ public void release() {
67
+ stopDrawing();
68
+ drawingId = -1;
69
+ if (surfaceId >= 0) {
70
+ nativeDetach(surfaceId);
71
+ surfaceId = -1;
72
+ }
73
+ releaseSurface();
74
+ }
75
+
76
+ private void attach() {
77
+ if (surfaceId >= 0 && surface != null && surface.isValid() && width > 0 && height > 0) {
78
+ nativeAttach(surfaceId, surface, width, height);
79
+ if (drawingId >= 0) nativeDrawingInvalidate(drawingId);
80
+ startDrawing();
81
+ }
82
+ }
83
+
84
+ @Override
85
+ public void onSurfaceTextureAvailable(SurfaceTexture texture, int w, int h) {
86
+ surface = new Surface(texture);
87
+ width = w;
88
+ height = h;
89
+ attach();
90
+ }
91
+
92
+ @Override
93
+ public void onSurfaceTextureSizeChanged(SurfaceTexture texture, int w, int h) {
94
+ width = w;
95
+ height = h;
96
+ attach();
97
+ }
98
+
99
+ @Override
100
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture texture) {
101
+ stopDrawing();
102
+ // Wait for the renderer before Android destroys the texture. Keep the id so a screen covered by
103
+ // another route can attach a new surface when it comes back from the back stack.
104
+ if (surfaceId >= 0) {
105
+ nativeDetach(surfaceId);
106
+ }
107
+ releaseSurface();
108
+ return true;
109
+ }
110
+
111
+ @Override
112
+ public void onSurfaceTextureUpdated(SurfaceTexture texture) {}
113
+
114
+ private void releaseSurface() {
115
+ if (surface != null) {
116
+ surface.release();
117
+ surface = null;
118
+ }
119
+ }
120
+
121
+ public void setDrawingId(int id) {
122
+ stopDrawing();
123
+ drawingId = id;
124
+ if (id >= 0) nativeDrawingInvalidate(id);
125
+ startDrawing();
126
+ }
127
+ public void setDrawingMode(int mode) {
128
+ if (drawingPointer >= 0) nativeDrawingTouch(drawingId, 3, 0, 0, 1);
129
+ drawingPointer = -1;
130
+ drawingMode = mode;
131
+ }
132
+ public void setDrawingBackground(int color) {
133
+ drawingBackground = color;
134
+ if (drawingId >= 0) nativeDrawingInvalidate(drawingId);
135
+ }
136
+ private void startDrawing() {
137
+ if (!drawingTick && drawingId >= 0 && surface != null && isShown() && hasWindowFocus()) {
138
+ drawingTick = true;
139
+ Choreographer.getInstance().postFrameCallback(this);
140
+ }
141
+ }
142
+ private void stopDrawing() {
143
+ drawingTick = false;
144
+ Choreographer.getInstance().removeFrameCallback(this);
145
+ if (drawingPointer >= 0) nativeDrawingTouch(drawingId, 2, lastX, lastY, 1);
146
+ drawingPointer = -1;
147
+ }
148
+ @Override public void doFrame(long frameTimeNanos) {
149
+ if (!drawingTick || drawingId < 0 || surface == null) return;
150
+ nativeDrawingPresent(drawingId, surfaceId, width / density, height / density, drawingBackground);
151
+ if (frameTimeNanos - lastDrawingEvent >= 100_000_000L && getContext() instanceof ReactContext) {
152
+ lastDrawingEvent = frameTimeNanos;
153
+ byte[] data = nativeDrawingEvent(drawingId);
154
+ if (data != null) {
155
+ String state = new String(data, StandardCharsets.UTF_8);
156
+ ReactContext context = (ReactContext)getContext();
157
+ EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, getId());
158
+ if (dispatcher != null) dispatcher.dispatchEvent(new DrawingChangeEvent(UIManagerHelper.getSurfaceId(context), getId(), drawingId, state));
159
+ }
160
+ }
161
+ Choreographer.getInstance().postFrameCallback(this);
162
+ }
163
+ private static final class DrawingChangeEvent extends Event<DrawingChangeEvent> {
164
+ private final String state;
165
+ private final int document;
166
+ DrawingChangeEvent(int surface, int view, int document, String state) { super(surface, view); this.document = document; this.state = state; }
167
+ @Override public String getEventName() { return "topDrawingChange"; }
168
+ @Override public boolean canCoalesce() { return true; }
169
+ @Override protected WritableMap getEventData() { WritableMap data = Arguments.createMap(); data.putString("state", state); data.putInt("documentId", document); return data; }
170
+ }
171
+ @Override public void onWindowFocusChanged(boolean focused) {
172
+ super.onWindowFocusChanged(focused);
173
+ if (focused) startDrawing(); else stopDrawing();
174
+ }
175
+ @Override protected void onDetachedFromWindow() {
176
+ stopDrawing();
177
+ super.onDetachedFromWindow();
178
+ }
179
+ @Override protected void onWindowVisibilityChanged(int visibility) {
180
+ super.onWindowVisibilityChanged(visibility);
181
+ if (visibility == VISIBLE) startDrawing(); else stopDrawing();
182
+ }
183
+ @Override public boolean onTouchEvent(MotionEvent event) {
184
+ if (drawingId < 0) return super.onTouchEvent(event);
185
+ getParent().requestDisallowInterceptTouchEvent(true);
186
+ int action = event.getActionMasked();
187
+ if (action == MotionEvent.ACTION_DOWN) {
188
+ drawingPointer = -1;
189
+ lastX = event.getX() / density;
190
+ lastY = event.getY() / density;
191
+ pencil = event.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS || event.getToolType(0) == MotionEvent.TOOL_TYPE_ERASER;
192
+ if (drawingMode == 0) {
193
+ drawingPointer = event.getPointerId(0);
194
+ nativeDrawingTouch(drawingId, event.getToolType(0) == MotionEvent.TOOL_TYPE_ERASER ? 4 : 0, lastX, lastY, pencil ? event.getPressure() : 1);
195
+ }
196
+ }
197
+ if (!pencil) scaleDetector.onTouchEvent(event);
198
+ if (action == MotionEvent.ACTION_POINTER_DOWN && !pencil) {
199
+ if (drawingPointer >= 0) nativeDrawingTouch(drawingId, 3, 0, 0, 1);
200
+ drawingPointer = -1;
201
+ lastX = event.getX() / density;
202
+ lastY = event.getY() / density;
203
+ }
204
+ if (action == MotionEvent.ACTION_MOVE) {
205
+ int index = drawingPointer < 0 ? -1 : event.findPointerIndex(drawingPointer);
206
+ if (index >= 0) {
207
+ for (int h = 0; h < event.getHistorySize(); h++) nativeDrawingTouch(drawingId, 1, event.getHistoricalX(index, h) / density, event.getHistoricalY(index, h) / density, pencil ? event.getHistoricalPressure(index, h) : 1);
208
+ lastX = event.getX(index) / density;
209
+ lastY = event.getY(index) / density;
210
+ nativeDrawingTouch(drawingId, 1, lastX, lastY, pencil ? event.getPressure(index) : 1);
211
+ } else if (drawingMode != 0 || event.getPointerCount() > 1) {
212
+ float x = event.getX() / density, y = event.getY() / density;
213
+ if (!scaleDetector.isInProgress()) nativeDrawingTransform(drawingId, x - lastX, y - lastY, 1);
214
+ lastX = x;
215
+ lastY = y;
216
+ }
217
+ }
218
+ if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL || (action == MotionEvent.ACTION_POINTER_UP && event.getPointerId(event.getActionIndex()) == drawingPointer)) {
219
+ if (drawingPointer >= 0) nativeDrawingTouch(drawingId, action == MotionEvent.ACTION_CANCEL ? 3 : 2, lastX, lastY, 1);
220
+ drawingPointer = -1;
221
+ if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { pencil = false; getParent().requestDisallowInterceptTouchEvent(false); }
222
+ }
223
+ return true;
224
+ }
225
+ private static native void nativeDrawingPresent(int drawing, int surface, float width, float height, int color);
226
+ private static native void nativeDrawingTouch(int drawing, int phase, float x, float y, float pressure);
227
+ private static native void nativeDrawingTransform(int drawing, float dx, float dy, float scale);
228
+ private static native byte[] nativeDrawingEvent(int drawing);
229
+ private static native void nativeDrawingInvalidate(int drawing);
230
+
231
+ private static native boolean nativeAttach(int surfaceId, Surface surface, int width, int height);
232
+
233
+ private static native void nativeDetach(int surfaceId);
234
+ }
@@ -0,0 +1,45 @@
1
+ package com.nayanui.engine;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import java.util.Map;
5
+ import com.facebook.react.common.MapBuilder;
6
+ import com.facebook.react.uimanager.SimpleViewManager;
7
+ import com.facebook.react.uimanager.ThemedReactContext;
8
+ import com.facebook.react.uimanager.annotations.ReactProp;
9
+
10
+ public class EngineSurfaceViewManager extends SimpleViewManager<EngineSurfaceView> {
11
+ @NonNull
12
+ @Override
13
+ public String getName() {
14
+ return "NayanEngineSurface";
15
+ }
16
+
17
+ @NonNull
18
+ @Override
19
+ protected EngineSurfaceView createViewInstance(@NonNull ThemedReactContext context) {
20
+ return new EngineSurfaceView(context);
21
+ }
22
+
23
+ // React unmounted the screen; stop rendering while its last texture finishes the exit animation.
24
+ @Override
25
+ public void onDropViewInstance(@NonNull EngineSurfaceView view) {
26
+ view.release();
27
+ super.onDropViewInstance(view);
28
+ }
29
+
30
+ @Override
31
+ public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
32
+ return MapBuilder.of("topDrawingChange", MapBuilder.of("registrationName", "onDrawingChange"));
33
+ }
34
+
35
+ @ReactProp(name = "surfaceId", defaultInt = -1)
36
+ public void setSurfaceId(EngineSurfaceView view, int surfaceId) {
37
+ view.setSurfaceId(surfaceId);
38
+ }
39
+ @ReactProp(name = "drawingId", defaultInt = -1)
40
+ public void setDrawingId(EngineSurfaceView view, int id) { view.setDrawingId(id); }
41
+ @ReactProp(name = "drawingMode", defaultInt = 0)
42
+ public void setDrawingMode(EngineSurfaceView view, int mode) { view.setDrawingMode(mode); }
43
+ @ReactProp(name = "drawingBackground", defaultInt = 0xffffff)
44
+ public void setDrawingBackground(EngineSurfaceView view, int color) { view.setDrawingBackground(color); }
45
+ }
@@ -0,0 +1,24 @@
1
+ package com.nayanui.engine;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.facebook.react.ReactPackage;
5
+ import com.facebook.react.bridge.NativeModule;
6
+ import com.facebook.react.bridge.ReactApplicationContext;
7
+ import com.facebook.react.uimanager.ViewManager;
8
+ import java.util.Collections;
9
+ import java.util.List;
10
+
11
+ /** Registers the EngineSurface view (the native module is a C++ TurboModule, registered separately). */
12
+ public class NayanEnginePackage implements ReactPackage {
13
+ @NonNull
14
+ @Override
15
+ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext context) {
16
+ return Collections.emptyList();
17
+ }
18
+
19
+ @NonNull
20
+ @Override
21
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext context) {
22
+ return Collections.singletonList(new EngineSurfaceViewManager());
23
+ }
24
+ }
@@ -0,0 +1,43 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>AvailableLibraries</key>
6
+ <array>
7
+ <dict>
8
+ <key>BinaryPath</key>
9
+ <string>libengine_core.a</string>
10
+ <key>LibraryIdentifier</key>
11
+ <string>ios-arm64</string>
12
+ <key>LibraryPath</key>
13
+ <string>libengine_core.a</string>
14
+ <key>SupportedArchitectures</key>
15
+ <array>
16
+ <string>arm64</string>
17
+ </array>
18
+ <key>SupportedPlatform</key>
19
+ <string>ios</string>
20
+ </dict>
21
+ <dict>
22
+ <key>BinaryPath</key>
23
+ <string>libengine_core.a</string>
24
+ <key>LibraryIdentifier</key>
25
+ <string>ios-arm64-simulator</string>
26
+ <key>LibraryPath</key>
27
+ <string>libengine_core.a</string>
28
+ <key>SupportedArchitectures</key>
29
+ <array>
30
+ <string>arm64</string>
31
+ </array>
32
+ <key>SupportedPlatform</key>
33
+ <string>ios</string>
34
+ <key>SupportedPlatformVariant</key>
35
+ <string>simulator</string>
36
+ </dict>
37
+ </array>
38
+ <key>CFBundlePackageType</key>
39
+ <string>XFWK</string>
40
+ <key>XCFrameworkFormatVersion</key>
41
+ <string>1.0</string>
42
+ </dict>
43
+ </plist>
@@ -0,0 +1,58 @@
1
+ Drawing renderer dependencies
2
+ =============================
3
+
4
+ raqote 0.8.5
5
+ https://github.com/jrmuizel/raqote
6
+
7
+ Copyright (c) 2019 Jeff Muizelaar
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ * Redistributions of source code must retain the above copyright notice, this
14
+ list of conditions and the following disclaimer.
15
+
16
+ * Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ * Neither the name of the copyright holder nor the names of its
21
+ contributors may be used to endorse or promote products derived from
22
+ this software without specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+
36
+ svgtypes 0.16.1 (MIT option)
37
+ https://github.com/linebender/svgtypes
38
+
39
+ Copyright (c) 2018 Yevhenii Reizner
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining a copy
42
+ of this software and associated documentation files (the "Software"), to deal
43
+ in the Software without restriction, including without limitation the rights
44
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45
+ copies of the Software, and to permit persons to whom the Software is
46
+ furnished to do so, subject to the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be included in
49
+ all copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
54
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
57
+ THE SOFTWARE.
58
+