@symbiote-native/gl 0.0.0-stage → 0.1.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.
Files changed (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -2
  3. package/build/angular/gl-view/index.d.ts +18 -0
  4. package/build/angular/gl-view/index.js +87 -0
  5. package/build/angular/index.d.ts +2 -0
  6. package/build/angular/index.js +3 -0
  7. package/build/core/constants.d.ts +4 -0
  8. package/build/core/constants.js +4 -0
  9. package/build/core/gl-context.d.ts +13 -0
  10. package/build/core/gl-context.js +54 -0
  11. package/build/core/gl-errors.d.ts +1 -0
  12. package/build/core/gl-errors.js +8 -0
  13. package/build/core/gl-utils.d.ts +5 -0
  14. package/build/core/gl-utils.js +84 -0
  15. package/build/core/gl-view.d.ts +16 -0
  16. package/build/core/gl-view.js +107 -0
  17. package/build/core/index.d.ts +6 -0
  18. package/build/core/index.js +5 -0
  19. package/build/core/native-module.d.ts +15 -0
  20. package/build/core/native-module.js +3 -0
  21. package/build/core/types.d.ts +75 -0
  22. package/build/core/types.js +13 -0
  23. package/build/core/worklet-context-manager.d.ts +6 -0
  24. package/build/core/worklet-context-manager.js +35 -0
  25. package/build/react/gl-view.d.ts +8 -0
  26. package/build/react/gl-view.js +6 -0
  27. package/build/react/index.d.ts +3 -0
  28. package/build/react/index.js +3 -0
  29. package/build/solid/gl-view.d.ts +13 -0
  30. package/build/solid/gl-view.js +4 -0
  31. package/build/solid/index.d.ts +2 -0
  32. package/build/solid/index.js +3 -0
  33. package/build/svelte/gl-view.svelte +19 -0
  34. package/build/svelte/gl-view.svelte.d.ts +9 -0
  35. package/build/svelte/index.d.ts +2 -0
  36. package/build/svelte/index.js +3 -0
  37. package/build/vue/gl-view.d.ts +2 -0
  38. package/build/vue/gl-view.js +4 -0
  39. package/build/vue/index.d.ts +2 -0
  40. package/build/vue/index.js +3 -0
  41. package/build-ngc/angular/gl-view/index.d.ts +21 -0
  42. package/build-ngc/angular/gl-view/index.js +46 -0
  43. package/build-ngc/angular/gl-view/index.js.map +1 -0
  44. package/build-ngc/angular/index.d.ts +2 -0
  45. package/build-ngc/angular/index.js +4 -0
  46. package/build-ngc/angular/index.js.map +1 -0
  47. package/build-ngc/core/constants.d.ts +4 -0
  48. package/build-ngc/core/constants.js +5 -0
  49. package/build-ngc/core/constants.js.map +1 -0
  50. package/build-ngc/core/gl-context.d.ts +13 -0
  51. package/build-ngc/core/gl-context.js +55 -0
  52. package/build-ngc/core/gl-context.js.map +1 -0
  53. package/build-ngc/core/gl-errors.d.ts +1 -0
  54. package/build-ngc/core/gl-errors.js +9 -0
  55. package/build-ngc/core/gl-errors.js.map +1 -0
  56. package/build-ngc/core/gl-utils.d.ts +5 -0
  57. package/build-ngc/core/gl-utils.js +85 -0
  58. package/build-ngc/core/gl-utils.js.map +1 -0
  59. package/build-ngc/core/gl-view.d.ts +16 -0
  60. package/build-ngc/core/gl-view.js +108 -0
  61. package/build-ngc/core/gl-view.js.map +1 -0
  62. package/build-ngc/core/index.d.ts +6 -0
  63. package/build-ngc/core/index.js +6 -0
  64. package/build-ngc/core/index.js.map +1 -0
  65. package/build-ngc/core/native-module.d.ts +15 -0
  66. package/build-ngc/core/native-module.js +4 -0
  67. package/build-ngc/core/native-module.js.map +1 -0
  68. package/build-ngc/core/types.d.ts +75 -0
  69. package/build-ngc/core/types.js +14 -0
  70. package/build-ngc/core/types.js.map +1 -0
  71. package/build-ngc/core/worklet-context-manager.d.ts +6 -0
  72. package/build-ngc/core/worklet-context-manager.js +36 -0
  73. package/build-ngc/core/worklet-context-manager.js.map +1 -0
  74. package/native-link.json +12 -0
  75. package/package.json +145 -3
  76. package/src/angular/gl-view/index.ts +51 -0
  77. package/src/angular/index.ts +4 -0
  78. package/src/core/constants.ts +6 -0
  79. package/src/core/gl-context.ts +79 -0
  80. package/src/core/gl-errors.ts +8 -0
  81. package/src/core/gl-utils.ts +106 -0
  82. package/src/core/gl-view.ts +160 -0
  83. package/src/core/index.ts +26 -0
  84. package/src/core/native-module.ts +22 -0
  85. package/src/core/types.ts +95 -0
  86. package/src/core/worklet-context-manager.ts +52 -0
  87. package/src/react/gl-view.ts +17 -0
  88. package/src/react/index.ts +5 -0
  89. package/src/solid/gl-view.ts +8 -0
  90. package/src/solid/index.ts +4 -0
  91. package/src/svelte/gl-view.svelte +19 -0
  92. package/src/svelte/index.ts +4 -0
  93. package/src/svelte/svelte-ambient.d.ts +3 -0
  94. package/src/svelte/svelte-compile.test-helper.ts +6 -0
  95. package/src/vue/gl-view.ts +5 -0
  96. package/src/vue/index.ts +4 -0
@@ -0,0 +1,85 @@
1
+ import { GL_ERRORS } from './gl-errors';
2
+ import { GLLoggingOption } from './types';
3
+ const MAX_STRING_LENGTH = 20;
4
+ const SET_LOGGING_KEY = '__expoSetLogging';
5
+ const wrappers = new WeakSet();
6
+ function isGLFunction(value) {
7
+ return typeof value === 'function';
8
+ }
9
+ function constantNameOf(gl, value) {
10
+ for (const name in gl) {
11
+ if (Reflect.get(gl, name) === value)
12
+ return name;
13
+ }
14
+ return undefined;
15
+ }
16
+ // Numbers get the name of a constant that holds them, which can mislead for a size, so the
17
+ // number stays. Strings are cut because a shader is long and logging it blocks the bridge
18
+ function describeArg(gl, option, arg) {
19
+ if (option & GLLoggingOption.RESOLVE_CONSTANTS && typeof arg === 'number') {
20
+ const name = constantNameOf(gl, arg);
21
+ if (name)
22
+ return `${arg} (${name})`;
23
+ }
24
+ const isLong = typeof arg === 'string' && arg.length > MAX_STRING_LENGTH;
25
+ if (option & GLLoggingOption.TRUNCATE_STRINGS && isLong) {
26
+ const lastSpace = arg.lastIndexOf(' ', MAX_STRING_LENGTH);
27
+ return `${arg.slice(0, lastSpace >= 0 ? lastSpace : MAX_STRING_LENGTH)}...`;
28
+ }
29
+ return String(arg);
30
+ }
31
+ // The original `getError`, a wrapped one would log itself
32
+ function reportError(gl) {
33
+ const getError = Reflect.get(Reflect.getPrototypeOf(gl) ?? {}, 'getError');
34
+ if (!isGLFunction(getError))
35
+ return;
36
+ const error = getError.call(gl);
37
+ if (typeof error !== 'number' || error === Reflect.get(gl, 'NO_ERROR'))
38
+ return;
39
+ console.warn(`\x1b[31mExpoGL: Error ${GL_ERRORS[error]}\x1b[0m`);
40
+ }
41
+ function wrapMethod(gl, key, original, getOption) {
42
+ const wrapper = (...args) => {
43
+ const option = getOption();
44
+ if (option & GLLoggingOption.METHOD_CALLS) {
45
+ const params = args.map(arg => describeArg(gl, option, arg));
46
+ console.warn(`ExpoGL: ${key}(${params.join(', ')})`);
47
+ }
48
+ const result = original.apply(gl, args);
49
+ if (option & GLLoggingOption.METHOD_CALLS)
50
+ console.warn(`ExpoGL: = ${String(result)}`);
51
+ if (option & GLLoggingOption.GET_ERRORS && key !== 'getError')
52
+ reportError(gl);
53
+ return result;
54
+ };
55
+ wrappers.add(wrapper);
56
+ Reflect.set(gl, key, wrapper);
57
+ }
58
+ function wrapMethods(gl, getOption) {
59
+ for (const [key, original] of Object.entries(Reflect.getPrototypeOf(gl) ?? {})) {
60
+ if (isGLFunction(original) && key !== SET_LOGGING_KEY) {
61
+ wrapMethod(gl, key, original, getOption);
62
+ }
63
+ }
64
+ }
65
+ function unwrapMethods(gl) {
66
+ for (const [key, value] of Object.entries(gl)) {
67
+ if (isGLFunction(value) && wrappers.has(value))
68
+ Reflect.deleteProperty(gl, key);
69
+ }
70
+ }
71
+ /** Adds `__expoSetLogging` to the context, for the logging options useful in debugging GL calls */
72
+ export function configureLogging(gl) {
73
+ let loggingOption = GLLoggingOption.DISABLED;
74
+ gl.__expoSetLogging = (option) => {
75
+ // Both on or both off needs no wrapping or unwrapping, only the new option
76
+ if (!loggingOption !== !option) {
77
+ if (option)
78
+ wrapMethods(gl, () => loggingOption);
79
+ else
80
+ unwrapMethods(gl);
81
+ }
82
+ loggingOption = option;
83
+ };
84
+ }
85
+ //# sourceMappingURL=gl-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gl-utils.js","sourceRoot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B,IAAI,MAAM;gBAAE,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;;gBAC5C,aAAa,CAAC,EAAE,CAAC,CAAC;QACzB,CAAC;QACD,aAAa,GAAG,MAAM,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { IDescriptor } from '@symbiote-native/components';
2
+ import type { ISymbioteNode } from '@symbiote-native/engine';
3
+ import type { IGLViewHandle } from './types';
4
+ export declare const glViewName: () => string;
5
+ export declare const ensureGLViewRegistered: () => boolean;
6
+ export type IGLView = {
7
+ handle: IGLViewHandle;
8
+ /** `null` means the view cannot register and the caller renders nothing */
9
+ render(props: object): IDescriptor | null;
10
+ /** Forgets the context of the surface, called when the view unmounts */
11
+ dispose(): void;
12
+ };
13
+ type IGetNode = () => ISymbioteNode | null | undefined;
14
+ /** One per mounted view, `getNode` is kept for the shape the adapters share */
15
+ export declare function createGLView(_getNode: IGetNode): IGLView;
16
+ export {};
@@ -0,0 +1,108 @@
1
+ import { Platform, UnavailabilityError, requireNativeViewManager, } from 'expo-modules-core';
2
+ import { el } from '@symbiote-native/components';
3
+ import { defineExpoNativeView, getNativeTag, isDevBuild, isSymbioteNode, } from '@symbiote-native/engine';
4
+ import { GL_MODULE_NAME, GL_PACKAGE_NAME } from './constants';
5
+ import { getGl, takeSnapshotAsync, unregisterGLContext } from './gl-context';
6
+ import { glNativeModule } from './native-module';
7
+ // Registered on render: a barrel side effect is lost in a release build
8
+ const glView = defineExpoNativeView(requireNativeViewManager, GL_MODULE_NAME);
9
+ export const glViewName = glView.name;
10
+ export const ensureGLViewRegistered = glView.ensureRegistered;
11
+ const DEFAULT_MSAA_SAMPLES = 4;
12
+ function isSurfaceCreated(value) {
13
+ return typeof Reflect.get(Object(value), 'exglCtxId') === 'number';
14
+ }
15
+ function isContextCallback(value) {
16
+ return typeof value === 'function';
17
+ }
18
+ // Adapters hand over the props they hold, a missing callback is a view nobody listens to
19
+ function toViewProps(props) {
20
+ const onContextCreate = Reflect.get(props, 'onContextCreate');
21
+ return {
22
+ ...props,
23
+ onContextCreate: isContextCallback(onContextCreate)
24
+ ? onContextCreate
25
+ : () => undefined,
26
+ };
27
+ }
28
+ function nativeTagOf(camera) {
29
+ const tag = isSymbioteNode(camera) ? getNativeTag(camera) : camera;
30
+ if (typeof tag !== 'number')
31
+ throw new Error('The camera view has no native tag yet');
32
+ return tag;
33
+ }
34
+ /** One per mounted view, `getNode` is kept for the shape the adapters share */
35
+ export function createGLView(_getNode) {
36
+ let exglCtxId;
37
+ let latestProps;
38
+ let hasWorkletSupport;
39
+ const onSurfaceCreate = (event) => {
40
+ if (!isSurfaceCreated(event.nativeEvent))
41
+ return;
42
+ exglCtxId = event.nativeEvent.exglCtxId;
43
+ latestProps?.onContextCreate(getGl(exglCtxId));
44
+ };
45
+ function warnOnWorkletChange(enabled) {
46
+ if (hasWorkletSupport !== undefined && hasWorkletSupport !== enabled) {
47
+ console.warn('Updating prop enableExperimentalWorkletSupport is not supported');
48
+ }
49
+ hasWorkletSupport = enabled;
50
+ }
51
+ const handle = {
52
+ get exglCtxId() {
53
+ return exglCtxId;
54
+ },
55
+ async createCameraTextureAsync(camera) {
56
+ if (!glNativeModule.createCameraTextureAsync) {
57
+ throw new UnavailabilityError(GL_PACKAGE_NAME, 'createCameraTextureAsync');
58
+ }
59
+ if (!exglCtxId)
60
+ throw new Error("GLView's surface is not created yet!");
61
+ const { exglObjId } = await glNativeModule.createCameraTextureAsync(exglCtxId, nativeTagOf(camera));
62
+ const texture = { id: exglObjId };
63
+ return texture;
64
+ },
65
+ async destroyObjectAsync(glObject) {
66
+ if (!glNativeModule.destroyObjectAsync) {
67
+ throw new UnavailabilityError(GL_PACKAGE_NAME, 'destroyObjectAsync');
68
+ }
69
+ return glNativeModule.destroyObjectAsync(glObject.id);
70
+ },
71
+ takeSnapshotAsync: (options) => takeSnapshotAsync(exglCtxId, options),
72
+ };
73
+ return {
74
+ handle,
75
+ dispose: () => {
76
+ if (exglCtxId)
77
+ unregisterGLContext(exglCtxId);
78
+ },
79
+ render: props => {
80
+ if (!ensureGLViewRegistered()) {
81
+ if (isDevBuild())
82
+ console.warn("'GLView' is not available.");
83
+ return null;
84
+ }
85
+ latestProps = toViewProps(props);
86
+ const { onContextCreate, msaaSamples = DEFAULT_MSAA_SAMPLES, enableExperimentalWorkletSupport = false, ...viewProps } = latestProps;
87
+ warnOnWorkletChange(enableExperimentalWorkletSupport);
88
+ return el('view', viewProps, [
89
+ el(glViewName(), {
90
+ style: {
91
+ flex: 1,
92
+ ...Platform.select({
93
+ ios: { backgroundColor: 'transparent' },
94
+ default: {},
95
+ }),
96
+ },
97
+ onSurfaceCreate,
98
+ enableExperimentalWorkletSupport,
99
+ msaaSamples: Platform.select({
100
+ ios: msaaSamples,
101
+ default: undefined,
102
+ }),
103
+ }),
104
+ ]);
105
+ },
106
+ };
107
+ }
108
+ //# sourceMappingURL=gl-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gl-view.js","sourceRoot":"","sources":["../../src/core/gl-view.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAC;AAEjD,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AASjD,wEAAwE;AACxE,MAAM,MAAM,GAAG,oBAAoB,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC;AAE9E,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CA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,SAAS;gBAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,EAAE,KAAK,CAAC,EAAE;YACd,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;gBAC9B,IAAI,UAAU,EAAE;oBAAE,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;gBAC7D,OAAO,IAAI,CAAC;YACd,CAAC;YACD,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;YACjC,MAAM,EACJ,eAAe,EACf,WAAW,GAAG,oBAAoB,EAClC,gCAAgC,GAAG,KAAK,EACxC,GAAG,SAAS,EACb,GAAG,WAAW,CAAC;YAChB,mBAAmB,CAAC,gCAAgC,CAAC,CAAC;YACtD,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE;gBAC3B,EAAE,CAAC,UAAU,EAAE,EAAE;oBACf,KAAK,EAAE;wBACL,IAAI,EAAE,CAAC;wBACP,GAAG,QAAQ,CAAC,MAAM,CAAC;4BACjB,GAAG,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE;4BACvC,OAAO,EAAE,EAAE;yBACZ,CAAC;qBACH;oBACD,eAAe;oBACf,gCAAgC;oBAChC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC;wBAC3B,GAAG,EAAE,WAAW;wBAChB,OAAO,EAAE,SAAS;qBACnB,CAAC;iBACH,CAAC;aACH,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { GL_MODULE_NAME } from './constants';
2
+ export { createContextAsync, destroyContextAsync, getGl, getWorkletContext, takeSnapshotAsync, } from './gl-context';
3
+ export { configureLogging } from './gl-utils';
4
+ export { createGLView, ensureGLViewRegistered, glViewName, type IGLView, } from './gl-view';
5
+ export { GLLoggingOption } from './types';
6
+ export type { IExpoWebGLRenderingContext, IGLNodeOrTag, IGLObject, IGLSnapshot, IGLSnapshotOptions, IGLSurfaceCreateEvent, IGLViewHandle, IGLViewProps, } from './types';
@@ -0,0 +1,6 @@
1
+ export { GL_MODULE_NAME } from './constants';
2
+ export { createContextAsync, destroyContextAsync, getGl, getWorkletContext, takeSnapshotAsync, } from './gl-context';
3
+ export { configureLogging } from './gl-utils';
4
+ export { createGLView, ensureGLViewRegistered, glViewName, } from './gl-view';
5
+ export { GLLoggingOption } from './types';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,UAAU,GAEX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { IGLSnapshot, IGLSnapshotOptions } from './types';
2
+ export type INativeGLModule = {
3
+ createContextAsync(): Promise<{
4
+ exglCtxId: number;
5
+ }>;
6
+ destroyContextAsync(exglCtxId: number): Promise<boolean>;
7
+ takeSnapshotAsync(exglCtxId: number, options: IGLSnapshotOptions): Promise<IGLSnapshot>;
8
+ /** Absent where there is no camera texture support */
9
+ createCameraTextureAsync?(exglCtxId: number, cameraTag: number): Promise<{
10
+ exglObjId: number;
11
+ }>;
12
+ /** Absent where objects cannot be destroyed one by one */
13
+ destroyObjectAsync?(exglObjId: number): Promise<boolean>;
14
+ };
15
+ export declare const glNativeModule: INativeGLModule;
@@ -0,0 +1,4 @@
1
+ import { requireNativeModule } from 'expo-modules-core';
2
+ import { GL_MODULE_NAME } from './constants';
3
+ export const glNativeModule = requireNativeModule(GL_MODULE_NAME);
4
+ //# sourceMappingURL=native-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-module.js","sourceRoot":"","sources":["../../src/core/native-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAmB7C,MAAM,CAAC,MAAM,cAAc,GACzB,mBAAmB,CAAkB,cAAc,CAAC,CAAC"}
@@ -0,0 +1,75 @@
1
+ import type { IAccessibilityProps, IAriaProps, IResponderProps } from '@symbiote-native/components';
2
+ import type { IStyleProp, ISymbioteEvent, ISymbioteNode, IViewStyle } from '@symbiote-native/engine';
3
+ export type IGLObject = {
4
+ id: number;
5
+ };
6
+ export type IGLSurfaceCreateEvent = {
7
+ nativeEvent: {
8
+ exglCtxId: number;
9
+ };
10
+ };
11
+ export type IGLSnapshotOptions = {
12
+ /** @default false */
13
+ flip?: boolean;
14
+ /** Defaults to the framebuffer shown in the view, or the current one of a headless context */
15
+ framebuffer?: WebGLFramebuffer;
16
+ /** Passed to `glReadPixels` */
17
+ rect?: {
18
+ x: number;
19
+ y: number;
20
+ width: number;
21
+ height: number;
22
+ };
23
+ /** PNG is lossless but slower, iOS writes a PNG instead of WebP. @default 'jpeg' */
24
+ format?: 'jpeg' | 'png' | 'webp';
25
+ /** From `0` (most compressed) to `1.0` (none). @default 1.0 */
26
+ compress?: number;
27
+ };
28
+ export type IGLSnapshot = {
29
+ uri: string | Blob | null;
30
+ /** Same as `uri`, which makes a snapshot usable in `texImage2D` */
31
+ localUri: string;
32
+ width: number;
33
+ height: number;
34
+ };
35
+ export type IExpoWebGLRenderingContext = WebGL2RenderingContext & {
36
+ contextId: number;
37
+ endFrameEXP(): void;
38
+ flushEXP(): void;
39
+ __expoSetLogging(option: GLLoggingOption): void;
40
+ };
41
+ /** A native tag, or the host node of a view such as a camera */
42
+ export type IGLNodeOrTag = number | ISymbioteNode | null;
43
+ export type IGLViewProps = IAccessibilityProps & IAriaProps & IResponderProps & {
44
+ style?: IStyleProp<IViewStyle>;
45
+ testID?: string;
46
+ nativeID?: string;
47
+ onLayout?: (event: ISymbioteEvent) => void;
48
+ /** Called with the context once the surface exists */
49
+ onContextCreate(gl: IExpoWebGLRenderingContext): void;
50
+ /** Multisampling, `0` turns it off. @default 4 @platform ios */
51
+ msaaSamples?: number;
52
+ /** Lets the Reanimated worklet thread use the `gl` object. @default false */
53
+ enableExperimentalWorkletSupport?: boolean;
54
+ };
55
+ export declare enum GLLoggingOption {
56
+ DISABLED = 0,
57
+ /** Logs calls, their parameters and results */
58
+ METHOD_CALLS = 1,
59
+ /** Calls `getError` after each call, which blocks and slows drawing down */
60
+ GET_ERRORS = 2,
61
+ /** Prints the name of the constant a numeric parameter holds */
62
+ RESOLVE_CONSTANTS = 4,
63
+ /** Cuts long strings such as shaders */
64
+ TRUNCATE_STRINGS = 8,
65
+ ALL = 15
66
+ }
67
+ /** What a ref to the view hands out */
68
+ export type IGLViewHandle = {
69
+ /** The id of the context of the view, `undefined` until the surface exists */
70
+ readonly exglCtxId: number | undefined;
71
+ createCameraTextureAsync(camera: IGLNodeOrTag): Promise<WebGLTexture>;
72
+ destroyObjectAsync(glObject: IGLObject): Promise<boolean>;
73
+ /** A snapshot of the context of this view */
74
+ takeSnapshotAsync(options?: IGLSnapshotOptions): Promise<IGLSnapshot>;
75
+ };
@@ -0,0 +1,14 @@
1
+ export var GLLoggingOption;
2
+ (function (GLLoggingOption) {
3
+ GLLoggingOption[GLLoggingOption["DISABLED"] = 0] = "DISABLED";
4
+ /** Logs calls, their parameters and results */
5
+ GLLoggingOption[GLLoggingOption["METHOD_CALLS"] = 1] = "METHOD_CALLS";
6
+ /** Calls `getError` after each call, which blocks and slows drawing down */
7
+ GLLoggingOption[GLLoggingOption["GET_ERRORS"] = 2] = "GET_ERRORS";
8
+ /** Prints the name of the constant a numeric parameter holds */
9
+ GLLoggingOption[GLLoggingOption["RESOLVE_CONSTANTS"] = 4] = "RESOLVE_CONSTANTS";
10
+ /** Cuts long strings such as shaders */
11
+ GLLoggingOption[GLLoggingOption["TRUNCATE_STRINGS"] = 8] = "TRUNCATE_STRINGS";
12
+ GLLoggingOption[GLLoggingOption["ALL"] = 15] = "ALL";
13
+ })(GLLoggingOption || (GLLoggingOption = {}));
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAyEA,MAAM,CAAN,IAAY,eAWX;AAXD,WAAY,eAAe;IACzB,6DAAY,CAAA;IACZ,+CAA+C;IAC/C,qEAAgB,CAAA;IAChB,4EAA4E;IAC5E,iEAAc,CAAA;IACd,gEAAgE;IAChE,+EAAqB,CAAA;IACrB,wCAAwC;IACxC,6EAAoB,CAAA;IACpB,oDAAsE,CAAA;AACxE,CAAC,EAXW,eAAe,KAAf,eAAe,QAW1B"}
@@ -0,0 +1,6 @@
1
+ import type { IExpoWebGLRenderingContext } from './types';
2
+ export type IWorkletContextManager = {
3
+ getContext(contextId: number): IExpoWebGLRenderingContext | undefined;
4
+ unregister?(contextId: number): void;
5
+ };
6
+ export declare function createWorkletContextManager(): IWorkletContextManager;
@@ -0,0 +1,36 @@
1
+ import { GL_CONTEXTS_GLOBAL } from './constants';
2
+ function isRunOnUI(value) {
3
+ return typeof value === 'function';
4
+ }
5
+ // Reanimated stays optional, and an import of it in a try block in the module that also holds the
6
+ // view breaks with `inlineRequires`, so the manager lives in its own file
7
+ export function createWorkletContextManager() {
8
+ try {
9
+ // Reanimated has to load before any workletized code is created
10
+ // eslint-disable-next-line @typescript-eslint/no-require-imports -- optional dependency, see above
11
+ const reanimated = require('react-native-reanimated');
12
+ const runOnUI = Reflect.get(Object(reanimated), 'runOnUI');
13
+ if (!isRunOnUI(runOnUI))
14
+ throw new Error('react-native-reanimated has no runOnUI');
15
+ return {
16
+ getContext: contextId => {
17
+ 'worklet';
18
+ return Reflect.get(Object(Reflect.get(globalThis, GL_CONTEXTS_GLOBAL)), String(contextId));
19
+ },
20
+ unregister: contextId => {
21
+ runOnUI(id => {
22
+ 'worklet';
23
+ Reflect.deleteProperty(Object(Reflect.get(globalThis, GL_CONTEXTS_GLOBAL)), String(id));
24
+ })(contextId);
25
+ },
26
+ };
27
+ }
28
+ catch {
29
+ return {
30
+ getContext: () => {
31
+ throw new Error('Worklet runtime is not available');
32
+ },
33
+ };
34
+ }
35
+ }
36
+ //# sourceMappingURL=worklet-context-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worklet-context-manager.js","sourceRoot":"","sources":["../../src/core/worklet-context-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAYjD,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED,kGAAkG;AAClG,0EAA0E;AAC1E,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC;QACH,gEAAgE;QAChE,mGAAmG;QACnG,MAAM,UAAU,GAAY,OAAO,CAAC,yBAAyB,CAAC,CAAC;QAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC;QAC3D,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,OAAO;YACL,UAAU,EAAE,SAAS,CAAC,EAAE;gBACtB,SAAS,CAAC;gBACV,OAAO,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC,EACnD,MAAM,CAAC,SAAS,CAAC,CAClB,CAAC;YACJ,CAAC;YACD,UAAU,EAAE,SAAS,CAAC,EAAE;gBACtB,OAAO,CAAC,EAAE,CAAC,EAAE;oBACX,SAAS,CAAC;oBACV,OAAO,CAAC,cAAc,CACpB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC,EACnD,MAAM,CAAC,EAAE,CAAC,CACX,CAAC;gBACJ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,UAAU,EAAE,GAAG,EAAE;gBACf,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACtD,CAAC;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ {
2
+ "android": {
3
+ "gradleProjectName": "expo-gl",
4
+ "modules": [
5
+ {
6
+ "importPath": "expo.modules.gl.GLModule",
7
+ "className": "GLModule",
8
+ "nativeName": "ExpoGL"
9
+ }
10
+ ]
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,148 @@
1
1
  {
2
2
  "name": "@symbiote-native/gl",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "expo-gl wrapped for SymbioteNative — one framework-agnostic core, built once and reachable from the React, Vue, Svelte, Solid, and Angular adapters. A GLView that gives a WebGL context to draw into, headless contexts and snapshots.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/OneEyed1366/symbiote-native.git",
9
+ "directory": "packages/gl"
10
+ },
11
+ "homepage": "https://github.com/OneEyed1366/symbiote-native/tree/master/packages/gl#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/OneEyed1366/symbiote-native/issues"
14
+ },
15
+ "author": "Andrey Prokopenko <psevdoproger@gmail.com>",
16
+ "keywords": [
17
+ "react-native",
18
+ "symbiote-native",
19
+ "expo-gl",
20
+ "react",
21
+ "vue",
22
+ "svelte",
23
+ "solid",
24
+ "angular",
25
+ "webgl",
26
+ "opengl"
27
+ ],
28
+ "type": "module",
29
+ "main": "./build/core/index.js",
30
+ "module": "./build/core/index.js",
31
+ "types": "./build/core/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./build/core/index.d.ts",
35
+ "default": "./build/core/index.js"
36
+ },
37
+ "./vue": {
38
+ "types": "./build/vue/index.d.ts",
39
+ "default": "./build/vue/index.js"
40
+ },
41
+ "./react": {
42
+ "types": "./build/react/index.d.ts",
43
+ "default": "./build/react/index.js"
44
+ },
45
+ "./svelte": "./src/svelte/index.ts",
46
+ "./solid": {
47
+ "types": "./build/solid/index.d.ts",
48
+ "default": "./build/solid/index.js"
49
+ },
50
+ "./angular": {
51
+ "types": "./build-ngc/angular/index.d.ts",
52
+ "react-native": "./build-ngc/angular/index.js",
53
+ "default": "./src/angular/index.ts"
54
+ }
55
+ },
56
+ "files": [
57
+ "src",
58
+ "build",
59
+ "build-ngc",
60
+ "native-link.json",
61
+ "!src/**/*.test.*",
62
+ "!src/**/*.spec.*",
63
+ "!src/**/*.detox.*"
64
+ ],
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "dependencies": {
69
+ "expo-gl": "57.0.2",
70
+ "expo-modules-core": "57.0.20",
71
+ "@symbiote-native/components": "3.2.0"
72
+ },
73
+ "peerDependencies": {
74
+ "@angular/core": ">=20",
75
+ "@vue/runtime-core": "^3.5.13",
76
+ "react": ">=19.0.0",
77
+ "react-native": ">=0.86",
78
+ "solid-js": ">=1.9.0",
79
+ "svelte": ">=5.56.0",
80
+ "vue": ">=3.5.0",
81
+ "@symbiote-native/angular": "^3.3.0",
82
+ "@symbiote-native/engine": "^1.6.0",
83
+ "@symbiote-native/react": "^3.3.0",
84
+ "@symbiote-native/solid": "^3.2.0",
85
+ "@symbiote-native/svelte": "^3.2.0",
86
+ "@symbiote-native/vue": "^3.3.0"
87
+ },
88
+ "peerDependenciesMeta": {
89
+ "@symbiote-native/angular": {
90
+ "optional": true
91
+ },
92
+ "@symbiote-native/react": {
93
+ "optional": true
94
+ },
95
+ "@symbiote-native/solid": {
96
+ "optional": true
97
+ },
98
+ "@symbiote-native/svelte": {
99
+ "optional": true
100
+ },
101
+ "@symbiote-native/vue": {
102
+ "optional": true
103
+ },
104
+ "@angular/core": {
105
+ "optional": true
106
+ },
107
+ "@vue/runtime-core": {
108
+ "optional": true
109
+ },
110
+ "react": {
111
+ "optional": true
112
+ },
113
+ "solid-js": {
114
+ "optional": true
115
+ },
116
+ "svelte": {
117
+ "optional": true
118
+ },
119
+ "vue": {
120
+ "optional": true
121
+ }
122
+ },
123
+ "devDependencies": {
124
+ "@angular/compiler": "~22.0.8",
125
+ "@angular/compiler-cli": "~22.0.8",
126
+ "@angular/core": "~22.0.8",
127
+ "@types/node": "^26.0.0",
128
+ "@types/react": "^19.2.0",
129
+ "@vue/runtime-core": "^3.5.13",
130
+ "react": "19.2.3",
131
+ "solid-js": "^1.9.14",
132
+ "svelte": "^5.56.0",
133
+ "typescript": "~6.0.0",
134
+ "@symbiote-native/angular": "3.3.0",
135
+ "@symbiote-native/engine": "1.6.0",
136
+ "@symbiote-native/react": "3.3.0",
137
+ "@symbiote-native/solid": "3.2.0",
138
+ "@symbiote-native/svelte": "3.2.0",
139
+ "@symbiote-native/test-utils": "0.4.7",
140
+ "@symbiote-native/vue": "3.3.0"
141
+ },
142
+ "scripts": {
143
+ "typecheck": "tsc --build",
144
+ "clean": "rm -rf build-ngc",
145
+ "ng:build": "pnpm run clean && ngc -p tsconfig.angular.json",
146
+ "format": "prettier --write \"src/**/*.{ts,tsx}\""
147
+ }
6
148
  }
@@ -0,0 +1,51 @@
1
+ import { ChangeDetectionStrategy, Component } from '@angular/core';
2
+ import { DescriptorOutlet, NativeViewBase } from '@symbiote-native/angular';
3
+ import type { IDescriptor } from '@symbiote-native/components';
4
+ import { createGLView } from '../../core';
5
+ import type { IGLViewProps } from '../../core';
6
+
7
+ // One list is the inputs of the component and the props it hands to the native view
8
+ const GL_VIEW_INPUTS = [
9
+ 'onContextCreate',
10
+ 'msaaSamples',
11
+ 'enableExperimentalWorkletSupport',
12
+ ] as const;
13
+
14
+ // Types the inputs for the template, the decorators that would do it are replaced by `inputs`
15
+ export interface GLView extends Partial<
16
+ Pick<IGLViewProps, (typeof GL_VIEW_INPUTS)[number]>
17
+ > {}
18
+
19
+ /** Angular twin of `expo-gl`'s `GLView` */
20
+ @Component({
21
+ selector: 'GLView',
22
+ standalone: true,
23
+ imports: [DescriptorOutlet],
24
+ inputs: [...GL_VIEW_INPUTS],
25
+ changeDetection: ChangeDetectionStrategy.OnPush,
26
+ template: `@if (descriptor; as node) {
27
+ <symbiote-descriptor-outlet [node]="node" />
28
+ }`,
29
+ })
30
+ export class GLView extends NativeViewBase {
31
+ private readonly view = createGLView(() => this.hostNode());
32
+
33
+ // The functions of the view are members of the component, a `@ViewChild` reaches them
34
+ readonly createCameraTextureAsync = this.view.handle.createCameraTextureAsync;
35
+ readonly destroyObjectAsync = this.view.handle.destroyObjectAsync;
36
+ readonly takeSnapshotAsync = this.view.handle.takeSnapshotAsync;
37
+
38
+ get exglCtxId(): number | undefined {
39
+ return this.view.handle.exglCtxId;
40
+ }
41
+
42
+ protected override readonly propNames = GL_VIEW_INPUTS;
43
+
44
+ protected override renderView(props: object): IDescriptor | null {
45
+ return this.view.render(props);
46
+ }
47
+
48
+ protected override disposeView(): void {
49
+ this.view.dispose();
50
+ }
51
+ }
@@ -0,0 +1,4 @@
1
+ // @symbiote-native/gl/angular: a GLView that gives a WebGL context to draw into, on a shared core
2
+
3
+ export { GLView } from './gl-view';
4
+ export * from '../core';
@@ -0,0 +1,6 @@
1
+ export const GL_MODULE_NAME = 'ExpoGL';
2
+
3
+ export const GL_PACKAGE_NAME = 'expo-gl';
4
+
5
+ /** Where the native module keeps the contexts it installs on the runtime, by id */
6
+ export const GL_CONTEXTS_GLOBAL = '__EXGLContexts';