expo-gl 15.1.1 → 15.1.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.
- package/CHANGELOG.md +8 -0
- package/android/build.gradle +2 -2
- package/build/Canvas.d.ts.map +1 -1
- package/build/Canvas.js +25 -22
- package/build/Canvas.js.map +1 -1
- package/build/GLErrors.d.ts +2 -2
- package/build/GLErrors.d.ts.map +1 -1
- package/build/GLErrors.js +2 -1
- package/build/GLErrors.js.map +1 -1
- package/build/GLUtils.d.ts.map +1 -1
- package/build/GLUtils.js +11 -10
- package/build/GLUtils.js.map +1 -1
- package/build/GLView.types.d.ts +4 -1
- package/build/GLView.types.d.ts.map +1 -1
- package/build/GLView.types.js.map +1 -1
- package/build/GLView.web.d.ts +2 -2
- package/build/GLView.web.d.ts.map +1 -1
- package/build/GLView.web.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/{15.1.1/expo.modules.gl-15.1.1.module → 15.1.3/expo.modules.gl-15.1.3.module} +17 -17
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/{15.1.1/expo.modules.gl-15.1.1.pom → 15.1.3/expo.modules.gl-15.1.3.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.sha512 +1 -1
- package/package.json +3 -3
- package/src/Canvas.tsx +52 -36
- package/src/GLErrors.ts +3 -1
- package/src/GLUtils.ts +13 -11
- package/src/GLView.types.ts +5 -1
- package/src/GLView.web.tsx +4 -4
- package/src/ts-declarations/react-native-web.d.ts +3 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.pom.sha512 +0 -1
- /package/local-maven-repo/host/exp/exponent/expo.modules.gl/{15.1.1/expo.modules.gl-15.1.1-sources.jar → 15.1.3/expo.modules.gl-15.1.3-sources.jar} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.gl/{15.1.1/expo.modules.gl-15.1.1-sources.jar.md5 → 15.1.3/expo.modules.gl-15.1.3-sources.jar.md5} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.gl/{15.1.1/expo.modules.gl-15.1.1-sources.jar.sha1 → 15.1.3/expo.modules.gl-15.1.3-sources.jar.sha1} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.gl/{15.1.1/expo.modules.gl-15.1.1-sources.jar.sha256 → 15.1.3/expo.modules.gl-15.1.3-sources.jar.sha256} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.gl/{15.1.1/expo.modules.gl-15.1.1-sources.jar.sha512 → 15.1.3/expo.modules.gl-15.1.3-sources.jar.sha512} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 15.1.3 — 2025-04-21
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 15.1.2 — 2025-04-14
|
|
18
|
+
|
|
19
|
+
_This version does not introduce any user-facing changes._
|
|
20
|
+
|
|
13
21
|
## 15.1.1 — 2025-04-09
|
|
14
22
|
|
|
15
23
|
_This version does not introduce any user-facing changes._
|
package/android/build.gradle
CHANGED
|
@@ -9,7 +9,7 @@ def reactNativeArchitectures() {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
group = 'host.exp.exponent'
|
|
12
|
-
version = '15.1.
|
|
12
|
+
version = '15.1.3'
|
|
13
13
|
|
|
14
14
|
android {
|
|
15
15
|
if (rootProject.hasProperty("ndkPath")) {
|
|
@@ -22,7 +22,7 @@ android {
|
|
|
22
22
|
namespace "expo.modules.gl"
|
|
23
23
|
defaultConfig {
|
|
24
24
|
versionCode 31
|
|
25
|
-
versionName "15.1.
|
|
25
|
+
versionName "15.1.3"
|
|
26
26
|
|
|
27
27
|
externalNativeBuild {
|
|
28
28
|
cmake {
|
package/build/Canvas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAgD1F,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAC1C,SAAS,GAAG;IACV,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;CACzC,CAmEF,CAAC;AAQF,eAAe,aAAa,CAAC"}
|
package/build/Canvas.js
CHANGED
|
@@ -21,45 +21,48 @@ function setRef(refProp, ref) {
|
|
|
21
21
|
refProp.current = ref;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
function getSize({ size, ref }) {
|
|
25
|
+
if (size) {
|
|
26
|
+
return size;
|
|
27
|
+
}
|
|
28
|
+
else if (!ref.current || typeof window === 'undefined') {
|
|
29
|
+
return { width: 0, height: 0 };
|
|
30
|
+
}
|
|
31
|
+
const element = getElement(ref.current);
|
|
32
|
+
const { offsetWidth: width = 0, offsetHeight: height = 0 } = element;
|
|
33
|
+
return { width, height };
|
|
34
|
+
}
|
|
24
35
|
const Canvas = React.forwardRef((props, ref) => createElement('canvas', { ...props, ref }));
|
|
25
36
|
const CanvasWrapper = ({ pointerEvents, children, style, ...props }) => {
|
|
26
37
|
const [size, setSize] = React.useState(null);
|
|
27
38
|
const ref = React.useRef(null);
|
|
28
39
|
const _canvasRef = React.useRef(null);
|
|
29
|
-
|
|
40
|
+
const updateCanvasSize = React.useCallback(() => {
|
|
30
41
|
const canvas = _canvasRef.current;
|
|
31
42
|
if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement) {
|
|
32
|
-
const
|
|
43
|
+
const currentSize = getSize({
|
|
44
|
+
size,
|
|
45
|
+
ref,
|
|
46
|
+
});
|
|
33
47
|
const scale = PixelRatio.get();
|
|
34
|
-
canvas.style.width = `${
|
|
35
|
-
canvas.style.height = `${
|
|
36
|
-
canvas.width =
|
|
37
|
-
canvas.height =
|
|
48
|
+
canvas.style.width = `${currentSize.width}px`;
|
|
49
|
+
canvas.style.height = `${currentSize.height}px`;
|
|
50
|
+
canvas.width = currentSize.width * scale;
|
|
51
|
+
canvas.height = currentSize.height * scale;
|
|
38
52
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (size) {
|
|
42
|
-
return size;
|
|
43
|
-
}
|
|
44
|
-
else if (!ref.current || typeof window === 'undefined') {
|
|
45
|
-
return { width: 0, height: 0 };
|
|
46
|
-
}
|
|
47
|
-
const element = getElement(ref.current);
|
|
48
|
-
const { offsetWidth: width = 0, offsetHeight: height = 0 } = element;
|
|
49
|
-
return { width, height };
|
|
50
|
-
}
|
|
51
|
-
const onLayout = (event) => {
|
|
53
|
+
}, [size?.width, size?.height]);
|
|
54
|
+
const onLayout = React.useCallback((event) => {
|
|
52
55
|
const { nativeEvent: { layout: { width, height }, }, } = event;
|
|
53
|
-
if (width !== size?.width || height !== size
|
|
56
|
+
if (width !== size?.width || height !== size?.height) {
|
|
54
57
|
setSize({ width, height });
|
|
55
58
|
if (props.onLayout) {
|
|
56
59
|
props.onLayout(event);
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
|
-
};
|
|
62
|
+
}, [size?.width, size?.height, props.onLayout]);
|
|
60
63
|
React.useEffect(() => {
|
|
61
64
|
if (ref.current != null) {
|
|
62
|
-
setSize(getSize());
|
|
65
|
+
setSize(getSize({ size, ref }));
|
|
63
66
|
}
|
|
64
67
|
}, [ref]);
|
|
65
68
|
React.useEffect(() => {
|
package/build/Canvas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.js","sourceRoot":"","sources":["../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAqB,UAAU,EAAE,UAAU,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;AAC1F,OAAO,aAAa,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"Canvas.js","sourceRoot":"","sources":["../src/Canvas.tsx"],"names":[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CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAC5E;MAAA,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,EACtF;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE;QACP,aAAa,EAAE,UAAU;KAC1B;CACF,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC","sourcesContent":["import * 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\ninterface Size {\n width: number;\n height: number;\n}\n\ninterface GetSizeParams {\n size: Size | null;\n ref: React.RefObject<View | null>;\n}\n\nfunction getElement(component: React.ReactInstance): React.ReactInstance | Element | null | Text {\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\nfunction getSize({ size, ref }: GetSizeParams): Size {\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 as HTMLElement;\n return { width, height };\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<Size | null>(null);\n\n const ref = React.useRef<View>(null);\n const _canvasRef = React.useRef<HTMLCanvasElement>(null);\n\n const updateCanvasSize = React.useCallback(() => {\n const canvas = _canvasRef.current;\n if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement) {\n const currentSize = getSize({\n size,\n ref,\n });\n const scale = PixelRatio.get();\n\n canvas.style.width = `${currentSize.width}px`;\n canvas.style.height = `${currentSize.height}px`;\n\n canvas.width = currentSize.width * scale;\n canvas.height = currentSize.height * scale;\n }\n }, [size?.width, size?.height]);\n\n const onLayout = React.useCallback(\n (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 [size?.width, size?.height, props.onLayout]\n );\n\n React.useEffect(() => {\n if (ref.current != null) {\n setSize(getSize({ size, ref }));\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/GLErrors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
declare const GLErrors: {
|
|
2
2
|
1280: string;
|
|
3
3
|
1281: string;
|
|
4
4
|
1282: string;
|
|
@@ -6,5 +6,5 @@ declare const _default: {
|
|
|
6
6
|
1286: string;
|
|
7
7
|
37442: string;
|
|
8
8
|
};
|
|
9
|
-
export default
|
|
9
|
+
export default GLErrors;
|
|
10
10
|
//# sourceMappingURL=GLErrors.d.ts.map
|
package/build/GLErrors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLErrors.d.ts","sourceRoot":"","sources":["../src/GLErrors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GLErrors.d.ts","sourceRoot":"","sources":["../src/GLErrors.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,QAAQ;;;;;;;CAOb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/build/GLErrors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const GLErrors = {
|
|
2
2
|
1280: 'INVALID ENUM: An unacceptable value has been specified for an enumerated argument.',
|
|
3
3
|
1281: 'INVALID_VALUE: A numeric argument is out of range.',
|
|
4
4
|
1282: 'INVALID_OPERATION: The specified command is not allowed for the current state.',
|
|
@@ -6,4 +6,5 @@ export default {
|
|
|
6
6
|
1286: 'INVALID_FRAMEBUFFER_OPERATION: The currently bound framebuffer is not complete when trying to render to or to read from it.',
|
|
7
7
|
37442: 'CONTEXT_LOST_WEBGL: The WebGL context is lost.',
|
|
8
8
|
};
|
|
9
|
+
export default GLErrors;
|
|
9
10
|
//# sourceMappingURL=GLErrors.js.map
|
package/build/GLErrors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLErrors.js","sourceRoot":"","sources":["../src/GLErrors.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"GLErrors.js","sourceRoot":"","sources":["../src/GLErrors.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG;IACf,IAAI,EAAE,oFAAoF;IAC1F,IAAI,EAAE,oDAAoD;IAC1D,IAAI,EAAE,gFAAgF;IACtF,IAAI,EAAE,kEAAkE;IACxE,IAAI,EAAE,6HAA6H;IACnI,KAAK,EAAE,gDAAgD;CACxD,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["const GLErrors = {\n 1280: 'INVALID ENUM: An unacceptable value has been specified for an enumerated argument.',\n 1281: 'INVALID_VALUE: A numeric argument is out of range.',\n 1282: 'INVALID_OPERATION: The specified command is not allowed for the current state.',\n 1285: 'OUT_OF_MEMORY: Not enough memory is left to execute the command.',\n 1286: 'INVALID_FRAMEBUFFER_OPERATION: The currently bound framebuffer is not complete when trying to render to or to read from it.',\n 37442: 'CONTEXT_LOST_WEBGL: The WebGL context is lost.',\n};\n\nexport default GLErrors;\n"]}
|
package/build/GLUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLUtils.d.ts","sourceRoot":"","sources":["../src/GLUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAmB,MAAM,gBAAgB,CAAC;AAO5E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,yBAAyB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"GLUtils.d.ts","sourceRoot":"","sources":["../src/GLUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAmB,MAAM,gBAAgB,CAAC;AAO5E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,yBAAyB,GAAG,IAAI,CAkFpE"}
|
package/build/GLUtils.js
CHANGED
|
@@ -17,30 +17,31 @@ export function configureLogging(gl) {
|
|
|
17
17
|
loggingOption = option;
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
+
const __gl = gl;
|
|
20
21
|
// Turn off logging.
|
|
21
22
|
if (option === GLLoggingOption.DISABLED || !option) {
|
|
22
|
-
Object.entries(
|
|
23
|
+
Object.entries(__gl).forEach(([key, value]) => {
|
|
23
24
|
if (typeof value === 'function' && value.__logWrapper) {
|
|
24
|
-
delete
|
|
25
|
+
delete __gl[key];
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
28
|
loggingOption = option;
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
// Turn on logging.
|
|
31
|
-
Object.entries(Object.getPrototypeOf(
|
|
32
|
+
Object.entries(Object.getPrototypeOf(__gl)).forEach(([key, originalValue]) => {
|
|
32
33
|
if (typeof originalValue !== 'function' || key === '__expoSetLogging') {
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
__gl[key] = (...args) => {
|
|
36
37
|
if (loggingOption & GLLoggingOption.METHOD_CALLS) {
|
|
37
38
|
const params = args.map((arg) => {
|
|
38
39
|
// If the type is `number`, then try to find name of the constant that has such value,
|
|
39
40
|
// so it's easier to read these logs. In some cases it might be misleading
|
|
40
41
|
// if the parameter is for example a width or height, so the number is still logged.
|
|
41
42
|
if (loggingOption & GLLoggingOption.RESOLVE_CONSTANTS && typeof arg === 'number') {
|
|
42
|
-
for (const prop in
|
|
43
|
-
if (
|
|
43
|
+
for (const prop in __gl) {
|
|
44
|
+
if (__gl[prop] === arg) {
|
|
44
45
|
return `${arg} (${prop})`;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -58,20 +59,20 @@ export function configureLogging(gl) {
|
|
|
58
59
|
});
|
|
59
60
|
console.log(`ExpoGL: ${key}(${params.join(', ')})`);
|
|
60
61
|
}
|
|
61
|
-
const result = originalValue.apply(
|
|
62
|
+
const result = originalValue.apply(__gl, args);
|
|
62
63
|
if (loggingOption & GLLoggingOption.METHOD_CALLS) {
|
|
63
64
|
console.log(`ExpoGL: = ${result}`);
|
|
64
65
|
}
|
|
65
66
|
if (loggingOption & GLLoggingOption.GET_ERRORS && key !== 'getError') {
|
|
66
67
|
// @ts-ignore We need to call into the original `getError`.
|
|
67
68
|
// eslint-disable-next-line no-proto
|
|
68
|
-
const error =
|
|
69
|
-
if (error && error !==
|
|
69
|
+
const error = __gl.__proto__.getError.call(__gl);
|
|
70
|
+
if (error && error !== __gl.NO_ERROR) {
|
|
70
71
|
// `console.error` would cause a red screen, so let's just log with red color.
|
|
71
72
|
console.log(`\x1b[31mExpoGL: Error ${GLErrors[error]}\x1b[0m`);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
__gl[key].__logWrapper = true;
|
|
75
76
|
return result;
|
|
76
77
|
};
|
|
77
78
|
});
|
package/build/GLUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLUtils.js","sourceRoot":"","sources":["../src/GLUtils.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAA6B,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;GAEG;AACH,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAA6B;IAC5D,kDAAkD;IAClD,IAAI,aAAa,GAAG,eAAe,CAAC,QAAQ,CAAC;IAE7C,EAAE,CAAC,gBAAgB,GAAG,CAAC,MAAuB,EAAQ,EAAE;QACtD,kEAAkE;QAClE,0DAA0D;QAC1D,IAAI,CAAC,aAAa,KAAK,CAAC,MAAM,EAAE,CAAC;YAC/B,aAAa,GAAG,MAAM,CAAC;YACvB,OAAO;QACT,CAAC;QAED,oBAAoB;QACpB,IAAI,MAAM,KAAK,eAAe,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YACnD,MAAM,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"GLUtils.js","sourceRoot":"","sources":["../src/GLUtils.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAA6B,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;GAEG;AACH,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAA6B;IAC5D,kDAAkD;IAClD,IAAI,aAAa,GAAG,eAAe,CAAC,QAAQ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oBAEjD,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACrC,8EAA8E;wBAC9E,OAAO,CAAC,GAAG,CAAC,yBAAyB,QAAQ,CAAC,KAA8B,CAAC,SAAS,CAAC,CAAC;oBAC1F,CAAC;gBACH,CAAC;gBACD,IAAI,CAAC,GAAG,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC;gBAC9B,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,aAAa,GAAG,MAAM,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import GLErrors from './GLErrors';\nimport { ExpoWebGLRenderingContext, GLLoggingOption } from './GLView.types';\n\n/**\n * Maximum length of the strings printed to the console.\n */\nconst MAX_STRING_LENGTH = 20;\n\n/**\n * Sets up `__expoSetLogging` method providing some logging options useful when debugging GL calls.\n */\nexport function configureLogging(gl: ExpoWebGLRenderingContext): void {\n // Enable/disable logging of all GL function calls\n let loggingOption = GLLoggingOption.DISABLED;\n\n gl.__expoSetLogging = (option: GLLoggingOption): void => {\n // If boolean values are the same, just change the internal value,\n // there is no need to wrap/unwrap functions in this case.\n if (!loggingOption === !option) {\n loggingOption = option;\n return;\n }\n\n const __gl = gl as Record<keyof typeof gl | string, any>;\n\n // Turn off logging.\n if (option === GLLoggingOption.DISABLED || !option) {\n Object.entries(__gl).forEach(([key, value]) => {\n if (typeof value === 'function' && value.__logWrapper) {\n delete __gl[key];\n }\n });\n loggingOption = option;\n return;\n }\n\n // Turn on logging.\n Object.entries(Object.getPrototypeOf(__gl)).forEach(([key, originalValue]) => {\n if (typeof originalValue !== 'function' || key === '__expoSetLogging') {\n return;\n }\n\n __gl[key] = (...args: any[]) => {\n if (loggingOption & GLLoggingOption.METHOD_CALLS) {\n const params = args.map((arg) => {\n // If the type is `number`, then try to find name of the constant that has such value,\n // so it's easier to read these logs. In some cases it might be misleading\n // if the parameter is for example a width or height, so the number is still logged.\n if (loggingOption & GLLoggingOption.RESOLVE_CONSTANTS && typeof arg === 'number') {\n for (const prop in __gl) {\n if (__gl[prop] === arg) {\n return `${arg} (${prop})`;\n }\n }\n }\n\n // Truncate strings so they don't produce too much output and don't block the bridge.\n // It mostly applies to shaders which might be very long...\n if (loggingOption & GLLoggingOption.TRUNCATE_STRINGS && typeof arg === 'string') {\n if (arg.length > MAX_STRING_LENGTH) {\n const lastIndex = arg.lastIndexOf(' ', MAX_STRING_LENGTH);\n return arg.substr(0, lastIndex >= 0 ? lastIndex : MAX_STRING_LENGTH) + '...';\n }\n }\n\n // Just return the parameter as a string.\n return '' + arg;\n });\n console.log(`ExpoGL: ${key}(${params.join(', ')})`);\n }\n\n const result = originalValue.apply(__gl, args);\n\n if (loggingOption & GLLoggingOption.METHOD_CALLS) {\n console.log(`ExpoGL: = ${result}`);\n }\n if (loggingOption & GLLoggingOption.GET_ERRORS && key !== 'getError') {\n // @ts-ignore We need to call into the original `getError`.\n // eslint-disable-next-line no-proto\n const error = __gl.__proto__.getError.call(__gl);\n\n if (error && error !== __gl.NO_ERROR) {\n // `console.error` would cause a red screen, so let's just log with red color.\n console.log(`\\x1b[31mExpoGL: Error ${GLErrors[error as keyof typeof GLErrors]}\\x1b[0m`);\n }\n }\n __gl[key].__logWrapper = true;\n return result;\n };\n });\n\n loggingOption = option;\n };\n}\n"]}
|
package/build/GLView.types.d.ts
CHANGED
|
@@ -63,6 +63,9 @@ export interface ExpoWebGLRenderingContext extends WebGL2RenderingContext {
|
|
|
63
63
|
endFrameEXP(): void;
|
|
64
64
|
flushEXP(): void;
|
|
65
65
|
__expoSetLogging(option: GLLoggingOption): void;
|
|
66
|
+
/** @internal */
|
|
67
|
+
_expo_texSubImage2D?(...props: any[]): void;
|
|
68
|
+
_expo_texImage2D?(...props: any[]): void;
|
|
66
69
|
}
|
|
67
70
|
export type ComponentOrHandle = null | number | Component<any, any> | ComponentClass<any>;
|
|
68
71
|
export type GLViewProps = {
|
|
@@ -87,7 +90,7 @@ export type GLViewProps = {
|
|
|
87
90
|
* @hidden
|
|
88
91
|
* A ref callback for the native GLView
|
|
89
92
|
*/
|
|
90
|
-
nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | null):
|
|
93
|
+
nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | null): void;
|
|
91
94
|
} & ViewProps;
|
|
92
95
|
export declare enum GLLoggingOption {
|
|
93
96
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLView.types.d.ts","sourceRoot":"","sources":["../src/GLView.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE;QACX,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B;;OAEG;IACH,IAAI,CAAC,EAAE;QACL,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MA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,EAAE,MAAM,CAAC;IAClB,WAAW,IAAI,IAAI,CAAC;IACpB,QAAQ,IAAI,IAAI,CAAC;IACjB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAEhD,gBAAgB;IAChB,mBAAmB,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5C,gBAAgB,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC1C;AAGD,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;AAG1F,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACrD;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,gCAAgC,EAAE,OAAO,CAAC;IAC1C;;;OAGG;IACH,sBAAsB,CAAC,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAAC;CACnE,GAAG,SAAS,CAAC;AAGd,oBAAY,eAAe;IACzB;;OAEG;IACH,QAAQ,IAAI;IACZ;;OAEG;IACH,YAAY,IAAI;IAChB;;;OAGG;IACH,UAAU,IAAI;IACd;;OAEG;IACH,iBAAiB,IAAI;IACrB;;;OAGG;IACH,gBAAgB,IAAI;IACpB;;OAEG;IACH,GAAG,KAAmE;CACvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLView.types.js","sourceRoot":"","sources":["../src/GLView.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GLView.types.js","sourceRoot":"","sources":["../src/GLView.types.ts"],"names":[],"mappings":"AA4GA,cAAc;AACd,MAAM,CAAN,IAAY,eA2BX;AA3BD,WAAY,eAAe;IACzB;;OAEG;IACH,6DAAY,CAAA;IACZ;;OAEG;IACH,qEAAgB,CAAA;IAChB;;;OAGG;IACH,iEAAc,CAAA;IACd;;OAEG;IACH,+EAAqB,CAAA;IACrB;;;OAGG;IACH,6EAAoB,CAAA;IACpB;;OAEG;IACH,oDAAsE,CAAA;AACxE,CAAC,EA3BW,eAAe,KAAf,eAAe,QA2B1B","sourcesContent":["import { Component, ComponentClass } from 'react';\nimport { ViewProps } from 'react-native';\n\n// @docsMissing\nexport type SurfaceCreateEvent = {\n nativeEvent: {\n exglCtxId: number;\n };\n};\n\n// @needsAudit\nexport type SnapshotOptions = {\n /**\n * Whether to flip the snapshot vertically.\n * @default false\n */\n flip?: boolean;\n /**\n * Specify the framebuffer that we will be reading from.\n * Defaults to underlying framebuffer that is presented in the view or the current framebuffer if context is headless.\n */\n framebuffer?: WebGLFramebuffer;\n /**\n * Rect to crop the snapshot. It's passed directly to `glReadPixels`.\n */\n rect?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n /**\n * Specifies what type of compression should be used and what is the result file extension.\n * PNG compression is lossless but slower, JPEG is faster but the image has visible artifacts.\n * > **Note:** When using WebP format, the iOS version will print a warning, and generate a `'png'` file instead.\n * > It is recommended to use [platform-specific](https://reactnative.dev/docs/platform-specific-code) code in this case.\n * @default 'jpeg'\n */\n format?: 'jpeg' | 'png' | 'webp';\n /**\n * A value in range `0` to `1.0` specifying compression level of the result image.\n * `1.0` means no compression and `0` the highest compression.\n * @default 1.0\n */\n compress?: number;\n};\n\n// @needsAudit\nexport type GLSnapshot = {\n /**\n * URI to the snapshot.\n */\n uri: string | Blob | null;\n /**\n * Synonym for `uri`. Makes snapshot object compatible with `texImage2D`.\n */\n localUri: string;\n /**\n * Width of the snapshot.\n */\n width: number;\n /**\n * Height of the snapshot.\n */\n height: number;\n};\n\n// @docsMissing\nexport interface ExpoWebGLRenderingContext extends WebGL2RenderingContext {\n contextId: number;\n endFrameEXP(): void;\n flushEXP(): void;\n __expoSetLogging(option: GLLoggingOption): void;\n\n /** @internal */\n _expo_texSubImage2D?(...props: any[]): void;\n _expo_texImage2D?(...props: any[]): void;\n}\n\n// @docsMissing\nexport type ComponentOrHandle = null | number | Component<any, any> | ComponentClass<any>;\n\n// @needsAudit\nexport type GLViewProps = {\n /**\n * A function that will be called when the OpenGL ES context is created.\n * The function is passed a single argument `gl` that extends a [WebGLRenderingContext](https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14) interface.\n */\n onContextCreate(gl: ExpoWebGLRenderingContext): void;\n /**\n * `GLView` can enable iOS's built-in [multisampling](https://www.khronos.org/registry/OpenGL/extensions/APPLE/APPLE_framebuffer_multisample.txt).\n * This prop specifies the number of samples to use. Setting this to `0` turns off multisampling.\n * @platform ios\n * @default 4\n */\n msaaSamples: number;\n /**\n * Enables support for interacting with a `gl` object from code running on the Reanimated worklet thread.\n * @default false\n */\n enableExperimentalWorkletSupport: boolean;\n /**\n * @hidden\n * A ref callback for the native GLView\n */\n nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | null): void;\n} & ViewProps;\n\n// @needsAudit\nexport enum GLLoggingOption {\n /**\n * Disables logging entirely.\n */\n DISABLED = 0,\n /**\n * Logs method calls, their parameters and results.\n */\n METHOD_CALLS = 1,\n /**\n * Calls `gl.getError()` after each other method call and prints an error if any is returned.\n * This option has a significant impact on the performance as this method is blocking.\n */\n GET_ERRORS = 2,\n /**\n * Resolves parameters of type `number` to their constant names.\n */\n RESOLVE_CONSTANTS = 4,\n /**\n * When this option is enabled, long strings will be truncated.\n * It's useful if your shaders are really big and logging them significantly reduces performance.\n */\n TRUNCATE_STRINGS = 8,\n /**\n * Enables all other options. It implies `GET_ERRORS` so be aware of the slowdown.\n */\n ALL = METHOD_CALLS | GET_ERRORS | RESOLVE_CONSTANTS | TRUNCATE_STRINGS,\n}\n"]}
|
package/build/GLView.web.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type GLViewWebProps = GLViewProps & {
|
|
|
6
6
|
onContextRestored?: (gl?: WebGLRenderingContext) => void;
|
|
7
7
|
onContextLost?: () => void;
|
|
8
8
|
webglContextAttributes?: WebGLContextAttributes;
|
|
9
|
-
nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | HTMLCanvasElement | null):
|
|
9
|
+
nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | HTMLCanvasElement | null): unknown;
|
|
10
10
|
};
|
|
11
11
|
export declare class GLView extends React.Component<GLViewWebProps> {
|
|
12
12
|
canvas?: HTMLCanvasElement;
|
|
@@ -16,7 +16,7 @@ export declare class GLView extends React.Component<GLViewWebProps> {
|
|
|
16
16
|
static takeSnapshotAsync(gl: WebGLRenderingContext, options?: SnapshotOptions): Promise<GLSnapshot>;
|
|
17
17
|
componentWillUnmount(): void;
|
|
18
18
|
render(): React.JSX.Element;
|
|
19
|
-
componentDidUpdate(prevProps:
|
|
19
|
+
componentDidUpdate(prevProps: GLViewWebProps): void;
|
|
20
20
|
private getGLContextOrReject;
|
|
21
21
|
private onContextLost;
|
|
22
22
|
private onContextRestored;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLView.web.d.ts","sourceRoot":"","sources":["../src/GLView.web.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,WAAW,EAEX,UAAU,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAiExB,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,eAAe,EAAE,CAAC,EAAE,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACrD,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACzD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAEhD,sBAAsB,CAAC,CAAC,QAAQ,EAAE,iBAAiB,GAAG,iBA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iBAAiB,CAAC,CAAC;YAE7E,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IAEK,KAAK,CAAC,iBAAiB,CAAC,UAA2B,EAAE;QAC1D,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;YAC9B,MAAM,IAAI,mBAAmB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QAChE,CAAC;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 const context =\n 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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E,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 const context =\n 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): unknown;\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: GLViewWebProps) {\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/expo-module.config.json
CHANGED
|
Binary file
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.aar.md5
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bc2205946f52f8687796cf32c928e98b
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.aar.sha1
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ea4a22150ad11afe7d32c0fb5f56e9684c822ee6
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.aar.sha256
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c222c645d235d4f68e0b94f3d9d054d413bfc53763daa19d4d4c01bca0050cde
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.aar.sha512
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
8f78010c50080eabf5f733bcf30b6c135eb8aff446d17427f408fc847f369b952f2905c1c63e90a562bb9a826ced38b7f27341067ee7ae973a0663107d1be74f
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "host.exp.exponent",
|
|
5
5
|
"module": "expo.modules.gl",
|
|
6
|
-
"version": "15.1.
|
|
6
|
+
"version": "15.1.3",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
{
|
|
27
|
-
"name": "expo.modules.gl-15.1.
|
|
28
|
-
"url": "expo.modules.gl-15.1.
|
|
29
|
-
"size":
|
|
30
|
-
"sha512": "
|
|
31
|
-
"sha256": "
|
|
32
|
-
"sha1": "
|
|
33
|
-
"md5": "
|
|
27
|
+
"name": "expo.modules.gl-15.1.3.aar",
|
|
28
|
+
"url": "expo.modules.gl-15.1.3.aar",
|
|
29
|
+
"size": 1044040,
|
|
30
|
+
"sha512": "8f78010c50080eabf5f733bcf30b6c135eb8aff446d17427f408fc847f369b952f2905c1c63e90a562bb9a826ced38b7f27341067ee7ae973a0663107d1be74f",
|
|
31
|
+
"sha256": "c222c645d235d4f68e0b94f3d9d054d413bfc53763daa19d4d4c01bca0050cde",
|
|
32
|
+
"sha1": "ea4a22150ad11afe7d32c0fb5f56e9684c822ee6",
|
|
33
|
+
"md5": "bc2205946f52f8687796cf32c928e98b"
|
|
34
34
|
}
|
|
35
35
|
]
|
|
36
36
|
},
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
],
|
|
54
54
|
"files": [
|
|
55
55
|
{
|
|
56
|
-
"name": "expo.modules.gl-15.1.
|
|
57
|
-
"url": "expo.modules.gl-15.1.
|
|
58
|
-
"size":
|
|
59
|
-
"sha512": "
|
|
60
|
-
"sha256": "
|
|
61
|
-
"sha1": "
|
|
62
|
-
"md5": "
|
|
56
|
+
"name": "expo.modules.gl-15.1.3.aar",
|
|
57
|
+
"url": "expo.modules.gl-15.1.3.aar",
|
|
58
|
+
"size": 1044040,
|
|
59
|
+
"sha512": "8f78010c50080eabf5f733bcf30b6c135eb8aff446d17427f408fc847f369b952f2905c1c63e90a562bb9a826ced38b7f27341067ee7ae973a0663107d1be74f",
|
|
60
|
+
"sha256": "c222c645d235d4f68e0b94f3d9d054d413bfc53763daa19d4d4c01bca0050cde",
|
|
61
|
+
"sha1": "ea4a22150ad11afe7d32c0fb5f56e9684c822ee6",
|
|
62
|
+
"md5": "bc2205946f52f8687796cf32c928e98b"
|
|
63
63
|
}
|
|
64
64
|
]
|
|
65
65
|
},
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
},
|
|
74
74
|
"files": [
|
|
75
75
|
{
|
|
76
|
-
"name": "expo.modules.gl-15.1.
|
|
77
|
-
"url": "expo.modules.gl-15.1.
|
|
76
|
+
"name": "expo.modules.gl-15.1.3-sources.jar",
|
|
77
|
+
"url": "expo.modules.gl-15.1.3-sources.jar",
|
|
78
78
|
"size": 12381,
|
|
79
79
|
"sha512": "1cab724074b050f7459a884ac9e98fbf2d009d8239810ca6384c5113f52dd33e5ac40a72ec7174b297e1b10521e56682d73f533715316be5be66ce0e482356d8",
|
|
80
80
|
"sha256": "e8892c6837d1eb5093b2c3b063883d7511799b0e246940c5b70f1515cb4451cd",
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.module.md5
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a5e0b5b8325ec1781a75ea6aac916d58
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.module.sha1
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4cba9b1fdf6b9a694217778462086271a7aac442
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2e2ca5c3083df52b05f7b4e3fa9699e97cb80d1c1fba4e82efee3b08259a6938
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b1c093682d8252d2c4571b80fa6889a59a81fadf00c0291ae7b7d660320cf43ba6d73506d2162103ad1915157f3e36b2a1eca9733912ad243a84febcfb04782e
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<modelVersion>4.0.0</modelVersion>
|
|
10
10
|
<groupId>host.exp.exponent</groupId>
|
|
11
11
|
<artifactId>expo.modules.gl</artifactId>
|
|
12
|
-
<version>15.1.
|
|
12
|
+
<version>15.1.3</version>
|
|
13
13
|
<packaging>aar</packaging>
|
|
14
14
|
<name>expo.modules.gl</name>
|
|
15
15
|
<url>https://github.com/expo/expo</url>
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.pom.md5
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a84c54bcedca3698d012788b1de62bdd
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.pom.sha1
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4a4b75d910bafda9959e551d613350a624b31871
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.pom.sha256
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
28146979c88071bee155097cfaeeac90ee4b1260ffef07bcd7c6987697df5268
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.3/expo.modules.gl-15.1.3.pom.sha512
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
63eed8341d652ac5ae17c539b138b44af5a2ff6ab4fb1d0e882a0003ae624216248c41f6fdeba4f5e0f1233df4fffb1342012861b15c16b06c8efc751f2b8270
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>host.exp.exponent</groupId>
|
|
4
4
|
<artifactId>expo.modules.gl</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>15.1.
|
|
7
|
-
<release>15.1.
|
|
6
|
+
<latest>15.1.3</latest>
|
|
7
|
+
<release>15.1.3</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>15.1.
|
|
9
|
+
<version>15.1.3</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20250421213338</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
45415ced62aeb7f1af589b64139d29f5
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4222179f4b6d7fd25b98fe3539f4df596db5cbea
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
291d415e2cba917775d886a852c231c4f9e42bb05b8b68da387ba4f2ab6686d1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d22b0c84d6bf32003ffe24e947c51d686ad113376fd184413df4cb3e2aa6047424311f379529fdf8b0e04f88de1686cbfa355bf154b9b280632f1c4d680991c3
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-gl",
|
|
3
|
-
"version": "15.1.
|
|
3
|
+
"version": "15.1.3",
|
|
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",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@types/invariant": "^2.2.33",
|
|
44
44
|
"@types/offscreencanvas": "2019.6.4",
|
|
45
45
|
"@types/webgl2": "^0.0.6",
|
|
46
|
-
"expo-module-scripts": "^4.1.
|
|
46
|
+
"expo-module-scripts": "^4.1.2",
|
|
47
47
|
"react-test-renderer": "19.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"optional": true
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "f1394f21ff2719a9a3037d7511db170704e5c492"
|
|
61
61
|
}
|
package/src/Canvas.tsx
CHANGED
|
@@ -3,7 +3,17 @@ import { findDOMNode } from 'react-dom';
|
|
|
3
3
|
import { LayoutChangeEvent, PixelRatio, StyleSheet, View, ViewProps } from 'react-native';
|
|
4
4
|
import createElement from 'react-native-web/dist/exports/createElement';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
interface Size {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface GetSizeParams {
|
|
12
|
+
size: Size | null;
|
|
13
|
+
ref: React.RefObject<View | null>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getElement(component: React.ReactInstance): React.ReactInstance | Element | null | Text {
|
|
7
17
|
try {
|
|
8
18
|
return findDOMNode(component);
|
|
9
19
|
} catch {
|
|
@@ -22,6 +32,17 @@ function setRef<T>(refProp: React.Ref<T>, ref: T | null) {
|
|
|
22
32
|
}
|
|
23
33
|
}
|
|
24
34
|
|
|
35
|
+
function getSize({ size, ref }: GetSizeParams): Size {
|
|
36
|
+
if (size) {
|
|
37
|
+
return size;
|
|
38
|
+
} else if (!ref.current || typeof window === 'undefined') {
|
|
39
|
+
return { width: 0, height: 0 };
|
|
40
|
+
}
|
|
41
|
+
const element = getElement(ref.current);
|
|
42
|
+
const { offsetWidth: width = 0, offsetHeight: height = 0 } = element as HTMLElement;
|
|
43
|
+
return { width, height };
|
|
44
|
+
}
|
|
45
|
+
|
|
25
46
|
const Canvas = React.forwardRef(
|
|
26
47
|
(props: React.ComponentProps<typeof View>, ref: React.Ref<HTMLCanvasElement>) =>
|
|
27
48
|
createElement('canvas', { ...props, ref })
|
|
@@ -32,55 +53,50 @@ const CanvasWrapper: React.FunctionComponent<
|
|
|
32
53
|
canvasRef: React.Ref<HTMLCanvasElement>;
|
|
33
54
|
}
|
|
34
55
|
> = ({ pointerEvents, children, style, ...props }) => {
|
|
35
|
-
const [size, setSize] = React.useState<
|
|
56
|
+
const [size, setSize] = React.useState<Size | null>(null);
|
|
36
57
|
|
|
37
58
|
const ref = React.useRef<View>(null);
|
|
38
59
|
const _canvasRef = React.useRef<HTMLCanvasElement>(null);
|
|
39
60
|
|
|
40
|
-
|
|
61
|
+
const updateCanvasSize = React.useCallback(() => {
|
|
41
62
|
const canvas = _canvasRef.current;
|
|
42
63
|
if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement) {
|
|
43
|
-
const
|
|
64
|
+
const currentSize = getSize({
|
|
65
|
+
size,
|
|
66
|
+
ref,
|
|
67
|
+
});
|
|
44
68
|
const scale = PixelRatio.get();
|
|
45
69
|
|
|
46
|
-
canvas.style.width = `${
|
|
47
|
-
canvas.style.height = `${
|
|
48
|
-
|
|
49
|
-
canvas.width = size.width * scale;
|
|
50
|
-
canvas.height = size.height * scale;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
70
|
+
canvas.style.width = `${currentSize.width}px`;
|
|
71
|
+
canvas.style.height = `${currentSize.height}px`;
|
|
53
72
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return size;
|
|
57
|
-
} else if (!ref.current || typeof window === 'undefined') {
|
|
58
|
-
return { width: 0, height: 0 };
|
|
73
|
+
canvas.width = currentSize.width * scale;
|
|
74
|
+
canvas.height = currentSize.height * scale;
|
|
59
75
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
props.onLayout(event);
|
|
76
|
+
}, [size?.width, size?.height]);
|
|
77
|
+
|
|
78
|
+
const onLayout = React.useCallback(
|
|
79
|
+
(event: LayoutChangeEvent) => {
|
|
80
|
+
const {
|
|
81
|
+
nativeEvent: {
|
|
82
|
+
layout: { width, height },
|
|
83
|
+
},
|
|
84
|
+
} = event;
|
|
85
|
+
|
|
86
|
+
if (width !== size?.width || height !== size?.height) {
|
|
87
|
+
setSize({ width, height });
|
|
88
|
+
|
|
89
|
+
if (props.onLayout) {
|
|
90
|
+
props.onLayout(event);
|
|
91
|
+
}
|
|
77
92
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
93
|
+
},
|
|
94
|
+
[size?.width, size?.height, props.onLayout]
|
|
95
|
+
);
|
|
80
96
|
|
|
81
97
|
React.useEffect(() => {
|
|
82
98
|
if (ref.current != null) {
|
|
83
|
-
setSize(getSize());
|
|
99
|
+
setSize(getSize({ size, ref }));
|
|
84
100
|
}
|
|
85
101
|
}, [ref]);
|
|
86
102
|
|
package/src/GLErrors.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const GLErrors = {
|
|
2
2
|
1280: 'INVALID ENUM: An unacceptable value has been specified for an enumerated argument.',
|
|
3
3
|
1281: 'INVALID_VALUE: A numeric argument is out of range.',
|
|
4
4
|
1282: 'INVALID_OPERATION: The specified command is not allowed for the current state.',
|
|
@@ -6,3 +6,5 @@ export default {
|
|
|
6
6
|
1286: 'INVALID_FRAMEBUFFER_OPERATION: The currently bound framebuffer is not complete when trying to render to or to read from it.',
|
|
7
7
|
37442: 'CONTEXT_LOST_WEBGL: The WebGL context is lost.',
|
|
8
8
|
};
|
|
9
|
+
|
|
10
|
+
export default GLErrors;
|
package/src/GLUtils.ts
CHANGED
|
@@ -21,11 +21,13 @@ export function configureLogging(gl: ExpoWebGLRenderingContext): void {
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
const __gl = gl as Record<keyof typeof gl | string, any>;
|
|
25
|
+
|
|
24
26
|
// Turn off logging.
|
|
25
27
|
if (option === GLLoggingOption.DISABLED || !option) {
|
|
26
|
-
Object.entries(
|
|
28
|
+
Object.entries(__gl).forEach(([key, value]) => {
|
|
27
29
|
if (typeof value === 'function' && value.__logWrapper) {
|
|
28
|
-
delete
|
|
30
|
+
delete __gl[key];
|
|
29
31
|
}
|
|
30
32
|
});
|
|
31
33
|
loggingOption = option;
|
|
@@ -33,20 +35,20 @@ export function configureLogging(gl: ExpoWebGLRenderingContext): void {
|
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
// Turn on logging.
|
|
36
|
-
Object.entries(Object.getPrototypeOf(
|
|
38
|
+
Object.entries(Object.getPrototypeOf(__gl)).forEach(([key, originalValue]) => {
|
|
37
39
|
if (typeof originalValue !== 'function' || key === '__expoSetLogging') {
|
|
38
40
|
return;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
__gl[key] = (...args: any[]) => {
|
|
42
44
|
if (loggingOption & GLLoggingOption.METHOD_CALLS) {
|
|
43
45
|
const params = args.map((arg) => {
|
|
44
46
|
// If the type is `number`, then try to find name of the constant that has such value,
|
|
45
47
|
// so it's easier to read these logs. In some cases it might be misleading
|
|
46
48
|
// if the parameter is for example a width or height, so the number is still logged.
|
|
47
49
|
if (loggingOption & GLLoggingOption.RESOLVE_CONSTANTS && typeof arg === 'number') {
|
|
48
|
-
for (const prop in
|
|
49
|
-
if (
|
|
50
|
+
for (const prop in __gl) {
|
|
51
|
+
if (__gl[prop] === arg) {
|
|
50
52
|
return `${arg} (${prop})`;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -67,7 +69,7 @@ export function configureLogging(gl: ExpoWebGLRenderingContext): void {
|
|
|
67
69
|
console.log(`ExpoGL: ${key}(${params.join(', ')})`);
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
const result = originalValue.apply(
|
|
72
|
+
const result = originalValue.apply(__gl, args);
|
|
71
73
|
|
|
72
74
|
if (loggingOption & GLLoggingOption.METHOD_CALLS) {
|
|
73
75
|
console.log(`ExpoGL: = ${result}`);
|
|
@@ -75,14 +77,14 @@ export function configureLogging(gl: ExpoWebGLRenderingContext): void {
|
|
|
75
77
|
if (loggingOption & GLLoggingOption.GET_ERRORS && key !== 'getError') {
|
|
76
78
|
// @ts-ignore We need to call into the original `getError`.
|
|
77
79
|
// eslint-disable-next-line no-proto
|
|
78
|
-
const error =
|
|
80
|
+
const error = __gl.__proto__.getError.call(__gl);
|
|
79
81
|
|
|
80
|
-
if (error && error !==
|
|
82
|
+
if (error && error !== __gl.NO_ERROR) {
|
|
81
83
|
// `console.error` would cause a red screen, so let's just log with red color.
|
|
82
|
-
console.log(`\x1b[31mExpoGL: Error ${GLErrors[error]}\x1b[0m`);
|
|
84
|
+
console.log(`\x1b[31mExpoGL: Error ${GLErrors[error as keyof typeof GLErrors]}\x1b[0m`);
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
|
-
|
|
87
|
+
__gl[key].__logWrapper = true;
|
|
86
88
|
return result;
|
|
87
89
|
};
|
|
88
90
|
});
|
package/src/GLView.types.ts
CHANGED
|
@@ -71,6 +71,10 @@ export interface ExpoWebGLRenderingContext extends WebGL2RenderingContext {
|
|
|
71
71
|
endFrameEXP(): void;
|
|
72
72
|
flushEXP(): void;
|
|
73
73
|
__expoSetLogging(option: GLLoggingOption): void;
|
|
74
|
+
|
|
75
|
+
/** @internal */
|
|
76
|
+
_expo_texSubImage2D?(...props: any[]): void;
|
|
77
|
+
_expo_texImage2D?(...props: any[]): void;
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
// @docsMissing
|
|
@@ -99,7 +103,7 @@ export type GLViewProps = {
|
|
|
99
103
|
* @hidden
|
|
100
104
|
* A ref callback for the native GLView
|
|
101
105
|
*/
|
|
102
|
-
nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | null);
|
|
106
|
+
nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | null): void;
|
|
103
107
|
} & ViewProps;
|
|
104
108
|
|
|
105
109
|
// @needsAudit
|
package/src/GLView.web.tsx
CHANGED
|
@@ -39,7 +39,7 @@ function asExpoContext(gl: ExpoWebGLRenderingContext): WebGLRenderingContext {
|
|
|
39
39
|
gl.texImage2D = (...props: any[]): any => {
|
|
40
40
|
const nextProps = [...props];
|
|
41
41
|
nextProps.push(getImageForAsset(nextProps.pop()));
|
|
42
|
-
return gl['_expo_texImage2D'](...nextProps);
|
|
42
|
+
return gl['_expo_texImage2D']!(...nextProps);
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -48,7 +48,7 @@ function asExpoContext(gl: ExpoWebGLRenderingContext): WebGLRenderingContext {
|
|
|
48
48
|
gl.texSubImage2D = (...props: any[]): any => {
|
|
49
49
|
const nextProps = [...props];
|
|
50
50
|
nextProps.push(getImageForAsset(nextProps.pop()));
|
|
51
|
-
return gl['_expo_texSubImage2D'](...nextProps);
|
|
51
|
+
return gl['_expo_texSubImage2D']!(...nextProps);
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -82,7 +82,7 @@ export type GLViewWebProps = GLViewProps & {
|
|
|
82
82
|
onContextLost?: () => void;
|
|
83
83
|
webglContextAttributes?: WebGLContextAttributes;
|
|
84
84
|
// type overwrite
|
|
85
|
-
nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | HTMLCanvasElement | null);
|
|
85
|
+
nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | HTMLCanvasElement | null): unknown;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
async function getBlobFromWebGLRenderingContext(
|
|
@@ -182,7 +182,7 @@ export class GLView extends React.Component<GLViewWebProps> {
|
|
|
182
182
|
return <Canvas {...domProps} canvasRef={this.setCanvasRef} />;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
componentDidUpdate(prevProps) {
|
|
185
|
+
componentDidUpdate(prevProps: GLViewWebProps) {
|
|
186
186
|
const { webglContextAttributes } = this.props;
|
|
187
187
|
if (this.canvas && webglContextAttributes !== prevProps.webglContextAttributes) {
|
|
188
188
|
this.onContextLost(null);
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.aar
DELETED
|
Binary file
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.aar.md5
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4e51904d935bc219545745417b20c2d7
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.aar.sha1
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
c929f7db323ea4ed4364d299c44fe2ee4a27d39d
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.aar.sha256
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f1d1b8dd2b85484a2d851be91b00b0ff7c98455a3ea5cd0bf5c2649e310d2bb5
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.aar.sha512
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
98e275d058da1c0fd707a4b197a86c02aa60c47ee43fc7dd99ccac4d14c8c84920a781a6fde5123ed350924286365a800bec6e7f9b00b81ce1d9de49ac862aa0
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.module.md5
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
82dbfc3f7d14f804213d9676ee582e00
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.module.sha1
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f529da717072ce0fc13b25711aa5baf2781226fc
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
fa7ceedfb3f81ff53c7c5616dc21ffe4520fafcf1fea55195c0d464b2201aae0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
5ea7b5f1874ecda7f874d32ab6623c47a81ffe63bc2dc3b51b519f57375ff8890750b5bb5d8fa6518938f48caa870cbe29ebd0331be3186f5ead123c82e999ce
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.pom.md5
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
772dbc6864c7de52b19dc64961e113a4
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.pom.sha1
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3af62474b4f5749a739bd96f81e26256252580ff
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.pom.sha256
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3065427ccd36c1d43af5686572c05ab926c3dac15804445aa061f0be844aa4ee
|
package/local-maven-repo/host/exp/exponent/expo.modules.gl/15.1.1/expo.modules.gl-15.1.1.pom.sha512
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
668748f250773080b5bddb6f1623b8c615f8c2e784758f23ac10b542ba4830f7f9ce059d5d4bc3454dc6f509fd7c6838e926cd8acae77b6e5be23efedcd38c24
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|