@things-factory/figure-ui 10.1.128 → 10.1.141

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 (95) hide show
  1. package/client/modeller/align.ts +24 -18
  2. package/client/modeller/editor.ts +165 -253
  3. package/client/modeller/fasten-geometry.ts +12 -9
  4. package/client/modeller/figure-facts.ts +12 -14
  5. package/client/modeller/figure-links.ts +16 -12
  6. package/client/modeller/figure-preview.ts +13 -4
  7. package/client/modeller/figure-properties.ts +6 -5
  8. package/client/modeller/figure-verdict.ts +14 -8
  9. package/client/modeller/joint-fan.ts +15 -17
  10. package/client/modeller/links.ts +17 -23
  11. package/client/modeller/live.ts +6 -3
  12. package/client/modeller/motion-ends.ts +6 -7
  13. package/client/modeller/occupancy.ts +2 -3
  14. package/client/modeller/product-session.ts +15 -0
  15. package/client/modeller/revision.ts +66 -0
  16. package/client/pages/figure-modeller-page.ts +5 -18
  17. package/dist-client/modeller/align.d.ts +12 -7
  18. package/dist-client/modeller/align.js +21 -17
  19. package/dist-client/modeller/align.js.map +1 -1
  20. package/dist-client/modeller/editor.d.ts +8 -34
  21. package/dist-client/modeller/editor.js +175 -250
  22. package/dist-client/modeller/editor.js.map +1 -1
  23. package/dist-client/modeller/fasten-geometry.d.ts +3 -2
  24. package/dist-client/modeller/fasten-geometry.js +11 -9
  25. package/dist-client/modeller/fasten-geometry.js.map +1 -1
  26. package/dist-client/modeller/figure-facts.d.ts +9 -1
  27. package/dist-client/modeller/figure-facts.js +11 -15
  28. package/dist-client/modeller/figure-facts.js.map +1 -1
  29. package/dist-client/modeller/figure-links.d.ts +4 -5
  30. package/dist-client/modeller/figure-links.js +14 -13
  31. package/dist-client/modeller/figure-links.js.map +1 -1
  32. package/dist-client/modeller/figure-preview.d.ts +5 -2
  33. package/dist-client/modeller/figure-preview.js +13 -4
  34. package/dist-client/modeller/figure-preview.js.map +1 -1
  35. package/dist-client/modeller/figure-properties.d.ts +3 -2
  36. package/dist-client/modeller/figure-properties.js +6 -6
  37. package/dist-client/modeller/figure-properties.js.map +1 -1
  38. package/dist-client/modeller/figure-verdict.d.ts +4 -2
  39. package/dist-client/modeller/figure-verdict.js +12 -9
  40. package/dist-client/modeller/figure-verdict.js.map +1 -1
  41. package/dist-client/modeller/joint-fan.d.ts +8 -4
  42. package/dist-client/modeller/joint-fan.js +15 -16
  43. package/dist-client/modeller/joint-fan.js.map +1 -1
  44. package/dist-client/modeller/links.d.ts +6 -5
  45. package/dist-client/modeller/links.js +17 -24
  46. package/dist-client/modeller/links.js.map +1 -1
  47. package/dist-client/modeller/live.d.ts +3 -2
  48. package/dist-client/modeller/live.js +7 -3
  49. package/dist-client/modeller/live.js.map +1 -1
  50. package/dist-client/modeller/motion-ends.d.ts +2 -2
  51. package/dist-client/modeller/motion-ends.js +5 -6
  52. package/dist-client/modeller/motion-ends.js.map +1 -1
  53. package/dist-client/modeller/occupancy.d.ts +2 -2
  54. package/dist-client/modeller/occupancy.js +2 -3
  55. package/dist-client/modeller/occupancy.js.map +1 -1
  56. package/dist-client/modeller/product-session.d.ts +44 -39
  57. package/dist-client/modeller/product-session.js +17 -0
  58. package/dist-client/modeller/product-session.js.map +1 -1
  59. package/dist-client/modeller/revision.d.ts +37 -0
  60. package/dist-client/modeller/revision.js +39 -0
  61. package/dist-client/modeller/revision.js.map +1 -0
  62. package/dist-client/pages/figure-modeller-page.d.ts +0 -6
  63. package/dist-client/pages/figure-modeller-page.js +6 -14
  64. package/dist-client/pages/figure-modeller-page.js.map +1 -1
  65. package/dist-client/tsconfig.tsbuildinfo +1 -1
  66. package/package.json +7 -7
  67. package/test/align.test.ts +14 -12
  68. package/test/browser/modeller-page.js +52 -4
  69. package/test/browser/modeller-revision.check.mjs +144 -0
  70. package/test/command-preview.test.ts +9 -8
  71. package/test/fasten-drawing.test.ts +1 -1
  72. package/test/fasten-geometry.test.ts +10 -9
  73. package/test/fields.test.ts +1 -1
  74. package/test/first-minute.test.ts +1 -1
  75. package/test/gizmo.test.ts +1 -1
  76. package/test/joint-fan.test.ts +30 -14
  77. package/test/joint-frames.test.ts +9 -8
  78. package/test/links.test.ts +13 -12
  79. package/test/live.test.ts +3 -3
  80. package/test/parts-wiring.test.ts +1 -1
  81. package/test/properties.test.ts +6 -5
  82. package/test/release-panel.test.ts +3 -3
  83. package/test/resize-with-placement.test.ts +8 -6
  84. package/test/revision-of.ts +22 -0
  85. package/test/revision.test.ts +172 -0
  86. package/test/section-editor.test.ts +4 -3
  87. package/test/section-panel.test.ts +5 -4
  88. package/test/verdict.test.ts +1 -1
  89. package/client/modeller/evaluated.ts +0 -47
  90. package/dist-client/modeller/evaluated.d.ts +0 -12
  91. package/dist-client/modeller/evaluated.js +0 -42
  92. package/dist-client/modeller/evaluated.js.map +0 -1
  93. package/dist-client/tsconfig.scratch.tsbuildinfo +0 -1
  94. package/test/evaluated.test.ts +0 -40
  95. package/test/mode-switch.test.ts +0 -43
@@ -1,5 +1,6 @@
1
1
  import type { FigureAsset, FigureFace } from '@hatiolab/figure-model';
2
2
  import { type Alignment } from './links.js';
3
+ import type { FigureRevision } from './revision.js';
3
4
  type Axis = 'x' | 'y' | 'z';
4
5
  export type FastenMode = 'meet' | 'flush' | 'centre';
5
6
  export type FastenTarget = {
@@ -11,7 +12,7 @@ export type FastenTarget = {
11
12
  * centre. Read from where each face looks now, so a part standing turned offers the face that is really there.
12
13
  * Undefined when the part has no such face.
13
14
  */
14
- export declare function myFaceFor(asset: FigureAsset, part: string, target: FastenTarget, mode: FastenMode): FigureFace | 'centre' | undefined;
15
+ export declare function myFaceFor(revision: FigureRevision, part: string, target: FastenTarget, mode: FastenMode): FigureFace | 'centre' | undefined;
15
16
  /** Which way the fastening is, read back from the part's face and facing. */
16
17
  export declare const modeOf: (face: string, facing: "meet" | "flush") => FastenMode;
17
18
  /**
@@ -24,7 +25,7 @@ export interface FaceView {
24
25
  part: Record<Axis, number>;
25
26
  edges: Record<Axis, boolean>;
26
27
  }
27
- export declare function faceViewOf(asset: FigureAsset, part: string, target: FastenTarget): FaceView | undefined;
28
+ export declare function faceViewOf(revision: FigureRevision, part: string, target: FastenTarget): FaceView | undefined;
28
29
  /** Where the part's centre is from the face's centre along one axis, for the way it is aligned there. */
29
30
  export declare function offsetOf(how: Alignment | undefined, mm: number | undefined, face: number | undefined, part: number): number;
30
31
  /**
@@ -4,11 +4,11 @@ import { alignAxesOf, facesOf, faceAxisOf, hasInstanceSize, mountingPlaneOf } fr
4
4
  const AXES = ['x', 'y', 'z'];
5
5
  const OPPOSITE = { left: 'right', right: 'left', bottom: 'top', top: 'bottom', back: 'front', front: 'back' };
6
6
  const NORMAL = { left: ['x', -1], right: ['x', 1], bottom: ['y', -1], top: ['y', 1], back: ['z', -1], front: ['z', 1] };
7
- /** The world direction a part's face looks along now, turns and all; by its name when the face's outline is not read. */
8
- function directionOf(asset, part, face) {
7
+ /** The world direction a part's face looks along now, as drawn, turns and all; by its name when the face's outline is not read. */
8
+ function directionOf(revision, part, face) {
9
9
  const area = (() => {
10
10
  try {
11
- return figurePartFaceOf(asset, part, face);
11
+ return figurePartFaceOf(revision.asset, part, face, revision.inputs);
12
12
  }
13
13
  catch {
14
14
  return undefined;
@@ -26,31 +26,33 @@ function directionOf(asset, part, face) {
26
26
  * centre. Read from where each face looks now, so a part standing turned offers the face that is really there.
27
27
  * Undefined when the part has no such face.
28
28
  */
29
- export function myFaceFor(asset, part, target, mode) {
29
+ export function myFaceFor(revision, part, target, mode) {
30
+ const asset = revision.asset;
30
31
  if (mode === 'centre')
31
32
  return target === 'plane' ? undefined : 'centre';
32
33
  const want = target === 'plane'
33
34
  ? /* The plane is met from above on a floor, from in front on a wall. */ [mountingPlaneOf(asset).normal, -1]
34
35
  : (() => {
35
- const d = directionOf(asset, target.part, target.face);
36
+ const d = directionOf(revision, target.part, target.face);
36
37
  return d && [d[0], (mode === 'meet' ? -d[1] : d[1])];
37
38
  })();
38
39
  if (!want)
39
40
  return undefined;
40
41
  const mine = facesOf(asset, part).filter((f) => f in NORMAL);
41
42
  const hit = mine.find(f => {
42
- const d = directionOf(asset, part, f);
43
+ const d = directionOf(revision, part, f);
43
44
  return d && d[0] === want[0] && d[1] === want[1];
44
45
  });
45
46
  return hit ?? (target !== 'plane' && mode === 'meet' && target.face in OPPOSITE ? OPPOSITE[target.face] : undefined);
46
47
  }
47
48
  /** Which way the fastening is, read back from the part's face and facing. */
48
49
  export const modeOf = (face, facing) => (face === 'centre' ? 'centre' : facing);
49
- export function faceViewOf(asset, part, target) {
50
+ export function faceViewOf(revision, part, target) {
51
+ const asset = revision.asset;
50
52
  const across = alignAxesOf(asset, part, target);
51
53
  if (across.length !== 2)
52
54
  return undefined;
53
- const box = boxOf(asset, part);
55
+ const box = boxOf(revision, part);
54
56
  if (!box)
55
57
  return undefined;
56
58
  const axes = [across[0].axis, across[1].axis];
@@ -61,7 +63,7 @@ export function faceViewOf(asset, part, target) {
61
63
  face[a] = asset.designInputs[`size.${a}`];
62
64
  }
63
65
  else {
64
- const theirs = boxOf(asset, target.part);
66
+ const theirs = boxOf(revision, target.part);
65
67
  const normal = faceAxisOf(asset, target.part, target.face);
66
68
  for (const a of axes)
67
69
  if (theirs && a !== normal)
@@ -1 +1 @@
1
- {"version":3,"file":"fasten-geometry.js","sourceRoot":"","sources":["../../client/modeller/fasten-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAA;AAU/G,MAAM,IAAI,GAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAIpC,MAAM,QAAQ,GAAmC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EA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U,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAA;AAEtM;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAA2B;IAClD,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;IACxC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAE,CAAA;IAClC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAA0B,EAAE,CAAA;AAC9F,CAAC","sourcesContent":["import { figurePartFaceOf } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureFace } from '@hatiolab/figure-model'\n\nimport { boxOf } from './align.js'\nimport { alignAxesOf, facesOf, faceAxisOf, hasInstanceSize, mountingPlaneOf, type Alignment } from './links.js'\n\n/*\n * What the 붙이기 drawing reads (user 2026-10-01): the face a part is fastened to, seen from above, and where the part\n * lies on it. A fastening is chosen by the target's face and how (올려놓기 · 같은 면에 맞추기 · 가운데를 면에); the part's\n * own face follows from those -- the kernel takes no other pairing (figure-model `attach`: meet is the facing face,\n * flush the same one, a face along another axis would need a turn).\n */\n\ntype Axis = 'x' | 'y' | 'z'\nconst AXES: Axis[] = ['x', 'y', 'z']\nexport type FastenMode = 'meet' | 'flush' | 'centre'\nexport type FastenTarget = { part: string; face: string } | 'plane'\n\nconst OPPOSITE: Record<FigureFace, FigureFace> = { left: 'right', right: 'left', bottom: 'top', top: 'bottom', back: 'front', front: 'back' }\nconst NORMAL: Record<FigureFace, [Axis, 1 | -1]> = { left: ['x', -1], right: ['x', 1], bottom: ['y', -1], top: ['y', 1], back: ['z', -1], front: ['z', 1] }\n\n/** The world direction a part's face looks along now, turns and all; by its name when the face's outline is not read. */\nfunction directionOf(asset: FigureAsset, part: string, face: string): [Axis, 1 | -1] | undefined {\n const area = (() => {\n try {\n return figurePartFaceOf(asset, part, face)\n } catch {\n return undefined\n }\n })()\n if (area) {\n const k = area.normal.findIndex(v => Math.abs(v) > 0.5)\n if (k >= 0) return [AXES[k]!, area.normal[k]! > 0 ? 1 : -1]\n }\n return face in NORMAL ? NORMAL[face as FigureFace] : undefined\n}\n\n/**\n * The part's own face a fastening takes: the one looking against the target's face (올려놓기), with it (같은 면), or its\n * centre. Read from where each face looks now, so a part standing turned offers the face that is really there.\n * Undefined when the part has no such face.\n */\nexport function myFaceFor(asset: FigureAsset, part: string, target: FastenTarget, mode: FastenMode): FigureFace | 'centre' | undefined {\n if (mode === 'centre') return target === 'plane' ? undefined : 'centre'\n const want: [Axis, 1 | -1] | undefined =\n target === 'plane'\n ? /* The plane is met from above on a floor, from in front on a wall. */ [mountingPlaneOf(asset).normal, -1]\n : (() => {\n const d = directionOf(asset, target.part, target.face)\n return d && [d[0], (mode === 'meet' ? -d[1] : d[1]) as 1 | -1]\n })()\n if (!want) return undefined\n const mine = facesOf(asset, part).filter((f): f is FigureFace => f in NORMAL)\n const hit = mine.find(f => {\n const d = directionOf(asset, part, f)\n return d && d[0] === want[0] && d[1] === want[1]\n })\n return hit ?? (target !== 'plane' && mode === 'meet' && target.face in OPPOSITE ? OPPOSITE[target.face as FigureFace] : undefined)\n}\n\n/** Which way the fastening is, read back from the part's face and facing. */\nexport const modeOf = (face: string, facing: 'meet' | 'flush'): FastenMode => (face === 'centre' ? 'centre' : facing)\n\n/**\n * The face seen from above: its two axes across (as the form's alignment names them), the face's size on each -- none\n * for a plane with no declared size -- the part's footprint on each, and whether its edges can be lined up with.\n */\nexport interface FaceView {\n axes: [Axis, Axis]\n face: Partial<Record<Axis, number>>\n part: Record<Axis, number>\n edges: Record<Axis, boolean>\n}\n\nexport function faceViewOf(asset: FigureAsset, part: string, target: FastenTarget): FaceView | undefined {\n const across = alignAxesOf(asset, part, target)\n if (across.length !== 2) return undefined\n const box = boxOf(asset, part)\n if (!box) return undefined\n const axes = [across[0]!.axis, across[1]!.axis] as [Axis, Axis]\n const face: Partial<Record<Axis, number>> = {}\n if (target === 'plane') {\n for (const a of axes) if (hasInstanceSize(asset, a)) face[a] = asset.designInputs[`size.${a}`]!\n } else {\n const theirs = boxOf(asset, target.part)\n const normal = faceAxisOf(asset, target.part, target.face)\n for (const a of axes) if (theirs && a !== normal) face[a] = theirs.extent[a]\n }\n return {\n axes,\n face,\n part: { x: box.extent.x, y: box.extent.y, z: box.extent.z },\n edges: Object.fromEntries(across.map(o => [o.axis, o.edges])) as Record<Axis, boolean>\n }\n}\n\n/** Where the part's centre is from the face's centre along one axis, for the way it is aligned there. */\nexport function offsetOf(how: Alignment | undefined, mm: number | undefined, face: number | undefined, part: number): number {\n if (how === 'min' && face !== undefined) return -(face - part) / 2\n if (how === 'max' && face !== undefined) return (face - part) / 2\n if (how === 'mm' || how === 'share') return mm ?? 0\n return 0\n}\n\n/**\n * A place dropped on the face, as the form's alignment: caught at the centre, at an edge from inside (level with it:\n * `min` / `max`, where the edges can be lined up with), or at an edge from outside (touching it, as a distance), when\n * within `catchMm`; anywhere else a distance off centre, whole millimetres.\n */\nexport function alignmentAt(d: number, face: number | undefined, part: number, edges: boolean, catchMm: number): { how: Alignment; mm?: number; caught?: 'centre' | 'inside' | 'outside' } {\n if (Math.abs(d) <= catchMm) return { how: 'centre', caught: 'centre' }\n if (face !== undefined) {\n const inside = (face - part) / 2,\n outside = (face + part) / 2\n for (const [at, how] of [\n [-inside, 'min'],\n [inside, 'max']\n ] as const)\n if (Math.abs(d - at) <= catchMm && inside > 0) return edges ? { how, caught: 'inside' } : { how: 'mm', mm: Math.round(at), caught: 'inside' }\n for (const at of [-outside, outside]) if (Math.abs(d - at) <= catchMm) return { how: 'mm', mm: Math.round(at), caught: 'outside' }\n }\n return { how: 'mm', mm: Math.round(d) }\n}\n\n/** How far the footprint comes past the face's edges, per side, and whether it touches the face at all. */\nexport function overhangOf(view: FaceView, at: Record<Axis, number>): { touching: boolean; sides: Array<{ axis: Axis; side: 'low' | 'high'; mm: number }> } {\n const sides: Array<{ axis: Axis; side: 'low' | 'high'; mm: number }> = []\n let touching = true\n for (const a of view.axes) {\n const face = view.face[a]\n if (face === undefined) continue\n const lo = at[a] - view.part[a] / 2,\n hi = at[a] + view.part[a] / 2\n if (lo >= face / 2 || hi <= -face / 2) touching = false\n if (-face / 2 - lo > 0.5) sides.push({ axis: a, side: 'low', mm: Math.round(-face / 2 - lo) })\n if (hi - face / 2 > 0.5) sides.push({ axis: a, side: 'high', mm: Math.round(hi - face / 2) })\n }\n return { touching, sides }\n}\n\n/** Whether the part turns about a joint: then 가운데를 면에 is offered -- a roller spinning in place. */\nexport const turnsInPlace = (asset: FigureAsset, part: string) => (asset.joints ?? []).some(j => j.body1.part === part && (j.type === 'revolute' || ('face' in j.body1 && j.body1.face === 'centre')))\n\n/**\n * How the face lies on the screen: X across when it is one of the face's axes, else Z; the other down the screen -- up\n * for Y, which rises, so a front face is seen as it stands and not upside down.\n */\nexport function screenOf(axes: readonly [Axis, Axis]): { h: Axis; v: Axis; sign: Record<Axis, 1 | -1> } {\n const h = axes.includes('x') ? 'x' : 'z'\n const v = axes.find(a => a !== h)!\n return { h, v, sign: { x: 1, y: 1, z: 1, [v]: v === 'y' ? -1 : 1 } as Record<Axis, 1 | -1> }\n}\n"]}
1
+ {"version":3,"file":"fasten-geometry.js","sourceRoot":"","sources":["../../client/modeller/fasten-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,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AAM,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,CAAA;IAC/F,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;AAC5B,CAAC;AAED,mGAAmG;AACnG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAkB,EAAE,IAAY,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAA;AAEtM;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAA2B;IAClD,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;IACxC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAE,CAAA;IAClC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAA0B,EAAE,CAAA;AAC9F,CAAC","sourcesContent":["import { figurePartFaceOf } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureFace } from '@hatiolab/figure-model'\n\nimport { boxOf } from './align.js'\nimport { alignAxesOf, facesOf, faceAxisOf, hasInstanceSize, mountingPlaneOf, type Alignment } from './links.js'\nimport type { FigureRevision } from './revision.js'\n\n/*\n * What the 붙이기 drawing reads (user 2026-10-01): the face a part is fastened to, seen from above, and where the part\n * lies on it. A fastening is chosen by the target's face and how (올려놓기 · 같은 면에 맞추기 · 가운데를 면에); the part's\n * own face follows from those -- the kernel takes no other pairing (figure-model `attach`: meet is the facing face,\n * flush the same one, a face along another axis would need a turn).\n */\n\ntype Axis = 'x' | 'y' | 'z'\nconst AXES: Axis[] = ['x', 'y', 'z']\nexport type FastenMode = 'meet' | 'flush' | 'centre'\nexport type FastenTarget = { part: string; face: string } | 'plane'\n\nconst OPPOSITE: Record<FigureFace, FigureFace> = { left: 'right', right: 'left', bottom: 'top', top: 'bottom', back: 'front', front: 'back' }\nconst NORMAL: Record<FigureFace, [Axis, 1 | -1]> = { left: ['x', -1], right: ['x', 1], bottom: ['y', -1], top: ['y', 1], back: ['z', -1], front: ['z', 1] }\n\n/** The world direction a part's face looks along now, as drawn, turns and all; by its name when the face's outline is not read. */\nfunction directionOf(revision: FigureRevision, part: string, face: string): [Axis, 1 | -1] | undefined {\n const area = (() => {\n try {\n return figurePartFaceOf(revision.asset, part, face, revision.inputs)\n } catch {\n return undefined\n }\n })()\n if (area) {\n const k = area.normal.findIndex(v => Math.abs(v) > 0.5)\n if (k >= 0) return [AXES[k]!, area.normal[k]! > 0 ? 1 : -1]\n }\n return face in NORMAL ? NORMAL[face as FigureFace] : undefined\n}\n\n/**\n * The part's own face a fastening takes: the one looking against the target's face (올려놓기), with it (같은 면), or its\n * centre. Read from where each face looks now, so a part standing turned offers the face that is really there.\n * Undefined when the part has no such face.\n */\nexport function myFaceFor(revision: FigureRevision, part: string, target: FastenTarget, mode: FastenMode): FigureFace | 'centre' | undefined {\n const asset = revision.asset\n if (mode === 'centre') return target === 'plane' ? undefined : 'centre'\n const want: [Axis, 1 | -1] | undefined =\n target === 'plane'\n ? /* The plane is met from above on a floor, from in front on a wall. */ [mountingPlaneOf(asset).normal, -1]\n : (() => {\n const d = directionOf(revision, target.part, target.face)\n return d && [d[0], (mode === 'meet' ? -d[1] : d[1]) as 1 | -1]\n })()\n if (!want) return undefined\n const mine = facesOf(asset, part).filter((f): f is FigureFace => f in NORMAL)\n const hit = mine.find(f => {\n const d = directionOf(revision, part, f)\n return d && d[0] === want[0] && d[1] === want[1]\n })\n return hit ?? (target !== 'plane' && mode === 'meet' && target.face in OPPOSITE ? OPPOSITE[target.face as FigureFace] : undefined)\n}\n\n/** Which way the fastening is, read back from the part's face and facing. */\nexport const modeOf = (face: string, facing: 'meet' | 'flush'): FastenMode => (face === 'centre' ? 'centre' : facing)\n\n/**\n * The face seen from above: its two axes across (as the form's alignment names them), the face's size on each -- none\n * for a plane with no declared size -- the part's footprint on each, and whether its edges can be lined up with.\n */\nexport interface FaceView {\n axes: [Axis, Axis]\n face: Partial<Record<Axis, number>>\n part: Record<Axis, number>\n edges: Record<Axis, boolean>\n}\n\nexport function faceViewOf(revision: FigureRevision, part: string, target: FastenTarget): FaceView | undefined {\n const asset = revision.asset\n const across = alignAxesOf(asset, part, target)\n if (across.length !== 2) return undefined\n const box = boxOf(revision, part)\n if (!box) return undefined\n const axes = [across[0]!.axis, across[1]!.axis] as [Axis, Axis]\n const face: Partial<Record<Axis, number>> = {}\n if (target === 'plane') {\n for (const a of axes) if (hasInstanceSize(asset, a)) face[a] = asset.designInputs[`size.${a}`]!\n } else {\n const theirs = boxOf(revision, target.part)\n const normal = faceAxisOf(asset, target.part, target.face)\n for (const a of axes) if (theirs && a !== normal) face[a] = theirs.extent[a]\n }\n return {\n axes,\n face,\n part: { x: box.extent.x, y: box.extent.y, z: box.extent.z },\n edges: Object.fromEntries(across.map(o => [o.axis, o.edges])) as Record<Axis, boolean>\n }\n}\n\n/** Where the part's centre is from the face's centre along one axis, for the way it is aligned there. */\nexport function offsetOf(how: Alignment | undefined, mm: number | undefined, face: number | undefined, part: number): number {\n if (how === 'min' && face !== undefined) return -(face - part) / 2\n if (how === 'max' && face !== undefined) return (face - part) / 2\n if (how === 'mm' || how === 'share') return mm ?? 0\n return 0\n}\n\n/**\n * A place dropped on the face, as the form's alignment: caught at the centre, at an edge from inside (level with it:\n * `min` / `max`, where the edges can be lined up with), or at an edge from outside (touching it, as a distance), when\n * within `catchMm`; anywhere else a distance off centre, whole millimetres.\n */\nexport function alignmentAt(d: number, face: number | undefined, part: number, edges: boolean, catchMm: number): { how: Alignment; mm?: number; caught?: 'centre' | 'inside' | 'outside' } {\n if (Math.abs(d) <= catchMm) return { how: 'centre', caught: 'centre' }\n if (face !== undefined) {\n const inside = (face - part) / 2,\n outside = (face + part) / 2\n for (const [at, how] of [\n [-inside, 'min'],\n [inside, 'max']\n ] as const)\n if (Math.abs(d - at) <= catchMm && inside > 0) return edges ? { how, caught: 'inside' } : { how: 'mm', mm: Math.round(at), caught: 'inside' }\n for (const at of [-outside, outside]) if (Math.abs(d - at) <= catchMm) return { how: 'mm', mm: Math.round(at), caught: 'outside' }\n }\n return { how: 'mm', mm: Math.round(d) }\n}\n\n/** How far the footprint comes past the face's edges, per side, and whether it touches the face at all. */\nexport function overhangOf(view: FaceView, at: Record<Axis, number>): { touching: boolean; sides: Array<{ axis: Axis; side: 'low' | 'high'; mm: number }> } {\n const sides: Array<{ axis: Axis; side: 'low' | 'high'; mm: number }> = []\n let touching = true\n for (const a of view.axes) {\n const face = view.face[a]\n if (face === undefined) continue\n const lo = at[a] - view.part[a] / 2,\n hi = at[a] + view.part[a] / 2\n if (lo >= face / 2 || hi <= -face / 2) touching = false\n if (-face / 2 - lo > 0.5) sides.push({ axis: a, side: 'low', mm: Math.round(-face / 2 - lo) })\n if (hi - face / 2 > 0.5) sides.push({ axis: a, side: 'high', mm: Math.round(hi - face / 2) })\n }\n return { touching, sides }\n}\n\n/** Whether the part turns about a joint: then 가운데를 면에 is offered -- a roller spinning in place. */\nexport const turnsInPlace = (asset: FigureAsset, part: string) => (asset.joints ?? []).some(j => j.body1.part === part && (j.type === 'revolute' || ('face' in j.body1 && j.body1.face === 'centre')))\n\n/**\n * How the face lies on the screen: X across when it is one of the face's axes, else Z; the other down the screen -- up\n * for Y, which rises, so a front face is seen as it stands and not upside down.\n */\nexport function screenOf(axes: readonly [Axis, Axis]): { h: Axis; v: Axis; sign: Record<Axis, 1 | -1> } {\n const h = axes.includes('x') ? 'x' : 'z'\n const v = axes.find(a => a !== h)!\n return { h, v, sign: { x: 1, y: 1, z: 1, [v]: v === 'y' ? -1 : 1 } as Record<Axis, 1 | -1> }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { FigureFace } from '@hatiolab/figure-model';
2
+ import { type FigureRevision } from './revision.js';
2
3
  export type Placement = 'floor' | 'ceiling' | 'center' | 'wall';
3
4
  /** What the properties tab reads off the asset. Absent parts of the asset read as absent, never as a default. */
4
5
  export interface FigureFigureFacts {
@@ -20,7 +21,14 @@ export interface FigureFigureFacts {
20
21
  face: FigureFace;
21
22
  };
22
23
  }
23
- export declare function figureFigureFacts(source: string): FigureFigureFacts;
24
+ /**
25
+ * The asset's own facts, as the properties tab shows them.
26
+ *
27
+ * The mounting face is read back from the feature `set-mounting-face` writes (`<part>.mount.<face>`): the asset
28
+ * records the face only as that node, so this is where the screen learns which one is chosen. Parts are the placed
29
+ * bodies (`place@1`), in the order the model lists them.
30
+ */
31
+ export declare function figureFigureFacts(revision: FigureRevision): FigureFigureFacts;
24
32
  /**
25
33
  * A tag line as a list: split on commas, drop a leading `#`, keep each once. An empty
26
34
  * line is an empty list, so an author can clear every tag.
@@ -1,4 +1,5 @@
1
- import { compileFigureAsset, parseFigureAsset, figureOccupiedBoxesOf, figureWritersOf } from '@hatiolab/figure-model';
1
+ import { boxesOf } from './align.js';
2
+ import { derivedOf } from './revision.js';
2
3
  /**
3
4
  * The asset's own facts, as the properties tab shows them.
4
5
  *
@@ -6,17 +7,11 @@ import { compileFigureAsset, parseFigureAsset, figureOccupiedBoxesOf, figureWrit
6
7
  * records the face only as that node, so this is where the screen learns which one is chosen. Parts are the placed
7
8
  * bodies (`place@1`), in the order the model lists them.
8
9
  */
9
- let lastFacts;
10
- export function figureFigureFacts(source) {
11
- /* The panel renders more often than the figure changes; the same text says the same facts. */
12
- if (lastFacts?.source === source)
13
- return lastFacts.facts;
14
- const facts = figureFactsOf(source);
15
- lastFacts = { source, facts };
16
- return facts;
10
+ export function figureFigureFacts(revision) {
11
+ return derivedOf(revision, 'figure-facts', () => figureFactsOf(revision));
17
12
  }
18
- function figureFactsOf(source) {
19
- const asset = parseFigureAsset(source);
13
+ function figureFactsOf(revision) {
14
+ const asset = revision.asset;
20
15
  const parts = asset.document.model.nodes.filter(node => node.op === 'place@1').map(node => node.id);
21
16
  const feature = asset.occupancy?.contact?.surface?.feature;
22
17
  const found = feature?.match(/^(.+)\.mount\.(left|right|bottom|top|back|front)\.value$/);
@@ -26,16 +21,17 @@ function figureFactsOf(source) {
26
21
  declared: !!asset.occupancy,
27
22
  placement: asset.placement,
28
23
  mounting: found ? { part: found[1], face: found[2] } : undefined,
29
- suggested: suggestedMountOf(asset, parts)
24
+ suggested: suggestedMountOf(revision, parts)
30
25
  };
31
26
  }
32
- function suggestedMountOf(asset, parts) {
33
- const placement = (asset.placement ?? 'floor');
27
+ /* As the parts are drawn now. */
28
+ function suggestedMountOf(revision, parts) {
29
+ const placement = (revision.asset.placement ?? 'floor');
34
30
  if (placement === 'center' || !parts.length)
35
31
  return undefined;
36
32
  let boxes;
37
33
  try {
38
- boxes = figureOccupiedBoxesOf(compileFigureAsset(asset).evaluate().geometry, figureWritersOf(asset)).filter(b => parts.includes(b.part));
34
+ boxes = boxesOf(revision).filter(b => parts.includes(b.part));
39
35
  }
40
36
  catch {
41
37
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"figure-facts.js","sourceRoot":"","sources":["../../client/modeller/figure-facts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAwBrH;;;;;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AAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,OAAO;QACL,GAAG,IAAI,GAAG,CACR,GAAG;aACA,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;aAChD,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CACjC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { compileFigureAsset, parseFigureAsset, figureOccupiedBoxesOf, figureWritersOf } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureFace } from '@hatiolab/figure-model'\n\n/*\n * What the properties tab reads, kept apart from the element so it can be tested without a browser.\n */\n\nexport type Placement = 'floor' | 'ceiling' | 'center' | 'wall'\n\n/** What the properties tab reads off the asset. Absent parts of the asset read as absent, never as a default. */\nexport interface FigureFigureFacts {\n name: string\n parts: string[]\n declared: boolean\n placement?: Placement\n mounting?: { part: string; face: FigureFace }\n /**\n * Where the figure meets its plane, as its parts stand: the part whose bottom is lowest for a floor, whose top is\n * highest for a ceiling, whose back is furthest back for a wall. What the mounting face is offered as before one is\n * chosen -- the first part in the list offered a conveyor's bed, 700 mm up on its legs (walk 1, 2026-09-26).\n */\n suggested?: { part: string; face: FigureFace }\n}\n\n/**\n * The asset's own facts, as the properties tab shows them.\n *\n * The mounting face is read back from the feature `set-mounting-face` writes (`<part>.mount.<face>`): the asset\n * records the face only as that node, so this is where the screen learns which one is chosen. Parts are the placed\n * bodies (`place@1`), in the order the model lists them.\n */\nlet lastFacts: { source: string; facts: FigureFigureFacts } | undefined\nexport function figureFigureFacts(source: string): FigureFigureFacts {\n /* The panel renders more often than the figure changes; the same text says the same facts. */\n if (lastFacts?.source === source) return lastFacts.facts\n const facts = figureFactsOf(source)\n lastFacts = { source, facts }\n return facts\n}\nfunction figureFactsOf(source: string): FigureFigureFacts {\n const asset = parseFigureAsset(source) as FigureAsset & { document: { model: { nodes: Array<{ id: string; op: string }> } } }\n const parts = asset.document.model.nodes.filter(node => node.op === 'place@1').map(node => node.id)\n const feature = (asset.occupancy?.contact as { surface?: { feature?: string } } | undefined)?.surface?.feature\n const found = feature?.match(/^(.+)\\.mount\\.(left|right|bottom|top|back|front)\\.value$/)\n return {\n name: asset.name,\n parts,\n declared: !!asset.occupancy,\n placement: asset.placement as Placement | undefined,\n mounting: found ? { part: found[1], face: found[2] as FigureFace } : undefined,\n suggested: suggestedMountOf(asset, parts)\n }\n}\n\nfunction suggestedMountOf(asset: FigureAsset, parts: string[]): { part: string; face: FigureFace } | undefined {\n const placement = (asset.placement ?? 'floor') as Placement\n if (placement === 'center' || !parts.length) return undefined\n let boxes\n try {\n boxes = figureOccupiedBoxesOf(compileFigureAsset(asset).evaluate().geometry, figureWritersOf(asset)).filter(b => parts.includes(b.part))\n } catch {\n return undefined\n }\n const [axis, face, sign] = placement === 'wall' ? (['z', 'back', -1] as const) : placement === 'ceiling' ? (['y', 'top', 1] as const) : (['y', 'bottom', -1] as const)\n /* The side of each box that faces the plane; the one furthest toward it, the first in the list among equals. */\n const reach = (b: (typeof boxes)[number]) => sign * (b.centre[axis] + (sign * b.extent[axis]) / 2)\n let best: (typeof boxes)[number] | undefined\n for (const b of boxes) if (!best || reach(b) > reach(best) + 1e-6) best = b\n return best ? { part: best.part, face } : undefined\n}\n\n/**\n * A tag line as a list: split on commas, drop a leading `#`, keep each once. An empty\n * line is an empty list, so an author can clear every tag.\n */\nexport function tagsOf(raw: string): string[] {\n return [\n ...new Set(\n raw\n .split(',')\n .map(one => one.trim().replace(/^#+/, '').trim())\n .filter(one => one.length > 0)\n )\n ]\n}\n"]}
1
+ {"version":3,"file":"figure-facts.js","sourceRoot":"","sources":["../../client/mod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;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,OAAO;QACL,GAAG,IAAI,GAAG,CACR,GAAG;aACA,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;aAChD,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CACjC;KACF,CAAA;AACH,CAAC","sourcesContent":["import type { FigureAsset, FigureFace } from '@hatiolab/figure-model'\n\nimport { boxesOf } from './align.js'\nimport { derivedOf, type FigureRevision } from './revision.js'\n\n/*\n * What the properties tab reads, kept apart from the element so it can be tested without a browser.\n */\n\nexport type Placement = 'floor' | 'ceiling' | 'center' | 'wall'\n\n/** What the properties tab reads off the asset. Absent parts of the asset read as absent, never as a default. */\nexport interface FigureFigureFacts {\n name: string\n parts: string[]\n declared: boolean\n placement?: Placement\n mounting?: { part: string; face: FigureFace }\n /**\n * Where the figure meets its plane, as its parts stand: the part whose bottom is lowest for a floor, whose top is\n * highest for a ceiling, whose back is furthest back for a wall. What the mounting face is offered as before one is\n * chosen -- the first part in the list offered a conveyor's bed, 700 mm up on its legs (walk 1, 2026-09-26).\n */\n suggested?: { part: string; face: FigureFace }\n}\n\n/**\n * The asset's own facts, as the properties tab shows them.\n *\n * The mounting face is read back from the feature `set-mounting-face` writes (`<part>.mount.<face>`): the asset\n * records the face only as that node, so this is where the screen learns which one is chosen. Parts are the placed\n * bodies (`place@1`), in the order the model lists them.\n */\nexport function figureFigureFacts(revision: FigureRevision): FigureFigureFacts {\n return derivedOf(revision, 'figure-facts', () => figureFactsOf(revision))\n}\nfunction figureFactsOf(revision: FigureRevision): FigureFigureFacts {\n const asset = revision.asset as FigureAsset & { document: { model: { nodes: Array<{ id: string; op: string }> } } }\n const parts = asset.document.model.nodes.filter(node => node.op === 'place@1').map(node => node.id)\n const feature = (asset.occupancy?.contact as { surface?: { feature?: string } } | undefined)?.surface?.feature\n const found = feature?.match(/^(.+)\\.mount\\.(left|right|bottom|top|back|front)\\.value$/)\n return {\n name: asset.name,\n parts,\n declared: !!asset.occupancy,\n placement: asset.placement as Placement | undefined,\n mounting: found ? { part: found[1], face: found[2] as FigureFace } : undefined,\n suggested: suggestedMountOf(revision, parts)\n }\n}\n\n/* As the parts are drawn now. */\nfunction suggestedMountOf(revision: FigureRevision, parts: string[]): { part: string; face: FigureFace } | undefined {\n const placement = (revision.asset.placement ?? 'floor') as Placement\n if (placement === 'center' || !parts.length) return undefined\n let boxes\n try {\n boxes = boxesOf(revision).filter(b => parts.includes(b.part))\n } catch {\n return undefined\n }\n const [axis, face, sign] = placement === 'wall' ? (['z', 'back', -1] as const) : placement === 'ceiling' ? (['y', 'top', 1] as const) : (['y', 'bottom', -1] as const)\n /* The side of each box that faces the plane; the one furthest toward it, the first in the list among equals. */\n const reach = (b: (typeof boxes)[number]) => sign * (b.centre[axis] + (sign * b.extent[axis]) / 2)\n let best: (typeof boxes)[number] | undefined\n for (const b of boxes) if (!best || reach(b) > reach(best) + 1e-6) best = b\n return best ? { part: best.part, face } : undefined\n}\n\n/**\n * A tag line as a list: split on commas, drop a leading `#`, keep each once. An empty\n * line is an empty list, so an author can clear every tag.\n */\nexport function tagsOf(raw: string): string[] {\n return [\n ...new Set(\n raw\n .split(',')\n .map(one => one.trim().replace(/^#+/, '').trim())\n .filter(one => one.length > 0)\n )\n ]\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import '@material/web/icon/icon.js';
2
2
  import { LitElement, nothing } from 'lit';
3
- import type { FigureAsset } from '@hatiolab/figure-model';
4
3
  import './figure-fasten-drawing.js';
4
+ import type { FigureRevision } from './revision.js';
5
5
  declare const FigureLinks_base: (new (...args: any[]) => LitElement) & typeof LitElement;
6
6
  /**
7
7
  * What a part is tied to — its size response, what it is fastened to, how it moves.
@@ -19,12 +19,11 @@ declare const FigureLinks_base: (new (...args: any[]) => LitElement) & typeof Li
19
19
  export declare class FigureLinks extends FigureLinks_base {
20
20
  private readonly help;
21
21
  static styles: import("lit").CSSResult[];
22
- /** The asset being edited. */
23
- asset?: FigureAsset;
22
+ /** The figure at the version on screen. */
23
+ revision?: FigureRevision;
24
+ private get asset();
24
25
  /** The selected part. */
25
26
  partId: string;
26
- /** The part's own extent along its axes now, in mm — what a dimension is fixed at when it stops following. */
27
- dims?: [number, number, number];
28
27
  locked: boolean;
29
28
  /** Which ties this shows: the part's shape (size and placement, in 속성), its places (자리·능력) or its motion (움직임). */
30
29
  section: 'shape' | 'places' | 'motion';
@@ -8,6 +8,7 @@ import { acceptsOf, alignAxesOf, mountingPlaneOf, alignOf, AXES, canFasten, face
8
8
  import { SidePanelStyles } from './side-panel-styles.js';
9
9
  import './figure-fasten-drawing.js';
10
10
  import { faceViewOf, modeOf, myFaceFor, turnsInPlace } from './fasten-geometry.js';
11
+ import { boxOf } from './align.js';
11
12
  import { HelpToggles } from './help.js';
12
13
  import { jointAxisWord } from './joint-axis.js';
13
14
  const FACES = Object.keys(FIGURE_FACES);
@@ -128,11 +129,14 @@ let FigureLinks = class FigureLinks extends localize(i18next)(LitElement) {
128
129
  min-width: 0;
129
130
  }
130
131
  `]; }
132
+ get asset() {
133
+ return this.revision?.asset;
134
+ }
131
135
  willUpdate(_changed) {
132
136
  if (this.asset && this.partId && this.partId !== this.loadedFor) {
133
137
  this.loadedFor = this.partId;
134
138
  /* A part's own fastening is not another part's choices: the form opens on it (walk 1, 2026-09-26). */
135
- const own = this.asset && this.partId ? fasteningOf(this.asset, this.partId) : null;
139
+ const own = this.revision && this.partId ? fasteningOf(this.revision, this.partId) : null;
136
140
  this.fasten = own ? { ...freshFasten(), ...own } : freshFasten();
137
141
  this.motion = freshMotion();
138
142
  this.place = freshPlace();
@@ -265,7 +269,7 @@ let FigureLinks = class FigureLinks extends localize(i18next)(LitElement) {
265
269
  const now = followOf(asset, this.partId, axis);
266
270
  const following = now.of === 'instance' && now.axis === axis;
267
271
  const custom = now.of !== 'own' && !following;
268
- const mm = measureNow(asset, this.partId, axis);
272
+ const mm = measureNow(this.revision, this.partId, axis);
269
273
  return html `<div row>
270
274
  <b>${word(axis)}</b>
271
275
  <span measure>${mm === undefined ? '—' : `${Math.round(mm)} mm`}</span>
@@ -341,7 +345,7 @@ let FigureLinks = class FigureLinks extends localize(i18next)(LitElement) {
341
345
  await this.openFastening(this.asset);
342
346
  }
343
347
  async openFastening(asset) {
344
- const own = fasteningOf(asset, this.partId);
348
+ const own = fasteningOf(this.revision, this.partId);
345
349
  this.fasten = own ? { ...freshFasten(), ...own } : freshFasten();
346
350
  this.spotlit = true;
347
351
  await this.updateComplete;
@@ -393,7 +397,8 @@ let FigureLinks = class FigureLinks extends localize(i18next)(LitElement) {
393
397
  follow(asset, axis, choice, now) {
394
398
  const following = now.of !== 'own';
395
399
  /* The measure as it stands: a dimension stops following at it, and a share is taken of it. */
396
- const current = dimensionNow(asset, this.partId, axis) ?? this.dims?.[AXES.indexOf(axis)] ?? 100;
400
+ /* The part's own extent along the axis now, as drawn: what a dimension is fixed at when it stops following. */
401
+ const current = dimensionNow(this.revision, this.partId, axis) ?? boxOf(this.revision, this.partId)?.dims[AXES.indexOf(axis)] ?? 100;
397
402
  if (choice === 'own') {
398
403
  if (!following)
399
404
  return;
@@ -438,12 +443,12 @@ let FigureLinks = class FigureLinks extends localize(i18next)(LitElement) {
438
443
  const theirFaces = f.target ? facesOf(asset, f.target) : FACES;
439
444
  const targetFace = theirFaces.includes(f.targetFace) ? f.targetFace : theirFaces[0];
440
445
  const aim = f.toPlane ? 'plane' : f.target ? { part: f.target, face: targetFace } : undefined;
441
- this.fasten = { ...f, ...(aim ? placeKeptOf(asset, this.partId, aim, !!f.twist) : { align: {}, alignMm: {}, alignInput: {} }) };
446
+ this.fasten = { ...f, ...(aim ? placeKeptOf(this.revision, this.partId, aim, !!f.twist) : { align: {}, alignMm: {}, alignInput: {} }) };
442
447
  }
443
448
  renderFastening(asset) {
444
449
  const held = heldBy(asset, this.partId);
445
450
  /* Placed by an origin (ADR-0107 decision 4): attach writes faces, so the form would move it off its origin. Said, and taken off only. */
446
- if (fasteningOf(asset, this.partId)?.atOrigin) {
451
+ if (fasteningOf(this.revision, this.partId)?.atOrigin) {
447
452
  this.fastenCandidate = undefined;
448
453
  return html `<div fastened fasten-at-origin>
449
454
  <p>${this.heldWords(asset)}</p>
@@ -472,7 +477,7 @@ let FigureLinks = class FigureLinks extends localize(i18next)(LitElement) {
472
477
  const aim = f.toPlane ? 'plane' : { part: f.target, face: targetFace };
473
478
  /* The part's own face is not chosen: the target's face and how give it (user 2026-10-01; the kernel takes no other). */
474
479
  const mode = f.toPlane ? 'meet' : modeOf(f.face, f.facing);
475
- const derived = f.toPlane || f.target ? myFaceFor(asset, this.partId, aim, mode) : undefined;
480
+ const derived = f.toPlane || f.target ? myFaceFor(this.revision, this.partId, aim, mode) : undefined;
476
481
  const myFace = derived ?? (mineFaces.includes(f.face) ? f.face : mineFaces[0]);
477
482
  const align = f.target || f.toPlane ? alignOf(asset, this.partId, aim, f.align, f.alignMm, !!f.twist, f.alignInput) : undefined;
478
483
  const action = f.toPlane || f.target
@@ -500,7 +505,7 @@ let FigureLinks = class FigureLinks extends localize(i18next)(LitElement) {
500
505
  ...(f.twist ? [i18next.t('figure.text.fasten-summary-twist', { degrees: String(f.twist) })] : [])
501
506
  ];
502
507
  /* Across the face, a row only where the drawing cannot set it: no drawing of the face, or a share or a field to follow. */
503
- const view = f.toPlane || f.target ? faceViewOf(asset, this.partId, aim) : undefined;
508
+ const view = f.toPlane || f.target ? faceViewOf(this.revision, this.partId, aim) : undefined;
504
509
  const alignRows = (f.toPlane || f.target ? alignAxesOf(asset, this.partId, aim, !!f.twist) : []).filter(({ axis }) => !view || !view.axes.includes(axis) || !!f.alignInput?.[axis] || hasInstanceSize(asset, axis));
505
510
  /* A fastening the part has is changed as soon as something is chosen, as the drawing does; a new one waits for 붙이기. */
506
511
  const settle = () => this.onFastenRelease(!!held);
@@ -925,15 +930,11 @@ let FigureLinks = class FigureLinks extends localize(i18next)(LitElement) {
925
930
  __decorate([
926
931
  property({ attribute: false }),
927
932
  __metadata("design:type", Object)
928
- ], FigureLinks.prototype, "asset", void 0);
933
+ ], FigureLinks.prototype, "revision", void 0);
929
934
  __decorate([
930
935
  property(),
931
936
  __metadata("design:type", Object)
932
937
  ], FigureLinks.prototype, "partId", void 0);
933
- __decorate([
934
- property({ attribute: false }),
935
- __metadata("design:type", Array)
936
- ], FigureLinks.prototype, "dims", void 0);
937
938
  __decorate([
938
939
  property({ type: Boolean }),
939
940
  __metadata("design:type", Object)