@tailorkit/client-core 0.1.0-beta.20 → 0.1.0-beta.21

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 (2) hide show
  1. package/README.md +2 -51
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,52 +1,3 @@
1
- # @tailorkit/client-core
1
+ # TailorKit Client Core
2
2
 
3
- Framework-independent endpoint clients and state shared by TailorKit's framework adapters.
4
-
5
- All stores live under `src/store` and are exported from `src/index.ts`. Separate entry points keep fetch state independent of local state:
6
-
7
- - `@tailorkit/client-core/client`: endpoint transport, shared client cache, and app/view resolution helpers.
8
- - `@tailorkit/client-core/store/fetch`: app discovery, metadata, slot instances, preview sessions, and the response cache.
9
- - `@tailorkit/client-core/store/local`: `NodeStore` and `createViewRegistry` for remote UI nodes and active view context.
10
-
11
- `createEndpointClient` exposes uncached endpoint calls independently of stores. Fetch stores expose snapshot getters, subscriptions, fetch, and invalidation methods without requiring a framework adapter to access TanStack Store. This separation allows a future adapter to use its own fetch layer, such as TanStack Query, while retaining the local stores and endpoint transport. The built-in cache currently uses TanStack Store.
12
-
13
- ```ts
14
- import { createTailorKitFetchClient, createTailorKitStore } from "@tailorkit/client-core";
15
-
16
- const client = createTailorKitFetchClient({
17
- baseUrl: "https://example.com/api/tailorkit",
18
- cache: {
19
- staleTime: 30_000,
20
- gcTime: 300_000,
21
- apps: { staleTime: 60_000 },
22
- meta: { staleTime: Infinity },
23
- slotInstances: { staleTime: 10_000 },
24
- },
25
- });
26
-
27
- // Share a client across roots to share responses and in-flight requests.
28
- // Each root retains its own active view registry and supplied app overrides.
29
- const root = createTailorKitStore(client.baseUrl, undefined, client);
30
- const stop = root.subscribeApps(() => {
31
- const snapshot = root.getAppsSnapshot();
32
- // Update the framework adapter with apps, status, error, and isFetching.
33
- });
34
-
35
- await root.fetchApps();
36
- await root.fetchApps({ force: true });
37
-
38
- stop();
39
- root.previews.dispose();
40
- ```
41
-
42
- Successful responses are fresh for 30 seconds by default. Mounting a consumer or calling `fetch()` reuses fresh data and refreshes stale data; stale times do not start polling. `staleTime: 0` always refreshes, while `Infinity` keeps successful data fresh until invalidated or explicitly refetched. Background requests retain successful data and set `isFetching`.
43
-
44
- Unused responses are retained for five minutes by default. `gcTime` controls eviction after the last subscriber leaves or an unobserved request finishes. Concurrent consumers share a request; slot requests are cancelled when their last subscriber leaves, and superseded responses cannot overwrite newer data. Slot cache keys include the app, deployment, preview session, slot, and active view context.
45
-
46
- Caches belong to a client instance. Create a new client when the authenticated identity changes; `client.clear()` discards responses and session providers. User-supplied apps remain authoritative for their root and do not seed the shared endpoint cache. Views derive from the same cached apps response.
47
-
48
- React's `createTailorKitClient` accepts the same `cache` configuration and an optional `fetch` implementation. `useApps` and `useViews` accept a `staleTime` override; `useSlotInstances` also accepts `gcTime`. Their `refetch()` methods force a new request.
49
-
50
- `useSlotInstances({ slot })` resolves instances across discovered apps in discovery order, with the originating `app` attached to each result. Managed `Slot` components resolve only their explicitly supplied app. Instance resolution requires a slot declared with `multiple: true`.
51
-
52
- `TailorKitApp` and `TailorKitView` are shared types; the React package re-exports them for compatibility.
3
+ Shared client functionality for TailorKit integrations.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailorkit/client-core",
3
- "version": "0.1.0-beta.20",
3
+ "version": "0.1.0-beta.21",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,10 +34,10 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@tailorkit/app": "0.1.0-beta.20",
38
- "@tailorkit/client-platform": "0.1.0-beta.20",
39
- "@tailorkit/core": "0.1.0-beta.20",
40
- "@tailorkit/sandbox": "0.1.0-beta.20",
37
+ "@tailorkit/app": "0.1.0-beta.21",
38
+ "@tailorkit/client-platform": "0.1.0-beta.21",
39
+ "@tailorkit/core": "0.1.0-beta.21",
40
+ "@tailorkit/sandbox": "0.1.0-beta.21",
41
41
  "@tanstack/store": "0.11.2"
42
42
  },
43
43
  "devDependencies": {