@wairon/cli 5.0.2-dev.3 → 5.0.2-dev.5

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/dist/index.js CHANGED
@@ -2650,12 +2650,21 @@ var MODEL = __MODEL_JSON__;
2650
2650
  var configuredLineStyle = ['bezier', 'straight', 'taxi'].indexOf(diagramConfig.lineStyle) >= 0 ? diagramConfig.lineStyle : 'bezier';
2651
2651
  var defaultViewKind = diagramConfig.defaultView === 'types' ? 'types' : (diagramConfig.defaultView === 'databases' && showDatabaseTab ? 'databases' : 'system');
2652
2652
 
2653
+ // Stage J: a deep link (opts.initialRoute) seeds the initial view directly so a
2654
+ // refresh / shared URL renders the right scope with NO root-first flash. Parsed
2655
+ // by the same resolver as openRoute (hoisted below). No onViewChange fires for
2656
+ // this initial seed.
2657
+ var initialView = { kind: defaultViewKind, id: null };
2658
+ if (typeof opts !== 'undefined' && opts && typeof opts.initialRoute === 'string' && opts.initialRoute.length) {
2659
+ initialView = resolveRoute(opts.initialRoute);
2660
+ }
2661
+
2653
2662
  var state = {
2654
- view: { kind: defaultViewKind, id: null },
2655
- internals: false,
2656
- externals: true,
2657
- dataCoupling: false,
2658
- showIssues: false,
2663
+ view: initialView,
2664
+ internals: typeof saved.internals === 'boolean' ? saved.internals : false,
2665
+ externals: typeof saved.externals === 'boolean' ? saved.externals : true,
2666
+ dataCoupling: typeof saved.dataCoupling === 'boolean' ? saved.dataCoupling : false,
2667
+ showIssues: typeof saved.showIssues === 'boolean' ? saved.showIssues : false,
2659
2668
  query: '',
2660
2669
  selected: null,
2661
2670
  selectedKind: null,
@@ -2670,6 +2679,9 @@ var MODEL = __MODEL_JSON__;
2670
2679
  // Set by buildTypeElements when the ERD is degraded for performance (huge
2671
2680
  // scopes); consumed by renderTypesNotice to explain the level-of-detail.
2672
2681
  var typesNotice = '';
2682
+ // Stage J: true while openRoute is applying a URL-driven view change, so the
2683
+ // onViewChange callback is suppressed and we do not loop URL -> engine -> URL.
2684
+ var applyingRoute = false;
2673
2685
 
2674
2686
  function viewKey() {
2675
2687
  // 'types2' + detail level: table sizes differ per detail, and the prefix
@@ -2689,6 +2701,10 @@ var MODEL = __MODEL_JSON__;
2689
2701
  lineStyle: state.lineStyle,
2690
2702
  panelOpen: state.panelOpen,
2691
2703
  panelWidth: state.panelWidth,
2704
+ internals: state.internals,
2705
+ externals: state.externals,
2706
+ dataCoupling: state.dataCoupling,
2707
+ showIssues: state.showIssues,
2692
2708
  }));
2693
2709
  } catch (e) { /* non-fatal */ }
2694
2710
  }
@@ -4095,6 +4111,78 @@ var MODEL = __MODEL_JSON__;
4095
4111
  state.typesRenderAll = false; // a fresh scope re-evaluates the LOD budget
4096
4112
  rebuild(true);
4097
4113
  renderPanel();
4114
+ notifyViewChange();
4115
+ }
4116
+
4117
+ // ---- Stage J: URL <-> view routing ----------------------------------------
4118
+ // The canvas navigation lives in the URL path (refresh-safe + shareable). A
4119
+ // route is the string AFTER /canvas/<project>: '' = system root; a '/'-joined
4120
+ // NAMESPACE (e.g. 'a/b') that resolves against the model to a subsystem or a
4121
+ // component; or the 'types'/'databases' view modes with an optional scope.
4122
+ // A segment is the '::' namespace with '/' as separator, each part encoded.
4123
+ function encSeg(s) { return encodeURIComponent(String(s)); }
4124
+ function routeOf(view) {
4125
+ if (!view) return '';
4126
+ var k = view.kind;
4127
+ if (k === 'system') return '';
4128
+ if (k === 'types' || k === 'databases') {
4129
+ return view.id ? k + '/' + view.id.split('::').map(encSeg).join('/') : k;
4130
+ }
4131
+ if (k === 'subsystem') {
4132
+ return view.id ? view.id.split('::').map(encSeg).join('/') : '';
4133
+ }
4134
+ if (k === 'component') {
4135
+ // A component's full namespace path IS its id: a chained subproject carries
4136
+ // the subsystem prefix in the id (a::b::comp), a flat project uses the bare
4137
+ // id (comp). Serializing comp.id split on '::' round-trips exactly via the
4138
+ // compById lookup in resolveRoute. Owner-pattern nesting is deliberately NOT
4139
+ // encoded (ownership is a separate axis; comp.id does not embed the owner).
4140
+ var c = compById[view.id];
4141
+ var full = c ? c.id : view.id;
4142
+ return full.split('::').map(encSeg).join('/');
4143
+ }
4144
+ return '';
4145
+ }
4146
+ function resolveRoute(routeStr) {
4147
+ var parts = String(routeStr || '').split('/').filter(function (s) { return s.length > 0; }).map(decodeURIComponent);
4148
+ if (!parts.length) return { kind: 'system', id: null };
4149
+ // NOTE: a subsystem literally named 'types'/'databases' is SHADOWED by these
4150
+ // view-mode routes (acceptable \u2014 the modes own those first segments).
4151
+ if (parts[0] === 'types') {
4152
+ return { kind: 'types', id: parts.length > 1 ? parts.slice(1).join('::') : null };
4153
+ }
4154
+ if (parts[0] === 'databases') {
4155
+ if (!showDatabaseTab) return { kind: 'system', id: null };
4156
+ return { kind: 'databases', id: parts.length > 1 ? parts.slice(1).join('::') : null };
4157
+ }
4158
+ var joined = parts.join('::');
4159
+ if (subById[joined]) return { kind: 'subsystem', id: joined };
4160
+ if (compById[joined]) return { kind: 'component', id: joined };
4161
+ return { kind: 'system', id: null }; // unknown id -> fall back to the root
4162
+ }
4163
+ // Apply a route (URL -> engine) WITHOUT echoing back through onViewChange.
4164
+ function openRoute(routeStr) {
4165
+ var v = resolveRoute(routeStr);
4166
+ if (state.view.kind === v.kind && state.view.id === v.id) return;
4167
+ applyingRoute = true;
4168
+ try {
4169
+ state.view = { kind: v.kind, id: v.id };
4170
+ state.selected = null;
4171
+ state.selectedKind = null;
4172
+ state.typesRenderAll = false;
4173
+ rebuild(true);
4174
+ renderPanel();
4175
+ } finally {
4176
+ applyingRoute = false;
4177
+ }
4178
+ }
4179
+ // Notify the embedder (engine -> URL) of the current view; suppressed while a
4180
+ // route is being applied so the URL is not driven in a loop.
4181
+ function notifyViewChange() {
4182
+ if (applyingRoute) return;
4183
+ if (typeof opts !== 'undefined' && opts && typeof opts.onViewChange === 'function') {
4184
+ try { opts.onViewChange(routeOf(state.view)); } catch (e) { /* ignore */ }
4185
+ }
4098
4186
  }
4099
4187
  // Explain (and offer to override) a performance-degraded ERD.
4100
4188
  function renderTypesNotice() {
@@ -4245,6 +4333,7 @@ var MODEL = __MODEL_JSON__;
4245
4333
  if (t.ghost) {
4246
4334
  state.view = parentViewOf(t.kind, t.id);
4247
4335
  rebuild(true);
4336
+ notifyViewChange();
4248
4337
  select(t.kind, t.id, true);
4249
4338
  return;
4250
4339
  }
@@ -4266,10 +4355,16 @@ var MODEL = __MODEL_JSON__;
4266
4355
  }
4267
4356
 
4268
4357
  document.getElementById('search').addEventListener('input', function (ev) { state.query = ev.target.value.trim(); rebuild(false); });
4269
- document.getElementById('internalsToggle').addEventListener('change', function (ev) { state.internals = ev.target.checked; rebuild(true); });
4270
- document.getElementById('externalsToggle').addEventListener('change', function (ev) { state.externals = ev.target.checked; rebuild(true); });
4271
- document.getElementById('dataCouplingToggle').addEventListener('change', function (ev) { state.dataCoupling = ev.target.checked; renderLegend(); rebuild(true); });
4272
- document.getElementById('issuesToggle').addEventListener('change', function (ev) { state.showIssues = ev.target.checked; rebuild(false); renderPanel(); });
4358
+ // Sync each View toggle's checkbox from the (possibly persisted) state, then
4359
+ // persist on change so the choices survive a refresh (see persist()/saved).
4360
+ document.getElementById('internalsToggle').checked = state.internals;
4361
+ document.getElementById('internalsToggle').addEventListener('change', function (ev) { state.internals = ev.target.checked; persist(); rebuild(true); });
4362
+ document.getElementById('externalsToggle').checked = state.externals;
4363
+ document.getElementById('externalsToggle').addEventListener('change', function (ev) { state.externals = ev.target.checked; persist(); rebuild(true); });
4364
+ document.getElementById('dataCouplingToggle').checked = state.dataCoupling;
4365
+ document.getElementById('dataCouplingToggle').addEventListener('change', function (ev) { state.dataCoupling = ev.target.checked; persist(); renderLegend(); rebuild(true); });
4366
+ document.getElementById('issuesToggle').checked = state.showIssues;
4367
+ document.getElementById('issuesToggle').addEventListener('change', function (ev) { state.showIssues = ev.target.checked; persist(); rebuild(false); renderPanel(); });
4273
4368
  document.getElementById('dragToggle').addEventListener('change', function (ev) { cy.autolock(!ev.target.checked); });
4274
4369
  // Mode seg: Components \u21C4 Types. Entering Types keeps the current subsystem
4275
4370
  // scope, so a subsystem's own types (plus shared ones) show scoped.
@@ -5259,10 +5354,12 @@ var MODEL = __MODEL_JSON__;
5259
5354
  if (kind === 'type' && state.view.kind !== 'types' && state.view.kind !== 'databases') {
5260
5355
  state.view = { kind: 'types', id: typesScopeFromView() };
5261
5356
  rebuild(true);
5357
+ notifyViewChange();
5262
5358
  } else if (kind === 'component' && (state.view.kind === 'types' || state.view.kind === 'databases')) {
5263
5359
  var c = compById[id];
5264
5360
  state.view = { kind: 'subsystem', id: c ? c.subsystem : null };
5265
5361
  rebuild(true);
5362
+ notifyViewChange();
5266
5363
  }
5267
5364
  state.selectedKind = kind;
5268
5365
  state.selected = id;
@@ -15230,7 +15327,7 @@ function defaultTargetConfig(type) {
15230
15327
  enabled: true
15231
15328
  };
15232
15329
  }
15233
- var WAIRON_VERSION = "5.0.2-dev.3";
15330
+ var WAIRON_VERSION = "5.0.2-dev.5";
15234
15331
  var GITHUB_REPO = "SYW-Apps/Waffle-AIron";
15235
15332
  var ARCHITECT_AGENT_ID = "agent-architect";
15236
15333
  var ARCHITECT_TEMPLATE_ID = "architect";