@servicetitan/mfe-shell-toolkit 0.0.1 → 0.1.7

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 (117) hide show
  1. package/dist/auth/header-interceptor.d.ts +32 -0
  2. package/dist/auth/header-interceptor.d.ts.map +1 -0
  3. package/dist/auth/header-interceptor.js +72 -0
  4. package/dist/auth/header-interceptor.js.map +1 -0
  5. package/dist/auth/index.d.ts +8 -0
  6. package/dist/auth/index.d.ts.map +1 -0
  7. package/dist/auth/index.js +5 -0
  8. package/dist/auth/index.js.map +1 -0
  9. package/dist/auth/jwt-provisioner.d.ts +27 -0
  10. package/dist/auth/jwt-provisioner.d.ts.map +1 -0
  11. package/dist/auth/jwt-provisioner.js +128 -0
  12. package/dist/auth/jwt-provisioner.js.map +1 -0
  13. package/dist/auth/jwt.d.ts +8 -0
  14. package/dist/auth/jwt.d.ts.map +1 -0
  15. package/dist/auth/jwt.js +19 -0
  16. package/dist/auth/jwt.js.map +1 -0
  17. package/dist/auth/jwt.test.d.ts +2 -0
  18. package/dist/auth/jwt.test.d.ts.map +1 -0
  19. package/dist/auth/jwt.test.js +28 -0
  20. package/dist/auth/jwt.test.js.map +1 -0
  21. package/dist/auth/token-store.d.ts +12 -0
  22. package/dist/auth/token-store.d.ts.map +1 -0
  23. package/dist/auth/token-store.js +10 -0
  24. package/dist/auth/token-store.js.map +1 -0
  25. package/dist/index.d.ts +7 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +14 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/ld/feature-flags-panel.d.ts +25 -0
  30. package/dist/ld/feature-flags-panel.d.ts.map +1 -0
  31. package/dist/ld/feature-flags-panel.js +27 -0
  32. package/dist/ld/feature-flags-panel.js.map +1 -0
  33. package/dist/ld/index.d.ts +5 -0
  34. package/dist/ld/index.d.ts.map +1 -0
  35. package/dist/ld/index.js +3 -0
  36. package/dist/ld/index.js.map +1 -0
  37. package/dist/ld/ld-service.d.ts +19 -0
  38. package/dist/ld/ld-service.d.ts.map +1 -0
  39. package/dist/ld/ld-service.js +57 -0
  40. package/dist/ld/ld-service.js.map +1 -0
  41. package/dist/mock/api-interceptor.d.ts +29 -0
  42. package/dist/mock/api-interceptor.d.ts.map +1 -0
  43. package/dist/mock/api-interceptor.js +76 -0
  44. package/dist/mock/api-interceptor.js.map +1 -0
  45. package/dist/mock/helpers.d.ts +11 -0
  46. package/dist/mock/helpers.d.ts.map +1 -0
  47. package/dist/mock/helpers.js +34 -0
  48. package/dist/mock/helpers.js.map +1 -0
  49. package/dist/mock/index.d.ts +4 -0
  50. package/dist/mock/index.d.ts.map +1 -0
  51. package/dist/mock/index.js +3 -0
  52. package/dist/mock/index.js.map +1 -0
  53. package/dist/shell-host/host-tokens.d.ts +2 -0
  54. package/dist/shell-host/host-tokens.d.ts.map +1 -0
  55. package/dist/shell-host/host-tokens.js +13 -0
  56. package/dist/shell-host/host-tokens.js.map +1 -0
  57. package/dist/shell-host/index.d.ts +5 -0
  58. package/dist/shell-host/index.d.ts.map +1 -0
  59. package/dist/shell-host/index.js +3 -0
  60. package/dist/shell-host/index.js.map +1 -0
  61. package/dist/shell-host/mfe-load-error-fallback.d.ts +15 -0
  62. package/dist/shell-host/mfe-load-error-fallback.d.ts.map +1 -0
  63. package/dist/shell-host/mfe-load-error-fallback.js +15 -0
  64. package/dist/shell-host/mfe-load-error-fallback.js.map +1 -0
  65. package/dist/shell-host/mfe-loader.d.ts +22 -0
  66. package/dist/shell-host/mfe-loader.d.ts.map +1 -0
  67. package/dist/shell-host/mfe-loader.js +14 -0
  68. package/dist/shell-host/mfe-loader.js.map +1 -0
  69. package/dist/store/index.d.ts +3 -0
  70. package/dist/store/index.d.ts.map +1 -0
  71. package/dist/store/index.js +3 -0
  72. package/dist/store/index.js.map +1 -0
  73. package/dist/store/store.d.ts +22 -0
  74. package/dist/store/store.d.ts.map +1 -0
  75. package/dist/store/store.js +117 -0
  76. package/dist/store/store.js.map +1 -0
  77. package/dist/store/store.test.d.ts +2 -0
  78. package/dist/store/store.test.d.ts.map +1 -0
  79. package/dist/store/store.test.js +106 -0
  80. package/dist/store/store.test.js.map +1 -0
  81. package/dist/store/use-store.d.ts +5 -0
  82. package/dist/store/use-store.d.ts.map +1 -0
  83. package/dist/store/use-store.js +11 -0
  84. package/dist/store/use-store.js.map +1 -0
  85. package/dist/toolbar/combobox-dropdown.d.ts +23 -0
  86. package/dist/toolbar/combobox-dropdown.d.ts.map +1 -0
  87. package/dist/toolbar/combobox-dropdown.js +24 -0
  88. package/dist/toolbar/combobox-dropdown.js.map +1 -0
  89. package/dist/toolbar/index.d.ts +8 -0
  90. package/dist/toolbar/index.d.ts.map +1 -0
  91. package/dist/toolbar/index.js +5 -0
  92. package/dist/toolbar/index.js.map +1 -0
  93. package/dist/toolbar/panel.d.ts +12 -0
  94. package/dist/toolbar/panel.d.ts.map +1 -0
  95. package/dist/toolbar/panel.js +33 -0
  96. package/dist/toolbar/panel.js.map +1 -0
  97. package/dist/toolbar/styles.d.ts +27 -0
  98. package/dist/toolbar/styles.d.ts.map +1 -0
  99. package/dist/toolbar/styles.js +138 -0
  100. package/dist/toolbar/styles.js.map +1 -0
  101. package/dist/toolbar/use-search-combobox.d.ts +57 -0
  102. package/dist/toolbar/use-search-combobox.d.ts.map +1 -0
  103. package/dist/toolbar/use-search-combobox.js +153 -0
  104. package/dist/toolbar/use-search-combobox.js.map +1 -0
  105. package/dist/version-picker/index.d.ts +5 -0
  106. package/dist/version-picker/index.d.ts.map +1 -0
  107. package/dist/version-picker/index.js +3 -0
  108. package/dist/version-picker/index.js.map +1 -0
  109. package/dist/version-picker/mfe-source-list.d.ts +18 -0
  110. package/dist/version-picker/mfe-source-list.d.ts.map +1 -0
  111. package/dist/version-picker/mfe-source-list.js +92 -0
  112. package/dist/version-picker/mfe-source-list.js.map +1 -0
  113. package/dist/version-picker/verdaccio-client.d.ts +33 -0
  114. package/dist/version-picker/verdaccio-client.d.ts.map +1 -0
  115. package/dist/version-picker/verdaccio-client.js +56 -0
  116. package/dist/version-picker/verdaccio-client.js.map +1 -0
  117. package/package.json +71 -2
@@ -0,0 +1,57 @@
1
+ import { getLDClient } from '@servicetitan/launchdarkly-service';
2
+ function parseOverrideValue(raw) {
3
+ try {
4
+ return JSON.parse(raw);
5
+ }
6
+ catch (_a) {
7
+ return raw;
8
+ }
9
+ }
10
+ /**
11
+ * Wraps a real `LDClient` so `variation`/`variationDetail`/`allFlags` return override values for
12
+ * explicitly-overridden keys and fall through to the real client for everything else. `on`/`off`
13
+ * and every other method pass straight through. Overrides are captured once at construction time
14
+ * (matching a "click Reload to apply" toolbar convention) rather than live-updated.
15
+ */
16
+ function createOverrideClient(real, overrides) {
17
+ return new Proxy(real, {
18
+ get(target, prop, receiver) {
19
+ if (prop === 'variation') {
20
+ return (key, defaultValue) => key in overrides ? overrides[key] : target.variation(key, defaultValue);
21
+ }
22
+ if (prop === 'variationDetail') {
23
+ return (key, defaultValue) => key in overrides
24
+ ? { value: overrides[key], variationIndex: undefined, reason: { kind: 'FALLTHROUGH' } }
25
+ : target.variationDetail(key, defaultValue);
26
+ }
27
+ if (prop === 'allFlags') {
28
+ return () => ({ ...target.allFlags(), ...overrides });
29
+ }
30
+ const value = Reflect.get(target, prop, receiver);
31
+ return typeof value === 'function' ? value.bind(target) : value;
32
+ },
33
+ });
34
+ }
35
+ /**
36
+ * Hands an MFE an `LDClient` scoped by whatever the shell currently has selected (typically the
37
+ * current tenant), ignoring whatever context the MFE itself would otherwise pass — the shell owns
38
+ * this context so the MFE can stay generic about where its LD context comes from. `getState` is
39
+ * read fresh on every `getClient()` call, which fires exactly once per Loader mount, so a "Reload
40
+ * MFE" action already picks up the current selection without any extra plumbing.
41
+ */
42
+ export function createShellLDService(clientSideId, getState) {
43
+ return {
44
+ getClient: () => {
45
+ var _a;
46
+ const state = getState();
47
+ const context = { kind: (_a = state.contextKind) !== null && _a !== void 0 ? _a : 'tenant', key: state.contextKey };
48
+ const real = getLDClient({ clientSideID: clientSideId, context });
49
+ if (!state.overridesEnabled) {
50
+ return real;
51
+ }
52
+ const overrides = Object.fromEntries(Object.entries(state.overrides).map(([key, rawValue]) => [key, parseOverrideValue(rawValue)]));
53
+ return createOverrideClient(real, overrides);
54
+ },
55
+ };
56
+ }
57
+ //# sourceMappingURL=ld-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ld-service.js","sourceRoot":"","sources":["../../src/ld/ld-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,oCAAoC,CAAC;AAa5E,SAAS,kBAAkB,CAAC,GAAW;IACnC,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAAC,WAAM,CAAC;QACL,OAAO,GAAG,CAAC;IACf,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,IAAc,EAAE,SAAkC;IAC5E,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;QACnB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;YACtB,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;gBACvB,OAAO,CAAC,GAAW,EAAE,YAAsB,EAAE,EAAE,CAC3C,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAChF,CAAC;YACD,IAAI,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBAC7B,OAAO,CAAC,GAAW,EAAE,YAAsB,EAAE,EAAE,CAC3C,GAAG,IAAI,SAAS;oBACZ,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE;oBACvF,CAAC,CAAC,MAAM,CAAC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D,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,29 @@
1
+ export interface MockRequest {
2
+ /** The full resolved request URL. Consumers typically slice `url.pathname` after their own prefix to get a route. */
3
+ url: URL;
4
+ method: string;
5
+ /** Request body as text (already read for you — see the caveats on {@link readRequestBody}). `null` for bodyless requests. */
6
+ body: string | null;
7
+ }
8
+ export interface ApiInterceptorConfig {
9
+ /** Whether this request belongs to this interceptor at all (origin + path-prefix match). Everything else passes through untouched. */
10
+ isMatch(url: URL): boolean;
11
+ /** Checked per-request, so toggling mock mode in a toolbar panel takes effect on the very next call. */
12
+ useMockData(): boolean;
13
+ /** Rewrites a matched, non-mocked request's URL to the real upstream. Return `null` to pass the original request through untouched (e.g. no upstream configured yet). */
14
+ rewriteToReal(url: URL): string | null;
15
+ /** Dispatches a matched, mocked request to whatever route table the consumer maintains. */
16
+ handleMock(request: MockRequest): Promise<Response>;
17
+ }
18
+ /**
19
+ * Monkey-patches `window.fetch` so a shell can transparently serve mock data or redirect to a real
20
+ * upstream for requests matching `config.isMatch` — the MFE itself has zero awareness that this is
21
+ * happening; it always calls the same relative BFF-prefixed URL.
22
+ *
23
+ * If this shell also installs an auth interceptor (attaching bearer tokens / static headers to
24
+ * requests against the *rewritten* upstream origin), install this one AFTER it — the fetch-wrapper
25
+ * chain runs last-registered-outermost, so installing this one last means it rewrites the URL
26
+ * before the auth interceptor's own origin match ever sees it.
27
+ */
28
+ export declare function installApiInterceptor(config: ApiInterceptorConfig): void;
29
+ //# sourceMappingURL=api-interceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-interceptor.d.ts","sourceRoot":"","sources":["../../src/mock/api-interceptor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IACxB,qHAAqH;IACrH,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,8HAA8H;IAC9H,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACjC,sIAAsI;IACtI,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC;IAC3B,wGAAwG;IACxG,WAAW,IAAI,OAAO,CAAC;IACvB,yKAAyK;IACzK,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC;IACvC,2FAA2F;IAC3F,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAsBxE"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Monkey-patches `window.fetch` so a shell can transparently serve mock data or redirect to a real
3
+ * upstream for requests matching `config.isMatch` — the MFE itself has zero awareness that this is
4
+ * happening; it always calls the same relative BFF-prefixed URL.
5
+ *
6
+ * If this shell also installs an auth interceptor (attaching bearer tokens / static headers to
7
+ * requests against the *rewritten* upstream origin), install this one AFTER it — the fetch-wrapper
8
+ * chain runs last-registered-outermost, so installing this one last means it rewrites the URL
9
+ * before the auth interceptor's own origin match ever sees it.
10
+ */
11
+ export function installApiInterceptor(config) {
12
+ const innerFetch = window.fetch.bind(window);
13
+ window.fetch = async (input, init) => {
14
+ const requestUrl = resolveRequestUrl(input);
15
+ if (!requestUrl || !config.isMatch(requestUrl)) {
16
+ return innerFetch(input, init);
17
+ }
18
+ if (config.useMockData()) {
19
+ return config.handleMock({
20
+ url: requestUrl,
21
+ method: methodOf(input, init),
22
+ body: await readRequestBody(input, init),
23
+ });
24
+ }
25
+ const rewritten = config.rewriteToReal(requestUrl);
26
+ if (!rewritten) {
27
+ return innerFetch(input, init);
28
+ }
29
+ return innerFetch(rewriteInput(input, rewritten), init);
30
+ };
31
+ }
32
+ function resolveRequestUrl(input) {
33
+ try {
34
+ if (typeof input === 'string') {
35
+ return new URL(input, window.location.href);
36
+ }
37
+ if (input instanceof URL) {
38
+ return new URL(input.href);
39
+ }
40
+ return new URL(input.url, window.location.href);
41
+ }
42
+ catch (_a) {
43
+ return null;
44
+ }
45
+ }
46
+ function methodOf(input, init) {
47
+ var _a;
48
+ return ((_a = init === null || init === void 0 ? void 0 : init.method) !== null && _a !== void 0 ? _a : (input instanceof Request ? input.method : 'GET')).toUpperCase();
49
+ }
50
+ /**
51
+ * The request body as text, for route dispatch. Axios's fetch adapter passes a serialised string
52
+ * in `init.body`; a bare `Request` input carries a readable stream we clone so the real send (on
53
+ * the non-mocked path) is unaffected.
54
+ */
55
+ async function readRequestBody(input, init) {
56
+ if (typeof (init === null || init === void 0 ? void 0 : init.body) === 'string') {
57
+ return init.body;
58
+ }
59
+ if (input instanceof Request) {
60
+ try {
61
+ return await input.clone().text();
62
+ }
63
+ catch (_a) {
64
+ return null;
65
+ }
66
+ }
67
+ return null;
68
+ }
69
+ function rewriteInput(input, newUrl) {
70
+ if (input instanceof Request) {
71
+ // Cloning a Request with a fresh URL preserves method, headers, body, credentials, etc.
72
+ return new Request(newUrl, input);
73
+ }
74
+ return newUrl;
75
+ }
76
+ //# sourceMappingURL=api-interceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-interceptor.js","sourceRoot":"","sources":["../../src/mock/api-interceptor.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA4B;IAC9D,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,CAAC,KAAK,GAAG,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACjC,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7C,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC;QAED,IAAI,MAA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WAAW,EAAE,CAAC;AAC7F,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,eAAe,CAAC,KAAwB,EAAE,IAAkB;IACvE,IAAI,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAA,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC;YACD,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;QACtC,CAAC;QAAC,WAAM,CAAC;YACL,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,KAAwB,EAAE,MAAc;IAC1D,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;QAC3B,wFAAwF;QACxF,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare function jsonResponse(payload: unknown, status?: number): Response;
2
+ export declare function errorResponse(message: string, status?: number): Response;
3
+ /** Delays resolution of `value` by `latencyMs` — wire a mock-data panel's latency slider straight into this. */
4
+ export declare function withLatency<T>(value: T | Promise<T>, latencyMs: number): Promise<T>;
5
+ /**
6
+ * A small seeded PRNG (mulberry32) for deterministic-but-varied mock fixtures — the same seed
7
+ * always produces the same sequence, so a given fixture (e.g. "report #42's attachments") looks
8
+ * identical across calls instead of reshuffling on every fetch.
9
+ */
10
+ export declare function mulberry32(seed: number): () => number;
11
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/mock/helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAM,GAAG,QAAQ,CAKrE;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAM,GAAG,QAAQ,CAErE;AAED,gHAAgH;AAChH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAOnF;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,MAAM,CASrD"}
@@ -0,0 +1,34 @@
1
+ export function jsonResponse(payload, status = 200) {
2
+ return new Response(JSON.stringify(payload), {
3
+ status,
4
+ headers: { 'Content-Type': 'application/json' },
5
+ });
6
+ }
7
+ export function errorResponse(message, status = 500) {
8
+ return jsonResponse({ error: message }, status);
9
+ }
10
+ /** Delays resolution of `value` by `latencyMs` — wire a mock-data panel's latency slider straight into this. */
11
+ export function withLatency(value, latencyMs) {
12
+ if (latencyMs <= 0) {
13
+ return Promise.resolve(value);
14
+ }
15
+ return new Promise(resolve => {
16
+ setTimeout(() => resolve(value), latencyMs);
17
+ });
18
+ }
19
+ /**
20
+ * A small seeded PRNG (mulberry32) for deterministic-but-varied mock fixtures — the same seed
21
+ * always produces the same sequence, so a given fixture (e.g. "report #42's attachments") looks
22
+ * identical across calls instead of reshuffling on every fetch.
23
+ */
24
+ export function mulberry32(seed) {
25
+ let state = seed;
26
+ return () => {
27
+ state |= 0;
28
+ state = (state + 0x6d2b79f5) | 0;
29
+ let t = Math.imul(state ^ (state >>> 15), 1 | state);
30
+ t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
31
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
32
+ };
33
+ }
34
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/mock/helpers.ts"],"names":[],"mappings":"AAAA,MAAM,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AC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CAAC;IACjD,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { installApiInterceptor } from './api-interceptor';
2
+ export type { ApiInterceptorConfig, MockRequest } from './api-interceptor';
3
+ export { jsonResponse, errorResponse, withLatency, mulberry32 } from './helpers';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mock/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { installApiInterceptor } from './api-interceptor';
2
+ export { jsonResponse, errorResponse, withLatency, mulberry32 } from './helpers';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mock/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ import '@servicetitan/tokens/dist/tokens.css';
2
+ //# sourceMappingURL=host-tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-tokens.d.ts","sourceRoot":"","sources":["../../src/shell-host/host-tokens.ts"],"names":[],"mappings":"AAWA,OAAO,sCAAsC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /*
2
+ * The shell is the MFE's host, so it must set up the host environment the MFE expects — just like
3
+ * the real host page does. The org design tokens (--spacing-*, --typescale-*, --border-radius-*, …)
4
+ * live on :root; the MFE renders inside a Shadow DOM and inherits them across the boundary as custom
5
+ * properties. The MFE's own copy of tokens.css is bundled into its shadow root, where its `:root`
6
+ * selector matches nothing — so without loading them here on the real document root, every token
7
+ * the MFE references is undefined and its layout collapses.
8
+ *
9
+ * Import this module once, for its side effect only, before the shell renders:
10
+ * import '@servicetitan/mfe-shell-toolkit/dist/shell-host/host-tokens';
11
+ */
12
+ import '@servicetitan/tokens/dist/tokens.css';
13
+ //# sourceMappingURL=host-tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-tokens.js","sourceRoot":"","sources":["../../src/shell-host/host-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,sCAAsC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { MfeLoader } from './mfe-loader';
2
+ export type { MfeLoaderProps } from './mfe-loader';
3
+ export { MfeLoadErrorFallback } from './mfe-load-error-fallback';
4
+ export type { MfeLoadErrorFallbackProps } from './mfe-load-error-fallback';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shell-host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { MfeLoader } from './mfe-loader';
2
+ export { MfeLoadErrorFallback } from './mfe-load-error-fallback';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shell-host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { FC } from 'react';
2
+ export interface MfeLoadErrorFallbackProps {
3
+ /** Reset just the MFE source back to its configured default (no reload needed — the caller's remount key should include it). */
4
+ onResetSource: () => void;
5
+ /** Last-resort recovery: wipe all shell-local overrides and hard-reload. */
6
+ onClearAndReload: () => void;
7
+ }
8
+ /**
9
+ * `<Loader>`'s errorFallback. The library's own default is a bare "Something went wrong" — a dead
10
+ * end unless you already know to open DevTools and clear storage. The most likely real cause here
11
+ * isn't a broken bundle: it's the MFE source (or another persisted toolbar override) stuck on a
12
+ * stale value from a past session, silently persisted in `localStorage` indefinitely.
13
+ */
14
+ export declare const MfeLoadErrorFallback: FC<MfeLoadErrorFallbackProps>;
15
+ //# sourceMappingURL=mfe-load-error-fallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-load-error-fallback.d.ts","sourceRoot":"","sources":["../../src/shell-host/mfe-load-error-fallback.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAG3B,MAAM,WAAW,yBAAyB;IACtC,gIAAgI;IAChI,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,4EAA4E;IAC5E,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAChC;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CAgB9D,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { buttonStyle, dangerButtonStyle, helpTextStyle } from '../toolbar/styles';
3
+ /**
4
+ * `<Loader>`'s errorFallback. The library's own default is a bare "Something went wrong" — a dead
5
+ * end unless you already know to open DevTools and clear storage. The most likely real cause here
6
+ * isn't a broken bundle: it's the MFE source (or another persisted toolbar override) stuck on a
7
+ * stale value from a past session, silently persisted in `localStorage` indefinitely.
8
+ */
9
+ export const MfeLoadErrorFallback = ({ onResetSource, onClearAndReload }) => (_jsxs("div", { style: styles.root, children: [_jsx("h2", { style: styles.heading, children: "Something went wrong loading the MFE" }), _jsxs("p", { style: helpTextStyle, children: ["If the MFE source was pointed at a specific build via the toolbar in a past session, that choice persists in", ' ', _jsx("code", { children: "localStorage" }), " indefinitely and can go stale without any visible warning."] }), _jsxs("div", { style: styles.actions, children: [_jsx("button", { type: "button", onClick: onResetSource, style: buttonStyle, children: "Reset MFE source" }), _jsx("button", { type: "button", onClick: onClearAndReload, style: dangerButtonStyle, children: "Clear all & hard reload" })] })] }));
10
+ const styles = {
11
+ root: { padding: '1rem', color: '#000' },
12
+ heading: { marginTop: 0 },
13
+ actions: { display: 'flex', gap: '0.5rem', marginTop: '0.75rem' },
14
+ };
15
+ //# sourceMappingURL=mfe-load-error-fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-load-error-fallback.js","sourceRoot":"","sources":["../../src/shell-host/mfe-load-error-fallback.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AASlF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAkC,CAAC,EAAE,aAAa,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC,CACxG,eAAK,KAAK,EAAE,MAAM,CAAC,IAAI,aACnB,aAAI,KAAK,EAAE,MAAM,CAAC,OAAO,qDAA2C,EACpE,aAAG,KAAK,EAAE,aAAa,6HAC0F,GAAG,EAChH,0CAAyB,mEACzB,EACJ,eAAK,KAAK,EAAE,MAAM,CAAC,OAAO,aACtB,iBAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,iCAEvD,EACT,iBAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,iBAAiB,wCAEhE,IACP,IACJ,CACT,CAAC;AAEF,MAAM,MAAM,GAAG;IACX,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IACxC,OAAO,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE;IACzB,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE;CAC3D,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { FC, ReactNode } from 'react';
2
+ export interface MfeLoaderProps {
3
+ /** URL the Loader mounts from — a same-origin bundled path, or any published unpkg build. */
4
+ src: string;
5
+ /**
6
+ * Values that should force a fresh mount when any of them change (e.g. the mock-data toggle,
7
+ * a manual reload counter). `src` itself is always included, so callers don't need to repeat it.
8
+ * `Loader` has no imperative reload API — remounting via a changed React `key` is the only way
9
+ * to force it to re-fetch `metadata.json` and re-mount the custom element.
10
+ */
11
+ remountDeps?: readonly (string | number | boolean)[];
12
+ errorFallback?: ReactNode;
13
+ }
14
+ /**
15
+ * Mounts an MFE bundle exactly the way the real production host does: the same
16
+ * `@servicetitan/web-components` `Loader` mounts the bundle as a custom element in a Shadow DOM,
17
+ * not a stand-in iframe or light-DOM import. This is deliberate — Shadow-DOM-only bugs (e.g.
18
+ * document-level listeners seeing retargeted event targets) only reproduce when the real Loader is
19
+ * used, so this component never takes a shortcut around it.
20
+ */
21
+ export declare const MfeLoader: FC<MfeLoaderProps>;
22
+ //# sourceMappingURL=mfe-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-loader.d.ts","sourceRoot":"","sources":["../../src/shell-host/mfe-loader.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,cAAc;IAC3B,6FAA6F;IAC7F,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IACrD,aAAa,CAAC,EAAE,SAAS,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAGxC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Loader } from '@servicetitan/web-components';
3
+ /**
4
+ * Mounts an MFE bundle exactly the way the real production host does: the same
5
+ * `@servicetitan/web-components` `Loader` mounts the bundle as a custom element in a Shadow DOM,
6
+ * not a stand-in iframe or light-DOM import. This is deliberate — Shadow-DOM-only bugs (e.g.
7
+ * document-level listeners seeing retargeted event targets) only reproduce when the real Loader is
8
+ * used, so this component never takes a shortcut around it.
9
+ */
10
+ export const MfeLoader = ({ src, remountDeps = [], errorFallback }) => {
11
+ const remountKey = [src, ...remountDeps].join('|');
12
+ return _jsx(Loader, { src: src, errorFallback: errorFallback }, remountKey);
13
+ };
14
+ //# sourceMappingURL=mfe-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-loader.js","sourceRoot":"","sources":["../../src/shell-host/mfe-loader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAgBtD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAuB,CAAC,EAAE,GAAG,EAAE,WAAW,GAAG,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE;IACtF,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnD,OAAO,KAAC,MAAM,IAAkB,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,aAAa,IAAlD,UAAU,CAA4C,CAAC;AAC/E,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Store } from './store';
2
+ export { useStore, usePatchedStore } from './use-store';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Store } from './store';
2
+ export { useStore, usePatchedStore } from './use-store';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,22 @@
1
+ type Listener = () => void;
2
+ /**
3
+ * A minimal, `useSyncExternalStore`-compatible store, optionally persisted to `localStorage`
4
+ * under `persistKey`. Every consuming shell (mobile-command-center, mobile-sentinel, ...) gets its
5
+ * own `Store` instance per concern (shell UI state, minted-token cache, ...) — this class holds no
6
+ * shell-specific shape.
7
+ */
8
+ export declare class Store<T extends object> {
9
+ private readonly persistKey?;
10
+ private listeners;
11
+ private value;
12
+ constructor(initial: T, persistKey?: string | undefined);
13
+ get: () => T;
14
+ set(next: T): void;
15
+ update(updater: (prev: T) => T): void;
16
+ subscribe: (listener: Listener) => (() => void);
17
+ getSnapshot: () => T;
18
+ private load;
19
+ private save;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AA8B3B;;;;;GAKG;AACH,qBAAa,KAAK,CAAC,CAAC,SAAS,MAAM;IAM3B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IALhC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,KAAK,CAAI;gBAGb,OAAO,EAAE,CAAC,EACO,UAAU,CAAC,EAAE,MAAM,YAAA;IAKxC,GAAG,QAAO,CAAC,CAAe;IAE1B,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IASlB,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI;IAIrC,SAAS,GAAI,UAAU,QAAQ,KAAG,CAAC,MAAM,IAAI,CAAC,CAK5C;IAEF,WAAW,QAAO,CAAC,CAAe;IAElC,OAAO,CAAC,IAAI;IAeZ,OAAO,CAAC,IAAI;CAUf"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Keeps only the parsed keys that already exist on `initial` and whose value's type matches --
3
+ * a persisted blob survives indefinitely across app versions (no expiry, no migration), so it
4
+ * will eventually hold a field that's been removed, renamed, or changed shape, or just outright
5
+ * corrupted data. Spreading that in unchecked hands the rest of the app a state shape it was
6
+ * never built to handle instead of a clean fallback to `initial`.
7
+ *
8
+ * This is a shallow check: a nested object field only has its own `typeof` verified as `"object"`,
9
+ * not its inner shape. Deeper validation would need real per-field schemas, which isn't
10
+ * proportionate to what this guards against here.
11
+ */
12
+ function sanitize(parsed, initial) {
13
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
14
+ return {};
15
+ }
16
+ const result = {};
17
+ for (const key of Object.keys(initial)) {
18
+ if (!(key in parsed)) {
19
+ continue;
20
+ }
21
+ const value = parsed[key];
22
+ if (typeof value === typeof initial[key]) {
23
+ result[key] = value;
24
+ }
25
+ }
26
+ return result;
27
+ }
28
+ /**
29
+ * A minimal, `useSyncExternalStore`-compatible store, optionally persisted to `localStorage`
30
+ * under `persistKey`. Every consuming shell (mobile-command-center, mobile-sentinel, ...) gets its
31
+ * own `Store` instance per concern (shell UI state, minted-token cache, ...) — this class holds no
32
+ * shell-specific shape.
33
+ */
34
+ export class Store {
35
+ constructor(initial, persistKey) {
36
+ Object.defineProperty(this, "persistKey", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: persistKey
41
+ });
42
+ Object.defineProperty(this, "listeners", {
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true,
46
+ value: new Set()
47
+ });
48
+ Object.defineProperty(this, "value", {
49
+ enumerable: true,
50
+ configurable: true,
51
+ writable: true,
52
+ value: void 0
53
+ });
54
+ Object.defineProperty(this, "get", {
55
+ enumerable: true,
56
+ configurable: true,
57
+ writable: true,
58
+ value: () => this.value
59
+ });
60
+ Object.defineProperty(this, "subscribe", {
61
+ enumerable: true,
62
+ configurable: true,
63
+ writable: true,
64
+ value: (listener) => {
65
+ this.listeners.add(listener);
66
+ return () => {
67
+ this.listeners.delete(listener);
68
+ };
69
+ }
70
+ });
71
+ Object.defineProperty(this, "getSnapshot", {
72
+ enumerable: true,
73
+ configurable: true,
74
+ writable: true,
75
+ value: () => this.value
76
+ });
77
+ this.value = this.load(initial);
78
+ }
79
+ set(next) {
80
+ if (Object.is(next, this.value)) {
81
+ return;
82
+ }
83
+ this.value = next;
84
+ this.save();
85
+ this.listeners.forEach(l => l());
86
+ }
87
+ update(updater) {
88
+ this.set(updater(this.value));
89
+ }
90
+ load(initial) {
91
+ if (!this.persistKey) {
92
+ return initial;
93
+ }
94
+ try {
95
+ const raw = localStorage.getItem(this.persistKey);
96
+ if (raw === null) {
97
+ return initial;
98
+ }
99
+ return { ...initial, ...sanitize(JSON.parse(raw), initial) };
100
+ }
101
+ catch (_a) {
102
+ return initial;
103
+ }
104
+ }
105
+ save() {
106
+ if (!this.persistKey) {
107
+ return;
108
+ }
109
+ try {
110
+ localStorage.setItem(this.persistKey, JSON.stringify(this.value));
111
+ }
112
+ catch (_a) {
113
+ // ignore — quota / disabled storage
114
+ }
115
+ }
116
+ }
117
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,SAAS,QAAQ,CAAmB,MAAe,EAA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store.test.d.ts","sourceRoot":"","sources":["../../src/store/store.test.ts"],"names":[],"mappings":""}