@things-factory/board-ui 10.1.267 → 10.1.269

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.
@@ -0,0 +1,20 @@
1
+ type ThumbnailScene = {
2
+ root?: {
3
+ model?: {
4
+ threed?: boolean;
5
+ };
6
+ snapshot3d?: (width?: number, height?: number, type?: string, quality?: number, options?: {
7
+ pose?: 'current' | 'start';
8
+ }) => Promise<string | undefined>;
9
+ };
10
+ };
11
+ /**
12
+ * The thumbnail the modeller sends with a save, or undefined to leave it to board-service.
13
+ *
14
+ * A board that opens in 2D goes without one: board-service draws it headless, the same picture whoever saves. A board
15
+ * that opens in 3D is taken here, from the 3D view at the camera 3D starts with (things-scene `snapshot3d`, pose
16
+ * 'start'), whatever the person turned the camera to. When there is no 3D view to take - the modeller is showing 2D -
17
+ * or the picture fails, the save goes without one and board-service draws it.
18
+ */
19
+ export declare function startViewThumbnail(scene?: ThumbnailScene | null): Promise<string | undefined>;
20
+ export {};
@@ -0,0 +1,25 @@
1
+ /* the size board-service gives a thumbnail it renders, so tiles look alike whichever made them */
2
+ const THUMBNAIL_WIDTH = 400;
3
+ const THUMBNAIL_HEIGHT = 300;
4
+ /**
5
+ * The thumbnail the modeller sends with a save, or undefined to leave it to board-service.
6
+ *
7
+ * A board that opens in 2D goes without one: board-service draws it headless, the same picture whoever saves. A board
8
+ * that opens in 3D is taken here, from the 3D view at the camera 3D starts with (things-scene `snapshot3d`, pose
9
+ * 'start'), whatever the person turned the camera to. When there is no 3D view to take - the modeller is showing 2D -
10
+ * or the picture fails, the save goes without one and board-service draws it.
11
+ */
12
+ export async function startViewThumbnail(scene) {
13
+ const root = scene?.root;
14
+ if (!root?.model?.threed || !root.snapshot3d)
15
+ return;
16
+ try {
17
+ const url = await root.snapshot3d(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, 'image/png', undefined, { pose: 'start' });
18
+ return typeof url === 'string' && url.startsWith('data:image/') ? url : undefined;
19
+ }
20
+ catch (e) {
21
+ console.warn(`[thumbnail] could not take the picture -- ${e?.message ?? e}`);
22
+ return;
23
+ }
24
+ }
25
+ //# sourceMappingURL=board-thumbnail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"board-thumbnail.js","sourceRoot":"","sources":["../../client/utils/board-thumbnail.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,MAAM,eAAe,GAAG,GAAG,CAAA;AAC3B,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAe5B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAA6B;IACpE,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,CAAA;IACxB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU;QAAE,OAAM;IAEpD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QAC/G,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;IACnF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,6CAA8C,CAAW,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAA;QACvF,OAAM;IACR,CAAC;AACH,CAAC","sourcesContent":["/* the size board-service gives a thumbnail it renders, so tiles look alike whichever made them */\nconst THUMBNAIL_WIDTH = 400\nconst THUMBNAIL_HEIGHT = 300\n\ntype ThumbnailScene = {\n root?: {\n model?: { threed?: boolean }\n snapshot3d?: (\n width?: number,\n height?: number,\n type?: string,\n quality?: number,\n options?: { pose?: 'current' | 'start' }\n ) => Promise<string | undefined>\n }\n}\n\n/**\n * The thumbnail the modeller sends with a save, or undefined to leave it to board-service.\n *\n * A board that opens in 2D goes without one: board-service draws it headless, the same picture whoever saves. A board\n * that opens in 3D is taken here, from the 3D view at the camera 3D starts with (things-scene `snapshot3d`, pose\n * 'start'), whatever the person turned the camera to. When there is no 3D view to take - the modeller is showing 2D -\n * or the picture fails, the save goes without one and board-service draws it.\n */\nexport async function startViewThumbnail(scene?: ThumbnailScene | null): Promise<string | undefined> {\n const root = scene?.root\n if (!root?.model?.threed || !root.snapshot3d) return\n\n try {\n const url = await root.snapshot3d(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, 'image/png', undefined, { pose: 'start' })\n return typeof url === 'string' && url.startsWith('data:image/') ? url : undefined\n } catch (e) {\n console.warn(`[thumbnail] could not take the picture -- ${(e as Error)?.message ?? e}`)\n return\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/board-ui",
3
- "version": "10.1.267",
3
+ "version": "10.1.269",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -26,7 +26,7 @@
26
26
  "clean": "npm run clean:server && npm run clean:client"
27
27
  },
28
28
  "dependencies": {
29
- "@hatiolab/things-scene": "^10.1.111",
29
+ "@hatiolab/things-scene": "^10.1.112",
30
30
  "@material/web": "^2.0.0",
31
31
  "@operato/app": "^10.29.43",
32
32
  "@operato/attachment": "^10.29.43",
@@ -44,12 +44,12 @@
44
44
  "@operato/shell": "^10.29.69",
45
45
  "@operato/styles": "^10.29.70",
46
46
  "@operato/utils": "^10.29.43",
47
- "@things-factory/ai-assistant": "^10.1.267",
48
- "@things-factory/barcode-base": "^10.1.267",
49
- "@things-factory/board-ai": "^10.1.267",
50
- "@things-factory/fav-base": "^10.1.267",
51
- "@things-factory/setting-base": "^10.1.267",
47
+ "@things-factory/ai-assistant": "^10.1.269",
48
+ "@things-factory/barcode-base": "^10.1.269",
49
+ "@things-factory/board-ai": "^10.1.269",
50
+ "@things-factory/fav-base": "^10.1.269",
51
+ "@things-factory/setting-base": "^10.1.269",
52
52
  "@things-factory/utils": "^10.1.179"
53
53
  },
54
- "gitHead": "155585edfa5de984ec1d045b0378f8ffd623a6f4"
54
+ "gitHead": "d4fbddbb97458c60e7c32a2b3c8e4d04bab95464"
55
55
  }