@tailorkit/app 0.1.0-beta.21 → 0.1.0-beta.23

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.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
1
  # TailorKit App
2
2
 
3
3
  The SDK for building TailorKit extensions.
4
+
5
+ Apps require Preact 11. Install `preact@^11` alongside the SDK.
package/dist/builder.js CHANGED
@@ -75,7 +75,7 @@ function validateLogoAsset(content, contentType) {
75
75
  import { build as viteBuild } from "vite";
76
76
 
77
77
  // src/preact-version.ts
78
- var MINIMUM_PREACT_MAJOR_VERSION = 10;
78
+ var MINIMUM_PREACT_MAJOR_VERSION = 11;
79
79
  var parsePreactVersion = (version) => {
80
80
  const match = /^(\d+)\./u.exec(version);
81
81
  if (!match?.[1]) {
@@ -1086,7 +1086,7 @@ function getInstalledPreactVersion(root) {
1086
1086
  }
1087
1087
  } catch (error) {
1088
1088
  throw new Error(
1089
- `TailorKit requires Preact to build an app. Install preact@^10 and try again.`,
1089
+ `TailorKit requires Preact to build an app. Install preact@^11 and try again.`,
1090
1090
  { cause: error }
1091
1091
  );
1092
1092
  }
@@ -6,7 +6,7 @@ import {
6
6
  // src/views.ts
7
7
  import { createContext, h, render } from "preact";
8
8
  import { useContext } from "preact/hooks";
9
- var preactVersion = "10.29.8";
9
+ var preactVersion = "11.0.0";
10
10
  var defineView = (options) => {
11
11
  const path = options.view;
12
12
  const Context2 = createContext(
@@ -106,10 +106,10 @@ var createRemoteComponent = (name, options = {}) => {
106
106
  };
107
107
 
108
108
  // src/preact.ts
109
- import { createStore as createStore2 } from "@tanstack/store";
110
- import { useSelector } from "@tanstack/preact-store";
109
+ import { atom as atom2, computed } from "nanostores";
110
+ import { useStore } from "@nanostores/preact";
111
111
  import { createContext as createContext2, h as h2 } from "preact";
112
- import { useCallback, useContext as useContext2, useEffect, useMemo, useRef } from "preact/hooks";
112
+ import { useCallback, useContext as useContext2, useEffect, useLayoutEffect, useMemo, useRef } from "preact/hooks";
113
113
 
114
114
  // src/client/connection.ts
115
115
  import { createORPCClient } from "@orpc/client";
@@ -408,7 +408,7 @@ function waitForRetry(signal, delayMs) {
408
408
  }
409
409
 
410
410
  // src/client/query-store.ts
411
- import { createStore } from "@tanstack/store";
411
+ import { atom } from "nanostores";
412
412
  var pendingQuery = { data: void 0, error: null, status: "pending" };
413
413
  function serializeInput(input) {
414
414
  return JSON.stringify({ input, defined: input !== void 0 }, (_key, value) => {
@@ -419,7 +419,7 @@ function serializeInput(input) {
419
419
  });
420
420
  }
421
421
  var QueryStore = class {
422
- state = createStore(/* @__PURE__ */ new Map());
422
+ state = atom(/* @__PURE__ */ new Map());
423
423
  entries = /* @__PURE__ */ new Map();
424
424
  disposed = false;
425
425
  client;
@@ -442,7 +442,7 @@ var QueryStore = class {
442
442
  current.observers += 1;
443
443
  const publish = (state) => {
444
444
  if (!this.disposed && this.entries.get(key) === current) {
445
- this.state.setState((previous) => new Map(previous).set(key, state));
445
+ this.state.set(new Map(this.state.get()).set(key, state));
446
446
  }
447
447
  };
448
448
  if (first) {
@@ -474,11 +474,9 @@ var QueryStore = class {
474
474
  if (current.observers === 0 && this.entries.get(key) === current) {
475
475
  this.entries.delete(key);
476
476
  current.stop?.();
477
- this.state.setState((previous) => {
478
- const next = new Map(previous);
479
- next.delete(key);
480
- return next;
481
- });
477
+ const next = new Map(this.state.get());
478
+ next.delete(key);
479
+ this.state.set(next);
482
480
  }
483
481
  };
484
482
  }
@@ -490,7 +488,7 @@ var QueryStore = class {
490
488
  entry.stop?.();
491
489
  entry.stop = void 0;
492
490
  }
493
- this.state.setState(() => /* @__PURE__ */ new Map());
491
+ this.state.set(/* @__PURE__ */ new Map());
494
492
  if (this.ownsClient) {
495
493
  this.client.close();
496
494
  }
@@ -511,10 +509,10 @@ function ClientProvider({ children, client, onError }) {
511
509
  () => new QueryStore(client ?? createClient(), !client, (error) => errorHandler.current?.(error)),
512
510
  [client]
513
511
  );
514
- useEffect(() => () => store.dispose(), [store]);
512
+ useLayoutEffect(() => () => store.dispose(), [store]);
515
513
  return h2(Context.Provider, { value: store }, children);
516
514
  }
517
- function useStore() {
515
+ function useQueryStore() {
518
516
  const store = useContext2(Context);
519
517
  if (!store) {
520
518
  throw new Error("TailorKit backend hooks require a ClientProvider at the app root.");
@@ -522,17 +520,21 @@ function useStore() {
522
520
  return store;
523
521
  }
524
522
  function useQuery(ref, ...[input, options]) {
525
- const store = useStore();
523
+ const store = useQueryStore();
526
524
  const enabled = options?.enabled ?? true;
527
525
  const name = ref.name;
528
526
  const serialized = serializeInput(input);
529
527
  const key = `${name}\0${serialized}`;
530
528
  const stableInput = useMemo(() => JSON.parse(serialized).input, [serialized]);
531
529
  const stableReference = useMemo(() => reference(name, "query"), [name]);
532
- const state = useSelector(
533
- store.state,
534
- (queries) => enabled ? queries.get(key) ?? pendingQuery : pendingQuery
530
+ const query = useMemo(
531
+ () => computed(
532
+ store.state,
533
+ (queries) => enabled ? queries.get(key) ?? pendingQuery : pendingQuery
534
+ ),
535
+ [store, key, enabled]
535
536
  );
537
+ const state = useStore(query);
536
538
  useEffect(() => {
537
539
  if (enabled) {
538
540
  return store.watch(key, stableReference, stableInput);
@@ -548,25 +550,25 @@ function useQuery(ref, ...[input, options]) {
548
550
  }
549
551
  var idleCall = { data: void 0, error: null, status: "idle" };
550
552
  function useCall(kind, ref, options) {
551
- const store = useStore();
553
+ const store = useQueryStore();
552
554
  const name = ref.name;
553
555
  const identity = useMemo(
554
556
  () => ({
555
557
  store,
556
558
  name,
557
559
  kind,
558
- state: createStore2(idleCall)
560
+ state: atom2(idleCall)
559
561
  }),
560
562
  [store, name, kind]
561
563
  );
562
- const state = useSelector(identity.state);
564
+ const state = useStore(identity.state);
563
565
  const current = useRef({ identity, sequence: 0, mounted: true });
564
566
  if (current.current.identity !== identity) {
565
567
  current.current = { identity, sequence: current.current.sequence + 1, mounted: true };
566
568
  }
567
569
  const callbacks = useRef(options);
568
570
  callbacks.current = options;
569
- useEffect(() => {
571
+ useLayoutEffect(() => {
570
572
  current.current.mounted = true;
571
573
  return () => {
572
574
  current.current.mounted = false;
@@ -579,21 +581,21 @@ function useCall(kind, ref, options) {
579
581
  const settings = callbacks.current;
580
582
  const args = input;
581
583
  const isCurrent = () => current.current.mounted && current.current.identity === identity && current.current.sequence === sequence;
582
- identity.state.setState(() => ({ ...idleCall, status: "pending" }));
584
+ identity.state.set({ ...idleCall, status: "pending" });
583
585
  let data;
584
586
  try {
585
587
  data = kind === "mutation" ? await store.client.mutate(reference(name, "mutation"), args) : await store.client.action(reference(name, "action"), args);
586
588
  } catch (error) {
587
589
  const failure = appError(error);
588
590
  if (isCurrent()) {
589
- identity.state.setState(() => ({ data: void 0, error: failure, status: "error" }));
591
+ identity.state.set({ data: void 0, error: failure, status: "error" });
590
592
  settings.onError?.(failure, args);
591
593
  }
592
594
  store.onError(failure);
593
595
  throw failure;
594
596
  }
595
597
  if (isCurrent()) {
596
- identity.state.setState(() => ({ data, error: null, status: "success" }));
598
+ identity.state.set({ data, error: null, status: "success" });
597
599
  settings.onSuccess?.(data, args);
598
600
  }
599
601
  return data;
@@ -609,7 +611,7 @@ function useCall(kind, ref, options) {
609
611
  );
610
612
  const reset = useCallback(() => {
611
613
  current.current.sequence += 1;
612
- identity.state.setState(() => idleCall);
614
+ identity.state.set(idleCall);
613
615
  }, [identity]);
614
616
  return {
615
617
  ...state,
@@ -10,7 +10,7 @@ export declare const pendingQuery: QueryState<never>;
10
10
  export declare function serializeInput(input: unknown): string;
11
11
  /** One subscription per active query/input pair, scoped to this provider's client. */
12
12
  export declare class QueryStore {
13
- readonly state: import("@tanstack/store").Store<Map<string, QueryState<unknown>>, never>;
13
+ readonly state: import("nanostores").PreinitializedWritableAtom<Map<string, QueryState<unknown>>> & object;
14
14
  private readonly entries;
15
15
  private disposed;
16
16
  readonly client: Client;
package/dist/client.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  useAction,
11
11
  useMutation,
12
12
  useQuery
13
- } from "./chunk-RHCGWGSG.js";
13
+ } from "./chunk-LQJEPSUZ.js";
14
14
  import {
15
15
  AppError,
16
16
  appError
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  useAction,
11
11
  useMutation,
12
12
  useQuery
13
- } from "./chunk-RHCGWGSG.js";
13
+ } from "./chunk-LQJEPSUZ.js";
14
14
  import {
15
15
  action,
16
16
  and,
@@ -1,4 +1,4 @@
1
- export declare const MINIMUM_PREACT_MAJOR_VERSION = 10;
1
+ export declare const MINIMUM_PREACT_MAJOR_VERSION = 11;
2
2
  export interface PreactVersionCheck {
3
3
  major: number;
4
4
  version: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailorkit/app",
3
- "version": "0.1.0-beta.21",
3
+ "version": "0.1.0-beta.23",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -45,12 +45,12 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
+ "@nanostores/preact": "1.1.0",
48
49
  "@orpc/client": "2.0.0-beta.40",
49
50
  "@orpc/contract": "2.0.0-beta.40",
50
- "@tanstack/preact-store": "0.13.4",
51
- "@tanstack/store": "0.11.2",
52
51
  "cosmiconfig": "^10.0.1",
53
52
  "drizzle-orm": "1.0.0-rc.4-5d5b77c",
53
+ "nanostores": "1.5.4",
54
54
  "vite": "npm:@voidzero-dev/vite-plus-core@1.0.0",
55
55
  "zod": "^4.6.5"
56
56
  },
@@ -59,13 +59,13 @@
59
59
  "@tailorkit/config": "0.0.0",
60
60
  "@types/node": "26.6.4",
61
61
  "happy-dom": "^20.14.5",
62
- "preact": "^10.29.8",
62
+ "preact": "^11.0.0",
63
63
  "tsup": "^8.5.1",
64
64
  "typescript": "^7.0.2",
65
65
  "vite-plus": "1.0.0"
66
66
  },
67
67
  "peerDependencies": {
68
- "preact": "^10.0.0"
68
+ "preact": "^11.0.0"
69
69
  },
70
70
  "scripts": {
71
71
  "build": "tsup --config tsup.config.ts && tsc -p tsconfig.build.json",