@things-factory/figure-ui 10.1.150 → 10.1.151
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/client/modeller/editor.ts +14 -6
- package/dist-client/modeller/editor.d.ts +6 -0
- package/dist-client/modeller/editor.js +14 -6
- package/dist-client/modeller/editor.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/test/browser/part-ids.check.mjs +86 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/figure-ui",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.151",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"@things-factory:registry": "https://registry.npmjs.org"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "npm run build:server && npm run build:client",
|
|
20
20
|
"test": "FIGURE_FREEZE_COMPILED=1 node --import ./test/resolve-ts-siblings.mjs --test test/*.test.ts",
|
|
21
|
-
"test:browser": "node --test test/browser/build.check.mjs test/browser/modeller.check.mjs test/browser/modeller-revision.check.mjs test/browser/editing.check.mjs test/browser/links.check.mjs test/browser/section.check.mjs test/browser/screen.check.mjs test/browser/product-page.check.mjs test/browser/parts.check.mjs test/browser/places-mesh.check.mjs",
|
|
21
|
+
"test:browser": "node --test test/browser/build.check.mjs test/browser/modeller.check.mjs test/browser/modeller-revision.check.mjs test/browser/editing.check.mjs test/browser/links.check.mjs test/browser/section.check.mjs test/browser/screen.check.mjs test/browser/product-page.check.mjs test/browser/parts.check.mjs test/browser/places-mesh.check.mjs test/browser/part-ids.check.mjs",
|
|
22
22
|
"copy:files": "copyfiles -e \"./client/**/*.{ts,js,json}\" -u 1 \"./client/**/*\" dist-client",
|
|
23
23
|
"build:client": "npm run copy:files && npx tsc --p ./client/tsconfig.json",
|
|
24
24
|
"build:server": "npx tsc --p ./server/tsconfig.json",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"clean": "npm run clean:server && npm run clean:client"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@hatiolab/figure-model": "^0.
|
|
31
|
-
"@hatiolab/things-scene": "^10.1.
|
|
30
|
+
"@hatiolab/figure-model": "^0.6.0",
|
|
31
|
+
"@hatiolab/things-scene": "^10.1.83",
|
|
32
32
|
"@material/web": "^2.0.0",
|
|
33
33
|
"@operato/data-grist": "^10.0.0",
|
|
34
34
|
"@operato/graphql": "^10.0.0",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"@operato/styles": "^10.0.0",
|
|
43
43
|
"@operato/utils": "^10.0.0",
|
|
44
44
|
"@things-factory/ai-assistant": "^10.1.150",
|
|
45
|
-
"@things-factory/figure-service": "^10.1.
|
|
45
|
+
"@things-factory/figure-service": "^10.1.151",
|
|
46
46
|
"three": "^0.185.1"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "495d06ef9ecf4d19fc9bf45ebc3cff4fdfefca53"
|
|
49
49
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A new part's id, in a real browser, on a figure with a row: the palette's box, a copy from the parts list. A row's
|
|
3
|
+
* copies are drawn under ids of their own; the part made into the row still holds its id, and the next part is not
|
|
4
|
+
* offered it (on :3300, 2026-10-11, a box added after a row was refused with DUPLICATE_PART).
|
|
5
|
+
*
|
|
6
|
+
* Run: node --test test/browser/part-ids.check.mjs
|
|
7
|
+
*/
|
|
8
|
+
import { test, describe, before, after } from 'node:test'
|
|
9
|
+
import assert from 'node:assert/strict'
|
|
10
|
+
|
|
11
|
+
import { addFigureBox, applyFigureAuthoring, createFigureAsset, serializeFigureAsset } from '@hatiolab/figure-model'
|
|
12
|
+
|
|
13
|
+
import { buildPage } from './build.mjs'
|
|
14
|
+
import { openPage } from './serve.mjs'
|
|
15
|
+
|
|
16
|
+
const sleep = ms => new Promise(done => setTimeout(done, ms))
|
|
17
|
+
|
|
18
|
+
let opened
|
|
19
|
+
before(async () => {
|
|
20
|
+
opened = await openPage(await buildPage('places-mesh-page.js'))
|
|
21
|
+
})
|
|
22
|
+
after(async () => {
|
|
23
|
+
await opened?.close()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const page = () => opened.page
|
|
27
|
+
const read = (fn, ...args) => page().evaluate(fn, ...args)
|
|
28
|
+
const state = () => read(() => probe.state())
|
|
29
|
+
/** The parts as authored, one per part as the parts list shows them. */
|
|
30
|
+
const parts = () => read(() => probe.source().appearance.map(look => look.target))
|
|
31
|
+
|
|
32
|
+
async function until(fn, args, what, ms = 8000) {
|
|
33
|
+
const deadline = Date.now() + ms
|
|
34
|
+
for (;;) {
|
|
35
|
+
if (await read(fn, ...args)) return
|
|
36
|
+
if (Date.now() > deadline) assert.fail(`waited for ${what}`)
|
|
37
|
+
await sleep(50)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const settled = () => read(() => document.querySelector('figure-editor').updateComplete)
|
|
41
|
+
async function click(selector, options = {}, what = selector) {
|
|
42
|
+
const element = await page().evaluateHandle((s, o) => findDeep(s, o), selector, options)
|
|
43
|
+
assert.ok(await element.evaluate(e => !!e), `${what} is on the page`)
|
|
44
|
+
await element.evaluate(e => e.scrollIntoView({ block: 'center' }))
|
|
45
|
+
await element.click()
|
|
46
|
+
await settled()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* box-1 on the floor, box-2 on it made into a row 300 apart: box-2's id is drawn nowhere as it is. */
|
|
50
|
+
function rowed() {
|
|
51
|
+
let a = addFigureBox(createFigureAsset('Rowed'), { id: 'box-1', size: { x: 1000, y: 100, z: 400 }, position: { x: 0, y: 50, z: 0 } })
|
|
52
|
+
a = applyFigureAuthoring(a, { kind: 'attach', part: 'box-1', face: 'bottom', to: { plane: 'mounting-plane' } })
|
|
53
|
+
a = addFigureBox(a, { id: 'box-2', size: { x: 100, y: 100, z: 100 }, position: { x: 0, y: 150, z: 0 } })
|
|
54
|
+
a = applyFigureAuthoring(a, { kind: 'attach', part: 'box-2', face: 'bottom', to: { part: 'box-1', face: 'top' } })
|
|
55
|
+
return applyFigureAuthoring(a, { kind: 'make-repeat', part: 'box-2', axis: 'x', pitch: 300 })
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
describe('a new part on a figure with a row takes an id no part holds', () => {
|
|
59
|
+
before(async () => {
|
|
60
|
+
await read(text => harness.mount('given', text), serializeFigureAsset(rowed()))
|
|
61
|
+
await until(() => look.drawn().length > 0, [], 'the board is drawn')
|
|
62
|
+
assert.equal((await read(() => probe.ids())).includes('box-2'), false, 'the row is drawn under its copies\' ids')
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('a box from the palette: added as box-3, one step, selected', async () => {
|
|
66
|
+
const start = await state()
|
|
67
|
+
await click('button[shape]', { has: 'figure.label.primitive-cube' }, 'the palette\'s box')
|
|
68
|
+
await until(() => probe.state().selected === 'box-3', [], 'box-3 selected')
|
|
69
|
+
const after = await state()
|
|
70
|
+
assert.equal(after.error, '')
|
|
71
|
+
assert.equal(after.revision, start.revision + 1)
|
|
72
|
+
assert.deepEqual(await parts(), ['box-1', 'box-2', 'box-3'])
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('the row\'s part copied from the list: the copy is a part, and it is what is selected', async () => {
|
|
76
|
+
const at = await read(() => probe.row('box-2'))
|
|
77
|
+
await page().mouse.click(at.x, at.y)
|
|
78
|
+
await until(() => probe.state().selected === 'box-2', [], 'box-2 selected')
|
|
79
|
+
const before = await parts()
|
|
80
|
+
await click('button[op="duplicate-part"]')
|
|
81
|
+
await until(n => probe.source().appearance.length === n, [before.length + 1], 'the copy')
|
|
82
|
+
const copy = (await parts()).find(id => !before.includes(id))
|
|
83
|
+
assert.equal((await state()).selected, copy)
|
|
84
|
+
assert.equal((await state()).error, '')
|
|
85
|
+
})
|
|
86
|
+
})
|