@luma.gl/test-utils 9.0.0-alpha.1 → 9.0.0-alpha.11
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 +6 -3
- package/dist/create-test-device.d.ts.map +1 -1
- package/dist/create-test-device.js +26 -12
- 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/performance-test-runner.d.ts +4 -4
- package/dist/performance-test-runner.d.ts.map +1 -1
- package/dist/performance-test-runner.js +9 -7
- package/dist/performance-test-runner.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/dist/utils.d.ts +5 -5
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +8 -5
- package/src/create-test-device.ts +29 -19
- package/src/index.ts +3 -3
- package/src/performance-test-runner.ts +12 -10
- package/src/register-devices.ts +10 -0
- package/src/utils.ts +1 -1
- 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,11 +1,14 @@
|
|
|
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
|
-
export declare const
|
|
6
|
-
export declare const
|
|
8
|
+
export declare const webgl1Device: WebGLDevice;
|
|
9
|
+
export declare const webgl2Device: WebGLDevice;
|
|
7
10
|
/** Only available after getTestDevices() has completed */
|
|
8
|
-
export declare let
|
|
11
|
+
export declare let webgpuDevice: WebGPUDevice;
|
|
9
12
|
/** Synchronously get test devices (only WebGLDevices) */
|
|
10
13
|
export declare function getWebGLTestDevices(): WebGLDevice[];
|
|
11
14
|
/** Includes WebGPU device if available */
|
|
@@ -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,YAAY,EAAE,WAAuF,CAAC;AACnH,eAAO,MAAM,YAAY,EAAE,WAAuF,CAAC;AACnH,0DAA0D;AAC1D,eAAO,IAAI,YAAY,EAAE,YAAY,CAAC;AAItC,yDAAyD;AACzD,wBAAgB,mBAAmB,IAAI,WAAW,EAAE,CASnD;AAED,0CAA0C;AAC1C,wBAAsB,cAAc,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAezD"}
|
|
@@ -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);
|
|
@@ -23,33 +21,49 @@ export function createTestDevice(props = {}) {
|
|
|
23
21
|
return null;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
export const
|
|
24
|
+
export const webgl1Device = createTestDevice({
|
|
27
25
|
id: 'webgl1-test-device',
|
|
28
26
|
webgl1: true,
|
|
29
27
|
webgl2: false
|
|
30
28
|
});
|
|
31
|
-
export const
|
|
29
|
+
export const webgl2Device = createTestDevice({
|
|
32
30
|
id: 'webgl2-test-device',
|
|
33
31
|
webgl1: false,
|
|
34
32
|
webgl2: true
|
|
35
33
|
});
|
|
36
|
-
export let
|
|
34
|
+
export let webgpuDevice;
|
|
37
35
|
let webgpuCreated = false;
|
|
38
36
|
export function getWebGLTestDevices() {
|
|
39
|
-
|
|
37
|
+
const devices = [];
|
|
38
|
+
|
|
39
|
+
if (webgl2Device) {
|
|
40
|
+
devices.push(webgl2Device);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (webgl1Device) {
|
|
44
|
+
devices.push(webgl1Device);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return devices;
|
|
40
48
|
}
|
|
41
49
|
export async function getTestDevices() {
|
|
42
50
|
if (!webgpuCreated) {
|
|
43
51
|
webgpuCreated = true;
|
|
44
52
|
|
|
45
53
|
try {
|
|
46
|
-
|
|
54
|
+
webgpuDevice = await luma.createDevice({
|
|
47
55
|
id: 'webgpu-test-device',
|
|
48
56
|
type: 'webgpu'
|
|
49
57
|
});
|
|
50
58
|
} catch {}
|
|
51
59
|
}
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
const devices = getWebGLTestDevices();
|
|
62
|
+
|
|
63
|
+
if (webgpuDevice) {
|
|
64
|
+
devices.unshift(webgpuDevice);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return devices;
|
|
54
68
|
}
|
|
55
69
|
//# sourceMappingURL=create-test-device.js.map
|
|
@@ -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","webgl1Device","webgl1","webgl2","webgl2Device","webgpuDevice","webgpuCreated","getWebGLTestDevices","devices","push","getTestDevices","createDevice","type","unshift"],"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,gBAA0DF,KAAD,CAAiBG,OAA1E;AACA,WAAO,IAAP;AACD;AACF;AAED,OAAO,MAAMC,YAAyB,GAAGP,gBAAgB,CAAC;AAACK,EAAAA,EAAE,EAAE,oBAAL;AAA2BG,EAAAA,MAAM,EAAE,IAAnC;AAAyCC,EAAAA,MAAM,EAAE;AAAjD,CAAD,CAAlD;AACP,OAAO,MAAMC,YAAyB,GAAGV,gBAAgB,CAAC;AAACK,EAAAA,EAAE,EAAE,oBAAL;AAA2BG,EAAAA,MAAM,EAAE,KAAnC;AAA0CC,EAAAA,MAAM,EAAE;AAAlD,CAAD,CAAlD;AAEP,OAAO,IAAIE,YAAJ;AAEP,IAAIC,aAAa,GAAG,KAApB;AAGA,OAAO,SAASC,mBAAT,GAA8C;AACnD,QAAMC,OAAsB,GAAG,EAA/B;;AACA,MAAIJ,YAAJ,EAAkB;AAChBI,IAAAA,OAAO,CAACC,IAAR,CAAaL,YAAb;AACD;;AACD,MAAIH,YAAJ,EAAkB;AAChBO,IAAAA,OAAO,CAACC,IAAR,CAAaR,YAAb;AACD;;AACD,SAAOO,OAAP;AACD;AAGD,OAAO,eAAeE,cAAf,GAAoD;AACzD,MAAI,CAACJ,aAAL,EAAoB;AAClBA,IAAAA,aAAa,GAAG,IAAhB;;AACA,QAAI;AACFD,MAAAA,YAAY,GAAG,MAAMpB,IAAI,CAAC0B,YAAL,CAAkB;AAACZ,QAAAA,EAAE,EAAE,oBAAL;AAA2Ba,QAAAA,IAAI,EAAE;AAAjC,OAAlB,CAArB;AACD,KAFD,CAEE,MAAM,CAEP;AACF;;AAED,QAAMJ,OAAiB,GAAGD,mBAAmB,EAA7C;;AACA,MAAIF,YAAJ,EAAkB;AAChBG,IAAAA,OAAO,CAACK,OAAR,CAAgBR,YAAhB;AACD;;AACD,SAAOG,OAAP;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 as Error).message}`);\n return null;\n }\n}\n\nexport const webgl1Device: WebGLDevice = createTestDevice({id: 'webgl1-test-device', webgl1: true, webgl2: false});\nexport const webgl2Device: WebGLDevice = createTestDevice({id: 'webgl2-test-device', webgl1: false, webgl2: true});\n/** Only available after getTestDevices() has completed */\nexport let webgpuDevice: WebGPUDevice;\n\nlet webgpuCreated = false;\n\n/** Synchronously get test devices (only WebGLDevices) */\nexport function getWebGLTestDevices(): WebGLDevice[] {\n const devices: WebGLDevice[] = [];\n if (webgl2Device) {\n devices.push(webgl2Device);\n }\n if (webgl1Device) {\n devices.push(webgl1Device);\n }\n return devices;\n}\n\n/** Includes WebGPU device if available */\nexport async function getTestDevices() : Promise<Device[]> {\n if (!webgpuCreated) {\n webgpuCreated = true;\n try {\n webgpuDevice = await luma.createDevice({id: 'webgpu-test-device', type: 'webgpu'}) as WebGPUDevice;\n } catch {\n // ignore (assume WebGPU was not available)\n }\n }\n\n const devices: Device[] = getWebGLTestDevices();\n if (webgpuDevice) {\n devices.unshift(webgpuDevice);\n }\n return devices;\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, webgl1Device, webgl2Device, webgpuDevice } 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,YAAY,EAAE,YAAY,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACnH,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, webgl1Device, webgl2Device, webgpuDevice } 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","webgl1Device","webgl2Device","webgpuDevice","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,YAA7C,EAA2DC,YAA3D,EAAyEC,YAAzE,QAA4F,sBAA5F;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, webgl1Device, webgl2Device, webgpuDevice} from './create-test-device';\nexport {getTestDevices, getWebGLTestDevices} from './create-test-device';\n\nexport {checkType} from './check-type';\n"],"file":"index.js"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import TestRunner, { TestRunnerOptions } from './test-runner';
|
|
1
|
+
import TestRunner, { TestRunnerOptions, TestRunnerTestCase } from './test-runner';
|
|
2
2
|
export default class PerformanceTestRunner extends TestRunner {
|
|
3
3
|
private _stats;
|
|
4
4
|
private _fps;
|
|
5
5
|
constructor(props: TestRunnerOptions);
|
|
6
|
-
initTestCase(testCase:
|
|
7
|
-
shouldRender(animationProps: any): boolean;
|
|
8
|
-
assert(testCase:
|
|
6
|
+
initTestCase(testCase: TestRunnerTestCase): void;
|
|
7
|
+
shouldRender(animationProps: Record<string, any>): boolean;
|
|
8
|
+
assert(testCase: TestRunnerTestCase): void;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=performance-test-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performance-test-runner.d.ts","sourceRoot":"","sources":["../src/performance-test-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"performance-test-runner.d.ts","sourceRoot":"","sources":["../src/performance-test-runner.ts"],"names":[],"mappings":"AAGA,OAAO,UAAU,EAAE,EAAC,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAEhF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU;IAC3D,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,IAAI,CAAqB;gBAErB,KAAK,EAAE,iBAAiB;IASpC,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAMhD,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO;IAY1D,MAAM,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;CAa3C"}
|
|
@@ -5,9 +5,9 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props);
|
|
7
7
|
|
|
8
|
-
_defineProperty(this, "_stats",
|
|
8
|
+
_defineProperty(this, "_stats", null);
|
|
9
9
|
|
|
10
|
-
_defineProperty(this, "_fps",
|
|
10
|
+
_defineProperty(this, "_fps", null);
|
|
11
11
|
|
|
12
12
|
Object.assign(this.testOptions, {
|
|
13
13
|
maxFramesToRender: 60,
|
|
@@ -24,9 +24,10 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
shouldRender(animationProps) {
|
|
27
|
-
|
|
27
|
+
var _this$_fps, _this$_fps2;
|
|
28
28
|
|
|
29
|
-
this._fps.
|
|
29
|
+
(_this$_fps = this._fps) === null || _this$_fps === void 0 ? void 0 : _this$_fps.timeEnd();
|
|
30
|
+
(_this$_fps2 = this._fps) === null || _this$_fps2 === void 0 ? void 0 : _this$_fps2.timeStart();
|
|
30
31
|
|
|
31
32
|
if (this._fps.count > this.testOptions.maxFramesToRender) {
|
|
32
33
|
animationProps.done();
|
|
@@ -36,10 +37,11 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
assert(testCase) {
|
|
39
|
-
|
|
40
|
-
const count = this._fps.count;
|
|
40
|
+
var _this$_fps3, _this$_fps4;
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;
|
|
43
|
+
const count = (_this$_fps3 = this._fps) === null || _this$_fps3 === void 0 ? void 0 : _this$_fps3.count;
|
|
44
|
+
const fps = ((_this$_fps4 = this._fps) === null || _this$_fps4 === void 0 ? void 0 : _this$_fps4.getHz()) || 0;
|
|
43
45
|
|
|
44
46
|
if (fps >= targetFPS) {
|
|
45
47
|
this._pass({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/performance-test-runner.ts"],"names":["Stats","TestRunner","PerformanceTestRunner","constructor","props","Object","assign","testOptions","maxFramesToRender","targetFPS","initTestCase","testCase","_stats","id","name","_fps","get","shouldRender","animationProps","timeEnd","timeStart","count","done","assert","fps","getHz","_pass","framesRendered","_fail","_next"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../src/performance-test-runner.ts"],"names":["Stats","TestRunner","PerformanceTestRunner","constructor","props","Object","assign","testOptions","maxFramesToRender","targetFPS","initTestCase","testCase","_stats","id","name","_fps","get","shouldRender","animationProps","timeEnd","timeStart","count","done","assert","fps","getHz","_pass","framesRendered","_fail","_next"],"mappings":";AAEA,SAAQA,KAAR,QAA0B,iBAA1B;AACA,OAAOC,UAAP,MAAgE,eAAhE;AAEA,eAAe,MAAMC,qBAAN,SAAoCD,UAApC,CAA+C;AAI5DE,EAAAA,WAAW,CAACC,KAAD,EAA2B;AACpC,UAAMA,KAAN;;AADoC,oCAHP,IAGO;;AAAA,kCAFV,IAEU;;AAGpCC,IAAAA,MAAM,CAACC,MAAP,CAAc,KAAKC,WAAnB,EAAgC;AAC9BC,MAAAA,iBAAiB,EAAE,EADW;AAE9BC,MAAAA,SAAS,EAAE;AAFmB,KAAhC;AAID;;AAEDC,EAAAA,YAAY,CAACC,QAAD,EAAqC;AAC/C,UAAMD,YAAN,CAAmBC,QAAnB;AACA,SAAKC,MAAL,GAAc,IAAIZ,KAAJ,CAAU;AAACa,MAAAA,EAAE,EAAEF,QAAQ,CAACG;AAAd,KAAV,CAAd;AACA,SAAKC,IAAL,GAAY,KAAKH,MAAL,CAAYI,GAAZ,CAAgB,KAAhB,CAAZ;AACD;;AAEDC,EAAAA,YAAY,CAACC,cAAD,EAA+C;AAAA;;AACzD,uBAAKH,IAAL,0DAAWI,OAAX;AACA,wBAAKJ,IAAL,4DAAWK,SAAX;;AAGA,QAAI,KAAKL,IAAL,CAAUM,KAAV,GAAkB,KAAKd,WAAL,CAAiBC,iBAAvC,EAA0D;AACxDU,MAAAA,cAAc,CAACI,IAAf;AACD;;AAED,WAAO,IAAP;AACD;;AAEDC,EAAAA,MAAM,CAACZ,QAAD,EAAqC;AAAA;;AAEzC,UAAMF,SAAS,GAAGE,QAAQ,CAACF,SAAT,IAAsB,KAAKF,WAAL,CAAiBE,SAAzD;AACA,UAAMY,KAAK,kBAAG,KAAKN,IAAR,gDAAG,YAAWM,KAAzB;AACA,UAAMG,GAAG,GAAG,qBAAKT,IAAL,4DAAWU,KAAX,OAAsB,CAAlC;;AAEA,QAAID,GAAG,IAAIf,SAAX,EAAsB;AACpB,WAAKiB,KAAL,CAAW;AAACF,QAAAA,GAAD;AAAMG,QAAAA,cAAc,EAAEN;AAAtB,OAAX;AACD,KAFD,MAEO;AACL,WAAKO,KAAL,CAAW;AAACJ,QAAAA,GAAD;AAAMG,QAAAA,cAAc,EAAEN;AAAtB,OAAX;AACD;;AACD,SAAKQ,KAAL;AACD;;AA3C2D","sourcesContent":["// luma.gl, MIT license\n\nimport {Stats, Stat} from '@probe.gl/stats';\nimport TestRunner, {TestRunnerOptions, TestRunnerTestCase} from './test-runner';\n\nexport default class PerformanceTestRunner extends TestRunner {\n private _stats: Stats | null = null;\n private _fps: Stat | null = null;\n\n constructor(props: TestRunnerOptions) {\n super(props);\n\n Object.assign(this.testOptions, {\n maxFramesToRender: 60,\n targetFPS: 50\n });\n }\n\n initTestCase(testCase: TestRunnerTestCase): void {\n super.initTestCase(testCase);\n this._stats = new Stats({id: testCase.name});\n this._fps = this._stats.get('fps');\n }\n\n shouldRender(animationProps: Record<string, any>): boolean {\n this._fps?.timeEnd();\n this._fps?.timeStart();\n\n // @ts-expect-error\n if (this._fps.count > this.testOptions.maxFramesToRender) {\n animationProps.done();\n }\n\n return true;\n }\n\n assert(testCase: TestRunnerTestCase): void {\n // @ts-expect-error\n const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;\n const count = this._fps?.count;\n const fps = this._fps?.getHz() || 0;\n\n if (fps >= targetFPS) {\n this._pass({fps, framesRendered: count});\n } else {\n this._fail({fps, framesRendered: count});\n }\n this._next();\n }\n}\n"],"file":"performance-test-runner.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/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare function getBoundingBoxInPage(domElement:
|
|
2
|
-
x:
|
|
3
|
-
y:
|
|
4
|
-
width:
|
|
5
|
-
height:
|
|
1
|
+
export declare function getBoundingBoxInPage(domElement: HTMLElement): {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,wBAAgB,oBAAoB,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,WAAW,GAAG;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;CAAC,CAQpH"}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.ts"],"names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"mappings":"AACA,OAAO,SAASA,oBAAT,CAA8BC,UAA9B,
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"mappings":"AACA,OAAO,SAASA,oBAAT,CAA8BC,UAA9B,EAA+G;AACpH,QAAMC,IAAI,GAAGD,UAAU,CAACE,qBAAX,EAAb;AACA,SAAO;AACLC,IAAAA,CAAC,EAAEC,MAAM,CAACC,OAAP,GAAiBJ,IAAI,CAACE,CADpB;AAELG,IAAAA,CAAC,EAAEF,MAAM,CAACG,OAAP,GAAiBN,IAAI,CAACK,CAFpB;AAGLE,IAAAA,KAAK,EAAEP,IAAI,CAACO,KAHP;AAILC,IAAAA,MAAM,EAAER,IAAI,CAACQ;AAJR,GAAP;AAMD","sourcesContent":["// Get the bounding box of a DOMElement relative to the page\nexport function getBoundingBoxInPage(domElement: HTMLElement): {x: number; y: number; width: number; height: number;} {\n const bbox = domElement.getBoundingClientRect();\n return {\n x: window.scrollX + bbox.x,\n y: window.scrollY + bbox.y,\n width: bbox.width,\n height: bbox.height\n };\n}\n"],"file":"utils.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.11",
|
|
4
4
|
"description": "Automated WebGL testing utilities with Puppeteer and image diffing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,12 +31,15 @@
|
|
|
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
|
+
"@types/gl": "^6.0.2",
|
|
36
|
+
"gl": "^5.0.3"
|
|
35
37
|
},
|
|
36
38
|
"peerDependencies": {
|
|
37
|
-
"@luma.gl/
|
|
38
|
-
"@luma.gl/webgl": "
|
|
39
|
+
"@luma.gl/api": "9.0.0-alpha.9",
|
|
40
|
+
"@luma.gl/webgl": "9.0.0-alpha.9",
|
|
41
|
+
"@luma.gl/webgpu": "9.0.0-alpha.9",
|
|
39
42
|
"@probe.gl/test-utils": "^3.5.0"
|
|
40
43
|
},
|
|
41
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "3a99f57970a609d50948851aec7a56d56685ab62"
|
|
42
45
|
}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
|
|
2
3
|
import type {Device, DeviceProps} from '@luma.gl/api';
|
|
3
4
|
import {luma} from '@luma.gl/api';
|
|
4
5
|
import {WebGLDevice} from '@luma.gl/webgl';
|
|
5
6
|
import {WebGPUDevice} from '@luma.gl/webgpu';
|
|
6
|
-
import {createHeadlessContext} from './create-headless-context';
|
|
7
|
-
|
|
8
|
-
const ERR_HEADLESSGL_FAILED =
|
|
9
|
-
'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
10
|
-
|
|
11
|
-
const ERR_HEADLESSGL_LOAD = `\
|
|
12
|
-
luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
|
|
13
|
-
contexts can not be created. This may not be an error. For example, this is a \
|
|
14
|
-
typical configuration for isorender applications running on the server.`;
|
|
15
7
|
|
|
16
8
|
const CONTEXT_DEFAULTS: Partial<DeviceProps> = {
|
|
17
9
|
width: 1,
|
|
@@ -19,28 +11,41 @@ const CONTEXT_DEFAULTS: Partial<DeviceProps> = {
|
|
|
19
11
|
debug: true
|
|
20
12
|
};
|
|
21
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 */
|
|
22
21
|
export function createTestDevice(props: DeviceProps = {}): WebGLDevice | null {
|
|
23
22
|
try {
|
|
24
|
-
|
|
25
|
-
props = {...CONTEXT_DEFAULTS, ...props, gl, debug: true};
|
|
23
|
+
props = {...CONTEXT_DEFAULTS, ...props, debug: true};
|
|
26
24
|
// We dont use luma.createDevice since this tests current expect this context to be created synchronously
|
|
27
25
|
return new WebGLDevice(props);
|
|
28
26
|
} catch (error) {
|
|
29
|
-
console.error(`Failed to created device '${props.id}': ${error.message}`);
|
|
27
|
+
console.error(`Failed to created device '${props.id}': ${(error as Error).message}`);
|
|
30
28
|
return null;
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
export const
|
|
35
|
-
export const
|
|
32
|
+
export const webgl1Device: WebGLDevice = createTestDevice({id: 'webgl1-test-device', webgl1: true, webgl2: false});
|
|
33
|
+
export const webgl2Device: WebGLDevice = createTestDevice({id: 'webgl2-test-device', webgl1: false, webgl2: true});
|
|
36
34
|
/** Only available after getTestDevices() has completed */
|
|
37
|
-
export let
|
|
35
|
+
export let webgpuDevice: WebGPUDevice;
|
|
38
36
|
|
|
39
37
|
let webgpuCreated = false;
|
|
40
38
|
|
|
41
39
|
/** Synchronously get test devices (only WebGLDevices) */
|
|
42
40
|
export function getWebGLTestDevices(): WebGLDevice[] {
|
|
43
|
-
|
|
41
|
+
const devices: WebGLDevice[] = [];
|
|
42
|
+
if (webgl2Device) {
|
|
43
|
+
devices.push(webgl2Device);
|
|
44
|
+
}
|
|
45
|
+
if (webgl1Device) {
|
|
46
|
+
devices.push(webgl1Device);
|
|
47
|
+
}
|
|
48
|
+
return devices;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
/** Includes WebGPU device if available */
|
|
@@ -48,10 +53,15 @@ export async function getTestDevices() : Promise<Device[]> {
|
|
|
48
53
|
if (!webgpuCreated) {
|
|
49
54
|
webgpuCreated = true;
|
|
50
55
|
try {
|
|
51
|
-
|
|
56
|
+
webgpuDevice = await luma.createDevice({id: 'webgpu-test-device', type: 'webgpu'}) as WebGPUDevice;
|
|
52
57
|
} catch {
|
|
53
58
|
// ignore (assume WebGPU was not available)
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
|
-
|
|
61
|
+
|
|
62
|
+
const devices: Device[] = getWebGLTestDevices();
|
|
63
|
+
if (webgpuDevice) {
|
|
64
|
+
devices.unshift(webgpuDevice);
|
|
65
|
+
}
|
|
66
|
+
return devices;
|
|
57
67
|
}
|
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, webgl1Device, webgl2Device, webgpuDevice} from './create-test-device';
|
|
9
9
|
export {getTestDevices, getWebGLTestDevices} from './create-test-device';
|
|
10
10
|
|
|
11
11
|
export {checkType} from './check-type';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
|
|
1
3
|
import {Stats, Stat} from '@probe.gl/stats';
|
|
2
|
-
import TestRunner, {TestRunnerOptions} from './test-runner';
|
|
4
|
+
import TestRunner, {TestRunnerOptions, TestRunnerTestCase} from './test-runner';
|
|
3
5
|
|
|
4
6
|
export default class PerformanceTestRunner extends TestRunner {
|
|
5
|
-
private _stats: Stats;
|
|
6
|
-
private _fps: Stat;
|
|
7
|
+
private _stats: Stats | null = null;
|
|
8
|
+
private _fps: Stat | null = null;
|
|
7
9
|
|
|
8
10
|
constructor(props: TestRunnerOptions) {
|
|
9
11
|
super(props);
|
|
@@ -14,15 +16,15 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
initTestCase(testCase) {
|
|
19
|
+
initTestCase(testCase: TestRunnerTestCase): void {
|
|
18
20
|
super.initTestCase(testCase);
|
|
19
21
|
this._stats = new Stats({id: testCase.name});
|
|
20
22
|
this._fps = this._stats.get('fps');
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
shouldRender(animationProps) {
|
|
24
|
-
this._fps
|
|
25
|
-
this._fps
|
|
25
|
+
shouldRender(animationProps: Record<string, any>): boolean {
|
|
26
|
+
this._fps?.timeEnd();
|
|
27
|
+
this._fps?.timeStart();
|
|
26
28
|
|
|
27
29
|
// @ts-expect-error
|
|
28
30
|
if (this._fps.count > this.testOptions.maxFramesToRender) {
|
|
@@ -32,11 +34,11 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
32
34
|
return true;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
assert(testCase) {
|
|
37
|
+
assert(testCase: TestRunnerTestCase): void {
|
|
36
38
|
// @ts-expect-error
|
|
37
39
|
const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;
|
|
38
|
-
const count = this._fps
|
|
39
|
-
const fps = this._fps
|
|
40
|
+
const count = this._fps?.count;
|
|
41
|
+
const fps = this._fps?.getHz() || 0;
|
|
40
42
|
|
|
41
43
|
if (fps >= targetFPS) {
|
|
42
44
|
this._pass({fps, framesRendered: count});
|
|
@@ -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]);
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Get the bounding box of a DOMElement relative to the page
|
|
2
|
-
export function getBoundingBoxInPage(domElement) {
|
|
2
|
+
export function getBoundingBoxInPage(domElement: HTMLElement): {x: number; y: number; width: number; height: number;} {
|
|
3
3
|
const bbox = domElement.getBoundingClientRect();
|
|
4
4
|
return {
|
|
5
5
|
x: window.scrollX + bbox.x,
|
|
@@ -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
|
-
*/
|