@servicetitan/docs-uikit 38.1.0 → 38.2.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.
|
@@ -12,6 +12,7 @@ See [Cancelation handling](./cancelation-handling.mdx) for how to handle cancela
|
|
|
12
12
|
|
|
13
13
|
## API
|
|
14
14
|
|
|
15
|
+
- initAjaxHandlers - Use to register axios interceptors for authentication, error handling, and loading state; pass a notifier to receive error details including the full `AxiosError`.
|
|
15
16
|
- [withMicroservice](./with-microservice.mdx) - Use to wrap components and authenticate requests to protected resources with support for Bearer and Token Server authentication.
|
|
16
17
|
- [initAjaxHandlersLoginRequired](./init-ajax-handlers-login-required.mdx) - Use to register handler for invalid TokenServer session.
|
|
17
18
|
- [initAjaxHandlersParseDates](./init-ajax-handlers-parse-dates.mdx) - Use to automatically transform date strings in axios responses into JavaScript Date objects.
|
package/docs/install.mdx
CHANGED
|
@@ -62,6 +62,8 @@ pnpm support is experimental. It has been validated against several internal rep
|
|
|
62
62
|
|
|
63
63
|
In npm projects `@servicetitan/install` blocks untrusted packages from running any install script (`preinstall`, `install`, and `postinstall`), protecting against supply chain attacks. When an installed package has an untrusted install script, `@servicetitan/install` skips it and warns:
|
|
64
64
|
|
|
65
|
+
Projects that depend on `@servicetitan/startup` automatically trust a small built-in allowlist of packages. Projects that don't depend on `@servicetitan/startup` trust only the packages listed explicitly via `--allow-scripts`.
|
|
66
|
+
|
|
65
67
|
```
|
|
66
68
|
WARNING: The following packages have untrusted install scripts.
|
|
67
69
|
Review and add trusted packages to --allow-scripts:
|
package/docs/react-ioc.mdx
CHANGED
|
@@ -266,6 +266,56 @@ const SaveButton: React.FC = () => {
|
|
|
266
266
|
|
|
267
267
|
Use this when a service is genuinely optional, for example a logger that is only bound in production builds. The component works either way and skips the call when `Log` is not provided.
|
|
268
268
|
|
|
269
|
+
### `useLocalStores` {#use-local-stores}
|
|
270
|
+
|
|
271
|
+
Instantiates one or more stores **local to the invocation site** and returns `[instances, isInitialized]`, where `instances` holds the stores in argument order. It combines [`provide`](#provide) and [`useDependencies`](#use-dependencies) into a single call: the listed classes are provided and resolved on the spot, with their transitive `@inject` dependencies satisfied from the surrounding container hierarchy if not provided in the `useLocalStores` arguments.
|
|
272
|
+
|
|
273
|
+
```tsx
|
|
274
|
+
import { useLocalStores } from '@servicetitan/react-ioc';
|
|
275
|
+
|
|
276
|
+
function useOrderEditor(orderId: string) {
|
|
277
|
+
const [[orders, drafts], isInitialized] = useLocalStores(OrdersStore, DraftsStore);
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
// orders and drafts are private to this hook call
|
|
281
|
+
orders,
|
|
282
|
+
drafts,
|
|
283
|
+
|
|
284
|
+
// isInitialized flips to true once every store's `initialize()` promise has settled
|
|
285
|
+
isInitialized,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Use this to let a **hook** own its own stores. A `<Provider>` can only supply services to components rendered _below_ it in the tree, so a store consumed inside a hook would otherwise have to be provided by every caller. `useLocalStores` instantiates the store right where the hook runs instead.
|
|
291
|
+
|
|
292
|
+
#### How it differs from `<Provider>`
|
|
293
|
+
|
|
294
|
+
| Aspect | `<Provider>` / `@provide` | `useLocalStores` |
|
|
295
|
+
| :--------------------- | :----------------------------------------------- | :------------------------------------------------------- |
|
|
296
|
+
| Scope | The provided sub-tree | Only the hook invocation |
|
|
297
|
+
| Visible to descendants | Yes — descendants resolve via `useDependencies` | **No** — the instances never enter the React context |
|
|
298
|
+
| Instantiation | Lazy (singletons construct on first resolution) | **Eager** — constructed synchronously when the hook runs |
|
|
299
|
+
| Async `initialize` | Renders `loadingFallback` until it settles | Never blocks rendering; `isInitialized` reports status |
|
|
300
|
+
| Error handling | Renders `errorFallback` if a store's init throws | errors thrown by store `initialize()` re-thrown async |
|
|
301
|
+
|
|
302
|
+
#### Semantics
|
|
303
|
+
|
|
304
|
+
- **One instance per call.** Each listed class is instantiated once per hook invocation and stays stable across re-renders. As with `useDependencies`, changing the argument list on a later render is ignored. Listing the same class twice is an error: it throws in development and collapses onto a single instance (with a console warning) in production.
|
|
305
|
+
- **Siblings share.** If a listed class injects another class listed in the **same** call, it receives that sibling's instance — not one from higher in the context. Dependency graphs between the listed classes are resolved in the correct order automatically.
|
|
306
|
+
- **Transitive dependencies come from above.** Any `@inject` dependency that is _not_ listed in the call must be provided above the callsite by an ordinary `provide()` / `<Provider>` / `@provide`. This is the one part of the hook's contract that leaks to callers: "to use this hook, provide these prerequisites." If a prerequisite is missing, resolution throws.
|
|
307
|
+
- **Lifecycle.** [`Store`](#store-lifecycle) `initialize()` runs on mount and `dispose()` on unmount, for the listed `Store` subclasses only (plain `@injectable` classes get no lifecycle, matching `<Provider>`). Collaborators resolved from above are owned by whoever provided them. Rendering is never gated on `initialize()`; initialization errors are rethrown asynchronously so they reach the global error handler.
|
|
308
|
+
|
|
309
|
+
:::warning Contract
|
|
310
|
+
Because the stores are constructed **during render**, a concurrent render that React discards runs the constructor without ever calling `initialize()` or `dispose()`. Store constructors must therefore be side-effect-free; put side effects in `initialize()`.
|
|
311
|
+
|
|
312
|
+
Unlike `<Provider>`, which builds fresh instances on every mount, the hook retains its instances across a simulated unmount/remount (React `<StrictMode>` in development, `<Activity>` in production). The **same instance** then receives `initialize()`, `dispose()`, `initialize()` — so `dispose()` must leave the store re-initializable rather than permanently torn down.
|
|
313
|
+
:::
|
|
314
|
+
|
|
315
|
+
:::note
|
|
316
|
+
This hook takes bare classes only — no [symbol tokens](#tokens), `useClass`, or `useValue`. For shared, overridable, or token-based bindings, use [`<Provider>`](#provider).
|
|
317
|
+
:::
|
|
318
|
+
|
|
269
319
|
### `@injectDependency` {#inject-dependency}
|
|
270
320
|
|
|
271
321
|
Property decorator for class components.
|
package/docs/startup/install.mdx
CHANGED
|
@@ -3,7 +3,8 @@ title: install
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
:::danger
|
|
6
|
-
The `startup install` command
|
|
6
|
+
The `startup install` command has been removed. Running it now exits with an error pointing to
|
|
7
|
+
[@servicetitan/install](../install); use that package directly instead.
|
|
7
8
|
:::
|
|
8
9
|
|
|
9
10
|
As `@servicetitan/startup` grew more features, it became too large for simple bootstrapping. The
|
package/docs/startup/startup.mdx
CHANGED
|
@@ -39,7 +39,7 @@ Already on webpack and want to switch? See [Migrating to Vite](https://docs.st.d
|
|
|
39
39
|
- [clean](./clean) resets project to fresh state
|
|
40
40
|
- [convert-eslint-config](./convert-eslint-config) convert v8.x eslintrc.json to v9.x flat config
|
|
41
41
|
- [init](./init) create example project
|
|
42
|
-
- [install](./install) install
|
|
42
|
+
- [install](./install) removed; use `@servicetitan/install` directly
|
|
43
43
|
- [kendo-ui-license](./kendo-ui-license) install KendoReact license key
|
|
44
44
|
- [lint](./lint) run eslint and stylelint
|
|
45
45
|
- [mfe-check](./mfe-check) check MFE/host dependency compatibility
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/docs-uikit",
|
|
3
|
-
"version": "38.
|
|
3
|
+
"version": "38.2.0",
|
|
4
4
|
"description": "Documentation content for Uikit packages published at docs.st.dev",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"cli": {
|
|
17
17
|
"webpack": false
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "fd8cf00982a529371e44d76a0ca455dbbb42bae5"
|
|
20
20
|
}
|