@things-factory/figure-ui 10.1.57 → 10.1.58

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/figure-ui",
3
- "version": "10.1.57",
3
+ "version": "10.1.58",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "@things-factory:registry": "https://registry.npmjs.org"
@@ -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.1.66",
31
- "@hatiolab/things-scene": "^10.1.43",
30
+ "@hatiolab/figure-model": "^0.1.67",
31
+ "@hatiolab/things-scene": "^10.1.44",
32
32
  "@material/web": "^2.0.0",
33
33
  "@operato/data-grist": "^10.0.0",
34
34
  "@operato/graphql": "^10.0.0",
@@ -39,9 +39,9 @@
39
39
  "@operato/shell": "^10.0.0",
40
40
  "@operato/styles": "^10.0.0",
41
41
  "@operato/utils": "^10.0.0",
42
- "@things-factory/ai-assistant": "^10.1.53",
43
- "@things-factory/figure-service": "^10.1.57",
42
+ "@things-factory/ai-assistant": "^10.1.58",
43
+ "@things-factory/figure-service": "^10.1.58",
44
44
  "three": "^0.185.1"
45
45
  },
46
- "gitHead": "b9ee95ca3900b88ec7d3aacc49049e9c3a855e2c"
46
+ "gitHead": "9410a421e67ef11035d1e13a68a1ae88ed91d18b"
47
47
  }
@@ -377,6 +377,39 @@ describe('a figure made in the modeller is given its size from its parts (user 2
377
377
  assert.deepEqual(await read(() => probe.fields('size.')), { 'size.x': 400, 'size.y': 400, 'size.z': 400 }, 'the size it is authored at: its parts now')
378
378
  })
379
379
 
380
+ test('the sizes it may be placed at are typed: the largest width, one step, and a smallest past its size refused', async () => {
381
+ const field = id =>
382
+ page().evaluateHandle(id => {
383
+ const deep = (root = document) => [...root.querySelectorAll('input')].concat(...[...root.querySelectorAll('*')].filter(e => e.shadowRoot).map(e => deep(e.shadowRoot)))
384
+ return deep().find(i => i.getAttribute('aria-label') === id) ?? null
385
+ }, id)
386
+ const declared = () =>
387
+ page().evaluate(() => {
388
+ const deep = (root = document) => [...root.querySelectorAll('figure-v3-editor')].concat(...[...root.querySelectorAll('*')].filter(e => e.shadowRoot).map(e => deep(e.shadowRoot)))
389
+ const inputs = JSON.parse(deep()[0].session.source()).document.model.inputs
390
+ return Object.fromEntries(inputs.filter(i => i.id.startsWith('size.')).map(i => [i.id, [i.min, i.max]]))
391
+ })
392
+ const type = async (id, text) => {
393
+ const input = await field(id)
394
+ assert.ok(await input.evaluate(i => !!i), `${id} is a field`)
395
+ await input.evaluate(i => i.scrollIntoView({ block: 'center' }))
396
+ await input.click({ clickCount: 3 })
397
+ await page().keyboard.type(text)
398
+ await page().keyboard.press('Tab')
399
+ await sleep(600)
400
+ }
401
+ const start = await state()
402
+ await type('size.x.max', '3000')
403
+ const after = await state()
404
+ assert.equal(after.error, '', 'not refused')
405
+ assert.equal(after.revision, start.revision + 1, 'one step')
406
+ assert.equal((await declared())['size.x'][1], 3000, 'the largest width is what was typed')
407
+ await type('size.x.min', '500')
408
+ assert.match((await state()).error, /500|400/, 'the figure is 400 wide: a smallest of 500 is refused, and said')
409
+ assert.equal((await declared())['size.x'][0] < 400, true, 'and the range is as it was')
410
+ assert.equal(await (await field('size.x.min')).evaluate(i => Number(i.value) < 400), true, 'the field shows the range it still has')
411
+ })
412
+
380
413
  test('a part follows the figure\'s width less a difference: chosen and typed, the width is the size less it', async () => {
381
414
  await click(await read(() => probe.partOnPage('box')))
382
415
  assert.equal((await state()).selected, 'box')
@@ -10,7 +10,7 @@ import assert from 'node:assert/strict'
10
10
  import { addV3Box, addV3Primitive, applyV3Authoring, createV3Asset } from '@hatiolab/figure-model'
11
11
  import type { V3Asset } from '@hatiolab/figure-model'
12
12
 
13
- import { acceptsOf, canFasten, canFollow, dimensionNow, instanceRangeOf, rangeDiffers, turnsAboutAJoint, fastenedTo, followableAxes, followOf, hasInstanceSize, positionIsShare, holdsThings, motionOf, placeFacesOf, placeIdFor, placesOn, positionsWorkedOut } from '../client/modeller/v3-links.ts'
13
+ import { acceptsOf, canFasten, canFollow, dimensionNow, instanceRangeOf, rangeDiffers, rangeWith, turnsAboutAJoint, fastenedTo, followableAxes, followOf, hasInstanceSize, positionIsShare, holdsThings, motionOf, placeFacesOf, placeIdFor, placesOn, positionsWorkedOut } from '../client/modeller/v3-links.ts'
14
14
 
15
15
  const pair = (): V3Asset => {
16
16
  let asset = createV3Asset('Pair')
@@ -226,6 +226,25 @@ test('놓일 수 있는 크기 — 남은 만큼 채우던 부품을 비례로
226
226
  assert.ok(editor.includes("this.linkCommand({ kind: 'declare-instance-size', range: range.measured, replace: true })"))
227
227
  })
228
228
 
229
+ test('놓일 수 있는 크기 — 저작자가 끝을 적어 좁힌다(갠트리, 09-25)', () => {
230
+ let asset = sizedPair()
231
+ for (const axis of ['x', 'z'] as const) {
232
+ asset.document.model.inputs.push({ id: `size.${axis}`, unit: 'mm', min: 1, max: 20000, role: 'design' } as never)
233
+ asset.designInputs[`size.${axis}`] = 200
234
+ }
235
+ const declared = instanceRangeOf(asset)!.declared
236
+ assert.equal(rangeWith(declared, 'x', 'min', Number.NaN), undefined, '숫자가 아니면 명령이 없다')
237
+ const next = rangeWith(declared, 'x', 'min', 150)!
238
+ assert.deepEqual(next.x, { min: 150, max: 20000 })
239
+ assert.deepEqual(declared.x, { min: 1, max: 20000 }, '선언된 범위는 그대로')
240
+ asset = applyV3Authoring(asset, { kind: 'declare-instance-size', range: next, replace: true })
241
+ assert.deepEqual(instanceRangeOf(asset)!.declared.x, { min: 150, max: 20000 })
242
+ assert.throws(() => applyV3Authoring(asset, { kind: 'declare-instance-size', range: rangeWith(next, 'x', 'min', 300)!, replace: true }), (e: { code?: string }) => e.code === 'INSTANCE_SIZE_RANGE', '저작한 크기(200)를 벗어나면 거절')
243
+ const editor = read('../client/modeller/v3-editor.ts')
244
+ assert.ok(editor.includes("const next = rangeWith(range.declared, axis, bound, (e.target as HTMLInputElement).valueAsNumber)"))
245
+ assert.ok(editor.includes("if (next) this.linkCommand({ kind: 'declare-instance-size', range: next, replace: true })"))
246
+ })
247
+
229
248
  test('관절이 있는 도형에는 한 비율로 키우기를 권하고, 선언하면 규칙으로 보인다(수석 아키텍트 판정 09-24)', () => {
230
249
  let asset = sizedPair()
231
250
  assert.equal(turnsAboutAJoint(asset), false)