@xh/hoist 89.0.0 → 89.1.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 (68) hide show
  1. package/CHANGELOG.md +61 -5
  2. package/appcontainer/MessageModel.ts +11 -10
  3. package/appcontainer/README.md +6 -2
  4. package/build/types/appcontainer/MessageModel.d.ts +4 -1
  5. package/build/types/cmp/input/impl/LiveCommas.d.ts +21 -0
  6. package/build/types/core/XH.d.ts +7 -6
  7. package/build/types/core/model/HoistModel.d.ts +1 -0
  8. package/build/types/core/model/ManagedRefreshContextModel.d.ts +1 -0
  9. package/build/types/data/cube/View.d.ts +0 -2
  10. package/build/types/data/cube/impl/RowCache.d.ts +1 -1
  11. package/build/types/data/cube/row/BaseRow.d.ts +5 -0
  12. package/build/types/desktop/cmp/grid/editors/impl/InlineEditorModel.d.ts +6 -1
  13. package/build/types/desktop/cmp/input/NumberInput.d.ts +5 -2
  14. package/build/types/mobile/cmp/input/NumberInput.d.ts +5 -2
  15. package/build/types/test-support/agGrid.d.ts +2 -0
  16. package/build/types/test-support/hoistCore.d.ts +7 -1
  17. package/build/types/test-support/index.d.ts +1 -0
  18. package/build/types/test-support/jsonBlobs.d.ts +130 -0
  19. package/build/types/test-support/testApp.d.ts +5 -2
  20. package/cmp/grid/Grid.ts +1 -1
  21. package/cmp/grid/GridModel.ts +8 -3
  22. package/cmp/grid/columns/Column.ts +1 -1
  23. package/cmp/input/impl/LiveCommas.ts +59 -0
  24. package/core/XH.ts +7 -6
  25. package/core/model/HoistModel.ts +4 -2
  26. package/core/model/Hooks.ts +1 -0
  27. package/core/model/ManagedRefreshContextModel.ts +5 -1
  28. package/data/README.md +3 -2
  29. package/data/cube/View.ts +3 -9
  30. package/data/cube/impl/RowCache.ts +2 -2
  31. package/data/cube/row/BaseRow.ts +14 -1
  32. package/data/cube/row/ParentRow.ts +1 -1
  33. package/desktop/cmp/dash/canvas/impl/DashCanvasView.ts +49 -52
  34. package/desktop/cmp/grid/editors/BooleanEditor.ts +2 -1
  35. package/desktop/cmp/grid/editors/DateEditor.ts +4 -1
  36. package/desktop/cmp/grid/editors/SelectEditor.ts +4 -1
  37. package/desktop/cmp/grid/editors/impl/InlineEditorModel.ts +17 -5
  38. package/desktop/cmp/input/NumberInput.ts +51 -12
  39. package/desktop/cmp/input/Select.ts +25 -7
  40. package/docs/README.md +2 -0
  41. package/docs/companion-library-docs.md +205 -0
  42. package/docs/doc-registry.json +8 -0
  43. package/docs/lifecycle-app.md +17 -0
  44. package/docs/unit-testing.md +54 -3
  45. package/docs/upgrade-notes/v89-upgrade-notes.md +101 -2
  46. package/docs/version-compatibility.md +2 -1
  47. package/icon/README.md +4 -1
  48. package/mcp/README.md +79 -4
  49. package/mcp/cli/docs.ts +75 -30
  50. package/mcp/data/doc-id-resolver.ts +50 -9
  51. package/mcp/data/doc-registry.ts +462 -44
  52. package/mcp/data/doc-search.ts +25 -6
  53. package/mcp/formatters/docs.ts +136 -36
  54. package/mcp/instructions.ts +69 -0
  55. package/mcp/resources/docs.ts +10 -8
  56. package/mcp/server.ts +7 -13
  57. package/mcp/tools/docs.ts +64 -18
  58. package/mcp/util/paths.ts +85 -2
  59. package/mobile/cmp/input/NumberInput.ts +42 -4
  60. package/package.json +19 -19
  61. package/public/msal-redirect-bridge.min.js +1 -1
  62. package/svc/JsonBlobService.ts +7 -4
  63. package/test-support/agGrid.ts +12 -2
  64. package/test-support/hoistCore.ts +32 -5
  65. package/test-support/index.ts +1 -0
  66. package/test-support/jsonBlobs.ts +543 -0
  67. package/test-support/setup.ts +16 -6
  68. package/test-support/testApp.ts +36 -7
package/mcp/util/paths.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Path utilities for the Hoist MCP server.
3
3
  *
4
- * Provides repo root resolution (via `import.meta.url`) and safe path
5
- * construction that prevents directory traversal outside the repository.
4
+ * Provides repo root resolution (via `import.meta.url`), app root and installed package lookup
5
+ * for companion library discovery, and safe path construction that prevents directory traversal
6
+ * outside a package root.
6
7
  */
7
8
  import {existsSync, readFileSync} from 'node:fs';
8
9
  import {resolve, dirname, sep} from 'node:path';
@@ -76,6 +77,88 @@ export function resolveHoistVersion(): string {
76
77
  return cachedHoistVersion;
77
78
  }
78
79
 
80
+ //------------------------------------------------------------------
81
+ // Consuming package (app root) and its dependencies
82
+ //------------------------------------------------------------------
83
+
84
+ /** The subset of a package.json the tools read. */
85
+ export interface PackageJson {
86
+ name?: string;
87
+ version?: string;
88
+ description?: string;
89
+ dependencies?: Record<string, string>;
90
+ devDependencies?: Record<string, string>;
91
+ peerDependencies?: Record<string, string>;
92
+ hoist?: {docRegistry?: string};
93
+ }
94
+
95
+ /** Read `<dir>/package.json`, or return null if it is missing or unreadable. */
96
+ export function readPackageJson(dir: string): PackageJson | null {
97
+ const path = resolve(dir, 'package.json');
98
+ if (!existsSync(path)) return null;
99
+ try {
100
+ return JSON.parse(readFileSync(path, 'utf8'));
101
+ } catch {
102
+ return null;
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Resolve the root of the package that consumes `@xh/hoist` - the anchor for companion library
108
+ * discovery. The server cannot find companion libraries from its own location, because under
109
+ * pnpm `@xh/hoist` lives in the `.pnpm` store and does not depend on them.
110
+ *
111
+ * Checks, in order:
112
+ * 1. The `HOIST_MCP_APP_ROOT` env var, if set. Used as given.
113
+ * 2. `cwd` and `cwd/client-app` (the standard Hoist app layout), then the same pair in each
114
+ * parent folder. The first package.json that is `@xh/hoist` or depends on it wins, so a run
115
+ * from deep inside an app (e.g. `client-app/src`) still finds it.
116
+ * 3. Else the first package.json in `cwd` or `cwd/client-app`.
117
+ *
118
+ * Returns null when no package.json is found. Params exist for specs - callers pass none.
119
+ */
120
+ export function resolveAppRoot(
121
+ cwd: string = process.cwd(),
122
+ env: Record<string, string | undefined> = process.env
123
+ ): string | null {
124
+ if (env.HOIST_MCP_APP_ROOT) return resolve(cwd, env.HOIST_MCP_APP_ROOT);
125
+
126
+ const start = resolve(cwd);
127
+ let fallback: string | null = null;
128
+ for (let dir = start; ; dir = dirname(dir)) {
129
+ for (const candidate of [dir, resolve(dir, 'client-app')]) {
130
+ const pkg = readPackageJson(candidate);
131
+ if (!pkg) continue;
132
+ if (usesHoist(pkg)) return candidate;
133
+ if (dir === start) fallback ??= candidate;
134
+ }
135
+ if (dirname(dir) === dir) return fallback;
136
+ }
137
+ }
138
+
139
+ /** True if `pkg` is `@xh/hoist` or depends on it. */
140
+ function usesHoist(pkg: PackageJson): boolean {
141
+ const deps = {...pkg.dependencies, ...pkg.devDependencies, ...pkg.peerDependencies};
142
+ return pkg.name === '@xh/hoist' || '@xh/hoist' in deps;
143
+ }
144
+
145
+ /**
146
+ * Find an installed package by walking up from `fromDir` through each `node_modules/<name>`,
147
+ * as Node does. Returns its `node_modules` path, which under pnpm is a link into the store, or
148
+ * null if not installed. Reads the folder directly rather than `require.resolve()`, which fails
149
+ * for packages whose `exports` map hides `package.json`.
150
+ */
151
+ export function findInstalledPackage(fromDir: string, name: string): string | null {
152
+ let dir = resolve(fromDir);
153
+ while (true) {
154
+ const candidate = resolve(dir, 'node_modules', name);
155
+ if (existsSync(resolve(candidate, 'package.json'))) return candidate;
156
+ const parent = dirname(dir);
157
+ if (parent === dir) return null;
158
+ dir = parent;
159
+ }
160
+ }
161
+
79
162
  /**
80
163
  * Resolve a relative path within the repo root, with traversal protection.
81
164
  *
@@ -11,15 +11,22 @@ import {
11
11
  PasswordManagerSupportProps,
12
12
  useHoistInputModel
13
13
  } from '@xh/hoist/cmp/input';
14
+ import {
15
+ addCommasWhileEditing,
16
+ getCaretSkippingCommas,
17
+ setCaretSkippingCommas,
18
+ skipCommaOnDelete
19
+ } from '@xh/hoist/cmp/input/impl/LiveCommas';
14
20
  import {hoistCmp, HoistProps, LayoutProps, StyleProps} from '@xh/hoist/core';
15
21
  import {fmtNumber, NumericPrecision, Precision, ZeroPad} from '@xh/hoist/format';
16
22
  import {input} from '@xh/hoist/kit/onsen';
17
23
  import '@xh/hoist/mobile/register';
18
24
  import {wait} from '@xh/hoist/promise';
19
25
  import {TEST_ID, throwIf, withDefault} from '@xh/hoist/utils/js';
20
- import {getLayoutProps} from '@xh/hoist/utils/react';
26
+ import {getLayoutProps, useOnMount} from '@xh/hoist/utils/react';
21
27
  import type {Property} from 'csstype';
22
28
  import {debounce, isNaN, isNil, isNumber, round} from 'lodash';
29
+ import {useEffect} from 'react';
23
30
  import './NumberInput.scss';
24
31
 
25
32
  export interface NumberInputProps
@@ -29,8 +36,11 @@ export interface NumberInputProps
29
36
  /** True to commit on every change/keystroke, default false. */
30
37
  commitOnChange?: boolean;
31
38
 
32
- /** True to insert commas in displayed value. */
33
- displayWithCommas?: boolean;
39
+ /**
40
+ * Insert commas in displayed value - 'whenBlurred' (or true) to show them only when the input
41
+ * does not have focus, 'always' to also show them while the user types.
42
+ */
43
+ displayWithCommas?: boolean | 'always' | 'whenBlurred';
34
44
 
35
45
  /** True to convert entries suffixed with k/m/b to thousands/millions/billions. */
36
46
  enableShorthandUnits?: boolean;
@@ -120,6 +130,13 @@ class NumberInputModel extends HoistInputModel {
120
130
  return withDefault(this.componentProps.enableShorthandUnits, false);
121
131
  }
122
132
 
133
+ get commasWhileEditing(): boolean {
134
+ return this.componentProps.displayWithCommas === 'always';
135
+ }
136
+
137
+ // Caret position to restore after a reformat while editing, as a count of non-comma chars.
138
+ caretPos: number = null;
139
+
123
140
  override select() {
124
141
  // first focus, and then wait one tick for value to be put into input element
125
142
  this.focus();
@@ -127,6 +144,8 @@ class NumberInputModel extends HoistInputModel {
127
144
  }
128
145
 
129
146
  onValueChange = ev => {
147
+ if (this.commasWhileEditing)
148
+ this.caretPos = getCaretSkippingCommas(this.inputEl as HTMLInputElement);
130
149
  this.noteValueChange(ev.target.value);
131
150
  };
132
151
 
@@ -179,6 +198,10 @@ class NumberInputModel extends HoistInputModel {
179
198
  this.componentProps.onKeyDown?.(ev);
180
199
  };
181
200
 
201
+ onBeforeInput = (ev: InputEvent) => {
202
+ if (this.commasWhileEditing) skipCommaOnDelete(ev);
203
+ };
204
+
182
205
  override onFocus = ev => {
183
206
  this.noteFocused();
184
207
 
@@ -196,7 +219,9 @@ class NumberInputModel extends HoistInputModel {
196
219
 
197
220
  if (this.hasFocus) {
198
221
  if (isNumber(value) && !isNil(precision)) value = round(value, precision);
199
- return value.toString();
222
+ return this.commasWhileEditing
223
+ ? addCommasWhileEditing(value.toString())
224
+ : value.toString();
200
225
  }
201
226
 
202
227
  const {valueLabel, displayWithCommas} = componentProps,
@@ -245,6 +270,19 @@ const cmp = hoistCmp.factory<NumberInputModel>(
245
270
  renderValue = model.formatRenderValue(model.renderValue),
246
271
  inputMode = enableShorthandUnits ? 'text' : 'decimal';
247
272
 
273
+ // Restore the caret after a reformat while editing moved it. Runs after Onsen's own
274
+ // effect writes the value into the input.
275
+ useEffect(() => {
276
+ const input = model.inputEl as HTMLInputElement;
277
+ if (input && model.caretPos != null) {
278
+ setCaretSkippingCommas(input, model.caretPos);
279
+ model.caretPos = null;
280
+ }
281
+ });
282
+
283
+ // Native listener, as React's onBeforeInput does not fire for deletes.
284
+ useOnMount(() => model.inputEl?.addEventListener('beforeinput', model.onBeforeInput));
285
+
248
286
  // Using type=text rather than type=number, to support shorthand units and rich
249
287
  // rendering but also because of issues with typing in decimal point (see #3450)
250
288
  // Rely on inputMode, and Hoist's parsing to enforce numbers only.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "89.0.0",
3
+ "version": "89.1.0",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,17 +39,17 @@
39
39
  ]
40
40
  },
41
41
  "dependencies": {
42
- "@auth0/auth0-spa-js": "~2.28.2",
42
+ "@auth0/auth0-spa-js": "~2.28.3",
43
43
  "@azure/msal-browser": "~5.25.0",
44
44
  "@azure/msal-common": "~16.14.2",
45
45
  "@blueprintjs/core": "^6.21.0",
46
46
  "@blueprintjs/datetime": "^6.3.0",
47
47
  "@codemirror/commands": "^6.11.1",
48
- "@codemirror/language": "^6.12.4",
48
+ "@codemirror/language": "^6.13.1",
49
49
  "@codemirror/language-data": "^6.5.2",
50
50
  "@codemirror/lint": "^6.9.7",
51
51
  "@codemirror/state": "^6.7.6",
52
- "@codemirror/view": "^6.43.13",
52
+ "@codemirror/view": "^6.43.14",
53
53
  "@daypicker/react": "^10.0.2",
54
54
  "@floating-ui/react": "^0.27.20",
55
55
  "@fortawesome/fontawesome-svg-core": "^7.3.1",
@@ -59,15 +59,15 @@
59
59
  "@fortawesome/pro-thin-svg-icons": "^7.3.1",
60
60
  "@fortawesome/react-fontawesome": "^3.5.0",
61
61
  "@hello-pangea/dnd": "~18.0.1",
62
- "@modelcontextprotocol/sdk": "^1.32.0",
62
+ "@modelcontextprotocol/sdk": "^1.32.1",
63
63
  "@uiw/codemirror-theme-github": "~4.25.12",
64
64
  "classnames": "^2.5.1",
65
65
  "commander": "^15.0.0",
66
66
  "core-js": "^3.50.0",
67
67
  "date-fns": "^4.4.0",
68
- "dompurify": "^3.4.16",
68
+ "dompurify": "^3.4.17",
69
69
  "fast-deep-equal": "^3.1.3",
70
- "filesize": "~11.0.25",
70
+ "filesize": "~11.0.26",
71
71
  "http-status-codes": "^2.3.0",
72
72
  "inter-ui": "~4.1.1",
73
73
  "jwt-decode": "^4.0.0",
@@ -80,12 +80,12 @@
80
80
  "numbro": "~2.5.0",
81
81
  "onsenui": "~2.12.9",
82
82
  "qs": "^6.16.0",
83
- "react-dropzone": "~20.1.2",
83
+ "react-dropzone": "~20.1.3",
84
84
  "react-grid-layout": "~2.3.0",
85
85
  "react-markdown": "~10.1.0",
86
86
  "react-onsenui": "~1.13.3",
87
87
  "react-select": "~5.10.2",
88
- "react-window": "~2.3.3",
88
+ "react-window": "~2.3.4",
89
89
  "react-windowed-select": "~5.2.0",
90
90
  "remark-breaks": "~4.0.0",
91
91
  "remark-gfm": "~4.0.1",
@@ -100,7 +100,7 @@
100
100
  "tsx": "^4.23.15",
101
101
  "ua-parser-js": "^2.0.10",
102
102
  "unified": "~11.0.5",
103
- "zod": "^4.6.5"
103
+ "zod": "^4.6.7"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "@testing-library/dom": "^10.4.2",
@@ -131,11 +131,11 @@
131
131
  "devDependencies": {
132
132
  "@testing-library/dom": "^10.4.2",
133
133
  "@testing-library/react": "^16.3.3",
134
- "@types/lodash": "^4.17.25",
135
- "@types/node": "^26.6.3",
134
+ "@types/lodash": "^4.17.26",
135
+ "@types/node": "^26.6.5",
136
136
  "@types/react": "^19.3.0",
137
137
  "@types/react-dom": "^19.3.0",
138
- "@vitest/ui": "^5.0.3",
138
+ "@vitest/ui": "^5.0.4",
139
139
  "@xh/eslint-config": "^8.1.0",
140
140
  "@xh/hoist-dev-utils": "^16.1.0",
141
141
  "ag-grid-community": "~36.2.0",
@@ -146,19 +146,19 @@
146
146
  "eslint-plugin-tsdoc": "^0.5.4",
147
147
  "globals": "^17.13.0",
148
148
  "husky": "^9.1.7",
149
- "jsdom": "^30.1.1",
149
+ "jsdom": "^30.1.2",
150
150
  "lint-staged": "^17.6.0",
151
- "msw": "^3.0.2",
152
- "postcss": "^8.5.28",
153
- "prettier": "^3.9.9",
151
+ "msw": "^3.0.3",
152
+ "postcss": "^8.5.30",
153
+ "prettier": "^3.9.10",
154
154
  "react": "^19.3.0",
155
155
  "react-dom": "^19.3.0",
156
156
  "stylelint": "^17.16.0",
157
157
  "stylelint-config-recommended-scss": "^17.0.1",
158
158
  "type-fest": "^5.10.0",
159
159
  "typescript": "^7.0.2",
160
- "vite": "^8.3.2",
161
- "vitest": "^5.0.3"
160
+ "vite": "^8.3.4",
161
+ "vitest": "^5.0.4"
162
162
  },
163
163
  "scripts": {
164
164
  "lint": "pnpm lint:all",
@@ -1,2 +1,2 @@
1
- /*! @azure/msal-browser v5.25.0 2026-10-06 */
1
+ /*! @azure/msal-browser v5.25.1 2026-10-13 */
2
2
  "use strict";!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).msalRedirectBridge={})}(this,function(t){const e="common",r="organizations";class n extends Error{constructor(t,e,r,o){const s=r||(t?`See https://aka.ms/msal.js.errors#${t} for details`:"");super(s?`${t}: ${s}`:t),Object.setPrototypeOf(this,n.prototype),this.errorCode=t||"",this.errorMessage=s||"",this.subError=o||"",this.correlationId=e,this.name="AuthError"}}class o extends n{constructor(t,e,r){super(t,e,r),this.name="ClientAuthError",Object.setPrototypeOf(this,o.prototype)}}function s(t,e,r){return new o(t,e,r)}const i="invalid_state";class a extends n{constructor(t,e){super(t,e),this.name="ClientConfigurationError",Object.setPrototypeOf(this,a.prototype)}}function c(t,e){return new a(t,e)}const l="url_parse_error";class u{static isEmptyObj(t){if(t)try{const e=JSON.parse(t);return 0===Object.keys(e).length}catch(t){}return!0}static startsWith(t,e){return 0===t.indexOf(e)}static endsWith(t,e){return t.length>=e.length&&t.lastIndexOf(e)===t.length-e.length}static queryStringToObject(t){const e={},r=t.split("&"),n=t=>decodeURIComponent(t.replace(/\+/g," "));return r.forEach(t=>{if(t.trim()){const[r,o]=t.split(/=(.+)/g,2);r&&o&&(e[n(r)]=n(o))}}),e}static trimArrayEntries(t){return t.map(t=>t.trim())}static removeEmptyStringsFromArray(t){return t.filter(t=>!!t)}static jsonParseHelper(t){try{return JSON.parse(t)}catch(t){return null}}}class h{get urlString(){return this._urlString}constructor(t,e){if(this._urlString=t,this.correlationId=e,!this._urlString)throw c("empty_url_error",e);t.includes("#")||(this._urlString=h.canonicalizeUri(t))}static canonicalizeUri(t){if(t){let e=t.toLowerCase();return u.endsWith(e,"?")?e=e.slice(0,-1):u.endsWith(e,"?/")&&(e=e.slice(0,-2)),u.endsWith(e,"/")||(e+="/"),e}return t}validateAsUri(){let t;try{t=this.getUrlComponents()}catch(t){throw c(l,this.correlationId)}if(!t.HostNameAndPort||!t.PathSegments)throw c(l,this.correlationId);if(!t.Protocol||"https:"!==t.Protocol.toLowerCase())throw c("authority_uri_insecure",this.correlationId)}static appendQueryString(t,e){return e?t.indexOf("?")<0?`${t}?${e}`:`${t}&${e}`:t}static removeHashFromUrl(t){return h.canonicalizeUri(t.split("#")[0])}replaceTenantPath(t){const n=this.getUrlComponents(),o=n.PathSegments;return!t||0===o.length||o[0]!==e&&o[0]!==r||(o[0]=t),h.constructAuthorityUriFromObject(n,this.correlationId)}getUrlComponents(){const t=RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?"),e=this.urlString.match(t);if(!e)throw c(l,this.correlationId);const r={Protocol:e[1],HostNameAndPort:e[4],AbsolutePath:e[5],QueryString:e[7]};let n=r.AbsolutePath.split("/");return n=n.filter(t=>t&&t.length>0),r.PathSegments=n,r.QueryString&&r.QueryString.endsWith("/")&&(r.QueryString=r.QueryString.substring(0,r.QueryString.length-1)),r}static getDomainFromUrl(t,e){const r=RegExp("^([^:/?#]+://)?([^/?#]*)"),n=t.match(r);if(!n)throw c(l,e);return n[2]}static getAbsoluteUrl(t,e,r){if("/"===t[0]){const n=new h(e,r).getUrlComponents();return n.Protocol+"//"+n.HostNameAndPort+t}return t}static constructAuthorityUriFromObject(t,e){return new h(t.Protocol+"//"+t.HostNameAndPort+"/"+t.PathSegments.join("/"),e)}}const d="invalid_base64_string";class p extends n{constructor(t,e,r){super(t,e,`See https://aka.ms/msal.js.errors#${t} for details`,r),Object.setPrototypeOf(this,p.prototype),this.name="BrowserAuthError"}}function g(t,e,r){return new p(t,e,r)}function f(t){return(new TextDecoder).decode(function(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw g(d,"")}const r=atob(e);return Uint8Array.from(r,t=>t.codePointAt(0)||0)}(t))}const m="signout",w="request.origin",y="urlHash",S="interaction.status",b=865,P=961;var _;function $(){const t=window.location.hash,e=window.location.search;let r,n=!1,o=!1,a="";if(t&&t.length>1){const e="#"===t.charAt(0)?t.substring(1):t,o=new URLSearchParams(e);o.has("state")&&(n=!0,a=e,r=o)}if(e&&e.length>1){const t="?"===e.charAt(0)?e.substring(1):e,n=new URLSearchParams(t);n.has("state")&&(o=!0,a=t,r=n)}if(n&&o){a=`${"?"===e.charAt(0)?e.substring(1):e}${"#"===t.charAt(0)?t.substring(1):t}`,r=new URLSearchParams(a)}if(!a||!r)throw g("empty_response","");const c=r.get("state");if(!c)throw g("no_state_in_hash","");const{libraryState:l}=function(t,e,r){if(!t)throw s("no_crypto_object",r);if(!e)throw s(i,r);try{const r=e.split("|"),n=r[0],o=r.length>1?r.slice(1).join("|"):"",s=t(n);return{userRequestState:o||"",libraryState:JSON.parse(s)}}catch(t){throw s(i,r)}}(f,c,""),{id:u,meta:h}=l;if(!u||!h)throw g("unable_to_parse_state","","missing_library_state");return{params:r,payload:a,urlHash:t,urlQuery:e,hasResponseInHash:n,hasResponseInQuery:o,libraryState:{id:u,meta:h}}}!function(t){t.Redirect="redirect",t.Popup="popup",t.Silent="silent",t.None="none"}(_||(_={}));class A{navigateInternal(t,e){return A.defaultNavigateWindow(t,e)}navigateExternal(t,e){return A.defaultNavigateWindow(t,e)}static defaultNavigateWindow(t,e){return e.noHistory?window.location.replace(t):window.location.assign(t),new Promise((t,r)=>{setTimeout(()=>{r(g("timed_out","","failed_to_redirect"))},e.timeout)})}}const I="msal";t.broadcastResponseToMainFrame=async function(t){let e;document.title="Microsoft Authentication";try{e=$()}catch(t){throw r=window,"function"==typeof r.history?.replaceState&&r.history.replaceState(null,"",`${r.location.origin}${r.location.pathname}`),t}var r;const{payload:n,urlHash:o,urlQuery:s,hasResponseInHash:i,hasResponseInQuery:a,libraryState:c}=e,{id:l,meta:u}=c;if(u.interactionType===_.Redirect){const e=t||new A;let r="",o="",s="";const i=`${I}.${S}`;try{const t=window.sessionStorage.getItem(i),e=JSON.parse(t||"");if(o=e.clientId||"",s=e.type,o){const t=`${I}.${o}.${w}`;r=window.sessionStorage.getItem(t)||""}}catch{}const a={apiId:s===m?P:b,noHistory:!0,timeout:3e4};if(o)try{window.sessionStorage.setItem(`${I}.${o}.${y}`,n)}catch{}const c=r||function(){const t=new h(window.location.href,"").getUrlComponents();return`${t.Protocol}//${t.HostNameAndPort}/`}(),l=c.endsWith("?")?c.slice(0,-1):c;return void await e.navigateInternal(l,a)}if("function"==typeof window.history.replaceState){let t=`${window.location.origin}${window.location.pathname}`;!i&&o&&(t+=o),!a&&s&&(t+=s),window.history.replaceState(null,"",t)}const d=new BroadcastChannel(l);d.postMessage({v:1,payload:n}),d.close();try{window.close()}catch{}}});
@@ -129,10 +129,13 @@ export class JsonBlobService extends HoistService {
129
129
 
130
130
  /** Find a blob owned by this user with a specific type and name. If none exists, return null. */
131
131
  async findAsync(type: string, name: string, ctx?: CallContextLike): Promise<JsonBlob> {
132
- return this.runner(ctx).span('find').fetchJson({
133
- url: 'xh/findJsonBlob',
134
- params: {type, name}
135
- });
132
+ // The server matches `owner` exactly, and reads a missing owner as null - a global blob.
133
+ return this.runner(ctx)
134
+ .span('find')
135
+ .fetchJson({
136
+ url: 'xh/findJsonBlob',
137
+ params: {type, name, owner: XH.getUsername()}
138
+ });
136
139
  }
137
140
 
138
141
  /** Archive (soft-delete) an existing JSONBlob, as identified by its unique token. */
@@ -4,7 +4,8 @@
4
4
  *
5
5
  * Copyright © 2026 Extremely Heavy Industries Inc.
6
6
  */
7
- import {installAgGrid} from '@xh/hoist/kit/ag-grid';
7
+ import {agGridVersion, installAgGrid} from '@xh/hoist/kit/ag-grid';
8
+ import {throwIf} from '@xh/hoist/utils/js';
8
9
  import {
9
10
  CellStyleModule,
10
11
  ClientSideRowModelApiModule,
@@ -41,6 +42,8 @@ let installed = false;
41
42
  * ag-Grid renders its header, rows and cells in jsdom, which has no layout. Every row and column
42
43
  * renders regardless of the viewport, so virtualisation cannot be observed here, and measured
43
44
  * sizes read back as zero. Inline styles and CSS variables can be read as set.
45
+ *
46
+ * Throws if the installed ag-Grid is outside the range Hoist supports.
44
47
  */
45
48
  export function installAgGridForTests() {
46
49
  if (installed) return;
@@ -62,6 +65,13 @@ export function installAgGridForTests() {
62
65
  TextFilterModule,
63
66
  TooltipModule
64
67
  ]);
65
- installAgGrid(AgGridReact as any, ClientSideRowModelModule.version);
68
+ const {version} = ClientSideRowModelModule;
69
+ installAgGrid(AgGridReact as any, version);
70
+ // installAgGrid() only logs an unsupported version. Without ag-Grid, every grid renders a
71
+ // placeholder, and a spec could pass without testing one.
72
+ throwIf(
73
+ !agGridVersion,
74
+ `ag-Grid ${version} is not supported by this version of Hoist - see the logged error.`
75
+ );
66
76
  installed = true;
67
77
  }
@@ -8,6 +8,7 @@ import {type PlainObject, XH} from '@xh/hoist/core';
8
8
  import {isArray, isPlainObject, mapValues, pick, pickBy} from 'lodash';
9
9
  import {http, HttpResponse, type HttpHandler, matchRequestUrl} from 'msw';
10
10
  import {setupServer} from 'msw/node';
11
+ import {FakeJsonBlobStore, FakeServerError} from './jsonBlobs';
11
12
 
12
13
  /*
13
14
  * A small, in-memory stand-in for hoist-core, served to Hoist's real client code via MSW.
@@ -19,8 +20,9 @@ import {setupServer} from 'msw/node';
19
20
  * server contract changes.
20
21
  *
21
22
  * The fake models shapes, status codes, and the `clientUsername` session check. It deliberately
22
- * does not re-implement server business rules. Tests serve other endpoints, such as an app's own,
23
- * with `hoistCore.route()`. `server.use()` adds raw MSW handlers for one test.
23
+ * does not re-implement server business rules, apart from which JsonBlobs a user can read - see
24
+ * jsonBlobs.ts. Tests serve other endpoints, such as an app's own, with `hoistCore.route()`.
25
+ * `server.use()` adds raw MSW handlers for one test.
24
26
  *
25
27
  * hoist-core accepts any HTTP method on these endpoints. Each handler here accepts only the method
26
28
  * the client uses, so a test fails if the client changes how it calls the server.
@@ -139,10 +141,16 @@ export class FakeHoistCore {
139
141
  */
140
142
  environment: PlainObject;
141
143
 
144
+ /** JsonBlobs, including ViewManager views and each user's view state. Starts empty. */
145
+ readonly jsonBlobs = new FakeJsonBlobStore(this);
146
+
142
147
  /** Every request the fake has served in this test - the kit's setup clears it before each. */
143
148
  requests: RecordedRequest[] = [];
144
149
 
145
- /** @internal - called with a message when a route throws. The kit's setup fails the test. */
150
+ /**
151
+ * @internal - called with a message for each problem the kit's guards catch, such as a route
152
+ * that throws. The kit's setup fails the running test, or `initTestAppAsync()` the boot.
153
+ */
146
154
  onProblem: (msg: string) => void = null;
147
155
 
148
156
  private routes: Route[] = [];
@@ -169,6 +177,7 @@ export class FakeHoistCore {
169
177
  this.configs = defaultConfigs();
170
178
  this.prefs = defaultPrefs();
171
179
  this.environment = defaultEnvironment();
180
+ this.jsonBlobs.reset();
172
181
  this.clearRequests();
173
182
  }
174
183
 
@@ -359,15 +368,33 @@ export class FakeHoistCore {
359
368
  return HttpResponse.json({preferences: this.prefEntries(keys)});
360
369
  }),
361
370
 
362
- // XhController.clearUserState - resets all of the user's prefs. The server also clears
363
- // the user's ViewManager state, which this fake does not model.
371
+ // XhController.clearUserState - resets all of the user's prefs, and removes their
372
+ // ViewManager state.
364
373
  this.post('xh/clearUserState', req => {
365
374
  const err = this.checkUser(req);
366
375
  if (err) return err;
367
376
  Object.values(this.prefs).forEach(pref => delete pref.value);
377
+ this.jsonBlobs.clearViewState();
368
378
  return noContent();
369
379
  }),
370
380
 
381
+ // XhController's JsonBlob actions and XhViewController - see FakeJsonBlobStore.
382
+ ...this.jsonBlobs.paths.map(path =>
383
+ this.post(path, req => {
384
+ try {
385
+ const ret = this.jsonBlobs.serve(
386
+ path,
387
+ {...req.query, ...req.form},
388
+ req.json
389
+ );
390
+ return ret === undefined ? noContent() : HttpResponse.json(ret);
391
+ } catch (e) {
392
+ if (e instanceof FakeServerError) return hoistError(e.status, e.error);
393
+ throw e;
394
+ }
395
+ })
396
+ ),
397
+
371
398
  // XhController.track, recordMetrics, submitSpans - accepted, nothing returned.
372
399
  ...['xh/track', 'xh/recordMetrics', 'xh/submitSpans'].map(path =>
373
400
  this.post(path, req => this.checkUser(req) ?? noContent())
@@ -10,4 +10,5 @@
10
10
  * See docs/unit-testing.md.
11
11
  */
12
12
  export * from './hoistCore';
13
+ export {type FakeJsonBlob, FakeJsonBlobStore, type JsonBlobSpec, type ViewSpec} from './jsonBlobs';
13
14
  export * from './testApp';