@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,153 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ const SEARCH_DEBOUNCE_MS = 250;
3
+ /** Close-on-blur delay so an in-flight `mousedown` on a dropdown row can register first. */
4
+ const BLUR_CLOSE_DELAY_MS = 150;
5
+ /**
6
+ * Shared debounced-search-combobox behavior: debounce → abortable fetch → dropdown, plus a
7
+ * "bootstrap" pass that auto-picks the first result the first time an empty-search fetch completes
8
+ * for a given {@link UseSearchComboboxOptions.bootstrapScopeKey}, and a blur-close delay so an
9
+ * in-flight row `mousedown` can still register before the dropdown closes.
10
+ *
11
+ * Rendering (placeholders, disabled states, per-row markup) stays with the caller — this hook only
12
+ * owns the fetch/open/bootstrap state machine any live-searched picker needs (environment/tenant
13
+ * lookups, the version picker, ...).
14
+ */
15
+ export function useSearchCombobox(options) {
16
+ const { fetchDepsKey, bootstrapScopeKey, currentValue, hasSelection, fetchResults, onBootstrapPick, onPick } = options;
17
+ const [searchText, setSearchText] = useState('');
18
+ const [results, setResults] = useState([]);
19
+ const [loading, setLoading] = useState(false);
20
+ const [error, setError] = useState(null);
21
+ const [open, setOpen] = useState(false);
22
+ const [bootstrappedScope, setBootstrappedScope] = useState(null);
23
+ const [hasAnyResults, setHasAnyResults] = useState(true);
24
+ const blurTimeoutRef = useRef(null);
25
+ /**
26
+ * Live guard for the auto-pick: refs read current, so the bootstrap branch fires exactly once
27
+ * per scope even though the fetch effect deliberately omits the display state from its deps
28
+ * (re-running on a state flip would duplicate the fetch).
29
+ */
30
+ const bootstrappedScopeRef = useRef(null);
31
+ useEffect(() => {
32
+ if (fetchDepsKey === null) {
33
+ setResults([]);
34
+ return;
35
+ }
36
+ const controller = new AbortController();
37
+ const handle = window.setTimeout(() => {
38
+ setLoading(true);
39
+ void fetchResults(searchText, controller.signal)
40
+ .then(items => {
41
+ if (controller.signal.aborted) {
42
+ return;
43
+ }
44
+ setResults(items);
45
+ setError(null);
46
+ /*
47
+ * Bootstrap pass: only the first completed empty-search fetch for a scope
48
+ * auto-picks, so a later user-typed search can't clear the pick. A stale
49
+ * response for a scope that's since changed never reaches here — changing
50
+ * `fetchDepsKey` reruns this effect, whose cleanup aborts the prior controller.
51
+ */
52
+ if (searchText === '' && bootstrappedScopeRef.current !== bootstrapScopeKey) {
53
+ bootstrappedScopeRef.current = bootstrapScopeKey;
54
+ setBootstrappedScope(bootstrapScopeKey);
55
+ setHasAnyResults(items.length > 0);
56
+ if (items.length > 0 && !hasSelection()) {
57
+ onBootstrapPick(items[0]);
58
+ }
59
+ }
60
+ })
61
+ .catch((e) => {
62
+ if (controller.signal.aborted) {
63
+ return;
64
+ }
65
+ if (e instanceof DOMException && e.name === 'AbortError') {
66
+ return;
67
+ }
68
+ setError(e instanceof Error ? e.message : String(e));
69
+ })
70
+ .finally(() => {
71
+ if (controller.signal.aborted) {
72
+ return;
73
+ }
74
+ setLoading(false);
75
+ });
76
+ }, SEARCH_DEBOUNCE_MS);
77
+ return () => {
78
+ window.clearTimeout(handle);
79
+ controller.abort();
80
+ };
81
+ /*
82
+ * `bootstrapScopeKey` / `hasSelection` / `onBootstrapPick` / `fetchResults` / `onPick` are
83
+ * intentionally not in the deps list — bootstrap state is written inside this effect, and
84
+ * re-running after the write would duplicate the fetch. `bootstrapScopeKey` changes are
85
+ * always accompanied by a `fetchDepsKey` change from the same caller state, which IS a dep.
86
+ */
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
88
+ }, [searchText, fetchDepsKey]);
89
+ const onChange = (e) => {
90
+ setSearchText(e.target.value);
91
+ setOpen(true);
92
+ };
93
+ const onFocus = (e) => {
94
+ /*
95
+ * Standard combobox UX: pre-fill the input with the current selection and select-all so
96
+ * the first keystroke replaces it. Reading it fresh from the store (via the caller's
97
+ * getter) avoids a stale snapshot after a pick within the same focus pass.
98
+ */
99
+ setSearchText(currentValue());
100
+ setOpen(true);
101
+ // requestAnimationFrame defers select() until React has applied the new value.
102
+ const target = e.target;
103
+ window.requestAnimationFrame(() => target.select());
104
+ if (blurTimeoutRef.current !== null) {
105
+ window.clearTimeout(blurTimeoutRef.current);
106
+ blurTimeoutRef.current = null;
107
+ }
108
+ };
109
+ const onBlur = () => {
110
+ // Defer close so a click on a dropdown row gets a chance to fire.
111
+ blurTimeoutRef.current = window.setTimeout(() => {
112
+ setOpen(false);
113
+ blurTimeoutRef.current = null;
114
+ }, BLUR_CLOSE_DELAY_MS);
115
+ };
116
+ const pick = (result, input) => {
117
+ onPick(result);
118
+ setOpen(false);
119
+ if (blurTimeoutRef.current !== null) {
120
+ window.clearTimeout(blurTimeoutRef.current);
121
+ blurTimeoutRef.current = null;
122
+ }
123
+ input === null || input === void 0 ? void 0 : input.blur();
124
+ };
125
+ const onKeyDown = (e) => {
126
+ if (e.key === 'Escape') {
127
+ e.currentTarget.blur();
128
+ return;
129
+ }
130
+ if (e.key === 'Enter' && results.length > 0 && !loading) {
131
+ e.preventDefault();
132
+ pick(results[0], e.currentTarget);
133
+ }
134
+ };
135
+ return {
136
+ results,
137
+ loading,
138
+ error,
139
+ open,
140
+ showDropdown: open && (loading || error !== null || results.length > 0 || searchText !== ''),
141
+ bootstrapped: bootstrappedScope === bootstrapScopeKey,
142
+ hasAnyResults,
143
+ inputProps: {
144
+ value: open ? searchText : currentValue(),
145
+ onChange,
146
+ onFocus,
147
+ onBlur,
148
+ onKeyDown,
149
+ },
150
+ pick,
151
+ };
152
+ }
153
+ //# sourceMappingURL=use-search-combobox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-search-combobox.js","sourceRoot":"","sources":["../../src/toolbar/use-search-combobox.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5F,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,4FAA4F;AAC5F,MAAM,mBAAmB,G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ACf,IAAI,cAAc,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAClC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAC5C,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC;QAClC,CAAC;QACD,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,EAAE,CAAC;IAClB,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,CAAkC,EAAQ,EAAE;QAC3D,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YACrB,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;YACvB,OAAO;QACX,CAAC;QACD,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACtD,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC;QACtC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACH,OAAO;QACP,OAAO;QACP,KAAK;QACL,IAAI;QACJ,YAAY,EAAE,IAAI,IAAI,CAAC,OAAO,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,KAAK,EAAE,CAAC;QAC5F,YAAY,EAAE,iBAAiB,KAAK,iBAAiB;QACrD,aAAa;QACb,UAAU,EAAE;YACR,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,EAAE;YACzC,QAAQ;YACR,OAAO;YACP,MAAM;YACN,SAAS;SACZ;QACD,IAAI;KACP,CAAC;AACN,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { createVerdaccioVersionSource } from './verdaccio-client';
2
+ export type { VerdaccioVersionSource, VerdaccioVersionSourceConfig, VersionEntry } from './verdaccio-client';
3
+ export { MfeSourceList } from './mfe-source-list';
4
+ export type { MfeSourceListProps } from './mfe-source-list';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/version-picker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7G,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { createVerdaccioVersionSource } from './verdaccio-client';
2
+ export { MfeSourceList } from './mfe-source-list';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/version-picker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { FC } from 'react';
2
+ import { VerdaccioVersionSource } from './verdaccio-client';
3
+ export interface MfeSourceListProps {
4
+ versionSource: VerdaccioVersionSource;
5
+ /** The currently-selected `src` (whatever a consuming `<MfeLoader src=...>` is pointed at right now). */
6
+ currentSrc: string;
7
+ /** The same-origin, image-baked bundle URL (e.g. `/mfe`) — always offered above the published-version list. */
8
+ bundledSrc: string;
9
+ bundledLabel?: string;
10
+ onSelect: (src: string) => void;
11
+ }
12
+ /**
13
+ * Lets an engineer switch the mounted MFE between the bundle baked into this shell's own Docker
14
+ * image (`bundledSrc`, same-origin, no rebuild required to pick it) and any version published to
15
+ * Verdaccio (fetched cross-origin from unpkg at runtime, no shell rebuild required either).
16
+ */
17
+ export declare const MfeSourceList: FC<MfeSourceListProps>;
18
+ //# sourceMappingURL=mfe-source-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-source-list.d.ts","sourceRoot":"","sources":["../../src/version-picker/mfe-source-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,EAAE,EAA4D,MAAM,OAAO,CAAC;AAGpG,OAAO,EAAE,sBAAsB,EAAgB,MAAM,oBAAoB,CAAC;AAK1E,MAAM,WAAW,kBAAkB;IAC/B,aAAa,EAAE,sBAAsB,CAAC;IACtC,yGAAyG;IACzG,UAAU,EAAE,MAAM,CAAC;IACnB,+GAA+G;IAC/G,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAqFhD,CAAC"}
@@ -0,0 +1,92 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment, useCallback, useEffect, useState } from 'react';
3
+ import { List } from 'react-window';
4
+ import { buttonStyle, errorStyle, fieldStyle, helpTextStyle } from '../toolbar/styles';
5
+ const ROW_HEIGHT = 28;
6
+ const LIST_HEIGHT = 224; // 8 rows visible
7
+ /**
8
+ * Lets an engineer switch the mounted MFE between the bundle baked into this shell's own Docker
9
+ * image (`bundledSrc`, same-origin, no rebuild required to pick it) and any version published to
10
+ * Verdaccio (fetched cross-origin from unpkg at runtime, no shell rebuild required either).
11
+ */
12
+ export const MfeSourceList = ({ versionSource, currentSrc, bundledSrc, bundledLabel = 'Local (served by shell)', onSelect, }) => {
13
+ const [versions, setVersions] = useState([]);
14
+ const [loading, setLoading] = useState(false);
15
+ const [error, setError] = useState(null);
16
+ const [filter, setFilter] = useState('');
17
+ const load = useCallback((fresh) => {
18
+ setLoading(true);
19
+ setError(null);
20
+ versionSource
21
+ .listVersions(fresh)
22
+ .then(setVersions)
23
+ .catch((e) => setError(e instanceof Error ? e.message : String(e)))
24
+ .finally(() => setLoading(false));
25
+ }, [versionSource]);
26
+ useEffect(() => {
27
+ load(false);
28
+ }, [load]);
29
+ const lower = filter.trim().toLowerCase();
30
+ const filteredVersions = lower
31
+ ? versions.filter(v => v.version.toLowerCase().includes(lower) || v.tags.some(t => t.toLowerCase().includes(lower)))
32
+ : versions;
33
+ const showBundled = !lower || bundledLabel.toLowerCase().includes(lower) || bundledSrc.toLowerCase().includes(lower);
34
+ return (_jsxs(Fragment, { children: [_jsxs("div", { style: { display: 'flex', gap: '0.4rem', marginBottom: '0.4rem' }, children: [_jsx("input", { placeholder: "filter by version or tag\u2026", value: filter, onChange: e => setFilter(e.target.value), style: fieldStyle }), _jsx("button", { type: "button", onClick: () => load(true), disabled: loading, style: buttonStyle, title: "Reload", children: loading ? '…' : '↻' })] }), error && _jsx("pre", { style: errorStyle, children: error }), !loading && !error && !showBundled && filteredVersions.length === 0 && (_jsx("p", { style: helpTextStyle, children: "(no versions match the filter)" })), showBundled && (_jsx("div", { style: { marginBottom: filteredVersions.length > 0 ? '0.2rem' : 0 }, children: _jsx(SourceRow, { selected: currentSrc === bundledSrc, onClick: () => onSelect(bundledSrc), label: bundledLabel, meta: `${bundledSrc} · shadow DOM` }) })), filteredVersions.length > 0 && (_jsx(List, { style: {
35
+ height: Math.min(LIST_HEIGHT, filteredVersions.length * ROW_HEIGHT),
36
+ width: '100%',
37
+ }, rowCount: filteredVersions.length, rowHeight: ROW_HEIGHT, overscanCount: 4, rowComponent: VersionRow, rowProps: {
38
+ entries: filteredVersions,
39
+ selectedSrc: currentSrc,
40
+ onSelect,
41
+ unpkgUrl: versionSource.unpkgUrl,
42
+ } }))] }));
43
+ };
44
+ function VersionRow({ index, style, entries, selectedSrc, onSelect, unpkgUrl, }) {
45
+ const entry = entries[index];
46
+ const url = unpkgUrl(entry.version);
47
+ return (_jsx("div", { style: style, children: _jsx(SourceRow, { selected: selectedSrc === url, onClick: () => onSelect(url), label: entry.version, tags: entry.tags, meta: entry.publishedAt !== null ? timeAgo(entry.publishedAt) : undefined }) }));
48
+ }
49
+ const SourceRow = ({ selected, onClick, label, tags, meta }) => (_jsxs("button", { type: "button", onClick: onClick, style: {
50
+ ...rowStyle,
51
+ background: selected ? '#2a4a6a' : '#1f1f1f',
52
+ borderColor: selected ? '#3e6da3' : '#444',
53
+ }, children: [_jsxs("span", { style: { flex: 1, overflow: 'hidden', textOverflow: 'ellipsis' }, children: [_jsx("code", { children: label }), tags && tags.length > 0 && _jsxs("span", { style: { marginLeft: '0.4rem', opacity: 0.75 }, children: ["@", tags.join(' @')] })] }), meta && _jsx("span", { style: { marginLeft: '0.5rem', opacity: 0.55, whiteSpace: 'nowrap' }, children: meta })] }));
54
+ /*
55
+ * No marginBottom — when rendered inside a virtualized List, row spacing is folded into ROW_HEIGHT
56
+ * (the row sits in a 28px slot with the button itself ~24px, leaving a ~4px visual gap).
57
+ */
58
+ const rowStyle = {
59
+ display: 'flex',
60
+ alignItems: 'center',
61
+ width: '100%',
62
+ height: 'calc(100% - 4px)',
63
+ boxSizing: 'border-box',
64
+ textAlign: 'left',
65
+ padding: '0.3rem 0.5rem',
66
+ color: '#eaeaea',
67
+ border: '1px solid #444',
68
+ fontFamily: 'inherit',
69
+ fontSize: '0.7rem',
70
+ cursor: 'pointer',
71
+ };
72
+ function timeAgo(ts) {
73
+ const diff = Date.now() - ts;
74
+ const day = 86400000;
75
+ if (diff < 0) {
76
+ return 'just now';
77
+ }
78
+ if (diff < day) {
79
+ return 'today';
80
+ }
81
+ if (diff < day * 2) {
82
+ return 'yesterday';
83
+ }
84
+ if (diff < day * 30) {
85
+ return `${Math.floor(diff / day)}d ago`;
86
+ }
87
+ if (diff < day * 365) {
88
+ return `${Math.floor(diff / (day * 30))}mo ago`;
89
+ }
90
+ return `${Math.floor(diff / (day * 365))}y ago`;
91
+ }
92
+ //# sourceMappingURL=mfe-source-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-source-list.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CAAC,OAAO,CAAC;AACpD,CAAC"}
@@ -0,0 +1,33 @@
1
+ export interface VersionEntry {
2
+ version: string;
3
+ tags: string[];
4
+ publishedAt: number | null;
5
+ }
6
+ export interface VerdaccioVersionSourceConfig {
7
+ /** Scoped npm package name, e.g. `@servicetitan/mobile-sentinel-in-app-reports`. */
8
+ packageName: string;
9
+ /**
10
+ * Path the shell's own server (webpack-dev-server proxy locally, nginx when deployed) forwards
11
+ * to the real Verdaccio registry, attaching the read token server-side so it never reaches the
12
+ * browser. Defaults to `/verdaccio`.
13
+ */
14
+ verdaccioProxyPath?: string;
15
+ /** unpkg mirror base a published version's bundle is actually fetched from at runtime. */
16
+ unpkgBase?: string;
17
+ }
18
+ export interface VerdaccioVersionSource {
19
+ /**
20
+ * Lists every published version of the configured package, newest first. Cached as a Promise
21
+ * (not a value) so concurrent calls during an initial load dedupe onto one request; pass
22
+ * `fresh: true` to bypass the cache.
23
+ */
24
+ listVersions(fresh?: boolean): Promise<VersionEntry[]>;
25
+ /** The runtime URL a `<MfeLoader src=...>` mounts a specific published version from. */
26
+ unpkgUrl(version: string): string;
27
+ }
28
+ /**
29
+ * Talks to ST's Verdaccio registry (never raw npm, never unpkg directly) to enumerate every
30
+ * published version of one MFE package, for the shell's version-switcher toolbar panel.
31
+ */
32
+ export declare function createVerdaccioVersionSource(config: VerdaccioVersionSourceConfig): VerdaccioVersionSource;
33
+ //# sourceMappingURL=verdaccio-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdaccio-client.d.ts","sourceRoot":"","sources":["../../src/version-picker/verdaccio-client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,4BAA4B;IACzC,oFAAoF;IACpF,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,0FAA0F;IAC1F,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACnC;;;;OAIG;IACH,YAAY,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACvD,wFAAwF;IACxF,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;CACrC;AAQD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,4BAA4B,GAAG,sBAAsB,CAqDzG"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Talks to ST's Verdaccio registry (never raw npm, never unpkg directly) to enumerate every
3
+ * published version of one MFE package, for the shell's version-switcher toolbar panel.
4
+ */
5
+ export function createVerdaccioVersionSource(config) {
6
+ const { packageName, verdaccioProxyPath = '/verdaccio', unpkgBase = 'https://unpkg.servicetitan.com' } = config;
7
+ // Per-source cache (not a shared module-level global) so two pickers for two packages never collide.
8
+ let cachedVersions = null;
9
+ async function fetchVersionsImpl() {
10
+ var _a, _b, _c;
11
+ const url = `${verdaccioProxyPath}/${encodeURIComponent(packageName)}`;
12
+ /*
13
+ * Abbreviated registry format strips per-version metadata (deps, scripts, bin, etc.) the
14
+ * picker doesn't render. ST's Verdaccio preserves `dist-tags`, `versions` keys, and `time`
15
+ * — everything the picker needs.
16
+ */
17
+ const res = await fetch(url, { headers: { Accept: 'application/vnd.npm.install-v1+json' } });
18
+ if (!res.ok) {
19
+ throw new Error(`GET ${url} → ${res.status} ${res.statusText}`);
20
+ }
21
+ const doc = (await res.json());
22
+ const tagsByVersion = new Map();
23
+ for (const [tag, ver] of Object.entries((_a = doc['dist-tags']) !== null && _a !== void 0 ? _a : {})) {
24
+ const existing = (_b = tagsByVersion.get(ver)) !== null && _b !== void 0 ? _b : [];
25
+ existing.push(tag);
26
+ tagsByVersion.set(ver, existing);
27
+ }
28
+ return Object.keys((_c = doc.versions) !== null && _c !== void 0 ? _c : {})
29
+ .map(version => {
30
+ var _a, _b;
31
+ const t = (_a = doc.time) === null || _a === void 0 ? void 0 : _a[version];
32
+ return {
33
+ version,
34
+ tags: (_b = tagsByVersion.get(version)) !== null && _b !== void 0 ? _b : [],
35
+ publishedAt: t ? Date.parse(t) : null,
36
+ };
37
+ })
38
+ .sort((a, b) => { var _a, _b; return ((_a = b.publishedAt) !== null && _a !== void 0 ? _a : 0) - ((_b = a.publishedAt) !== null && _b !== void 0 ? _b : 0); });
39
+ }
40
+ return {
41
+ listVersions(fresh = false) {
42
+ if (cachedVersions && !fresh) {
43
+ return cachedVersions;
44
+ }
45
+ cachedVersions = fetchVersionsImpl().catch(error => {
46
+ cachedVersions = null;
47
+ throw error;
48
+ });
49
+ return cachedVersions;
50
+ },
51
+ unpkgUrl(version) {
52
+ return `${unpkgBase}/${packageName}@${version}`;
53
+ },
54
+ };
55
+ }
56
+ //# sourceMappingURL=verdaccio-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdaccio-client.js","sourceRoot":"","sources":["../../src/version-picker/verdaccio-client.ts"],"names":[],"mappings":"AAoCA;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAAoC;IAC7E,MAAM,EAAE,WAAW,EAAE,kBAAkB,GAAG,YAAY,EAAE,SAAS,GAAG,gCAAgC,EAAE,GAAG,MAAM,CAAC;IAEhH,qGAAqG;IACrG,IAAI,cAAc,GAAmC,IAAI,CAAC;IAE1D,KAAK,UAAU,iBAAiB;;QAC5B,MAAM,GAAG,GAAG,GAAG,kBAAkB,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;QACvE;;;;WAIG;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,qCAAqC,EAAE,EAAE,CAAC,CAAC;QAC7F,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACV,MAAM,IAA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KAAK,GAAG,KAAK;YACtB,IAAI,cAAc,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,cAAc,CAAC;YAC1B,CAAC;YACD,cAAc,GAAG,iBAAiB,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;gBAC/C,cAAc,GAAG,IAAI,CAAC;gBACtB,MAAM,KAAK,CAAC;YAChB,CAAC,CAAC,CAAC;YACH,OAAO,cAAc,CAAC;QAC1B,CAAC;QACD,QAAQ,CAAC,OAAe;YACpB,OAAO,GAAG,SAAS,IAAI,WAAW,IAAI,OAAO,EAAE,CAAC;QACpD,CAAC;KACJ,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,4 +1,73 @@
1
1
  {
2
- "name": "@servicetitan/mfe-shell-toolkit",
3
- "version": "0.0.1"
2
+ "name": "@servicetitan/mfe-shell-toolkit",
3
+ "version": "0.1.7",
4
+ "description": "Reusable building blocks for ServiceTitan MFE engineering shells: exact-host-parity Loader mounting, a Verdaccio-backed bundle version switcher, a transparent mock/API-interception engine, and a pluggable auth-strategy framework (JWT minting or static header injection). Extracted from mobile-command-center-shell; consumed by mobile-command-center-shell and mobile-sentinel's in-app-reports-shell.",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "engines": {
14
+ "node": ">=24",
15
+ "npm": ">=11"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc -b",
19
+ "lint": "startup lint",
20
+ "test": "startup test"
21
+ },
22
+ "cli": {
23
+ "lint": {
24
+ "stylelint": {
25
+ "disabled": true
26
+ }
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "react-window": "^2.2.7"
31
+ },
32
+ "peerDependencies": {
33
+ "@servicetitan/anvil2": "^3.1.0",
34
+ "@servicetitan/launchdarkly-service": "^36.4.0",
35
+ "@servicetitan/log-service": "^36.4.0",
36
+ "@servicetitan/react-ioc": "^36.4.0",
37
+ "@servicetitan/tokens": "^12.9.0",
38
+ "@servicetitan/web-components": "^36.4.0",
39
+ "launchdarkly-js-client-sdk": "^3.9.3",
40
+ "launchdarkly-react-client-sdk": "^3.6.1",
41
+ "mobx": "^6.13.5",
42
+ "mobx-react": "^9.2.0",
43
+ "react": "~18.3.1",
44
+ "react-dom": "~18.3.1"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "@servicetitan/launchdarkly-service": {
48
+ "optional": true
49
+ },
50
+ "launchdarkly-js-client-sdk": {
51
+ "optional": true
52
+ },
53
+ "launchdarkly-react-client-sdk": {
54
+ "optional": true
55
+ }
56
+ },
57
+ "devDependencies": {
58
+ "@servicetitan/anvil2": "^3.1.0",
59
+ "@servicetitan/launchdarkly-service": "^36.4.0",
60
+ "@servicetitan/log-service": "^36.4.0",
61
+ "@servicetitan/react-ioc": "^36.4.0",
62
+ "@servicetitan/tokens": "^12.9.0",
63
+ "@servicetitan/web-components": "^36.4.0",
64
+ "@types/react": "^18.3.31",
65
+ "@types/react-dom": "^18.3.7",
66
+ "launchdarkly-js-client-sdk": "^3.9.3",
67
+ "launchdarkly-react-client-sdk": "^3.6.1",
68
+ "mobx": "^6.13.5",
69
+ "mobx-react": "^9.2.0",
70
+ "react": "~18.3.1",
71
+ "react-dom": "~18.3.1"
72
+ }
4
73
  }