@luma.gl/test-utils 9.0.0-alpha.6 → 9.0.0-alpha.7
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/dist/create-test-device.d.ts +3 -0
- package/dist/create-test-device.d.ts.map +1 -1
- package/dist/create-test-device.js +4 -6
- package/dist/create-test-device.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/register-devices.d.ts +2 -0
- package/dist/register-devices.d.ts.map +1 -0
- package/dist/register-devices.js +7 -0
- package/dist/register-devices.js.map +1 -0
- package/package.json +5 -4
- package/src/create-test-device.ts +8 -12
- package/src/index.ts +3 -3
- package/src/register-devices.ts +10 -0
- package/dist/create-headless-context.d.ts +0 -2
- package/dist/create-headless-context.d.ts.map +0 -1
- package/dist/create-headless-context.js +0 -37
- package/dist/create-headless-context.js.map +0 -1
- package/dist/create-test-context.d.ts +0 -2
- package/dist/create-test-context.d.ts.map +0 -1
- package/dist/create-test-context.js +0 -6
- package/dist/create-test-context.js.map +0 -1
- package/src/create-headless-context.ts +0 -36
- package/src/create-test-context.ts +0 -29
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Device, DeviceProps } from '@luma.gl/api';
|
|
2
2
|
import { WebGLDevice } from '@luma.gl/webgl';
|
|
3
3
|
import { WebGPUDevice } from '@luma.gl/webgpu';
|
|
4
|
+
/** Create a test WebGL context */
|
|
5
|
+
export declare function createTestContext(opts?: Record<string, any>): WebGLRenderingContext | null;
|
|
6
|
+
/** Create a test WebGLDevice */
|
|
4
7
|
export declare function createTestDevice(props?: DeviceProps): WebGLDevice | null;
|
|
5
8
|
export declare const webgl1TestDevice: WebGLDevice;
|
|
6
9
|
export declare const webgl2TestDevice: WebGLDevice;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-test-device.d.ts","sourceRoot":"","sources":["../src/create-test-device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-test-device.d.ts","sourceRoot":"","sources":["../src/create-test-device.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAQ7C,kCAAkC;AAClC,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,qBAAqB,GAAG,IAAI,CAG9F;AAED,gCAAgC;AAChC,wBAAgB,gBAAgB,CAAC,KAAK,GAAE,WAAgB,GAAG,WAAW,GAAG,IAAI,CAS5E;AAED,eAAO,MAAM,gBAAgB,EAAE,WAAuF,CAAC;AACvH,eAAO,MAAM,gBAAgB,EAAE,WAAuF,CAAC;AACvH,0DAA0D;AAC1D,eAAO,IAAI,gBAAgB,EAAE,YAAY,CAAC;AAI1C,yDAAyD;AACzD,wBAAgB,mBAAmB,IAAI,WAAW,EAAE,CAEnD;AAED,0CAA0C;AAC1C,wBAAsB,cAAc,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAUzD"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { isBrowser } from '@probe.gl/env';
|
|
2
1
|
import { luma } from '@luma.gl/api';
|
|
3
2
|
import { WebGLDevice } from '@luma.gl/webgl';
|
|
4
|
-
import { createHeadlessContext } from './create-headless-context';
|
|
5
|
-
const ERR_HEADLESSGL_FAILED = 'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
6
|
-
const ERR_HEADLESSGL_LOAD = " luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
|
|
7
3
|
const CONTEXT_DEFAULTS = {
|
|
8
4
|
width: 1,
|
|
9
5
|
height: 1,
|
|
10
6
|
debug: true
|
|
11
7
|
};
|
|
8
|
+
export function createTestContext(opts = {}) {
|
|
9
|
+
const device = createTestDevice(opts);
|
|
10
|
+
return device && device.gl;
|
|
11
|
+
}
|
|
12
12
|
export function createTestDevice(props = {}) {
|
|
13
13
|
try {
|
|
14
|
-
const gl = !isBrowser() ? createHeadlessContext(props) : undefined;
|
|
15
14
|
props = { ...CONTEXT_DEFAULTS,
|
|
16
15
|
...props,
|
|
17
|
-
gl,
|
|
18
16
|
debug: true
|
|
19
17
|
};
|
|
20
18
|
return new WebGLDevice(props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-test-device.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/create-test-device.ts"],"names":["luma","WebGLDevice","CONTEXT_DEFAULTS","width","height","debug","createTestContext","opts","device","createTestDevice","gl","props","error","console","id","message","webgl1TestDevice","webgl1","webgl2","webgl2TestDevice","webgpuTestDevice","webgpuCreated","getWebGLTestDevices","filter","Boolean","getTestDevices","createDevice","type"],"mappings":"AAGA,SAAQA,IAAR,QAAmB,cAAnB;AACA,SAAQC,WAAR,QAA0B,gBAA1B;AAGA,MAAMC,gBAAsC,GAAG;AAC7CC,EAAAA,KAAK,EAAE,CADsC;AAE7CC,EAAAA,MAAM,EAAE,CAFqC;AAG7CC,EAAAA,KAAK,EAAE;AAHsC,CAA/C;AAOA,OAAO,SAASC,iBAAT,CAA2BC,IAAyB,GAAG,EAAvD,EAAyF;AAC9F,QAAMC,MAAM,GAAGC,gBAAgB,CAACF,IAAD,CAA/B;AACA,SAAOC,MAAM,IAAIA,MAAM,CAACE,EAAxB;AACD;AAGD,OAAO,SAASD,gBAAT,CAA0BE,KAAkB,GAAG,EAA/C,EAAuE;AAC5E,MAAI;AACFA,IAAAA,KAAK,GAAG,EAAC,GAAGT,gBAAJ;AAAsB,SAAGS,KAAzB;AAAgCN,MAAAA,KAAK,EAAE;AAAvC,KAAR;AAEA,WAAO,IAAIJ,WAAJ,CAAgBU,KAAhB,CAAP;AACD,GAJD,CAIE,OAAOC,KAAP,EAAc;AACdC,IAAAA,OAAO,CAACD,KAAR,qCAA2CD,KAAK,CAACG,EAAjD,gBAAyDF,KAAK,CAACG,OAA/D;AACA,WAAO,IAAP;AACD;AACF;AAED,OAAO,MAAMC,gBAA6B,GAAGP,gBAAgB,CAAC;AAACK,EAAAA,EAAE,EAAE,oBAAL;AAA2BG,EAAAA,MAAM,EAAE,IAAnC;AAAyCC,EAAAA,MAAM,EAAE;AAAjD,CAAD,CAAtD;AACP,OAAO,MAAMC,gBAA6B,GAAGV,gBAAgB,CAAC;AAACK,EAAAA,EAAE,EAAE,oBAAL;AAA2BG,EAAAA,MAAM,EAAE,KAAnC;AAA0CC,EAAAA,MAAM,EAAE;AAAlD,CAAD,CAAtD;AAEP,OAAO,IAAIE,gBAAJ;AAEP,IAAIC,aAAa,GAAG,KAApB;AAGA,OAAO,SAASC,mBAAT,GAA8C;AACnD,SAAO,CAACH,gBAAD,EAAmBH,gBAAnB,EAAqCO,MAArC,CAA4CC,OAA5C,CAAP;AACD;AAGD,OAAO,eAAeC,cAAf,GAAoD;AACzD,MAAI,CAACJ,aAAL,EAAoB;AAClBA,IAAAA,aAAa,GAAG,IAAhB;;AACA,QAAI;AACFD,MAAAA,gBAAgB,GAAG,MAAMpB,IAAI,CAAC0B,YAAL,CAAkB;AAACZ,QAAAA,EAAE,EAAE,oBAAL;AAA2Ba,QAAAA,IAAI,EAAE;AAAjC,OAAlB,CAAzB;AACD,KAFD,CAEE,MAAM,CAEP;AACF;;AACD,SAAO,CAACP,gBAAD,EAAmBD,gBAAnB,EAAqCH,gBAArC,EAAuDO,MAAvD,CAA8DC,OAA9D,CAAP;AACD","sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, DeviceProps} from '@luma.gl/api';\nimport {luma} from '@luma.gl/api';\nimport {WebGLDevice} from '@luma.gl/webgl';\nimport {WebGPUDevice} from '@luma.gl/webgpu';\n\nconst CONTEXT_DEFAULTS: Partial<DeviceProps> = {\n width: 1,\n height: 1,\n debug: true\n};\n\n/** Create a test WebGL context */\nexport function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {\n const device = createTestDevice(opts);\n return device && device.gl;\n}\n\n/** Create a test WebGLDevice */\nexport function createTestDevice(props: DeviceProps = {}): WebGLDevice | null {\n try {\n props = {...CONTEXT_DEFAULTS, ...props, debug: true};\n // We dont use luma.createDevice since this tests current expect this context to be created synchronously\n return new WebGLDevice(props);\n } catch (error) {\n console.error(`Failed to created device '${props.id}': ${error.message}`);\n return null;\n }\n}\n\nexport const webgl1TestDevice: WebGLDevice = createTestDevice({id: 'webgl1-test-device', webgl1: true, webgl2: false});\nexport const webgl2TestDevice: WebGLDevice = createTestDevice({id: 'webgl2-test-device', webgl1: false, webgl2: true});\n/** Only available after getTestDevices() has completed */\nexport let webgpuTestDevice: WebGPUDevice;\n\nlet webgpuCreated = false;\n\n/** Synchronously get test devices (only WebGLDevices) */\nexport function getWebGLTestDevices(): WebGLDevice[] {\n return [webgl2TestDevice, webgl1TestDevice].filter(Boolean);\n}\n\n/** Includes WebGPU device if available */\nexport async function getTestDevices() : Promise<Device[]> {\n if (!webgpuCreated) {\n webgpuCreated = true;\n try {\n webgpuTestDevice = await luma.createDevice({id: 'webgpu-test-device', type: 'webgpu'}) as WebGPUDevice;\n } catch {\n // ignore (assume WebGPU was not available)\n }\n }\n return [webgpuTestDevice, webgl2TestDevice, webgl1TestDevice].filter(Boolean);\n}\n"],"file":"create-test-device.js"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import './register-devices';
|
|
1
2
|
export type { TestRunnerTestCase } from './test-runner';
|
|
2
3
|
export type { SnapshotTestRunnerTestCase } from './snapshot-test-runner';
|
|
3
4
|
export { default as SnapshotTestRunner } from './snapshot-test-runner';
|
|
4
5
|
export { default as PerformanceTestRunner } from './performance-test-runner';
|
|
5
|
-
export {
|
|
6
|
-
export { createTestContext } from './create-test-context';
|
|
7
|
-
export { createTestDevice, webgl1TestDevice, webgl2TestDevice, webgpuTestDevice } from './create-test-device';
|
|
6
|
+
export { createTestDevice, createTestContext, webgl1TestDevice, webgl2TestDevice, webgpuTestDevice } from './create-test-device';
|
|
8
7
|
export { getTestDevices, getWebGLTestDevices } from './create-test-device';
|
|
9
8
|
export { checkType } from './check-type';
|
|
10
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,YAAY,EAAC,0BAA0B,EAAC,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAC,OAAO,IAAI,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,YAAY,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,YAAY,EAAC,0BAA0B,EAAC,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAC,OAAO,IAAI,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAC,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAC/H,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import './register-devices';
|
|
1
2
|
export { default as SnapshotTestRunner } from './snapshot-test-runner';
|
|
2
3
|
export { default as PerformanceTestRunner } from './performance-test-runner';
|
|
3
|
-
export {
|
|
4
|
-
export { createTestContext } from './create-test-context';
|
|
5
|
-
export { createTestDevice, webgl1TestDevice, webgl2TestDevice, webgpuTestDevice } from './create-test-device';
|
|
4
|
+
export { createTestDevice, createTestContext, webgl1TestDevice, webgl2TestDevice, webgpuTestDevice } from './create-test-device';
|
|
6
5
|
export { getTestDevices, getWebGLTestDevices } from './create-test-device';
|
|
7
6
|
export { checkType } from './check-type';
|
|
8
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["default","SnapshotTestRunner","PerformanceTestRunner","
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["default","SnapshotTestRunner","PerformanceTestRunner","createTestDevice","createTestContext","webgl1TestDevice","webgl2TestDevice","webgpuTestDevice","getTestDevices","getWebGLTestDevices","checkType"],"mappings":"AAAA,OAAO,oBAAP;AAKA,SAAQA,OAAO,IAAIC,kBAAnB,QAA4C,wBAA5C;AACA,SAAQD,OAAO,IAAIE,qBAAnB,QAA+C,2BAA/C;AACA,SAAQC,gBAAR,EAA0BC,iBAA1B,EAA6CC,gBAA7C,EAA+DC,gBAA/D,EAAiFC,gBAAjF,QAAwG,sBAAxG;AACA,SAAQC,cAAR,EAAwBC,mBAAxB,QAAkD,sBAAlD;AAEA,SAAQC,SAAR,QAAwB,cAAxB","sourcesContent":["import './register-devices';\n\nexport type {TestRunnerTestCase} from './test-runner';\nexport type {SnapshotTestRunnerTestCase} from './snapshot-test-runner';\n\nexport {default as SnapshotTestRunner} from './snapshot-test-runner';\nexport {default as PerformanceTestRunner} from './performance-test-runner';\nexport {createTestDevice, createTestContext, webgl1TestDevice, webgl2TestDevice, webgpuTestDevice} from './create-test-device';\nexport {getTestDevices, getWebGLTestDevices} from './create-test-device';\n\nexport {checkType} from './check-type';\n"],"file":"index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-devices.d.ts","sourceRoot":"","sources":["../src/register-devices.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { luma } from '@luma.gl/api';
|
|
2
|
+
import { WebGLDevice, registerHeadlessGL } from '@luma.gl/webgl';
|
|
3
|
+
import { WebGPUDevice } from '@luma.gl/webgpu';
|
|
4
|
+
import headlessGL from 'gl';
|
|
5
|
+
registerHeadlessGL(headlessGL);
|
|
6
|
+
luma.registerDevices([WebGLDevice, WebGPUDevice]);
|
|
7
|
+
//# sourceMappingURL=register-devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/register-devices.ts"],"names":["luma","WebGLDevice","registerHeadlessGL","WebGPUDevice","headlessGL","registerDevices"],"mappings":"AAEA,SAAQA,IAAR,QAAmB,cAAnB;AACA,SAAQC,WAAR,EAAqBC,kBAArB,QAA8C,gBAA9C;AACA,SAAQC,YAAR,QAA2B,iBAA3B;AAEA,OAAOC,UAAP,MAAuB,IAAvB;AAEAF,kBAAkB,CAACE,UAAD,CAAlB;AACAJ,IAAI,CAACK,eAAL,CAAqB,CAACJ,WAAD,EAAcE,YAAd,CAArB","sourcesContent":["// luma.gl, MIT license\n\nimport {luma} from '@luma.gl/api';\nimport {WebGLDevice, registerHeadlessGL} from '@luma.gl/webgl';\nimport {WebGPUDevice} from '@luma.gl/webgpu';\n\nimport headlessGL from 'gl';\n\nregisterHeadlessGL(headlessGL);\nluma.registerDevices([WebGLDevice, WebGPUDevice]);\n"],"file":"register-devices.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/test-utils",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.7",
|
|
4
4
|
"description": "Automated WebGL testing utilities with Puppeteer and image diffing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,12 +31,13 @@
|
|
|
31
31
|
"pre-build": "echo test utils has no bundle"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@probe.gl/env": "^3.5.0"
|
|
34
|
+
"@probe.gl/env": "^3.5.0",
|
|
35
|
+
"gl": "^5.0.3"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"@luma.gl/
|
|
38
|
+
"@luma.gl/api": "9.0.0-alpha.5",
|
|
38
39
|
"@luma.gl/webgl": "9.0.0-alpha.5",
|
|
39
40
|
"@probe.gl/test-utils": "^3.5.0"
|
|
40
41
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "c1fbf71bb1311dcdc54338d82d299f8ed0d73346"
|
|
42
43
|
}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
// luma.gl, MIT license
|
|
2
2
|
|
|
3
|
-
import {isBrowser} from '@probe.gl/env';
|
|
4
3
|
import type {Device, DeviceProps} from '@luma.gl/api';
|
|
5
4
|
import {luma} from '@luma.gl/api';
|
|
6
5
|
import {WebGLDevice} from '@luma.gl/webgl';
|
|
7
6
|
import {WebGPUDevice} from '@luma.gl/webgpu';
|
|
8
|
-
import {createHeadlessContext} from './create-headless-context';
|
|
9
|
-
|
|
10
|
-
const ERR_HEADLESSGL_FAILED =
|
|
11
|
-
'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
12
|
-
|
|
13
|
-
const ERR_HEADLESSGL_LOAD = `\
|
|
14
|
-
luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
|
|
15
|
-
contexts can not be created. This may not be an error. For example, this is a \
|
|
16
|
-
typical configuration for isorender applications running on the server.`;
|
|
17
7
|
|
|
18
8
|
const CONTEXT_DEFAULTS: Partial<DeviceProps> = {
|
|
19
9
|
width: 1,
|
|
@@ -21,10 +11,16 @@ const CONTEXT_DEFAULTS: Partial<DeviceProps> = {
|
|
|
21
11
|
debug: true
|
|
22
12
|
};
|
|
23
13
|
|
|
14
|
+
/** Create a test WebGL context */
|
|
15
|
+
export function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {
|
|
16
|
+
const device = createTestDevice(opts);
|
|
17
|
+
return device && device.gl;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Create a test WebGLDevice */
|
|
24
21
|
export function createTestDevice(props: DeviceProps = {}): WebGLDevice | null {
|
|
25
22
|
try {
|
|
26
|
-
|
|
27
|
-
props = {...CONTEXT_DEFAULTS, ...props, gl, debug: true};
|
|
23
|
+
props = {...CONTEXT_DEFAULTS, ...props, debug: true};
|
|
28
24
|
// We dont use luma.createDevice since this tests current expect this context to be created synchronously
|
|
29
25
|
return new WebGLDevice(props);
|
|
30
26
|
} catch (error) {
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import './register-devices';
|
|
2
|
+
|
|
1
3
|
export type {TestRunnerTestCase} from './test-runner';
|
|
2
4
|
export type {SnapshotTestRunnerTestCase} from './snapshot-test-runner';
|
|
3
5
|
|
|
4
6
|
export {default as SnapshotTestRunner} from './snapshot-test-runner';
|
|
5
7
|
export {default as PerformanceTestRunner} from './performance-test-runner';
|
|
6
|
-
export {
|
|
7
|
-
export {createTestContext} from './create-test-context';
|
|
8
|
-
export {createTestDevice, webgl1TestDevice, webgl2TestDevice, webgpuTestDevice} from './create-test-device';
|
|
8
|
+
export {createTestDevice, createTestContext, webgl1TestDevice, webgl2TestDevice, webgpuTestDevice} from './create-test-device';
|
|
9
9
|
export {getTestDevices, getWebGLTestDevices} from './create-test-device';
|
|
10
10
|
|
|
11
11
|
export {checkType} from './check-type';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import {luma} from '@luma.gl/api';
|
|
4
|
+
import {WebGLDevice, registerHeadlessGL} from '@luma.gl/webgl';
|
|
5
|
+
import {WebGPUDevice} from '@luma.gl/webgpu';
|
|
6
|
+
|
|
7
|
+
import headlessGL from 'gl';
|
|
8
|
+
|
|
9
|
+
registerHeadlessGL(headlessGL);
|
|
10
|
+
luma.registerDevices([WebGLDevice, WebGPUDevice]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-headless-context.d.ts","sourceRoot":"","sources":["../src/create-headless-context.ts"],"names":[],"mappings":"AAmBA,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,qBAAqB,CAgB1E"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import headlessGL from 'gl';
|
|
2
|
-
const ERR_HEADLESSGL_FAILED = 'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
3
|
-
const ERR_HEADLESSGL_LOAD = " luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
|
|
4
|
-
const CONTEXT_DEFAULTS = {
|
|
5
|
-
width: 1,
|
|
6
|
-
height: 1,
|
|
7
|
-
debug: true,
|
|
8
|
-
throwOnError: false
|
|
9
|
-
};
|
|
10
|
-
export function createHeadlessContext(options) {
|
|
11
|
-
options = { ...CONTEXT_DEFAULTS,
|
|
12
|
-
...options
|
|
13
|
-
};
|
|
14
|
-
const {
|
|
15
|
-
width,
|
|
16
|
-
height,
|
|
17
|
-
webgl1,
|
|
18
|
-
webgl2
|
|
19
|
-
} = options;
|
|
20
|
-
|
|
21
|
-
if (webgl2 && !webgl1) {
|
|
22
|
-
throw new Error('headless-gl does not support WebGL2');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!headlessGL) {
|
|
26
|
-
throw new Error(ERR_HEADLESSGL_LOAD);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const gl = headlessGL(width, height, options);
|
|
30
|
-
|
|
31
|
-
if (!gl) {
|
|
32
|
-
throw new Error(ERR_HEADLESSGL_FAILED);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return gl;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=create-headless-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-headless-context.ts"],"names":["headlessGL","ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","createHeadlessContext","options","webgl1","webgl2","Error","gl"],"mappings":"AAAA,OAAOA,UAAP,MAAuB,IAAvB;AAEA,MAAMC,qBAAqB,GACzB,sEADF;AAGA,MAAMC,mBAAmB,gPAAzB;AAKA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,KAAK,EAAE,CADgB;AAEvBC,EAAAA,MAAM,EAAE,CAFe;AAGvBC,EAAAA,KAAK,EAAE,IAHgB;AAIvBC,EAAAA,YAAY,EAAE;AAJS,CAAzB;AASA,OAAO,SAASC,qBAAT,CAA+BC,OAA/B,EAAqE;AAC1EA,EAAAA,OAAO,GAAG,EAAC,GAAGN,gBAAJ;AAAsB,OAAGM;AAAzB,GAAV;AAEA,QAAM;AAACL,IAAAA,KAAD;AAAQC,IAAAA,MAAR;AAAgBK,IAAAA,MAAhB;AAAwBC,IAAAA;AAAxB,MAAkCF,OAAxC;;AAEA,MAAIE,MAAM,IAAI,CAACD,MAAf,EAAuB;AACrB,UAAM,IAAIE,KAAJ,CAAU,qCAAV,CAAN;AACD;;AACD,MAAI,CAACZ,UAAL,EAAiB;AACf,UAAM,IAAIY,KAAJ,CAAUV,mBAAV,CAAN;AACD;;AACD,QAAMW,EAAE,GAAGb,UAAU,CAACI,KAAD,EAAQC,MAAR,EAAgBI,OAAhB,CAArB;;AACA,MAAI,CAACI,EAAL,EAAS;AACP,UAAM,IAAID,KAAJ,CAAUX,qBAAV,CAAN;AACD;;AACD,SAAOY,EAAP;AACD","sourcesContent":["import headlessGL from 'gl';\n\nconst ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\n// Create headless gl context (for running under Node.js)\n// Create headless gl context (for running under Node.js)\nexport function createHeadlessContext(options?: any): WebGLRenderingContext {\n options = {...CONTEXT_DEFAULTS, ...options};\n\n const {width, height, webgl1, webgl2} = options;\n\n if (webgl2 && !webgl1) {\n throw new Error('headless-gl does not support WebGL2');\n }\n if (!headlessGL) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n throw new Error(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n"],"file":"create-headless-context.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-test-context.d.ts","sourceRoot":"","sources":["../src/create-test-context.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,qBAAqB,GAAG,IAAI,CAG9F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-test-context.ts"],"names":["createTestDevice","createTestContext","opts","device","gl"],"mappings":"AAAA,SAASA,gBAAT,QAAiC,sBAAjC;AAEA,OAAO,SAASC,iBAAT,CAA2BC,IAAyB,GAAG,EAAvD,EAAyF;AAC9F,QAAMC,MAAM,GAAGH,gBAAgB,CAACE,IAAD,CAA/B;AACA,SAAOC,MAAM,IAAIA,MAAM,CAACC,EAAxB;AACD","sourcesContent":["import { createTestDevice } from \"./create-test-device\";\n\nexport function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {\n const device = createTestDevice(opts);\n return device && device.gl;\n}\n\n /*\nimport {isBrowser} from '@probe.gl/env';\nimport {createGLContext, instrumentGLContext} from '@luma.gl/gltools';\nimport {createHeadlessContext} from './create-headless-context';\n\nexport function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {\n // try {\n if (!isBrowser()) {\n if (opts.webgl2 && !opts.webgl1) {\n return null;\n }\n const gl = createHeadlessContext(opts);\n return gl ? instrumentGLContext(gl) : null;\n }\n return createGLContext(opts);\n // } catch {\n // if (opts.webgl2) {\n // return null;\n // }\n // }\n}\n*/\n"],"file":"create-test-context.js"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import headlessGL from 'gl';
|
|
2
|
-
|
|
3
|
-
const ERR_HEADLESSGL_FAILED =
|
|
4
|
-
'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
5
|
-
|
|
6
|
-
const ERR_HEADLESSGL_LOAD = `\
|
|
7
|
-
luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
|
|
8
|
-
contexts can not be created. This may not be an error. For example, this is a \
|
|
9
|
-
typical configuration for isorender applications running on the server.`;
|
|
10
|
-
|
|
11
|
-
const CONTEXT_DEFAULTS = {
|
|
12
|
-
width: 1,
|
|
13
|
-
height: 1,
|
|
14
|
-
debug: true,
|
|
15
|
-
throwOnError: false
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// Create headless gl context (for running under Node.js)
|
|
19
|
-
// Create headless gl context (for running under Node.js)
|
|
20
|
-
export function createHeadlessContext(options?: any): WebGLRenderingContext {
|
|
21
|
-
options = {...CONTEXT_DEFAULTS, ...options};
|
|
22
|
-
|
|
23
|
-
const {width, height, webgl1, webgl2} = options;
|
|
24
|
-
|
|
25
|
-
if (webgl2 && !webgl1) {
|
|
26
|
-
throw new Error('headless-gl does not support WebGL2');
|
|
27
|
-
}
|
|
28
|
-
if (!headlessGL) {
|
|
29
|
-
throw new Error(ERR_HEADLESSGL_LOAD);
|
|
30
|
-
}
|
|
31
|
-
const gl = headlessGL(width, height, options);
|
|
32
|
-
if (!gl) {
|
|
33
|
-
throw new Error(ERR_HEADLESSGL_FAILED);
|
|
34
|
-
}
|
|
35
|
-
return gl;
|
|
36
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createTestDevice } from "./create-test-device";
|
|
2
|
-
|
|
3
|
-
export function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {
|
|
4
|
-
const device = createTestDevice(opts);
|
|
5
|
-
return device && device.gl;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
import {isBrowser} from '@probe.gl/env';
|
|
10
|
-
import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';
|
|
11
|
-
import {createHeadlessContext} from './create-headless-context';
|
|
12
|
-
|
|
13
|
-
export function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {
|
|
14
|
-
// try {
|
|
15
|
-
if (!isBrowser()) {
|
|
16
|
-
if (opts.webgl2 && !opts.webgl1) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
const gl = createHeadlessContext(opts);
|
|
20
|
-
return gl ? instrumentGLContext(gl) : null;
|
|
21
|
-
}
|
|
22
|
-
return createGLContext(opts);
|
|
23
|
-
// } catch {
|
|
24
|
-
// if (opts.webgl2) {
|
|
25
|
-
// return null;
|
|
26
|
-
// }
|
|
27
|
-
// }
|
|
28
|
-
}
|
|
29
|
-
*/
|