@playdrop/playdrop-cli 0.7.15 → 0.7.17

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 (70) hide show
  1. package/config/client-meta.json +1 -1
  2. package/node_modules/@playdrop/ai-client/dist/index.js +461 -444
  3. package/node_modules/@playdrop/ai-client/package.json +1 -1
  4. package/node_modules/@playdrop/api-client/dist/client.js +903 -882
  5. package/node_modules/@playdrop/api-client/dist/core/errors.js +69 -45
  6. package/node_modules/@playdrop/api-client/dist/core/request.js +188 -159
  7. package/node_modules/@playdrop/api-client/dist/domains/admin.js +516 -491
  8. package/node_modules/@playdrop/api-client/dist/domains/ai.js +40 -14
  9. package/node_modules/@playdrop/api-client/dist/domains/apps.js +480 -462
  10. package/node_modules/@playdrop/api-client/dist/domains/asset-packs.js +439 -419
  11. package/node_modules/@playdrop/api-client/dist/domains/assets.js +696 -676
  12. package/node_modules/@playdrop/api-client/dist/domains/auth.js +346 -320
  13. package/node_modules/@playdrop/api-client/dist/domains/comments.js +124 -98
  14. package/node_modules/@playdrop/api-client/dist/domains/free-credits.js +91 -65
  15. package/node_modules/@playdrop/api-client/dist/domains/me.js +71 -45
  16. package/node_modules/@playdrop/api-client/dist/domains/payments.js +407 -386
  17. package/node_modules/@playdrop/api-client/dist/domains/player-meta.js +144 -118
  18. package/node_modules/@playdrop/api-client/dist/domains/search.js +117 -104
  19. package/node_modules/@playdrop/api-client/dist/domains/tags.js +188 -162
  20. package/node_modules/@playdrop/api-client/dist/index.js +993 -552
  21. package/node_modules/@playdrop/api-client/package.json +1 -1
  22. package/node_modules/@playdrop/boxel-three/dist/src/animations.js +84 -62
  23. package/node_modules/@playdrop/boxel-three/dist/src/builders.js +341 -308
  24. package/node_modules/@playdrop/boxel-three/dist/src/context.js +55 -29
  25. package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.js +856 -858
  26. package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.js +267 -261
  27. package/node_modules/@playdrop/boxel-three/dist/src/index.js +64 -15
  28. package/node_modules/@playdrop/boxel-three/dist/src/instantiate.js +89 -63
  29. package/node_modules/@playdrop/boxel-three/dist/src/nodes.js +81 -56
  30. package/node_modules/@playdrop/boxel-three/dist/src/overlays.js +112 -86
  31. package/node_modules/@playdrop/boxel-three/dist/src/primitives.js +45 -17
  32. package/node_modules/@playdrop/boxel-three/dist/src/scene.js +160 -136
  33. package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.js +582 -584
  34. package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.js +123 -97
  35. package/node_modules/@playdrop/boxel-three/dist/src/textures.js +207 -182
  36. package/node_modules/@playdrop/boxel-three/dist/src/types.js +15 -1
  37. package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.js +451 -425
  38. package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.js +109 -84
  39. package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.js +127 -106
  40. package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.js +73 -51
  41. package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.js +97 -79
  42. package/node_modules/@playdrop/boxel-three/dist/test/index.test.js +29 -7
  43. package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.js +80 -60
  44. package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.js +41 -19
  45. package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.js +72 -50
  46. package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.js +84 -62
  47. package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.js +69 -47
  48. package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.js +129 -109
  49. package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.js +40 -18
  50. package/node_modules/@playdrop/boxel-three/package.json +1 -1
  51. package/node_modules/@playdrop/config/client-meta.json +1 -1
  52. package/node_modules/@playdrop/types/dist/api.js +289 -203
  53. package/node_modules/@playdrop/types/dist/app-capability-filters.js +112 -62
  54. package/node_modules/@playdrop/types/dist/app.js +91 -45
  55. package/node_modules/@playdrop/types/dist/asset-pack.js +37 -5
  56. package/node_modules/@playdrop/types/dist/asset-spec.js +170 -90
  57. package/node_modules/@playdrop/types/dist/asset.js +186 -108
  58. package/node_modules/@playdrop/types/dist/content-license.js +49 -15
  59. package/node_modules/@playdrop/types/dist/creator-public-image.js +60 -32
  60. package/node_modules/@playdrop/types/dist/ecs.js +102 -82
  61. package/node_modules/@playdrop/types/dist/engine-builtins.js +603 -573
  62. package/node_modules/@playdrop/types/dist/entity.js +63 -53
  63. package/node_modules/@playdrop/types/dist/graph.js +116 -80
  64. package/node_modules/@playdrop/types/dist/index.js +47 -20
  65. package/node_modules/@playdrop/types/dist/owned-assets.js +55 -33
  66. package/node_modules/@playdrop/types/dist/player-meta.js +151 -100
  67. package/node_modules/@playdrop/types/dist/realtime.js +27 -7
  68. package/node_modules/@playdrop/types/dist/version.js +182 -124
  69. package/node_modules/@playdrop/types/package.json +1 -1
  70. package/package.json +1 -1
@@ -1,88 +1,113 @@
1
- import { generateGreedyQuads } from '@playdrop/boxel-core';
2
- export function buildVoxelMesh(options) {
3
- const { voxels, dimensions, size } = options;
4
- const quads = generateGreedyQuads(voxels, dimensions);
5
- const halfSize = [size[0] / 2, size[1] / 2, size[2] / 2];
6
- const cellSizes = [
7
- dimensions[0] > 0 ? size[0] / dimensions[0] : 1,
8
- dimensions[1] > 0 ? size[1] / dimensions[1] : 1,
9
- dimensions[2] > 0 ? size[2] / dimensions[2] : 1,
10
- ];
11
- if (quads.length === 0) {
12
- return {
13
- positions: new Float32Array(0),
14
- normals: new Float32Array(0),
15
- uvs: new Float32Array(0),
16
- indices: new Uint32Array(0),
17
- groups: [],
18
- stats: {
19
- voxels: voxels.filter(value => value !== 0).length,
20
- faces: 0,
21
- },
22
- };
23
- }
24
- const positions = [];
25
- const normals = [];
26
- const uvs = [];
27
- const indices = [];
28
- const groups = [];
29
- const pushQuad = (quad) => {
30
- const baseIndex = positions.length / 3;
31
- const axis = quad.axis;
32
- const uAxis = ((axis + 1) % 3);
33
- const vAxis = ((axis + 2) % 3);
34
- const width = quad.size[0];
35
- const height = quad.size[1];
36
- const base = [quad.origin[0], quad.origin[1], quad.origin[2]];
37
- base[axis] = quad.plane;
38
- const corners = quad.normal === 1
39
- ? [
40
- [0, 0],
41
- [width, 0],
42
- [width, height],
43
- [0, height],
44
- ]
45
- : [
46
- [0, 0],
47
- [0, height],
48
- [width, height],
49
- [width, 0],
50
- ];
51
- const normalVector = [0, 0, 0];
52
- normalVector[axis] = quad.normal;
53
- corners.forEach(([uOffset, vOffset]) => {
54
- const vertex = [base[0], base[1], base[2]];
55
- vertex[uAxis] = base[uAxis] + uOffset;
56
- vertex[vAxis] = base[vAxis] + vOffset;
57
- positions.push(vertex[0] * cellSizes[0] - halfSize[0], vertex[1] * cellSizes[1] - halfSize[1], vertex[2] * cellSizes[2] - halfSize[2]);
58
- normals.push(normalVector[0], normalVector[1], normalVector[2]);
59
- const u = width > 0 ? uOffset / width : 0;
60
- const v = height > 0 ? vOffset / height : 0;
61
- uvs.push(u, v);
62
- });
63
- const startIndex = indices.length;
64
- indices.push(baseIndex, baseIndex + 1, baseIndex + 2, baseIndex, baseIndex + 2, baseIndex + 3);
65
- const lastGroup = groups[groups.length - 1];
66
- if (lastGroup && lastGroup.material === quad.material && lastGroup.start + lastGroup.count === startIndex) {
67
- lastGroup.count += 6;
68
- }
69
- else {
70
- groups.push({ material: quad.material, start: startIndex, count: 6 });
71
- }
72
- };
73
- quads.forEach(pushQuad);
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var mesher_exports = {};
19
+ __export(mesher_exports, {
20
+ buildVoxelMesh: () => buildVoxelMesh,
21
+ hasVoxelData: () => hasVoxelData
22
+ });
23
+ module.exports = __toCommonJS(mesher_exports);
24
+ var import_boxel_core = require("@playdrop/boxel-core");
25
+ function buildVoxelMesh(options) {
26
+ const { voxels, dimensions, size } = options;
27
+ const quads = (0, import_boxel_core.generateGreedyQuads)(voxels, dimensions);
28
+ const halfSize = [size[0] / 2, size[1] / 2, size[2] / 2];
29
+ const cellSizes = [
30
+ dimensions[0] > 0 ? size[0] / dimensions[0] : 1,
31
+ dimensions[1] > 0 ? size[1] / dimensions[1] : 1,
32
+ dimensions[2] > 0 ? size[2] / dimensions[2] : 1
33
+ ];
34
+ if (quads.length === 0) {
74
35
  return {
75
- positions: Float32Array.from(positions),
76
- normals: Float32Array.from(normals),
77
- uvs: Float32Array.from(uvs),
78
- indices: Uint32Array.from(indices),
79
- groups,
80
- stats: {
81
- voxels: voxels.filter(value => value !== 0).length,
82
- faces: quads.length,
83
- },
36
+ positions: new Float32Array(0),
37
+ normals: new Float32Array(0),
38
+ uvs: new Float32Array(0),
39
+ indices: new Uint32Array(0),
40
+ groups: [],
41
+ stats: {
42
+ voxels: voxels.filter((value) => value !== 0).length,
43
+ faces: 0
44
+ }
84
45
  };
46
+ }
47
+ const positions = [];
48
+ const normals = [];
49
+ const uvs = [];
50
+ const indices = [];
51
+ const groups = [];
52
+ const pushQuad = (quad) => {
53
+ const baseIndex = positions.length / 3;
54
+ const axis = quad.axis;
55
+ const uAxis = (axis + 1) % 3;
56
+ const vAxis = (axis + 2) % 3;
57
+ const width = quad.size[0];
58
+ const height = quad.size[1];
59
+ const base = [quad.origin[0], quad.origin[1], quad.origin[2]];
60
+ base[axis] = quad.plane;
61
+ const corners = quad.normal === 1 ? [
62
+ [0, 0],
63
+ [width, 0],
64
+ [width, height],
65
+ [0, height]
66
+ ] : [
67
+ [0, 0],
68
+ [0, height],
69
+ [width, height],
70
+ [width, 0]
71
+ ];
72
+ const normalVector = [0, 0, 0];
73
+ normalVector[axis] = quad.normal;
74
+ corners.forEach(([uOffset, vOffset]) => {
75
+ const vertex = [base[0], base[1], base[2]];
76
+ vertex[uAxis] = base[uAxis] + uOffset;
77
+ vertex[vAxis] = base[vAxis] + vOffset;
78
+ positions.push(vertex[0] * cellSizes[0] - halfSize[0], vertex[1] * cellSizes[1] - halfSize[1], vertex[2] * cellSizes[2] - halfSize[2]);
79
+ normals.push(normalVector[0], normalVector[1], normalVector[2]);
80
+ const u = width > 0 ? uOffset / width : 0;
81
+ const v = height > 0 ? vOffset / height : 0;
82
+ uvs.push(u, v);
83
+ });
84
+ const startIndex = indices.length;
85
+ indices.push(baseIndex, baseIndex + 1, baseIndex + 2, baseIndex, baseIndex + 2, baseIndex + 3);
86
+ const lastGroup = groups[groups.length - 1];
87
+ if (lastGroup && lastGroup.material === quad.material && lastGroup.start + lastGroup.count === startIndex) {
88
+ lastGroup.count += 6;
89
+ } else {
90
+ groups.push({ material: quad.material, start: startIndex, count: 6 });
91
+ }
92
+ };
93
+ quads.forEach(pushQuad);
94
+ return {
95
+ positions: Float32Array.from(positions),
96
+ normals: Float32Array.from(normals),
97
+ uvs: Float32Array.from(uvs),
98
+ indices: Uint32Array.from(indices),
99
+ groups,
100
+ stats: {
101
+ voxels: voxels.filter((value) => value !== 0).length,
102
+ faces: quads.length
103
+ }
104
+ };
85
105
  }
86
- export function hasVoxelData(primitive) {
87
- return Array.isArray(primitive.voxels) && primitive.voxels.length > 0;
106
+ function hasVoxelData(primitive) {
107
+ return Array.isArray(primitive.voxels) && primitive.voxels.length > 0;
88
108
  }
109
+ // Annotate the CommonJS export names for ESM import in node:
110
+ 0 && (module.exports = {
111
+ buildVoxelMesh,
112
+ hasVoxelData
113
+ });
@@ -1,116 +1,137 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import path from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- const HERE = path.dirname(fileURLToPath(import.meta.url));
6
- const WORKER_ENTRY = path.resolve(HERE, 'fixtures/render-worker.js');
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var import_node_test = __toESM(require("node:test"));
24
+ var import_strict = __toESM(require("node:assert/strict"));
25
+ var import_node_path = __toESM(require("node:path"));
26
+ var import_node_url = require("node:url");
27
+ const import_meta = {};
28
+ const HERE = import_node_path.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
29
+ const WORKER_ENTRY = import_node_path.default.resolve(HERE, "fixtures/render-worker.js");
7
30
  async function bundleEntityWorker() {
8
- const { build } = await import('esbuild');
9
- const result = await build({
10
- entryPoints: [WORKER_ENTRY],
11
- bundle: true,
12
- platform: 'browser',
13
- format: 'esm',
14
- target: 'es2022',
15
- write: false,
16
- sourcemap: false,
17
- logLevel: 'silent'
18
- });
19
- const output = result.outputFiles?.[0]?.text;
20
- if (!output) {
21
- throw new Error('failed_to_bundle_entity_worker');
22
- }
23
- return output;
31
+ const { build } = await import("esbuild");
32
+ const result = await build({
33
+ entryPoints: [WORKER_ENTRY],
34
+ bundle: true,
35
+ platform: "browser",
36
+ format: "esm",
37
+ target: "es2022",
38
+ write: false,
39
+ sourcemap: false,
40
+ logLevel: "silent"
41
+ });
42
+ const output = result.outputFiles?.[0]?.text;
43
+ if (!output) {
44
+ throw new Error("failed_to_bundle_entity_worker");
45
+ }
46
+ return output;
24
47
  }
25
48
  function createPlaywrightLaunchError(tool, error) {
26
- const message = error && typeof error === 'object' && 'message' in error ? String(error.message) : String(error);
27
- if (/browserType\.launch/i.test(message) || /MachPortRendezvousServer/i.test(message)) {
28
- return new Error([
29
- `[${tool}] Failed to launch Playwright Chromium.`,
30
- '',
31
- 'Required setup:',
32
- ' 1. npx playwright install chromium',
33
- ' 2. On macOS: xattr -dr com.apple.quarantine "$HOME/Library/Caches/ms-playwright"',
34
- '',
35
- `Original error: ${message}`,
36
- ].join('\n'));
37
- }
38
- return error instanceof Error ? error : new Error(message);
49
+ const message = error && typeof error === "object" && "message" in error ? String(error.message) : String(error);
50
+ if (/browserType\.launch/i.test(message) || /MachPortRendezvousServer/i.test(message)) {
51
+ return new Error([
52
+ `[${tool}] Failed to launch Playwright Chromium.`,
53
+ "",
54
+ "Required setup:",
55
+ " 1. npx playwright install chromium",
56
+ ' 2. On macOS: xattr -dr com.apple.quarantine "$HOME/Library/Caches/ms-playwright"',
57
+ "",
58
+ `Original error: ${message}`
59
+ ].join("\n"));
60
+ }
61
+ return error instanceof Error ? error : new Error(message);
39
62
  }
40
- test('renderBoxelToDataURL produces a PNG data URL', async (t) => {
41
- const { chromium } = await import('playwright-core');
42
- const bundle = await bundleEntityWorker();
43
- let browser = null;
44
- try {
45
- browser = await chromium.launch({ headless: true, args: ['--no-sandbox'], chromiumSandbox: false });
63
+ (0, import_node_test.default)("renderBoxelToDataURL produces a PNG data URL", async (t) => {
64
+ const { chromium } = await import("playwright-core");
65
+ const bundle = await bundleEntityWorker();
66
+ let browser = null;
67
+ try {
68
+ browser = await chromium.launch({ headless: true, args: ["--no-sandbox"], chromiumSandbox: false });
69
+ } catch (error) {
70
+ const launchError = createPlaywrightLaunchError("boxel-three-test", error);
71
+ t.skip(launchError.message);
72
+ return;
73
+ }
74
+ const page = await browser.newPage({ viewport: { width: 512, height: 512 } });
75
+ const consoleErrors = [];
76
+ page.on("console", (message) => {
77
+ if (message.type() === "error") {
78
+ consoleErrors.push(message.text());
46
79
  }
47
- catch (error) {
48
- const launchError = createPlaywrightLaunchError('boxel-three-test', error);
49
- t.skip(launchError.message);
50
- return;
51
- }
52
- const page = await browser.newPage({ viewport: { width: 512, height: 512 } });
53
- const consoleErrors = [];
54
- page.on('console', message => {
55
- if (message.type() === 'error') {
56
- consoleErrors.push(message.text());
80
+ });
81
+ page.on("pageerror", (error) => {
82
+ consoleErrors.push(error?.message ?? String(error));
83
+ });
84
+ try {
85
+ await page.setContent('<canvas id="viewport"></canvas>', { waitUntil: "domcontentloaded" });
86
+ await page.addScriptTag({ type: "module", content: bundle });
87
+ await page.waitForFunction(() => typeof window.boxelExport !== "undefined");
88
+ const minimalEntity = {
89
+ id: "render-test",
90
+ geometry: {
91
+ id: "geom",
92
+ root: {
93
+ id: "Root",
94
+ position: [0, 0, 0],
95
+ children: [
96
+ {
97
+ id: "Node",
98
+ position: [0, 0.5, 0],
99
+ mesh: "box",
100
+ children: []
101
+ }
102
+ ]
57
103
  }
58
- });
59
- page.on('pageerror', error => {
60
- consoleErrors.push(error?.message ?? String(error));
61
- });
62
- try {
63
- await page.setContent('<canvas id="viewport"></canvas>', { waitUntil: 'domcontentloaded' });
64
- await page.addScriptTag({ type: 'module', content: bundle });
65
- await page.waitForFunction(() => typeof window.boxelExport !== 'undefined');
66
- const minimalEntity = {
67
- id: 'render-test',
68
- geometry: {
69
- id: 'geom',
70
- root: {
71
- id: 'Root',
72
- position: [0, 0, 0],
73
- children: [
74
- {
75
- id: 'Node',
76
- position: [0, 0.5, 0],
77
- mesh: 'box',
78
- children: [],
79
- },
80
- ],
81
- },
82
- },
83
- primitives: [
84
- {
85
- id: 'box',
86
- kind: 'plain_box',
87
- size: [1, 1, 1],
88
- material: 'mat',
89
- },
90
- ],
91
- materials: [{ id: 'mat', baseColor: [200, 120, 60] }],
92
- textures: [],
93
- patterns: [],
94
- animations: [],
95
- };
96
- const dataUrl = await page.evaluate(model => window.boxelExport.renderBoxel(model, {
97
- mode: 'hierarchical',
98
- width: 512,
99
- height: 512,
100
- direction: 'preview',
101
- animationIds: null,
102
- }), minimalEntity);
103
- assert.strictEqual(typeof dataUrl, 'string');
104
- assert.ok(dataUrl.startsWith('data:image/png;base64,'), 'Render output is not a PNG data URL');
105
- assert.ok(dataUrl.length > 'data:image/png;base64,'.length, 'Render output is empty');
106
- if (consoleErrors.length > 0) {
107
- throw new Error(consoleErrors.join('\n'));
104
+ },
105
+ primitives: [
106
+ {
107
+ id: "box",
108
+ kind: "plain_box",
109
+ size: [1, 1, 1],
110
+ material: "mat"
108
111
  }
112
+ ],
113
+ materials: [{ id: "mat", baseColor: [200, 120, 60] }],
114
+ textures: [],
115
+ patterns: [],
116
+ animations: []
117
+ };
118
+ const dataUrl = await page.evaluate((model) => window.boxelExport.renderBoxel(model, {
119
+ mode: "hierarchical",
120
+ width: 512,
121
+ height: 512,
122
+ direction: "preview",
123
+ animationIds: null
124
+ }), minimalEntity);
125
+ import_strict.default.strictEqual(typeof dataUrl, "string");
126
+ import_strict.default.ok(dataUrl.startsWith("data:image/png;base64,"), "Render output is not a PNG data URL");
127
+ import_strict.default.ok(dataUrl.length > "data:image/png;base64,".length, "Render output is empty");
128
+ if (consoleErrors.length > 0) {
129
+ throw new Error(consoleErrors.join("\n"));
109
130
  }
110
- finally {
111
- await page.close();
112
- if (browser) {
113
- await browser.close();
114
- }
131
+ } finally {
132
+ await page.close();
133
+ if (browser) {
134
+ await browser.close();
115
135
  }
136
+ }
116
137
  });
@@ -1,63 +1,85 @@
1
- import * as THREE from 'three';
2
- import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js';
3
- import { exportModelToGLB, renderBoxelToDataURL } from '../../src/index.js';
4
- import { parseBoxel } from '@playdrop/boxel-core';
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var THREE = __toESM(require("three"));
24
+ var import_GLTFExporter = require("three/examples/jsm/exporters/GLTFExporter.js");
25
+ var import_src = require("../../src/index.js");
26
+ var import_boxel_core = require("@playdrop/boxel-core");
5
27
  function arrayBufferToBase64(buffer) {
6
- const bytes = new Uint8Array(buffer);
7
- const chunkSize = 0x8000;
8
- let binary = '';
9
- for (let index = 0; index < bytes.length; index += chunkSize) {
10
- const chunk = bytes.subarray(index, index + chunkSize);
11
- binary += String.fromCharCode(...chunk);
12
- }
13
- return btoa(binary);
28
+ const bytes = new Uint8Array(buffer);
29
+ const chunkSize = 32768;
30
+ let binary = "";
31
+ for (let index = 0; index < bytes.length; index += chunkSize) {
32
+ const chunk = bytes.subarray(index, index + chunkSize);
33
+ binary += String.fromCharCode(...chunk);
34
+ }
35
+ return btoa(binary);
14
36
  }
15
37
  let cachedRenderer = null;
16
38
  function getRenderer() {
17
- if (cachedRenderer) {
18
- return cachedRenderer;
19
- }
20
- const canvas = document.getElementById('viewport');
21
- if (!canvas) {
22
- throw new Error('render_canvas_unavailable');
23
- }
24
- cachedRenderer = new THREE.WebGLRenderer({
25
- canvas,
26
- antialias: true,
27
- preserveDrawingBuffer: true,
28
- alpha: true,
29
- });
39
+ if (cachedRenderer) {
30
40
  return cachedRenderer;
41
+ }
42
+ const canvas = document.getElementById("viewport");
43
+ if (!canvas) {
44
+ throw new Error("render_canvas_unavailable");
45
+ }
46
+ cachedRenderer = new THREE.WebGLRenderer({
47
+ canvas,
48
+ antialias: true,
49
+ preserveDrawingBuffer: true,
50
+ alpha: true
51
+ });
52
+ return cachedRenderer;
31
53
  }
32
54
  async function exportBoxel(modelJson, options) {
33
- const model = parseBoxel(modelJson);
34
- const blob = await exportModelToGLB({
35
- THREE,
36
- GLTFExporterCtor: GLTFExporter,
37
- model,
38
- mode: options?.mode,
39
- animationIds: options?.animationIds,
40
- });
41
- const arrayBuffer = await blob.arrayBuffer();
42
- return arrayBufferToBase64(arrayBuffer);
55
+ const model = (0, import_boxel_core.parseBoxel)(modelJson);
56
+ const blob = await (0, import_src.exportModelToGLB)({
57
+ THREE,
58
+ GLTFExporterCtor: import_GLTFExporter.GLTFExporter,
59
+ model,
60
+ mode: options?.mode,
61
+ animationIds: options?.animationIds
62
+ });
63
+ const arrayBuffer = await blob.arrayBuffer();
64
+ return arrayBufferToBase64(arrayBuffer);
43
65
  }
44
66
  async function renderBoxel(modelJson, options) {
45
- const model = parseBoxel(modelJson);
46
- const renderer = getRenderer();
47
- renderer.setPixelRatio(1);
48
- return renderBoxelToDataURL({
49
- THREE,
50
- renderer,
51
- entity: model,
52
- mode: options?.mode ?? 'hierarchical',
53
- animationIds: options?.animationIds,
54
- width: options?.width,
55
- height: options?.height,
56
- direction: options?.direction,
57
- background: options?.background ?? null,
58
- });
67
+ const model = (0, import_boxel_core.parseBoxel)(modelJson);
68
+ const renderer = getRenderer();
69
+ renderer.setPixelRatio(1);
70
+ return (0, import_src.renderBoxelToDataURL)({
71
+ THREE,
72
+ renderer,
73
+ entity: model,
74
+ mode: options?.mode ?? "hierarchical",
75
+ animationIds: options?.animationIds,
76
+ width: options?.width,
77
+ height: options?.height,
78
+ direction: options?.direction,
79
+ background: options?.background ?? null
80
+ });
59
81
  }
60
82
  window.boxelExport = {
61
- exportBoxel,
62
- renderBoxel,
83
+ exportBoxel,
84
+ renderBoxel
63
85
  };