expo-gl 13.3.0 → 13.5.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 CHANGED
@@ -10,6 +10,29 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 13.5.0 — 2023-11-14
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - Bumped iOS deployment target to 13.4. ([#25063](https://github.com/expo/expo/pull/25063) by [@gabrieldonadel](https://github.com/gabrieldonadel))
18
+ - On `Android` bump `compileSdkVersion` and `targetSdkVersion` to `34`. ([#24708](https://github.com/expo/expo/pull/24708) by [@alanjhughes](https://github.com/alanjhughes))
19
+
20
+ ### 💡 Others
21
+
22
+ - Use `pointerEvent` style instead of prop for components on web. ([#24931](https://github.com/expo/expo/pull/24931) by [@EvanBacon](https://github.com/EvanBacon))
23
+ - Remove deprecated `REACT_NATIVE_OVERRIDE_VERSION` for React Native nightly testing. ([#25151](https://github.com/expo/expo/pull/25151) by [@kudo](https://github.com/kudo))
24
+ - Removed backward compatible code for deprecated SDKs. ([#25154](https://github.com/expo/expo/pull/25154) by [@kudo](https://github.com/kudo))
25
+
26
+ ## 13.4.0 — 2023-10-17
27
+
28
+ ### 🛠 Breaking changes
29
+
30
+ - Dropped support for Android SDK 21 and 22. ([#24201](https://github.com/expo/expo/pull/24201) by [@behenate](https://github.com/behenate))
31
+
32
+ ### 💡 Others
33
+
34
+ - Ship untranspiled JSX to support custom handling of `jsx` and `createElement`. ([#24889](https://github.com/expo/expo/pull/24889) by [@EvanBacon](https://github.com/EvanBacon))
35
+
13
36
  ## 13.3.0 — 2023-09-15
14
37
 
15
38
  _This version does not introduce any user-facing changes._
package/ExpoGL.podspec CHANGED
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
10
10
  s.license = package['license']
11
11
  s.author = package['author']
12
12
  s.homepage = package['homepage']
13
- s.platform = :ios, '13.0'
13
+ s.platform = :ios, '13.4'
14
14
  s.source = { git: 'https://github.com/expo/expo-gl.git' }
15
15
  s.static_framework = true
16
16
 
@@ -9,7 +9,6 @@ set(CMAKE_CXX_STANDARD 17)
9
9
  set(PACKAGE_NAME "expo-gl")
10
10
  set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
11
11
  set(COMMON_DIR ${CMAKE_SOURCE_DIR}/../common)
12
- set(ignoreMe "${REACT_NATIVE_DIR} ${RN_SO_DIR}")
13
12
 
14
13
  add_library(
15
14
  ${PACKAGE_NAME} SHARED
@@ -3,36 +3,27 @@ import java.nio.file.Paths
3
3
  apply plugin: 'com.android.library'
4
4
  apply plugin: 'kotlin-android'
5
5
  apply plugin: 'maven-publish'
6
- apply plugin: "de.undercouch.download"
7
6
 
8
7
  group = 'host.exp.exponent'
9
- version = '13.3.0'
10
-
11
- def REACT_NATIVE_BUILD_FROM_SOURCE = findProject(":ReactAndroid") != null
12
- def REACT_NATIVE_DIR = REACT_NATIVE_BUILD_FROM_SOURCE
13
- ? findProject(":ReactAndroid").getProjectDir().parent
14
- : new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).parent
15
- def RN_SO_DIR = REACT_NATIVE_BUILD_FROM_SOURCE
16
- ? Paths.get(findProject(":ReactAndroid").getProjectDir().toString(), "build", "intermediates", "library_*", "*", "jni")
17
- : "${buildDir}/react/jni"
18
-
19
- def reactProperties = new Properties()
20
- file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
21
- def REACT_NATIVE_VERSION = System.getenv("REACT_NATIVE_OVERRIDE_VERSION") ?: reactProperties.getProperty("VERSION_NAME")
22
- def REACT_NATIVE_TARGET_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
8
+ version = '13.5.0'
23
9
 
24
10
  def reactNativeArchitectures() {
25
11
  def value = project.getProperties().get("reactNativeArchitectures")
26
12
  return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
27
13
  }
28
14
 
29
- buildscript {
30
- def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
31
- if (expoModulesCorePlugin.exists()) {
32
- apply from: expoModulesCorePlugin
33
- applyKotlinExpoModulesCorePlugin()
15
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
16
+ if (expoModulesCorePlugin.exists()) {
17
+ apply from: expoModulesCorePlugin
18
+ applyKotlinExpoModulesCorePlugin()
19
+ // Remove this check, but keep the contents after SDK49 support is dropped
20
+ if (safeExtGet("expoProvidesDefaultConfig", false)) {
21
+ useExpoPublishing()
22
+ useCoreDependencies()
34
23
  }
24
+ }
35
25
 
26
+ buildscript {
36
27
  // Simple helper that allows the root project to override versions declared by this library.
37
28
  ext.safeExtGet = { prop, fallback ->
38
29
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -53,27 +44,47 @@ buildscript {
53
44
 
54
45
  dependencies {
55
46
  classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
56
- classpath("de.undercouch:gradle-download-task:5.3.0")
57
47
  }
58
48
  }
59
49
 
60
- afterEvaluate {
61
- publishing {
62
- publications {
63
- release(MavenPublication) {
64
- from components.release
50
+ // Remove this if and it's contents, when support for SDK49 is dropped
51
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
52
+ afterEvaluate {
53
+ publishing {
54
+ publications {
55
+ release(MavenPublication) {
56
+ from components.release
57
+ }
65
58
  }
66
- }
67
- repositories {
68
- maven {
69
- url = mavenLocal().url
59
+ repositories {
60
+ maven {
61
+ url = mavenLocal().url
62
+ }
70
63
  }
71
64
  }
72
65
  }
73
66
  }
74
67
 
75
68
  android {
76
- compileSdkVersion safeExtGet("compileSdkVersion", 33)
69
+ // Remove this if and it's contents, when support for SDK49 is dropped
70
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
71
+ compileSdkVersion safeExtGet("compileSdkVersion", 34)
72
+
73
+ defaultConfig {
74
+ minSdkVersion safeExtGet("minSdkVersion", 23)
75
+ targetSdkVersion safeExtGet("targetSdkVersion", 34)
76
+ }
77
+
78
+ publishing {
79
+ singleVariant("release") {
80
+ withSourcesJar()
81
+ }
82
+ }
83
+
84
+ lintOptions {
85
+ abortOnError false
86
+ }
87
+ }
77
88
 
78
89
  if (rootProject.hasProperty("ndkPath")) {
79
90
  ndkPath rootProject.ext.ndkPath
@@ -96,28 +107,20 @@ android {
96
107
 
97
108
  namespace "expo.modules.gl"
98
109
  defaultConfig {
99
- minSdkVersion safeExtGet("minSdkVersion", 21)
100
- targetSdkVersion safeExtGet("targetSdkVersion", 33)
101
110
  versionCode 31
102
- versionName "13.3.0"
111
+ versionName "13.5.0"
103
112
 
104
113
  externalNativeBuild {
105
114
  cmake {
106
115
  abiFilters (*reactNativeArchitectures())
107
- arguments "-DANDROID_STL=c++_shared",
108
- "-DREACT_NATIVE_DIR=${REACT_NATIVE_DIR}",
109
- "-DRN_SO_DIR=${RN_SO_DIR}"
116
+ arguments "-DANDROID_STL=c++_shared"
110
117
  }
111
118
  }
112
119
  }
113
120
 
114
121
  externalNativeBuild {
115
122
  cmake {
116
- if (REACT_NATIVE_TARGET_VERSION >= 71) {
117
- path "CMakeLists.txt"
118
- } else {
119
- path "legacy/CMakeLists.txt"
120
- }
123
+ path "CMakeLists.txt"
121
124
  }
122
125
  }
123
126
 
@@ -137,15 +140,6 @@ android {
137
140
  extractHeaders
138
141
  extractJNI
139
142
  }
140
-
141
- lintOptions {
142
- abortOnError false
143
- }
144
- publishing {
145
- singleVariant("release") {
146
- withSourcesJar()
147
- }
148
- }
149
143
  }
150
144
 
151
145
  repositories {
@@ -154,21 +148,10 @@ repositories {
154
148
 
155
149
  dependencies {
156
150
  compileOnly 'com.facebook.soloader:soloader:0.8.2'
157
- implementation project(':expo-modules-core')
158
-
159
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
160
-
161
- // Remove this when we drop SDK 47
162
- if (REACT_NATIVE_TARGET_VERSION >= 71) {
163
- compileOnly 'com.facebook.react:react-android'
151
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
152
+ implementation project(':expo-modules-core')
153
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
164
154
  }
165
- }
166
155
 
167
- // Remove this when we drop SDK 47
168
- if (REACT_NATIVE_TARGET_VERSION < 71) {
169
- project.ext.extraLegacyReactNativeLibs = [
170
- 'prepareDoubleConversion',
171
- 'prepareFolly',
172
- ]
173
- applyLegacyReactNativeLibsExtractionPlugin()
156
+ compileOnly 'com.facebook.react:react-android'
174
157
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../src/Canvas.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAmD,SAAS,EAAE,MAAM,cAAc,CAAC;AA2B1F,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAC1C,SAAS,GAAG;IACV,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;CACzC,CAyEF,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAmD,SAAS,EAAE,MAAM,cAAc,CAAC;AA2B1F,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAC1C,SAAS,GAAG;IACV,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;CACzC,CAyEF,CAAC;AAQF,eAAe,aAAa,CAAC"}
package/build/Canvas.js CHANGED
@@ -1,4 +1,3 @@
1
- import { Platform } from 'expo-modules-core';
2
1
  import * as React from 'react';
3
2
  import { findDOMNode } from 'react-dom';
4
3
  import { PixelRatio, StyleSheet, View } from 'react-native';
@@ -23,7 +22,7 @@ function setRef(refProp, ref) {
23
22
  }
24
23
  }
25
24
  const Canvas = React.forwardRef((props, ref) => createElement('canvas', { ...props, ref }));
26
- const CanvasWrapper = ({ pointerEvents, children, ...props }) => {
25
+ const CanvasWrapper = ({ pointerEvents, children, style, ...props }) => {
27
26
  const [size, setSize] = React.useState(null);
28
27
  const ref = React.useRef(null);
29
28
  const _canvasRef = React.useRef(null);
@@ -43,7 +42,7 @@ const CanvasWrapper = ({ pointerEvents, children, ...props }) => {
43
42
  if (size) {
44
43
  return size;
45
44
  }
46
- else if (!ref.current || !Platform.isDOMAvailable) {
45
+ else if (!ref.current || typeof window === 'undefined') {
47
46
  return { width: 0, height: 0 };
48
47
  }
49
48
  const element = getElement(ref.current);
@@ -74,9 +73,15 @@ const CanvasWrapper = ({ pointerEvents, children, ...props }) => {
74
73
  }
75
74
  setRef(props.canvasRef, canvas);
76
75
  }, [_canvasRef]);
77
- return (React.createElement(View, { ...props, pointerEvents: "box-none", ref: ref, onLayout: onLayout },
78
- React.createElement(Canvas, { ref: _canvasRef, pointerEvents: pointerEvents, style: StyleSheet.absoluteFill }),
79
- children));
76
+ return (<View {...props} style={[styles.wrapper, style]} ref={ref} onLayout={onLayout}>
77
+ <Canvas ref={_canvasRef} pointerEvents={pointerEvents} style={StyleSheet.absoluteFill}/>
78
+ {children}
79
+ </View>);
80
80
  };
81
+ const styles = StyleSheet.create({
82
+ wrapper: {
83
+ pointerEvents: 'box-none',
84
+ },
85
+ });
81
86
  export default CanvasWrapper;
82
87
  //# sourceMappingURL=Canvas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.js","sourceRoot":"","sources":["../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,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AAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,GAAG,CAAC,OAAO,IAAI,IAAI,EAAE;YACvB,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;SACpB;IACH,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEV,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,gBAAgB,EAAE,CAAC;IACrB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,MAAM,EAAE;YACV,gBAAgB,EAAE,CAAC;SACpB;QACD,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK,EAAE,aAAa,EAAC,UAAU,EAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;QACpE,oBAAC,MAAM,IAAC,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,CAAC,YAAY,GAAI;QACxF,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\nimport * as React from 'react';\nimport { findDOMNode } from 'react-dom';\nimport { LayoutChangeEvent, PixelRatio, StyleSheet, View, ViewProps } from 'react-native';\nimport createElement from 'react-native-web/dist/exports/createElement';\n\nfunction getElement(component) {\n try {\n return findDOMNode(component);\n } catch {\n return component;\n }\n}\n\nfunction setRef<T>(refProp: React.Ref<T>, ref: T | null) {\n if (!refProp) return;\n\n if (typeof refProp === 'function') {\n refProp(ref);\n } else if ('current' in refProp) {\n // @ts-ignore\n refProp.current = ref;\n }\n}\n\nconst Canvas = React.forwardRef(\n (props: React.ComponentProps<typeof View>, ref: React.Ref<HTMLCanvasElement>) =>\n createElement('canvas', { ...props, ref })\n);\n\nconst CanvasWrapper: React.FunctionComponent<\n ViewProps & {\n canvasRef: React.Ref<HTMLCanvasElement>;\n }\n> = ({ pointerEvents, children, ...props }) => {\n const [size, setSize] = React.useState<{ width: number; height: number } | null>(null);\n\n const ref = React.useRef<View>(null);\n const _canvasRef = React.useRef<HTMLCanvasElement>(null);\n\n function updateCanvasSize(): void {\n const canvas = _canvasRef.current;\n // eslint-disable-next-line no-undef\n if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement) {\n const size = getSize();\n const scale = PixelRatio.get();\n\n canvas.style.width = `${size.width}px`;\n canvas.style.height = `${size.height}px`;\n\n canvas.width = size.width * scale;\n canvas.height = size.height * scale;\n }\n }\n\n function getSize(): { width: number; height: number } {\n if (size) {\n return size;\n } else if (!ref.current || !Platform.isDOMAvailable) {\n return { width: 0, height: 0 };\n }\n const element = getElement(ref.current);\n const { offsetWidth: width = 0, offsetHeight: height = 0 } = element;\n return { width, height };\n }\n\n const onLayout = (event: LayoutChangeEvent) => {\n const {\n nativeEvent: {\n layout: { width, height },\n },\n } = event;\n\n if (width !== size?.width || height !== size.height) {\n setSize({ width, height });\n\n if (props.onLayout) {\n props.onLayout(event);\n }\n }\n };\n\n React.useEffect(() => {\n if (ref.current != null) {\n setSize(getSize());\n }\n }, [ref]);\n\n React.useEffect(() => {\n updateCanvasSize();\n }, [size]);\n\n React.useEffect(() => {\n const canvas = _canvasRef.current;\n if (canvas) {\n updateCanvasSize();\n }\n setRef(props.canvasRef, canvas);\n }, [_canvasRef]);\n\n return (\n <View {...props} pointerEvents=\"box-none\" ref={ref} onLayout={onLayout}>\n <Canvas ref={_canvasRef} pointerEvents={pointerEvents} style={StyleSheet.absoluteFill} />\n {children}\n </View>\n );\n};\n\nexport default CanvasWrapper;\n"]}
1
+ {"version":3,"file":"Canvas.js","sourceRoot":"","sources":["../src/Canvas.tsx"],"names":[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React from 'react';\nimport { findDOMNode } from 'react-dom';\nimport { LayoutChangeEvent, PixelRatio, StyleSheet, View, ViewProps } from 'react-native';\nimport createElement from 'react-native-web/dist/exports/createElement';\n\nfunction getElement(component) {\n try {\n return findDOMNode(component);\n } catch {\n return component;\n }\n}\n\nfunction setRef<T>(refProp: React.Ref<T>, ref: T | null) {\n if (!refProp) return;\n\n if (typeof refProp === 'function') {\n refProp(ref);\n } else if ('current' in refProp) {\n // @ts-ignore\n refProp.current = ref;\n }\n}\n\nconst Canvas = React.forwardRef(\n (props: React.ComponentProps<typeof View>, ref: React.Ref<HTMLCanvasElement>) =>\n createElement('canvas', { ...props, ref })\n);\n\nconst CanvasWrapper: React.FunctionComponent<\n ViewProps & {\n canvasRef: React.Ref<HTMLCanvasElement>;\n }\n> = ({ pointerEvents, children, style, ...props }) => {\n const [size, setSize] = React.useState<{ width: number; height: number } | null>(null);\n\n const ref = React.useRef<View>(null);\n const _canvasRef = React.useRef<HTMLCanvasElement>(null);\n\n function updateCanvasSize(): void {\n const canvas = _canvasRef.current;\n // eslint-disable-next-line no-undef\n if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement) {\n const size = getSize();\n const scale = PixelRatio.get();\n\n canvas.style.width = `${size.width}px`;\n canvas.style.height = `${size.height}px`;\n\n canvas.width = size.width * scale;\n canvas.height = size.height * scale;\n }\n }\n\n function getSize(): { width: number; height: number } {\n if (size) {\n return size;\n } else if (!ref.current || typeof window === 'undefined') {\n return { width: 0, height: 0 };\n }\n const element = getElement(ref.current);\n const { offsetWidth: width = 0, offsetHeight: height = 0 } = element;\n return { width, height };\n }\n\n const onLayout = (event: LayoutChangeEvent) => {\n const {\n nativeEvent: {\n layout: { width, height },\n },\n } = event;\n\n if (width !== size?.width || height !== size.height) {\n setSize({ width, height });\n\n if (props.onLayout) {\n props.onLayout(event);\n }\n }\n };\n\n React.useEffect(() => {\n if (ref.current != null) {\n setSize(getSize());\n }\n }, [ref]);\n\n React.useEffect(() => {\n updateCanvasSize();\n }, [size]);\n\n React.useEffect(() => {\n const canvas = _canvasRef.current;\n if (canvas) {\n updateCanvasSize();\n }\n setRef(props.canvasRef, canvas);\n }, [_canvasRef]);\n\n return (\n <View {...props} style={[styles.wrapper, style]} ref={ref} onLayout={onLayout}>\n <Canvas ref={_canvasRef} pointerEvents={pointerEvents} style={StyleSheet.absoluteFill} />\n {children}\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n wrapper: {\n pointerEvents: 'box-none',\n },\n});\n\nexport default CanvasWrapper;\n"]}
package/build/GLView.js CHANGED
@@ -56,15 +56,16 @@ export class GLView extends React.Component {
56
56
  render() {
57
57
  const { onContextCreate, // eslint-disable-line no-unused-vars
58
58
  msaaSamples, enableExperimentalWorkletSupport, ...viewProps } = this.props;
59
- return (React.createElement(View, { ...viewProps },
60
- React.createElement(NativeView, { ref: this._setNativeRef, style: {
61
- flex: 1,
62
- ...(Platform.OS === 'ios'
63
- ? {
64
- backgroundColor: 'transparent',
65
- }
66
- : {}),
67
- }, onSurfaceCreate: this._onSurfaceCreate, enableExperimentalWorkletSupport: enableExperimentalWorkletSupport, msaaSamples: Platform.OS === 'ios' ? msaaSamples : undefined })));
59
+ return (<View {...viewProps}>
60
+ <NativeView ref={this._setNativeRef} style={{
61
+ flex: 1,
62
+ ...(Platform.OS === 'ios'
63
+ ? {
64
+ backgroundColor: 'transparent',
65
+ }
66
+ : {}),
67
+ }} onSurfaceCreate={this._onSurfaceCreate} enableExperimentalWorkletSupport={enableExperimentalWorkletSupport} msaaSamples={Platform.OS === 'ios' ? msaaSamples : undefined}/>
68
+ </View>);
68
69
  }
69
70
  _setNativeRef = (nativeRef) => {
70
71
  if (this.props.nativeRef_EXPERIMENTAL) {
@@ -1 +1 @@
1
- {"version":3,"file":"GLView.js","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,U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AC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3E,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QAC/C,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;KACjE;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import {\n NativeModulesProxy,\n UnavailabilityError,\n requireNativeModule,\n requireNativeViewManager,\n CodedError,\n} from 'expo-modules-core';\nimport * as React from 'react';\nimport { Platform, View, findNodeHandle } from 'react-native';\n\nimport { configureLogging } from './GLUtils';\nimport {\n ComponentOrHandle,\n SurfaceCreateEvent,\n GLSnapshot,\n ExpoWebGLRenderingContext,\n SnapshotOptions,\n GLViewProps,\n} from './GLView.types';\nimport { createWorkletContextManager } from './GLWorkletContextManager';\n\n// @docsMissing\nexport type WebGLObject = {\n id: number;\n};\n\ndeclare let global: any;\n\nconst ExponentGLObjectManager = requireNativeModule('ExponentGLObjectManager');\nconst { ExponentGLViewManager } = NativeModulesProxy;\n\nconst NativeView = requireNativeViewManager('ExponentGLView');\nconst workletContextManager = createWorkletContextManager();\n\n// @needsAudit\n/**\n * A View that acts as an OpenGL ES render target. On mounting, an OpenGL ES context is created.\n * Its drawing buffer is presented as the contents of the View every frame.\n */\nexport class GLView extends React.Component<GLViewProps> {\n static NativeView: any;\n\n static defaultProps = {\n msaaSamples: 4,\n enableExperimentalWorkletSupport: false,\n };\n\n /**\n * Imperative API that creates headless context which is devoid of underlying view.\n * It's useful for headless rendering or in case you want to keep just one context per application and share it between multiple components.\n * It is slightly faster than usual context as it doesn't swap framebuffers and doesn't present them on the canvas,\n * however it may require you to take a snapshot in order to present its results.\n * Also, keep in mind that you need to set up a viewport and create your own framebuffer and texture that you will be drawing to, before you take a snapshot.\n * @return A promise that resolves to WebGL context object. See [WebGL API](#webgl-api) for more details.\n */\n static async createContextAsync(): Promise<ExpoWebGLRenderingContext> {\n const { exglCtxId } = await ExponentGLObjectManager.createContextAsync();\n return getGl(exglCtxId);\n }\n\n /**\n * Destroys given context.\n * @param exgl WebGL context to destroy.\n * @return A promise that resolves to boolean value that is `true` if given context existed and has been destroyed successfully.\n */\n static async destroyContextAsync(exgl?: ExpoWebGLRenderingContext | number): Promise<boolean> {\n const exglCtxId = getContextId(exgl);\n unregisterGLContext(exglCtxId);\n return ExponentGLObjectManager.destroyContextAsync(exglCtxId);\n }\n\n /**\n * Takes a snapshot of the framebuffer and saves it as a file to app's cache directory.\n * @param exgl WebGL context to take a snapshot from.\n * @param options\n * @return A promise that resolves to `GLSnapshot` object.\n */\n static async takeSnapshotAsync(\n exgl?: ExpoWebGLRenderingContext | number,\n options: SnapshotOptions = {}\n ): Promise<GLSnapshot> {\n const exglCtxId = getContextId(exgl);\n return ExponentGLObjectManager.takeSnapshotAsync(exglCtxId, options);\n }\n\n static getWorkletContext: (contextId: number) => ExpoWebGLRenderingContext | undefined =\n workletContextManager.getContext;\n\n nativeRef: ComponentOrHandle = null;\n exglCtxId?: number;\n\n render() {\n const {\n onContextCreate, // eslint-disable-line no-unused-vars\n msaaSamples,\n enableExperimentalWorkletSupport,\n ...viewProps\n } = this.props;\n\n return (\n <View {...viewProps}>\n <NativeView\n ref={this._setNativeRef}\n style={{\n flex: 1,\n ...(Platform.OS === 'ios'\n ? {\n backgroundColor: 'transparent',\n }\n : {}),\n }}\n onSurfaceCreate={this._onSurfaceCreate}\n enableExperimentalWorkletSupport={enableExperimentalWorkletSupport}\n msaaSamples={Platform.OS === 'ios' ? msaaSamples : undefined}\n />\n </View>\n );\n }\n\n _setNativeRef = (nativeRef: ComponentOrHandle): void => {\n if (this.props.nativeRef_EXPERIMENTAL) {\n this.props.nativeRef_EXPERIMENTAL(nativeRef);\n }\n this.nativeRef = nativeRef;\n };\n\n _onSurfaceCreate = ({ nativeEvent: { exglCtxId } }: SurfaceCreateEvent): void => {\n const gl = getGl(exglCtxId);\n\n this.exglCtxId = exglCtxId;\n\n if (this.props.onContextCreate) {\n this.props.onContextCreate(gl);\n }\n };\n\n componentWillUnmount(): void {\n if (this.exglCtxId) {\n unregisterGLContext(this.exglCtxId);\n }\n }\n\n componentDidUpdate(prevProps: GLViewProps): void {\n if (\n this.props.enableExperimentalWorkletSupport !== prevProps.enableExperimentalWorkletSupport\n ) {\n console.warn('Updating prop enableExperimentalWorkletSupport is not supported');\n }\n }\n\n // @docsMissing\n async startARSessionAsync(): Promise<any> {\n if (!ExponentGLViewManager.startARSessionAsync) {\n throw new UnavailabilityError('expo-gl', 'startARSessionAsync');\n }\n return await ExponentGLViewManager.startARSessionAsync(findNodeHandle(this.nativeRef));\n }\n\n // @docsMissing\n async createCameraTextureAsync(cameraRefOrHandle: ComponentOrHandle): Promise<WebGLTexture> {\n if (!ExponentGLObjectManager.createCameraTextureAsync) {\n throw new UnavailabilityError('expo-gl', 'createCameraTextureAsync');\n }\n\n const { exglCtxId } = this;\n\n if (!exglCtxId) {\n throw new Error(\"GLView's surface is not created yet!\");\n }\n\n const cameraTag = findNodeHandle(cameraRefOrHandle);\n const { exglObjId } = await ExponentGLObjectManager.createCameraTextureAsync(\n exglCtxId,\n cameraTag\n );\n return { id: exglObjId } as WebGLTexture;\n }\n\n // @docsMissing\n async destroyObjectAsync(glObject: WebGLObject): Promise<boolean> {\n if (!ExponentGLObjectManager.destroyObjectAsync) {\n throw new UnavailabilityError('expo-gl', 'destroyObjectAsync');\n }\n return await ExponentGLObjectManager.destroyObjectAsync(glObject.id);\n }\n\n /**\n * Same as static [`takeSnapshotAsync()`](#glviewtakesnapshotasyncgl-options),\n * but uses WebGL context that is associated with the view on which the method is called.\n * @param options\n */\n async takeSnapshotAsync(options: SnapshotOptions = {}): Promise<GLSnapshot> {\n if (!GLView.takeSnapshotAsync) {\n throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');\n }\n const { exglCtxId } = this;\n return await GLView.takeSnapshotAsync(exglCtxId, options);\n }\n}\n\nGLView.NativeView = NativeView;\n\nfunction unregisterGLContext(exglCtxId: number) {\n if (global.__EXGLContexts) {\n delete global.__EXGLContexts[String(exglCtxId)];\n }\n workletContextManager.unregister?.(exglCtxId);\n}\n\n// Get the GL interface from an EXGLContextId\nconst getGl = (exglCtxId: number): ExpoWebGLRenderingContext => {\n if (!global.__EXGLContexts) {\n throw new CodedError(\n 'ERR_GL_NOT_AVAILABLE',\n 'GL is currently not available. (Have you enabled remote debugging? GL is not available while debugging remotely.)'\n );\n }\n const gl = global.__EXGLContexts[String(exglCtxId)];\n\n configureLogging(gl);\n\n return gl;\n};\n\nconst getContextId = (exgl?: ExpoWebGLRenderingContext | number): number => {\n const exglCtxId = exgl && typeof exgl === 'object' ? exgl.contextId : exgl;\n\n if (!exglCtxId || typeof exglCtxId !== 'number') {\n throw new Error(`Invalid EXGLContext id: ${String(exglCtxId)}`);\n }\n return exglCtxId;\n};\n"]}
1
+ {"version":3,"file":"GLView.js","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAS7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AASxE,MAAM,uBAAuB,GAAG,mBAAmB,CAAC,yBAAyB,CAAC,CAAC;AAC/E,MAAM,EAAE,qBAAqB,EAAE,GAAG,kBAAkB,CAAC;AAErD,MAAM,UAAU,GAAG,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;AAC9D,MAAM,qBAAqB,GAAG,2BAA2B,EAAE,CAAC;AAE5D,cAAc;AACd;;;GAGG;AACH,MAAM,OAAO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QAC3B,OAAO,MAAM,MAAM,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;;AAGH,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;AAE/B,SAAS,mBAAmB,CAAC,SAAiB;IAC5C,IAAI,MAAM,CAAC,cAAc,EAAE;QACzB,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;KACjD;IACD,qBAAqB,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,CAAC;AAChD,CAAC;AAED,6CAA6C;AAC7C,MAAM,KAAK,GAAG,CAAC,SAAiB,EAA6B,EAAE;IAC7D,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;QAC1B,MAAM,IAAI,UAAU,CAClB,sBAAsB,EACtB,mHAAmH,CACpH,CAAC;KACH;IACD,MAAM,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAEpD,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAErB,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,IAAyC,EAAU,EAAE;IACzE,MAAM,SAAS,GAAG,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3E,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QAC/C,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;KACjE;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import {\n NativeModulesProxy,\n UnavailabilityError,\n requireNativeModule,\n requireNativeViewManager,\n CodedError,\n} from 'expo-modules-core';\nimport * as React from 'react';\nimport { Platform, View, findNodeHandle } from 'react-native';\n\nimport { configureLogging } from './GLUtils';\nimport {\n ComponentOrHandle,\n SurfaceCreateEvent,\n GLSnapshot,\n ExpoWebGLRenderingContext,\n SnapshotOptions,\n GLViewProps,\n} from './GLView.types';\nimport { createWorkletContextManager } from './GLWorkletContextManager';\n\n// @docsMissing\nexport type WebGLObject = {\n id: number;\n};\n\ndeclare let global: any;\n\nconst ExponentGLObjectManager = requireNativeModule('ExponentGLObjectManager');\nconst { ExponentGLViewManager } = NativeModulesProxy;\n\nconst NativeView = requireNativeViewManager('ExponentGLView');\nconst workletContextManager = createWorkletContextManager();\n\n// @needsAudit\n/**\n * A View that acts as an OpenGL ES render target. On mounting, an OpenGL ES context is created.\n * Its drawing buffer is presented as the contents of the View every frame.\n */\nexport class GLView extends React.Component<GLViewProps> {\n static NativeView: any;\n\n static defaultProps = {\n msaaSamples: 4,\n enableExperimentalWorkletSupport: false,\n };\n\n /**\n * Imperative API that creates headless context which is devoid of underlying view.\n * It's useful for headless rendering or in case you want to keep just one context per application and share it between multiple components.\n * It is slightly faster than usual context as it doesn't swap framebuffers and doesn't present them on the canvas,\n * however it may require you to take a snapshot in order to present its results.\n * Also, keep in mind that you need to set up a viewport and create your own framebuffer and texture that you will be drawing to, before you take a snapshot.\n * @return A promise that resolves to WebGL context object. See [WebGL API](#webgl-api) for more details.\n */\n static async createContextAsync(): Promise<ExpoWebGLRenderingContext> {\n const { exglCtxId } = await ExponentGLObjectManager.createContextAsync();\n return getGl(exglCtxId);\n }\n\n /**\n * Destroys given context.\n * @param exgl WebGL context to destroy.\n * @return A promise that resolves to boolean value that is `true` if given context existed and has been destroyed successfully.\n */\n static async destroyContextAsync(exgl?: ExpoWebGLRenderingContext | number): Promise<boolean> {\n const exglCtxId = getContextId(exgl);\n unregisterGLContext(exglCtxId);\n return ExponentGLObjectManager.destroyContextAsync(exglCtxId);\n }\n\n /**\n * Takes a snapshot of the framebuffer and saves it as a file to app's cache directory.\n * @param exgl WebGL context to take a snapshot from.\n * @param options\n * @return A promise that resolves to `GLSnapshot` object.\n */\n static async takeSnapshotAsync(\n exgl?: ExpoWebGLRenderingContext | number,\n options: SnapshotOptions = {}\n ): Promise<GLSnapshot> {\n const exglCtxId = getContextId(exgl);\n return ExponentGLObjectManager.takeSnapshotAsync(exglCtxId, options);\n }\n\n static getWorkletContext: (contextId: number) => ExpoWebGLRenderingContext | undefined =\n workletContextManager.getContext;\n\n nativeRef: ComponentOrHandle = null;\n exglCtxId?: number;\n\n render() {\n const {\n onContextCreate, // eslint-disable-line no-unused-vars\n msaaSamples,\n enableExperimentalWorkletSupport,\n ...viewProps\n } = this.props;\n\n return (\n <View {...viewProps}>\n <NativeView\n ref={this._setNativeRef}\n style={{\n flex: 1,\n ...(Platform.OS === 'ios'\n ? {\n backgroundColor: 'transparent',\n }\n : {}),\n }}\n onSurfaceCreate={this._onSurfaceCreate}\n enableExperimentalWorkletSupport={enableExperimentalWorkletSupport}\n msaaSamples={Platform.OS === 'ios' ? msaaSamples : undefined}\n />\n </View>\n );\n }\n\n _setNativeRef = (nativeRef: ComponentOrHandle): void => {\n if (this.props.nativeRef_EXPERIMENTAL) {\n this.props.nativeRef_EXPERIMENTAL(nativeRef);\n }\n this.nativeRef = nativeRef;\n };\n\n _onSurfaceCreate = ({ nativeEvent: { exglCtxId } }: SurfaceCreateEvent): void => {\n const gl = getGl(exglCtxId);\n\n this.exglCtxId = exglCtxId;\n\n if (this.props.onContextCreate) {\n this.props.onContextCreate(gl);\n }\n };\n\n componentWillUnmount(): void {\n if (this.exglCtxId) {\n unregisterGLContext(this.exglCtxId);\n }\n }\n\n componentDidUpdate(prevProps: GLViewProps): void {\n if (\n this.props.enableExperimentalWorkletSupport !== prevProps.enableExperimentalWorkletSupport\n ) {\n console.warn('Updating prop enableExperimentalWorkletSupport is not supported');\n }\n }\n\n // @docsMissing\n async startARSessionAsync(): Promise<any> {\n if (!ExponentGLViewManager.startARSessionAsync) {\n throw new UnavailabilityError('expo-gl', 'startARSessionAsync');\n }\n return await ExponentGLViewManager.startARSessionAsync(findNodeHandle(this.nativeRef));\n }\n\n // @docsMissing\n async createCameraTextureAsync(cameraRefOrHandle: ComponentOrHandle): Promise<WebGLTexture> {\n if (!ExponentGLObjectManager.createCameraTextureAsync) {\n throw new UnavailabilityError('expo-gl', 'createCameraTextureAsync');\n }\n\n const { exglCtxId } = this;\n\n if (!exglCtxId) {\n throw new Error(\"GLView's surface is not created yet!\");\n }\n\n const cameraTag = findNodeHandle(cameraRefOrHandle);\n const { exglObjId } = await ExponentGLObjectManager.createCameraTextureAsync(\n exglCtxId,\n cameraTag\n );\n return { id: exglObjId } as WebGLTexture;\n }\n\n // @docsMissing\n async destroyObjectAsync(glObject: WebGLObject): Promise<boolean> {\n if (!ExponentGLObjectManager.destroyObjectAsync) {\n throw new UnavailabilityError('expo-gl', 'destroyObjectAsync');\n }\n return await ExponentGLObjectManager.destroyObjectAsync(glObject.id);\n }\n\n /**\n * Same as static [`takeSnapshotAsync()`](#glviewtakesnapshotasyncgl-options),\n * but uses WebGL context that is associated with the view on which the method is called.\n * @param options\n */\n async takeSnapshotAsync(options: SnapshotOptions = {}): Promise<GLSnapshot> {\n if (!GLView.takeSnapshotAsync) {\n throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');\n }\n const { exglCtxId } = this;\n return await GLView.takeSnapshotAsync(exglCtxId, options);\n }\n}\n\nGLView.NativeView = NativeView;\n\nfunction unregisterGLContext(exglCtxId: number) {\n if (global.__EXGLContexts) {\n delete global.__EXGLContexts[String(exglCtxId)];\n }\n workletContextManager.unregister?.(exglCtxId);\n}\n\n// Get the GL interface from an EXGLContextId\nconst getGl = (exglCtxId: number): ExpoWebGLRenderingContext => {\n if (!global.__EXGLContexts) {\n throw new CodedError(\n 'ERR_GL_NOT_AVAILABLE',\n 'GL is currently not available. (Have you enabled remote debugging? GL is not available while debugging remotely.)'\n );\n }\n const gl = global.__EXGLContexts[String(exglCtxId)];\n\n configureLogging(gl);\n\n return gl;\n};\n\nconst getContextId = (exgl?: ExpoWebGLRenderingContext | number): number => {\n const exglCtxId = exgl && typeof exgl === 'object' ? exgl.contextId : exgl;\n\n if (!exglCtxId || typeof exglCtxId !== 'number') {\n throw new Error(`Invalid EXGLContext id: ${String(exglCtxId)}`);\n }\n return exglCtxId;\n};\n"]}
@@ -116,7 +116,7 @@ export class GLView extends React.Component {
116
116
  const { onContextCreate, onContextRestored, onContextLost, webglContextAttributes, msaaSamples, nativeRef_EXPERIMENTAL,
117
117
  // @ts-ignore: ref does not exist
118
118
  ref, ...domProps } = this.props;
119
- return React.createElement(Canvas, { ...domProps, canvasRef: this.setCanvasRef });
119
+ return <Canvas {...domProps} canvasRef={this.setCanvasRef}/>;
120
120
  }
121
121
  componentDidUpdate(prevProps) {
122
122
  const { webglContextAttributes } = this.props;
@@ -1 +1 @@
1
- {"version":3,"file":"GLView.web.js","sourceRoot":"","sources":["../src/GLView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,MAAM,MAAM,UAAU,CAAC;AAU9B,SAAS,gBAAgB,CAAC,KAIzB;IACC,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,aAAa,EAAE;QACrE,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC;QAClD,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;QAC1B,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC;QACpB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAY;IACrC,OAAO,OAAO,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK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AAC,sBAAsB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAE7E,IAAI,CAAC,YAAY,EAAE,CAAC;SACrB;IACH,CAAC,CAAC;IAEK,KAAK,CAAC,iBAAiB,CAAC,UAA2B,EAAE;QAC1D,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE;YAC7B,MAAM,IAAI,mBAAmB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;SAC/D;QAED,MAAM,EAAE,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACvC,OAAO,MAAM,MAAM,CAAC,iBAAiB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,mBAAmB;QAC9B,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,wBAAwB;QACnC,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,QAAqB;QACnD,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["import { CodedError, Platform, UnavailabilityError } from 'expo-modules-core';\nimport invariant from 'invariant';\nimport * as React from 'react';\nimport { Dimensions } from 'react-native';\n\nimport Canvas from './Canvas';\nimport { WebGLObject } from './GLView';\nimport {\n GLViewProps,\n ExpoWebGLRenderingContext,\n GLSnapshot,\n SnapshotOptions,\n ComponentOrHandle,\n} from './GLView.types';\n\nfunction getImageForAsset(asset: {\n downloadAsync?: () => Promise<any>;\n uri?: string;\n localUri?: string;\n}): HTMLImageElement | any {\n if (asset != null && typeof asset === 'object' && asset.downloadAsync) {\n const dataURI = asset.localUri || asset.uri || '';\n const image = new Image();\n image.src = dataURI;\n return image;\n }\n return asset;\n}\n\nfunction isOffscreenCanvas(element: any): element is OffscreenCanvas {\n return element && typeof element.convertToBlob === 'function';\n}\n\nfunction asExpoContext(gl: ExpoWebGLRenderingContext): WebGLRenderingContext {\n gl.endFrameEXP = function glEndFrameEXP(): void {};\n\n if (!gl['_expo_texImage2D']) {\n gl['_expo_texImage2D'] = gl.texImage2D;\n gl.texImage2D = (...props: any[]): any => {\n const nextProps = [...props];\n nextProps.push(getImageForAsset(nextProps.pop()));\n return gl['_expo_texImage2D'](...nextProps);\n };\n }\n\n if (!gl['_expo_texSubImage2D']) {\n gl['_expo_texSubImage2D'] = gl.texSubImage2D;\n gl.texSubImage2D = (...props: any[]): any => {\n const nextProps = [...props];\n nextProps.push(getImageForAsset(nextProps.pop()));\n return gl['_expo_texSubImage2D'](...nextProps);\n };\n }\n\n return gl;\n}\n\nfunction ensureContext(\n canvas?: HTMLCanvasElement,\n contextAttributes?: WebGLContextAttributes\n): WebGLRenderingContext {\n if (!canvas) {\n throw new CodedError(\n 'ERR_GL_INVALID',\n 'Attempting to use the GL context before it has been created.'\n );\n }\n\n // Apple disables WebGL 2.0 and doesn't provide any way to detect if it's disabled.\n const isIOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);\n\n const context =\n (!isIOS && canvas.getContext('webgl2', contextAttributes)) ||\n canvas.getContext('webgl', contextAttributes) ||\n canvas.getContext('webgl-experimental', contextAttributes) ||\n canvas.getContext('experimental-webgl', contextAttributes);\n invariant(context, 'Browser does not support WebGL');\n return asExpoContext(context as ExpoWebGLRenderingContext);\n}\n\n// @needsAudit @docsMissing\nexport type GLViewWebProps = GLViewProps & {\n onContextCreate: (gl: WebGLRenderingContext) => void;\n onContextRestored?: (gl?: WebGLRenderingContext) => void;\n onContextLost?: () => void;\n webglContextAttributes?: WebGLContextAttributes;\n // type overwrite\n nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | HTMLCanvasElement | null);\n};\n\nasync function getBlobFromWebGLRenderingContext(\n gl: WebGLRenderingContext,\n options: SnapshotOptions = {}\n): Promise<{ width: number; height: number; blob: Blob | null }> {\n invariant(gl, 'getBlobFromWebGLRenderingContext(): WebGL Rendering Context is not defined');\n\n const { canvas } = gl;\n\n let blob: Blob | null = null;\n\n if (typeof (canvas as any).msToBlob === 'function') {\n // @ts-ignore: polyfill: https://stackoverflow.com/a/29815058/4047926\n blob = await canvas.msToBlob();\n } else if (isOffscreenCanvas(canvas)) {\n blob = await canvas.convertToBlob({ quality: options.compress, type: options.format });\n } else {\n blob = await new Promise((resolve) => {\n canvas.toBlob((blob: Blob | null) => resolve(blob), options.format, options.compress);\n });\n }\n\n return {\n blob,\n width: canvas.width,\n height: canvas.height,\n };\n}\n\nexport class GLView extends React.Component<GLViewWebProps> {\n canvas?: HTMLCanvasElement;\n\n gl?: WebGLRenderingContext;\n\n static async createContextAsync(): Promise<WebGLRenderingContext | null> {\n if (!Platform.isDOMAvailable) {\n return null;\n }\n const canvas = document.createElement('canvas');\n const { width, height, scale } = Dimensions.get('window');\n canvas.width = width * scale;\n canvas.height = height * scale;\n return ensureContext(canvas);\n }\n\n static async destroyContextAsync(exgl?: WebGLRenderingContext | number): Promise<boolean> {\n // Do nothing\n return true;\n }\n\n static async takeSnapshotAsync(\n gl: WebGLRenderingContext,\n options: SnapshotOptions = {}\n ): Promise<GLSnapshot> {\n const { blob, width, height } = await getBlobFromWebGLRenderingContext(gl, options);\n\n if (!blob) {\n throw new CodedError('ERR_GL_SNAPSHOT', 'Failed to save the GL context');\n }\n\n return {\n uri: blob,\n localUri: '',\n width,\n height,\n };\n }\n\n componentWillUnmount() {\n if (this.gl) {\n const loseContextExt = this.gl.getExtension('WEBGL_lose_context');\n if (loseContextExt) {\n loseContextExt.loseContext();\n }\n this.gl = undefined;\n }\n if (this.canvas) {\n this.canvas.removeEventListener('webglcontextlost', this.onContextLost);\n this.canvas.removeEventListener('webglcontextrestored', this.onContextRestored);\n }\n }\n\n render() {\n const {\n onContextCreate,\n onContextRestored,\n onContextLost,\n webglContextAttributes,\n msaaSamples,\n nativeRef_EXPERIMENTAL,\n // @ts-ignore: ref does not exist\n ref,\n ...domProps\n } = this.props;\n\n return <Canvas {...domProps} canvasRef={this.setCanvasRef} />;\n }\n\n componentDidUpdate(prevProps) {\n const { webglContextAttributes } = this.props;\n if (this.canvas && webglContextAttributes !== prevProps.webglContextAttributes) {\n this.onContextLost(null);\n this.onContextRestored();\n }\n }\n\n private getGLContextOrReject(): WebGLRenderingContext {\n const gl = this.getGLContext();\n if (!gl) {\n throw new CodedError(\n 'ERR_GL_INVALID',\n 'Attempting to use the GL context before it has been created.'\n );\n }\n return gl;\n }\n\n private onContextLost = (event: Event | null): void => {\n if (event && event.preventDefault) {\n event.preventDefault();\n }\n this.gl = undefined;\n\n if (typeof this.props.onContextLost === 'function') {\n this.props.onContextLost();\n }\n };\n\n private onContextRestored = (): void => {\n this.gl = undefined;\n if (this.getGLContext() == null) {\n throw new CodedError('ERR_GL_INVALID', 'Failed to restore GL context.');\n }\n };\n\n private getGLContext(): WebGLRenderingContext | null {\n if (this.gl) return this.gl;\n\n if (this.canvas) {\n this.gl = ensureContext(this.canvas, this.props.webglContextAttributes);\n if (typeof this.props.onContextCreate === 'function') {\n this.props.onContextCreate(this.gl);\n }\n return this.gl;\n }\n return null;\n }\n\n private setCanvasRef = (canvas: HTMLCanvasElement): void => {\n this.canvas = canvas;\n\n if (typeof this.props.nativeRef_EXPERIMENTAL === 'function') {\n this.props.nativeRef_EXPERIMENTAL(canvas);\n }\n\n if (this.canvas) {\n this.canvas.addEventListener('webglcontextlost', this.onContextLost);\n this.canvas.addEventListener('webglcontextrestored', this.onContextRestored);\n\n this.getGLContext();\n }\n };\n\n public async takeSnapshotAsync(options: SnapshotOptions = {}): Promise<GLSnapshot> {\n if (!GLView.takeSnapshotAsync) {\n throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');\n }\n\n const gl = this.getGLContextOrReject();\n return await GLView.takeSnapshotAsync(gl, options);\n }\n\n public async startARSessionAsync(): Promise<void> {\n throw new UnavailabilityError('GLView', 'startARSessionAsync');\n }\n\n public async createCameraTextureAsync(): Promise<void> {\n throw new UnavailabilityError('GLView', 'createCameraTextureAsync');\n }\n\n public async destroyObjectAsync(glObject: WebGLObject): Promise<void> {\n throw new UnavailabilityError('GLView', 'destroyObjectAsync');\n }\n}\n"]}
1
+ {"version":3,"file":"GLView.web.js","sourceRoot":"","sources":["../src/GLView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,MAAM,MAAM,UAAU,CAAC;AAU9B,SAAS,gBAAgB,CAAC,KAIzB;IACC,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,aAAa,EAAE;QACrE,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC;QAClD,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;QAC1B,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC;QACpB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAY;IACrC,OAAO,OAAO,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,UAAU,CAAC;AAChE,CAAC;AAED,SAAS,aAAa,CAAC,EAA6B;IAClD,EAAE,CAAC,WAAW,GAAG,SAAS,aAAa,KAAU,CAAC,CAAC;IAEnD,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,EAAE;QAC3B,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC;QACvC,EAAE,CAAC,UAAU,GAAG,CAAC,GAAG,KAAY,EAAO,EAAE;YACvC,MAAM,SAAS,GAA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AE,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACvC,OAAO,MAAM,MAAM,CAAC,iBAAiB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,mBAAmB;QAC9B,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,wBAAwB;QACnC,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,QAAqB;QACnD,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["import { CodedError, Platform, UnavailabilityError } from 'expo-modules-core';\nimport invariant from 'invariant';\nimport * as React from 'react';\nimport { Dimensions } from 'react-native';\n\nimport Canvas from './Canvas';\nimport { WebGLObject } from './GLView';\nimport {\n GLViewProps,\n ExpoWebGLRenderingContext,\n GLSnapshot,\n SnapshotOptions,\n ComponentOrHandle,\n} from './GLView.types';\n\nfunction getImageForAsset(asset: {\n downloadAsync?: () => Promise<any>;\n uri?: string;\n localUri?: string;\n}): HTMLImageElement | any {\n if (asset != null && typeof asset === 'object' && asset.downloadAsync) {\n const dataURI = asset.localUri || asset.uri || '';\n const image = new Image();\n image.src = dataURI;\n return image;\n }\n return asset;\n}\n\nfunction isOffscreenCanvas(element: any): element is OffscreenCanvas {\n return element && typeof element.convertToBlob === 'function';\n}\n\nfunction asExpoContext(gl: ExpoWebGLRenderingContext): WebGLRenderingContext {\n gl.endFrameEXP = function glEndFrameEXP(): void {};\n\n if (!gl['_expo_texImage2D']) {\n gl['_expo_texImage2D'] = gl.texImage2D;\n gl.texImage2D = (...props: any[]): any => {\n const nextProps = [...props];\n nextProps.push(getImageForAsset(nextProps.pop()));\n return gl['_expo_texImage2D'](...nextProps);\n };\n }\n\n if (!gl['_expo_texSubImage2D']) {\n gl['_expo_texSubImage2D'] = gl.texSubImage2D;\n gl.texSubImage2D = (...props: any[]): any => {\n const nextProps = [...props];\n nextProps.push(getImageForAsset(nextProps.pop()));\n return gl['_expo_texSubImage2D'](...nextProps);\n };\n }\n\n return gl;\n}\n\nfunction ensureContext(\n canvas?: HTMLCanvasElement,\n contextAttributes?: WebGLContextAttributes\n): WebGLRenderingContext {\n if (!canvas) {\n throw new CodedError(\n 'ERR_GL_INVALID',\n 'Attempting to use the GL context before it has been created.'\n );\n }\n\n // Apple disables WebGL 2.0 and doesn't provide any way to detect if it's disabled.\n const isIOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);\n\n const context =\n (!isIOS && canvas.getContext('webgl2', contextAttributes)) ||\n canvas.getContext('webgl', contextAttributes) ||\n canvas.getContext('webgl-experimental', contextAttributes) ||\n canvas.getContext('experimental-webgl', contextAttributes);\n invariant(context, 'Browser does not support WebGL');\n return asExpoContext(context as ExpoWebGLRenderingContext);\n}\n\n// @needsAudit @docsMissing\nexport type GLViewWebProps = GLViewProps & {\n onContextCreate: (gl: WebGLRenderingContext) => void;\n onContextRestored?: (gl?: WebGLRenderingContext) => void;\n onContextLost?: () => void;\n webglContextAttributes?: WebGLContextAttributes;\n // type overwrite\n nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | HTMLCanvasElement | null);\n};\n\nasync function getBlobFromWebGLRenderingContext(\n gl: WebGLRenderingContext,\n options: SnapshotOptions = {}\n): Promise<{ width: number; height: number; blob: Blob | null }> {\n invariant(gl, 'getBlobFromWebGLRenderingContext(): WebGL Rendering Context is not defined');\n\n const { canvas } = gl;\n\n let blob: Blob | null = null;\n\n if (typeof (canvas as any).msToBlob === 'function') {\n // @ts-ignore: polyfill: https://stackoverflow.com/a/29815058/4047926\n blob = await canvas.msToBlob();\n } else if (isOffscreenCanvas(canvas)) {\n blob = await canvas.convertToBlob({ quality: options.compress, type: options.format });\n } else {\n blob = await new Promise((resolve) => {\n canvas.toBlob((blob: Blob | null) => resolve(blob), options.format, options.compress);\n });\n }\n\n return {\n blob,\n width: canvas.width,\n height: canvas.height,\n };\n}\n\nexport class GLView extends React.Component<GLViewWebProps> {\n canvas?: HTMLCanvasElement;\n\n gl?: WebGLRenderingContext;\n\n static async createContextAsync(): Promise<WebGLRenderingContext | null> {\n if (!Platform.isDOMAvailable) {\n return null;\n }\n const canvas = document.createElement('canvas');\n const { width, height, scale } = Dimensions.get('window');\n canvas.width = width * scale;\n canvas.height = height * scale;\n return ensureContext(canvas);\n }\n\n static async destroyContextAsync(exgl?: WebGLRenderingContext | number): Promise<boolean> {\n // Do nothing\n return true;\n }\n\n static async takeSnapshotAsync(\n gl: WebGLRenderingContext,\n options: SnapshotOptions = {}\n ): Promise<GLSnapshot> {\n const { blob, width, height } = await getBlobFromWebGLRenderingContext(gl, options);\n\n if (!blob) {\n throw new CodedError('ERR_GL_SNAPSHOT', 'Failed to save the GL context');\n }\n\n return {\n uri: blob,\n localUri: '',\n width,\n height,\n };\n }\n\n componentWillUnmount() {\n if (this.gl) {\n const loseContextExt = this.gl.getExtension('WEBGL_lose_context');\n if (loseContextExt) {\n loseContextExt.loseContext();\n }\n this.gl = undefined;\n }\n if (this.canvas) {\n this.canvas.removeEventListener('webglcontextlost', this.onContextLost);\n this.canvas.removeEventListener('webglcontextrestored', this.onContextRestored);\n }\n }\n\n render() {\n const {\n onContextCreate,\n onContextRestored,\n onContextLost,\n webglContextAttributes,\n msaaSamples,\n nativeRef_EXPERIMENTAL,\n // @ts-ignore: ref does not exist\n ref,\n ...domProps\n } = this.props;\n\n return <Canvas {...domProps} canvasRef={this.setCanvasRef} />;\n }\n\n componentDidUpdate(prevProps) {\n const { webglContextAttributes } = this.props;\n if (this.canvas && webglContextAttributes !== prevProps.webglContextAttributes) {\n this.onContextLost(null);\n this.onContextRestored();\n }\n }\n\n private getGLContextOrReject(): WebGLRenderingContext {\n const gl = this.getGLContext();\n if (!gl) {\n throw new CodedError(\n 'ERR_GL_INVALID',\n 'Attempting to use the GL context before it has been created.'\n );\n }\n return gl;\n }\n\n private onContextLost = (event: Event | null): void => {\n if (event && event.preventDefault) {\n event.preventDefault();\n }\n this.gl = undefined;\n\n if (typeof this.props.onContextLost === 'function') {\n this.props.onContextLost();\n }\n };\n\n private onContextRestored = (): void => {\n this.gl = undefined;\n if (this.getGLContext() == null) {\n throw new CodedError('ERR_GL_INVALID', 'Failed to restore GL context.');\n }\n };\n\n private getGLContext(): WebGLRenderingContext | null {\n if (this.gl) return this.gl;\n\n if (this.canvas) {\n this.gl = ensureContext(this.canvas, this.props.webglContextAttributes);\n if (typeof this.props.onContextCreate === 'function') {\n this.props.onContextCreate(this.gl);\n }\n return this.gl;\n }\n return null;\n }\n\n private setCanvasRef = (canvas: HTMLCanvasElement): void => {\n this.canvas = canvas;\n\n if (typeof this.props.nativeRef_EXPERIMENTAL === 'function') {\n this.props.nativeRef_EXPERIMENTAL(canvas);\n }\n\n if (this.canvas) {\n this.canvas.addEventListener('webglcontextlost', this.onContextLost);\n this.canvas.addEventListener('webglcontextrestored', this.onContextRestored);\n\n this.getGLContext();\n }\n };\n\n public async takeSnapshotAsync(options: SnapshotOptions = {}): Promise<GLSnapshot> {\n if (!GLView.takeSnapshotAsync) {\n throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');\n }\n\n const gl = this.getGLContextOrReject();\n return await GLView.takeSnapshotAsync(gl, options);\n }\n\n public async startARSessionAsync(): Promise<void> {\n throw new UnavailabilityError('GLView', 'startARSessionAsync');\n }\n\n public async createCameraTextureAsync(): Promise<void> {\n throw new UnavailabilityError('GLView', 'createCameraTextureAsync');\n }\n\n public async destroyObjectAsync(glObject: WebGLObject): Promise<void> {\n throw new UnavailabilityError('GLView', 'destroyObjectAsync');\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-gl",
3
- "version": "13.3.0",
3
+ "version": "13.5.0",
4
4
  "description": "Provides GLView that acts as OpenGL ES render target and gives GL context object implementing WebGL 2.0 specification.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -49,5 +49,5 @@
49
49
  "peerDependencies": {
50
50
  "expo": "*"
51
51
  },
52
- "gitHead": "ee2c866ba3c7fbc35ff2a3e896041cf15d3bd7c5"
52
+ "gitHead": "3142a086578deffd8704a8f1b6f0f661527d836c"
53
53
  }
package/src/Canvas.tsx CHANGED
@@ -1,4 +1,3 @@
1
- import { Platform } from 'expo-modules-core';
2
1
  import * as React from 'react';
3
2
  import { findDOMNode } from 'react-dom';
4
3
  import { LayoutChangeEvent, PixelRatio, StyleSheet, View, ViewProps } from 'react-native';
@@ -32,7 +31,7 @@ const CanvasWrapper: React.FunctionComponent<
32
31
  ViewProps & {
33
32
  canvasRef: React.Ref<HTMLCanvasElement>;
34
33
  }
35
- > = ({ pointerEvents, children, ...props }) => {
34
+ > = ({ pointerEvents, children, style, ...props }) => {
36
35
  const [size, setSize] = React.useState<{ width: number; height: number } | null>(null);
37
36
 
38
37
  const ref = React.useRef<View>(null);
@@ -56,7 +55,7 @@ const CanvasWrapper: React.FunctionComponent<
56
55
  function getSize(): { width: number; height: number } {
57
56
  if (size) {
58
57
  return size;
59
- } else if (!ref.current || !Platform.isDOMAvailable) {
58
+ } else if (!ref.current || typeof window === 'undefined') {
60
59
  return { width: 0, height: 0 };
61
60
  }
62
61
  const element = getElement(ref.current);
@@ -99,11 +98,17 @@ const CanvasWrapper: React.FunctionComponent<
99
98
  }, [_canvasRef]);
100
99
 
101
100
  return (
102
- <View {...props} pointerEvents="box-none" ref={ref} onLayout={onLayout}>
101
+ <View {...props} style={[styles.wrapper, style]} ref={ref} onLayout={onLayout}>
103
102
  <Canvas ref={_canvasRef} pointerEvents={pointerEvents} style={StyleSheet.absoluteFill} />
104
103
  {children}
105
104
  </View>
106
105
  );
107
106
  };
108
107
 
108
+ const styles = StyleSheet.create({
109
+ wrapper: {
110
+ pointerEvents: 'box-none',
111
+ },
112
+ });
113
+
109
114
  export default CanvasWrapper;
@@ -1,62 +0,0 @@
1
- # Remove this legacy folder when we drop SDK 47
2
- cmake_minimum_required(VERSION 3.4.1)
3
-
4
- project(expo-gl)
5
-
6
- set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7
- set(CMAKE_VERBOSE_MAKEFILE ON)
8
- set(CMAKE_CXX_STANDARD 17)
9
-
10
- set(PACKAGE_NAME "expo-gl")
11
- set(BUILD_DIR ${CMAKE_SOURCE_DIR}/../build)
12
- set(COMMON_DIR ${CMAKE_SOURCE_DIR}/../../common)
13
-
14
- add_library(
15
- ${PACKAGE_NAME} SHARED
16
- ${COMMON_DIR}/EXGLNativeApi.cpp
17
- ${COMMON_DIR}/EXGLNativeApi.h
18
- ${COMMON_DIR}/EXGLImageUtils.cpp
19
- ${COMMON_DIR}/EXGLImageUtils.h
20
- ${COMMON_DIR}/EXGLNativeContext.cpp
21
- ${COMMON_DIR}/EXGLNativeContext.h
22
- ${COMMON_DIR}/EXGLContextManager.cpp
23
- ${COMMON_DIR}/EXGLContextManager.h
24
- ${COMMON_DIR}/EXWebGLMethods.cpp
25
- ${COMMON_DIR}/EXWebGLMethods.h
26
- ${COMMON_DIR}/EXWebGLRenderer.cpp
27
- ${COMMON_DIR}/EXWebGLRenderer.h
28
- ${COMMON_DIR}/EXTypedArrayApi.cpp
29
- ${COMMON_DIR}/EXTypedArrayApi.h
30
- ../src/main/cpp/EXGLJniApi.cpp)
31
-
32
- # Extracted AAR: ${BUILD_DIR}/react-native-0*/jni/${ANDROID_ABI}
33
- file(GLOB LIBRN_DIR "${RN_SO_DIR}/${ANDROID_ABI}")
34
- if(NOT LIBRN_DIR)
35
- # If /${ANDROID_ABI} dir not found, then ${RN_SO_DIR} is probably:
36
- # ReactAndroid/build/react-ndk/exported
37
- file(GLOB LIBRN_DIR "${RN_SO_DIR}")
38
- endif()
39
-
40
- target_include_directories(
41
- ${PACKAGE_NAME} PRIVATE "${REACT_NATIVE_DIR}/ReactCommon/jsi"
42
- "${COMMON_DIR}")
43
-
44
- find_library(
45
- JSI_LIB jsi
46
- PATHS ${LIBRN_DIR}
47
- NO_CMAKE_FIND_ROOT_PATH)
48
-
49
- find_library(LOG_LIB log)
50
- find_library(GLES_LIB GLESv3)
51
-
52
- target_compile_options(
53
- ${PACKAGE_NAME}
54
- PRIVATE -O2
55
- -fexceptions
56
- -frtti
57
- -Wall
58
- -Wextra
59
- -Wno-unused-parameter
60
- -Wshorten-64-to-32
61
- -Wstrict-prototypes)
62
- target_link_libraries(${PACKAGE_NAME} ${JSI_LIB} ${LOG_LIB} ${GLES_LIB} android)