@floless/app 0.138.2 → 0.139.0

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 (109) hide show
  1. package/autostart.mjs +6 -2
  2. package/desktop-access-production-manifest.mjs +7 -0
  3. package/dist/floless-server.cjs +157202 -70901
  4. package/dist/schemas/model.continuation.v1.schema.json +19 -0
  5. package/dist/schemas/model.continuation.v2.schema.json +19 -0
  6. package/dist/schemas/model.query-response.v1.schema.json +95 -0
  7. package/dist/schemas/model.query-response.v2.schema.json +80 -0
  8. package/dist/schemas/model.query.v1.schema.json +87 -0
  9. package/dist/schemas/model.query.v2.schema.json +87 -0
  10. package/dist/schemas/model.snap-candidate.v1.schema.json +48 -0
  11. package/dist/schemas/model.snap-constraint.v1.schema.json +18 -0
  12. package/dist/schemas/model.snap-query.v1.schema.json +24 -0
  13. package/dist/schemas/model.snap-result.v1.schema.json +33 -0
  14. package/dist/schemas/model.snapshot.v1.schema.json +136 -0
  15. package/dist/schemas/revit.model.v1.schema.json +24 -0
  16. package/dist/schemas/steel.model.v2.schema.json +45 -6
  17. package/dist/skills/floless-app-approval/SKILL.md +19 -5
  18. package/dist/skills/floless-app-bridge/SKILL.md +19 -6
  19. package/dist/skills/floless-app-knowledge/SKILL.md +22 -1
  20. package/dist/skills/floless-app-new-workflow/SKILL.md +31 -27
  21. package/dist/skills/floless-app-new-workflow/references/build-and-verify.md +13 -12
  22. package/dist/skills/floless-app-onboarding/SKILL.md +3 -3
  23. package/dist/skills/floless-app-onboarding/references/floless-app-tour.md +16 -9
  24. package/dist/skills/floless-app-steel-model/SKILL.md +11 -2
  25. package/dist/skills/floless-app-steel-model/references/detail-from-a-screenshot.md +95 -0
  26. package/dist/skills/floless-app-steel-takeoff/SKILL.md +142 -21
  27. package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +19 -0
  28. package/dist/skills/floless-app-tweak-contract/SKILL.md +42 -8
  29. package/dist/skills/floless-app-vectorize/SKILL.md +19 -6
  30. package/dist/skills/floless-app-workflows/SKILL.md +30 -3
  31. package/dist/skills/floless-app-workflows/references/workspace-data.md +77 -4
  32. package/dist/templates/floless-workspace-model-report.flo +77 -0
  33. package/dist/templates/revit-model.flo +111 -0
  34. package/dist/web/app.css +415 -177
  35. package/dist/web/app.js +302 -51
  36. package/dist/web/aware.js +1357 -1032
  37. package/dist/web/chat.css +692 -0
  38. package/dist/web/chat.js +2651 -0
  39. package/dist/web/commands-revit.js +42 -0
  40. package/dist/web/commands-shell.js +531 -70
  41. package/dist/web/commands-steel.js +344 -146
  42. package/dist/web/commands.js +1 -1
  43. package/dist/web/index.html +283 -77
  44. package/dist/web/instructor.js +217 -36
  45. package/dist/web/left-pane.js +636 -0
  46. package/dist/web/model-artifact-loader.js +75 -0
  47. package/dist/web/model-authoring-gestures.js +141 -0
  48. package/dist/web/model-cad-tools.js +20 -0
  49. package/dist/web/model-clip-gesture.js +148 -0
  50. package/dist/web/model-clip-list.js +156 -0
  51. package/dist/web/model-clip-session.js +274 -0
  52. package/dist/web/model-clip-three-overlay.js +295 -0
  53. package/dist/web/model-clip-three-preview.js +59 -0
  54. package/dist/web/model-editor-contract.js +519 -0
  55. package/dist/web/model-editor-revit-adapter.js +139 -0
  56. package/dist/web/model-editor-shell.js +271 -0
  57. package/dist/web/model-editor-state-recovery.js +44 -0
  58. package/dist/web/model-editor-steel-adapter.js +410 -0
  59. package/dist/web/model-editor.css +268 -0
  60. package/dist/web/model-frame.js +192 -0
  61. package/dist/web/model-inspector.js +128 -0
  62. package/dist/web/model-measure.js +390 -0
  63. package/dist/web/model-navigation-controls.js +246 -0
  64. package/dist/web/model-orientation-overlay.js +217 -0
  65. package/dist/web/model-panel-bridge.js +230 -0
  66. package/dist/web/model-pointer-dock.js +164 -0
  67. package/dist/web/model-revit-module.js +83 -0
  68. package/dist/web/model-selection-coordinator.js +151 -0
  69. package/dist/web/model-selection-tools.js +290 -0
  70. package/dist/web/model-snap-contract.js +267 -0
  71. package/dist/web/model-snapping.js +497 -0
  72. package/dist/web/model-spatial-panel.js +294 -0
  73. package/dist/web/model-spatial-tools.js +249 -0
  74. package/dist/web/model-tree.js +47 -0
  75. package/dist/web/model-viewport-lighting.js +166 -0
  76. package/dist/web/model-viewport-revit-adapter.js +1224 -0
  77. package/dist/web/model-viewport-state.js +505 -0
  78. package/dist/web/model-viewport-steel-adapter.js +150 -0
  79. package/dist/web/model-viewport-toolbar.js +516 -0
  80. package/dist/web/model-viewport.js +717 -0
  81. package/dist/web/panels.js +8 -15
  82. package/dist/web/renderers.js +3 -0
  83. package/dist/web/revit-editor.css +35 -0
  84. package/dist/web/revit-editor.html +74 -0
  85. package/dist/web/revit-editor.js +845 -0
  86. package/dist/web/steel-3d-core.js +16 -44
  87. package/dist/web/steel-3d-view.js +1384 -633
  88. package/dist/web/steel-canvas-guidance.js +3 -1
  89. package/dist/web/steel-editor.html +2121 -1253
  90. package/dist/web/steel-filter.html +5 -1
  91. package/dist/web/steel-model-v2-commands.js +72 -1
  92. package/dist/web/steel-split-view.js +5 -39
  93. package/dist/web/steel-view-generation.js +107 -17
  94. package/dist/web/vector-3d.html +12 -0
  95. package/dist/web/workspaces.js +2154 -283
  96. package/distribution-profile-active.mjs +2 -0
  97. package/distribution-profile-production.mjs +47 -0
  98. package/distribution-profile-shared.mjs +8 -0
  99. package/distribution-profile.mjs +18 -0
  100. package/distribution-resource-inventory.mjs +81 -0
  101. package/launch.mjs +18 -10
  102. package/log.mjs +2 -1
  103. package/managed-runtime-policy.mjs +104 -0
  104. package/model-reader-policy-active.mjs +7 -0
  105. package/network-policy-active.mjs +6 -0
  106. package/package.json +17 -2
  107. package/post-update-marker.mjs +3 -1
  108. package/rvt-production-uat-authority.mjs +60 -0
  109. package/teardown.mjs +4 -3
@@ -240,7 +240,7 @@
240
240
  if (owner) return owner.getAttribute('data-group');
241
241
  if (el.closest('header')) return 'In the header';
242
242
  if (el.closest('footer')) return 'In the footer';
243
- if (el.closest('#chat-panel')) return 'In the Narrative panel';
243
+ if (el.closest('#chat-panel')) return 'In the left panel';
244
244
  if (el.closest('.canvas')) return 'On the workflow canvas';
245
245
  if (el.closest('.inspect')) return 'In the Inspect panel';
246
246
  return null;
@@ -483,6 +483,16 @@
483
483
  mean; otherwise they are navigating by keyboard and focus wins. */
484
484
  var HOVER_INTENT_MS = 3000;
485
485
 
486
+ /* A model editor's panel tabs are its own controls, moved into the main window's #left-model-panel frame
487
+ (web/model-panel-bridge.js): a third document, searched after the editor's own. */
488
+ function panelDoc() {
489
+ try {
490
+ var frame = document.getElementById('left-model-panel');
491
+ var doc = frame && frame.contentDocument;
492
+ return doc && doc.body && doc.body.classList.contains('model-panel-host') ? doc : null;
493
+ } catch (e) { return null; }
494
+ }
495
+
486
496
  function currentActiveElement() {
487
497
  /* The shell's activeElement is only the iframe; the meaningful focus target
488
498
  is inside its same-origin document. A torn-down or not-yet-ready child
@@ -494,6 +504,9 @@
494
504
  if (childActive && childActive !== childDoc.body) return childActive;
495
505
  } catch (e) { /* frame changed while the key was being handled */ }
496
506
  }
507
+ var panel = panelDoc();
508
+ if (panel && document.activeElement && document.activeElement.id === 'left-model-panel'
509
+ && panel.activeElement && panel.activeElement !== panel.body) return panel.activeElement;
497
510
  return document.activeElement;
498
511
  }
499
512
 
@@ -586,7 +599,7 @@
586
599
  var sheetRows = [];
587
600
  var activeRow = -1;
588
601
 
589
- function sheetEntries() {
602
+ function sheetEntries(visibleTemplates) {
590
603
  if (!window.Commands) return [];
591
604
  var entries = [];
592
605
  window.Commands.all().forEach(function (cmd) {
@@ -599,7 +612,7 @@
599
612
  // you find out what FloLess can do somewhere else, and its zero-result copy
600
613
  // calls a miss "a gap worth reporting", which would be a lie if the
601
614
  // catalogue were quietly trimmed to the current screen.
602
- var sa = onScreen(a) ? 0 : 1, sb = onScreen(b) ? 0 : 1;
615
+ var sa = onScreen(a, visibleTemplates) ? 0 : 1, sb = onScreen(b, visibleTemplates) ? 0 : 1;
603
616
  if (sa !== sb) return sa - sb;
604
617
  var ga = a.group || 'Elsewhere', gb = b.group || 'Elsewhere';
605
618
  if (ga !== gb) {
@@ -640,6 +653,7 @@
640
653
  if (activeReporterWindow && snapshot.child) {
641
654
  try { collect(activeReporterWindow.document, snapshot.child.surface || 'shell'); } catch (e) { /* torn down */ }
642
655
  }
656
+ collect(panelDoc(), (snapshot.child && snapshot.child.surface) || 'shell');
643
657
  return found;
644
658
  }
645
659
 
@@ -695,11 +709,12 @@
695
709
  var GROUP_ORDER = [
696
710
  // the shell
697
711
  'In the header', 'In the workflow picker', 'In the project picker', 'In the project list',
698
- 'In the project workspace', 'On the workflow canvas',
712
+ 'In the Workspace directory dialog', 'In the new project dialog', 'In the project workspace', 'In the Revit workspace', 'In Company knowledge',
713
+ 'On the workflow canvas', 'In workflow setup dialogs',
699
714
  // The Informed by row sits at the top of the canvas column, so it is read right after the canvas.
700
- 'In the Informed by row',
701
- 'In the Narrative panel', 'At the edge of the Narrative or Inspect panel',
702
- 'In the AI answers tab', 'On a saved AI session', 'In the node Inspect panel', 'In the Instructor strip',
715
+ 'In the Informed by row', 'In Set inputs',
716
+ 'At the left edge of the workspace', 'At the edge of the left or Inspect panel', 'In the left panel', 'Between AI Chat and Model', 'In the Model section of the left panel',
717
+ 'In AI Chat', 'In AI Chat history', 'In AI Chat settings', 'In the node Inspect panel', 'In the Instructor strip',
703
718
  'In the ≡ menu', 'In the footer',
704
719
  'In the contract editor', 'In the report viewer', 'In the Knowledge Base viewer', 'In the guide',
705
720
  'In the agent library', 'In the requests list', 'In the revision review', 'In the run request dialog', 'In the Integrations dialog', 'In the Routines dialog',
@@ -710,8 +725,8 @@
710
725
  sections on screen: a single 'In the ⋯ menu' would have been about thirty
711
726
  rows under one heading, which is a scroll rather than a list. */
712
727
  'In the steel editor header', 'On the steel canvas', 'On the drawing canvas', 'In the Copy panel', 'In the Copy array panel', 'On the 2D zoom bar',
713
- 'In the 3D toolbar', 'In the label menus', 'In the 3D side panel', 'On the snap bar',
714
- 'In the grid panel', 'In the Inspect panel',
728
+ 'In the 3D toolbar', 'In the label menus', 'On the select bar', 'On the snap bar',
729
+ 'In the grid panel', 'In the Inspect panel', 'In the Properties panel',
715
730
  'In the Properties popup', 'In the snap override menu', 'In the dimension value popup', 'In the selection filter',
716
731
  'In the review list', // the connection-review popover — a sibling of the selection filter, and it hangs off the header stats above
717
732
  'In the registration list', // the SAME popover, different heading: it serves three header stats and names each list on screen (#935)
@@ -720,7 +735,9 @@
720
735
  'In the ⋯ menu — Model checks', 'In the ⋯ menu — Coordinate system', 'In the ⋯ menu — Session',
721
736
  'In the steel editor dialogs', 'In the Generate views dialog', 'In the Details dialog', 'In the RFI dialog',
722
737
  'In the Connections dialog', 'In the reference-model dialogs', 'In the connection-import dialog',
723
- 'In the confidence report', 'In the Ask AI dialog', 'In the Favourites dialog',
738
+ 'In the confidence report', 'In the Ask AI panel', 'In the Ask AI dialog', 'In the Favourites dialog',
739
+ // the read-only Revit model editor
740
+ 'In the Revit model header', 'In the Revit model toolbar', 'In the Revit model coordinate HUD', 'In the Revit model selection bar', 'In the Revit model snapping bar', 'On the Inspector',
724
741
  // the drawing filter
725
742
  'In the Drawing Filter header', 'In a Drawing Filter message',
726
743
  'In the Drawing Filter panel', 'On the Drawing Filter canvas',
@@ -734,26 +751,44 @@
734
751
  return i === -1 ? GROUP_ORDER.length : i;
735
752
  }
736
753
 
737
- /* Which surface the user is looking at. A child reporter names itself; with no
738
- child live, the shell is what is on screen.
739
-
740
- Only ONE surface is ever visible: the contract-editor overlay that hosts
741
- every child is `position: fixed; inset: 0` (app.css), so an open child hides
742
- the shell's own header, picker and canvas entirely. That is why an on-screen
743
- test is `surface === live` and not "shell plus the live child". */
754
+ /* A project workspace embeds its child beside shell-owned controls, including
755
+ the combined left pane. Full-screen editor overlays still expose only their child. */
744
756
  function activeSurface() {
745
757
  return (snapshot.child && snapshot.child.surface) || (snapshot.workspace ? 'workspaces' : 'shell');
746
758
  }
747
- function onScreen(cmd) {
759
+ function visibleCarrierTemplates() {
760
+ var visible = {};
761
+ function scan(doc) {
762
+ if (!doc || !doc.querySelectorAll) return;
763
+ Array.prototype.forEach.call(doc.querySelectorAll('[data-command-id]'), function (el) {
764
+ if (el.closest && el.closest('#command-sheet')) return;
765
+ if (!(el.offsetParent || (el.getClientRects && el.getClientRects().length))) return;
766
+ var raw = el.getAttribute('data-command-id') || '';
767
+ var parts = window.Commands.split ? window.Commands.split(raw) : null;
768
+ if (parts?.template) visible[parts.template] = true;
769
+ });
770
+ }
771
+ scan(document);
772
+ if (activeReporterWindow && snapshot.child) {
773
+ try { scan(activeReporterWindow.document); } catch (e) { /* torn down */ }
774
+ }
775
+ return visible;
776
+ }
777
+ function onScreen(cmd, visibleTemplates) {
748
778
  /* A command registered before `surface` existed would have none. Treating
749
779
  that as on-screen keeps it visible rather than silently exiling it, and
750
780
  verify-command-registry is what stops one being added. */
751
- return !cmd.surface || cmd.surface === activeSurface();
781
+ var surface = cmd.originSurface || cmd.surface;
782
+ if (!surface) return true;
783
+ if (snapshot.workspace && (surface === 'shell' || surface === 'workspaces')) return !!visibleTemplates?.[cmd.id];
784
+ if (snapshot.workspace && snapshot.child && surface === snapshot.child.surface) return true;
785
+ return surface === activeSurface();
752
786
  }
753
787
 
754
788
  function renderSheet() {
755
789
  var q = ($sheetFilter.value || '').trim().toLowerCase();
756
- var all = sheetEntries();
790
+ var visibleTemplates = visibleCarrierTemplates();
791
+ var all = sheetEntries(visibleTemplates);
757
792
  var hits = all.filter(function (c) { return matches(c, q); });
758
793
 
759
794
  $sheetList.textContent = '';
@@ -781,7 +816,7 @@
781
816
  /* One divider, at the first command that is not on this screen. The sort
782
817
  has already put every on-screen command ahead of every other, so a
783
818
  single boundary is all there is. */
784
- if (!dividedYet && !onScreen(cmd)) {
819
+ if (!dividedYet && !onScreen(cmd, visibleTemplates)) {
785
820
  dividedYet = true;
786
821
  lastGroup = null; // the first group below the rule still needs its heading
787
822
  var sep = document.createElement('div');
@@ -873,8 +908,9 @@
873
908
  : all.length + ' commands — this screen first';
874
909
  }
875
910
 
876
- /* Choosing a row takes you TO the control, when one is on screen. A list that
877
- only described things would make the user find them again by hand. */
911
+ /* Choosing a row takes you TO the control, when one is on screen or sits in a closed
912
+ menu that names its opener. A list that only described things would make the user
913
+ find them again by hand. */
878
914
  function activate(cmd) {
879
915
  /* Look for the control OUTSIDE the sheet. The rows carry data-command-id
880
916
  themselves (that is how a row knows what it is), so a naive query matches
@@ -882,7 +918,8 @@
882
918
  surface, such as every steel.* one while the editor is in an iframe, the
883
919
  row is the ONLY match. The result was focusing a row inside a dialog that
884
920
  had just been hidden. Visibility is checked too: a control in a closed
885
- panel is found by a selector but cannot be focused. */
921
+ panel is found by a selector but cannot be focused — unless the panel declares
922
+ `data-reveal-by` (see hiddenCarrier). */
886
923
  var exactCommandId = cmd.commandId || null;
887
924
  function matchesCommand(el) {
888
925
  var raw = el.getAttribute('data-command-id') || '';
@@ -925,6 +962,21 @@
925
962
  });
926
963
  } catch (e) { /* torn down mid-lookup, or cross-origin one day */ }
927
964
  }
965
+ var panel = live ? null : panelDoc();
966
+ if (panel) {
967
+ Array.prototype.forEach.call(panel.querySelectorAll('[data-command-id]'), function (el) {
968
+ if (live || !matchesCommand(el)) return;
969
+ if (el.offsetParent || (el.getClientRects && el.getClientRects().length)) {
970
+ live = el;
971
+ liveOrigin = (snapshot.child && snapshot.child.surface) || 'shell';
972
+ }
973
+ });
974
+ }
975
+
976
+ /* #1199 — nothing on screen, but the control may sit inside a CLOSED menu that the
977
+ markup says how to open (`data-reveal-by`): the ⋯ menu and its sections, the 3D
978
+ toolbar dropdowns, the Move/Copy menu, the ≡ menu. Found now; opened below. */
979
+ var hidden = live ? null : hiddenCarrier(matchesCommand);
928
980
 
929
981
  closeSheet();
930
982
  if (live && live.focus) {
@@ -936,11 +988,10 @@
936
988
  a registered command can carry its id on a <label> whose <input> is a
937
989
  DESCENDANT. Several carriers still do:
938
990
  shell.open-at-startup and shell.routine-enabled (index.html),
939
- steel.show-labels and steel.work-plane-show (steel-editor.html),
940
- vector.show-kind and vector.isolate-weak (vector-editor.html). For every one
941
- of them `live.focus()` above quietly does nothing — a <label> is not
942
- focusable — so this fall-through is the ONLY outcome those commands can
943
- reach, and `?` describes them instead of going to them.
991
+ vector.show-kind and vector.isolate-weak (vector-editor.html). For those,
992
+ `live.focus()` hands focus to the control the label labels, and focusFor()
993
+ resolves the label to its entry (#1035); only when it cannot does this
994
+ fall-through describe them instead.
944
995
  #805 Phase D moved the two steel-filter ones (filter.match-on,
945
996
  filter.facet-toggle) off that shape and left the rest alone: they are other
946
997
  surfaces, and moving them is not that slice's to do. Putting the id on the
@@ -959,13 +1010,37 @@
959
1010
  }
960
1011
  }
961
1012
 
962
- /* No control on screen — which is the NORMAL case for most of the list: every
963
- menu.* command (the ≡ menu is display:none until opened), every steel.*
964
- one (they live in an iframe), and anything registered without a
965
- data-command-id in markup. Closing and doing nothing would make the
966
- footer's "Enter — go to it" a promise the sheet breaks ~35 times out of 53.
967
- So it puts the command's own entry in the band instead: the user still
968
- learns what it does and where it lives, which is what they asked for. */
1013
+ if (hidden) {
1014
+ /* DEFERRED. The row click that brought us here is still bubbling, and a shell menu
1015
+ closes on any document click outside it (the ≡ menu does), so opening it now would
1016
+ see it shut again before focus arrives. */
1017
+ var reporter = activeReporterWindow;
1018
+ setTimeout(function () {
1019
+ /* The child the control lives in went away in between. Its reporter-gone has already
1020
+ cleared that surface from the band; describing the command now would put it back. */
1021
+ if (hidden.el.ownerDocument !== document && (activeReporterWindow !== reporter || !snapshot.child)) return;
1022
+ var shown = revealCarrier(hidden.el, matchesCommand);
1023
+ // `shown` has focus, or is disabled (its menus closed again) and narrates why; an entry the registry cannot build falls back to the command's own.
1024
+ if (shown && setFocusEntry(focusFor(shown), hidden.origin)) {
1025
+ paint();
1026
+ return;
1027
+ }
1028
+ describeCommand(cmd);
1029
+ }, 0);
1030
+ return;
1031
+ }
1032
+
1033
+ describeCommand(cmd);
1034
+ }
1035
+
1036
+ /* No control we can take the user to: a steel.* command whose surface is not up, one
1037
+ inside a menu with no declared opener or whose opener cannot be reached (the 3D bar in
1038
+ 2D, a pick armed, something covering it), one the page hides even inside its open menu
1039
+ (some ≡ items in a workspace), or one registered without a data-command-id in markup.
1040
+ Closing and doing nothing would make the footer's "Enter — go to it" a promise the
1041
+ sheet breaks. So it puts the command's own entry in the band instead: the user still
1042
+ learns what it does and where it lives, which is what they asked for. */
1043
+ function describeCommand(cmd) {
969
1044
  setFocusEntry({
970
1045
  label: cmd.label,
971
1046
  acts: cmd.actsOn ? cmd.actsOn.replace(/\{instance\}/g, cmd.instanceLabel || cmd.instance || 'the one you pick') : null,
@@ -980,6 +1055,112 @@
980
1055
  paint();
981
1056
  }
982
1057
 
1058
+ function isOnScreen(el) {
1059
+ return !!(el.offsetParent || (el.getClientRects && el.getClientRects().length));
1060
+ }
1061
+
1062
+ /* Every ancestor that declares `data-reveal-by`, open or closed, OUTERMOST first. */
1063
+ function revealChain(el) {
1064
+ var chain = [];
1065
+ for (var n = el.parentElement; n; n = n.parentElement) {
1066
+ if (n.getAttribute && n.getAttribute('data-reveal-by') !== null) chain.unshift(n);
1067
+ }
1068
+ return chain;
1069
+ }
1070
+
1071
+ /* #1199 — the first control for this command that is NOT on screen but sits inside at
1072
+ least one container declaring its opener. Same two documents, same order and same
1073
+ sheet exclusion as the on-screen lookup in activate(). */
1074
+ function hiddenCarrier(matches) {
1075
+ function scan(doc, origin) {
1076
+ var found = null;
1077
+ Array.prototype.forEach.call(doc.querySelectorAll('[data-command-id]'), function (el) {
1078
+ if (found || !matches(el) || (el.closest && el.closest('#command-sheet')) || isOnScreen(el)) return;
1079
+ if (revealChain(el).length) found = { el: el, origin: origin };
1080
+ });
1081
+ return found;
1082
+ }
1083
+ var hit = scan(document, 'shell');
1084
+ if (!hit && activeReporterWindow && snapshot.child) {
1085
+ try { hit = scan(activeReporterWindow.document, snapshot.child.surface || 'shell'); }
1086
+ catch (e) { /* torn down mid-lookup, or cross-origin one day */ }
1087
+ }
1088
+ return hit;
1089
+ }
1090
+
1091
+ /* Open every closed container around `el`, outermost first, by clicking the opener its
1092
+ `data-reveal-by` names (a selector in the same document), then focus the control. The
1093
+ page's real opener runs, so whatever it does on open — sync its state, build its rows,
1094
+ arm its outside-click close — happens exactly as for a person's click. A container
1095
+ already open is skipped (its opener is usually a toggle, and clicking it would shut it).
1096
+ Clicks nothing at an opener marked `data-cancels-pick`: while a pick is armed, Clip,
1097
+ Plane and Insert CANCEL it instead of opening, which would silently throw the user's pick
1098
+ away (the page sets the mark, so it holds whichever pane is active). Nor at an opener
1099
+ that cannot be reached: not laid out (a 3D toolbar menu while the editor shows 2D), or
1100
+ not what a click at its centre would hit, in its own document and in every frame above
1101
+ it (a shell modal over the ≡ button, or over the whole editor).
1102
+ Returns the control it focused; or one it found disabled, so its reason can still be
1103
+ narrated; or null. When it fails after opening something — an opener that did not open,
1104
+ a control the page hides even inside its open menu (some ≡ items in a workspace), one
1105
+ that takes no focus — the containers THIS call opened are closed again, innermost first,
1106
+ and focus goes back where it was. */
1107
+ function revealCarrier(el, matches) {
1108
+ var doc = el.ownerDocument || document;
1109
+ /* Only the shell's focus is worth keeping: the sheet that brought us here took focus in the shell,
1110
+ which already reset any focus inside a child document to its body. */
1111
+ var chain = revealChain(el), opened = [], focusBefore = document.activeElement;
1112
+ function reachable(node) {
1113
+ if (!isOnScreen(node)) return false;
1114
+ if (node.scrollIntoView) node.scrollIntoView({ block: 'nearest' }); // a section header below the fold of a scrolling menu
1115
+ var r = node.getBoundingClientRect(), x = r.left + r.width / 2, y = r.top + r.height / 2;
1116
+ for (var d = doc, target = node; ;) {
1117
+ var hit = d.elementFromPoint(x, y);
1118
+ if (!hit || !(hit === target || target.contains(hit))) return false;
1119
+ var frame = d !== document && d.defaultView ? d.defaultView.frameElement : null;
1120
+ if (!frame) return true;
1121
+ var f = frame.getBoundingClientRect();
1122
+ x += f.left + (frame.clientLeft || 0); y += f.top + (frame.clientTop || 0);
1123
+ d = frame.ownerDocument; target = frame;
1124
+ }
1125
+ }
1126
+ function giveUp() {
1127
+ for (var j = opened.length - 1; j >= 0; j--) {
1128
+ if (isOnScreen(opened[j].box) && isOnScreen(opened[j].opener)) opened[j].opener.click();
1129
+ }
1130
+ // Some openers move focus into their menu (Visibility, View): closing it would strand focus on the body.
1131
+ if (opened.length && focusBefore && focusBefore.focus) focusBefore.focus();
1132
+ return null;
1133
+ }
1134
+ for (var i = 0; i < chain.length; i++) {
1135
+ var box = chain[i];
1136
+ if (isOnScreen(box)) continue;
1137
+ var opener = null;
1138
+ try { opener = doc.querySelector(box.getAttribute('data-reveal-by')); }
1139
+ catch (e) { opener = null; }
1140
+ if (!opener || typeof opener.click !== 'function' || opener.getAttribute('data-cancels-pick') !== null || !reachable(opener)) return giveUp();
1141
+ opener.click();
1142
+ if (!isOnScreen(box)) return giveUp();
1143
+ opened.push({ box: box, opener: opener });
1144
+ }
1145
+ if (!isOnScreen(el)) {
1146
+ // A menu that builds its rows on open (Profile colours, Insert) has replaced the node found while it was shut.
1147
+ el = null;
1148
+ Array.prototype.forEach.call(doc.querySelectorAll('[data-command-id]'), function (n) {
1149
+ if (!el && matches(n) && !(n.closest && n.closest('#command-sheet')) && isOnScreen(n)) el = n;
1150
+ });
1151
+ }
1152
+ if (!el || typeof el.focus !== 'function') return giveUp();
1153
+ if (el.scrollIntoView) el.scrollIntoView({ block: 'nearest' });
1154
+ el.focus();
1155
+ // A <label> carrier hands focus to the control it labels ("Start on startup" in the ≡ menu).
1156
+ var landed = doc.activeElement;
1157
+ if (landed && (landed === el || landed === el.control)) return el;
1158
+ giveUp();
1159
+ // A disabled control takes no focus, but its entry still says why ("Select objects first").
1160
+ var ctl = el.control || el; // a <label> carrier is as disabled as the control it labels
1161
+ return ctl.disabled || ctl.getAttribute('aria-disabled') === 'true' ? el : null;
1162
+ }
1163
+
983
1164
  function setActiveRow(next) {
984
1165
  if (!sheetRows.length) return;
985
1166
  if (activeRow >= 0 && sheetRows[activeRow]) {