@tailorkit/react 0.1.0-beta.1 → 0.1.0-beta.11

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.
@@ -14,4 +14,3 @@ export declare class NodeStore {
14
14
  subscribeRoot(listener: Listener): () => void;
15
15
  }
16
16
  export {};
17
- //# sourceMappingURL=node-store.d.ts.map
@@ -2,37 +2,28 @@ import type { CSSProperties, ReactNode } from "react";
2
2
  import type { TailorKitTheme } from "@tailorkit/core/schema";
3
3
  type PrimitiveProps = Record<string, unknown>;
4
4
  interface PrimitiveThemeContextValue {
5
- screenId: string;
5
+ viewId: string;
6
6
  theme: TailorKitTheme;
7
7
  }
8
8
  export declare const PrimitiveThemeContext: import("react").Context<PrimitiveThemeContextValue | null>;
9
- export declare const buildThemeCss: (screenId: string, theme: TailorKitTheme) => string;
9
+ export declare const buildThemeCss: (viewId: string, theme: TailorKitTheme) => string;
10
10
  export declare const primitives: {
11
- readonly Box: ({ props, slots }: {
11
+ readonly Box: ({ props, children }: {
12
12
  props: PrimitiveProps;
13
- slots: {
14
- default?: ReactNode;
15
- };
13
+ children?: ReactNode;
16
14
  }) => import("react").JSX.Element;
17
- readonly Flex: ({ props, slots }: {
15
+ readonly Flex: ({ props, children }: {
18
16
  props: PrimitiveProps;
19
- slots: {
20
- default?: ReactNode;
21
- };
17
+ children?: ReactNode;
22
18
  }) => import("react").JSX.Element;
23
- readonly Grid: ({ props, slots }: {
19
+ readonly Grid: ({ props, children }: {
24
20
  props: PrimitiveProps;
25
- slots: {
26
- default?: ReactNode;
27
- };
21
+ children?: ReactNode;
28
22
  }) => import("react").JSX.Element;
29
- readonly Inline: ({ props, slots }: {
23
+ readonly Inline: ({ props, children }: {
30
24
  props: PrimitiveProps;
31
- slots: {
32
- default?: ReactNode;
33
- };
25
+ children?: ReactNode;
34
26
  }) => import("react").JSX.Element;
35
27
  };
36
28
  export type PrimitiveStyle = CSSProperties;
37
29
  export {};
38
- //# sourceMappingURL=primitives.d.ts.map
@@ -1,9 +1,8 @@
1
- import type { HostToWorkerPayload } from "@tailorkit/sandbox/protocol";
1
+ import type { HostToIframePayload } from "@tailorkit/sandbox/protocol";
2
2
  import type { NodeStore } from "./node-store";
3
3
  export interface RemoteViewContext {
4
4
  components: Record<string, unknown>;
5
- dispatch: (payload: HostToWorkerPayload) => void;
5
+ dispatch: (payload: HostToIframePayload) => void;
6
6
  store: NodeStore;
7
7
  }
8
8
  export declare const RemoteUIContext: import("react").Context<RemoteViewContext | null>;
9
- //# sourceMappingURL=remote-context.d.ts.map
@@ -4,12 +4,11 @@ interface RemoteViewHostProps {
4
4
  components: Record<string, unknown>;
5
5
  createIframe?: () => HTMLIFrameElement;
6
6
  props?: Record<string, unknown>;
7
- runtimeUrl?: string | URL;
8
7
  }
9
- export declare function RemoteViewHost({ appUrl, components, createIframe, props, runtimeUrl, }: RemoteViewHostProps): ReactNode;
8
+ export declare function RemoteViewHost({ appUrl, components, createIframe, props, }: RemoteViewHostProps): ReactNode;
10
9
  interface RemoteViewProps {
11
10
  nodeId: string;
12
11
  }
13
- export declare const RemoteView: import("react").MemoExoticComponent<({ nodeId }: RemoteViewProps) => ReactNode>;
12
+ declare function RemoteViewComponent({ nodeId }: RemoteViewProps): ReactNode;
13
+ export declare const RemoteView: import("react").MemoExoticComponent<typeof RemoteViewComponent>;
14
14
  export {};
15
- //# sourceMappingURL=remote-view.d.ts.map
@@ -0,0 +1,33 @@
1
+ import type { TailorKitSchemaSpecType } from "@tailorkit/core/spec";
2
+ import type { TailorKitApp } from "./tailor-kit";
3
+ export interface TailorKitAppsSnapshot {
4
+ apps: TailorKitApp[];
5
+ error: Error | null;
6
+ status: "error" | "idle" | "loading" | "ready";
7
+ }
8
+ interface TailorKitMetaSnapshot {
9
+ assetsBaseUrl: string | null;
10
+ error: Error | null;
11
+ schema: TailorKitSchemaSpecType | null;
12
+ status: "error" | "idle" | "loading" | "ready";
13
+ }
14
+ export type TailorKitStore = ReturnType<typeof createTailorKitStore>;
15
+ export declare function createTailorKitStore(baseUrlInput: string | URL, initialApps?: TailorKitApp[], previewSessionId?: string): {
16
+ baseUrl: URL;
17
+ views: {
18
+ getSnapshot: () => import("@tailorkit/core/views").ActiveView | null;
19
+ subscribe(listener: () => void): () => void;
20
+ register(entry: Omit<import("./view-registry").ViewEntry, "order">): void;
21
+ unregister(id: symbol): void;
22
+ };
23
+ setProvidedApps(apps: TailorKitApp[] | undefined): void;
24
+ fetchApps: (options?: {
25
+ force?: boolean;
26
+ }) => Promise<void>;
27
+ fetchMeta: () => Promise<void>;
28
+ getAppsSnapshot: () => TailorKitAppsSnapshot;
29
+ getMetaSnapshot: () => TailorKitMetaSnapshot;
30
+ subscribe: (listener: () => void) => (() => void);
31
+ };
32
+ export declare function toBaseUrl(value: string | URL): URL;
33
+ export {};
@@ -1,17 +1,13 @@
1
1
  import type { ReactNode } from "react";
2
- import type { TailorKitSchemaSpecType } from "@tailorkit/core/spec";
3
- import type { TailorKitTheme, CallbackMap, ComponentDefinition, ComponentProps, ComponentSlots, Schema, ScreenDefinition, TailorKitSchema } from "@tailorkit/core/schema";
2
+ import type { TailorKitTheme, CallbackMap, ComponentDefinition, ComponentProps, Schema, ViewDefinition, SlotDefinitions, TailorKitSchema } from "@tailorkit/core/schema";
4
3
  import type { primitives } from "./primitives";
5
- import { Root } from "./components";
6
- import type { UseAppsResult } from "./hooks/use-apps";
7
- import type { CurrentScreenOptions, ScreenName } from "./hooks/use-current-screen";
8
- type ReactComponentSlots<TComponent> = {
9
- [TSlot in keyof ComponentSlots<TComponent>]: ReactNode;
10
- };
11
- type AnyComponentDefinition = ComponentDefinition<Schema | undefined, CallbackMap, readonly string[] | undefined>;
4
+ import type { ViewOptions, ViewName } from "./hooks/use-view";
5
+ type AnyComponentDefinition = ComponentDefinition<Schema | undefined, CallbackMap, boolean | undefined>;
12
6
  type ComponentRenderer<TComponent extends AnyComponentDefinition> = (args: {
13
7
  props: ComponentProps<TComponent>;
14
- slots: ReactComponentSlots<TComponent>;
8
+ children?: TComponent extends {
9
+ children: true;
10
+ } ? ReactNode : never;
15
11
  }) => ReactNode;
16
12
  type ComponentRenderers<TComponents extends Record<string, AnyComponentDefinition>> = {
17
13
  [TName in keyof TComponents]?: ComponentRenderer<TComponents[TName]>;
@@ -23,64 +19,75 @@ export interface TailorKitApp {
23
19
  clientPath?: string;
24
20
  description?: string;
25
21
  id: string;
22
+ logoPaths?: {
23
+ dark?: string;
24
+ light?: string;
25
+ };
26
26
  projectId?: string;
27
27
  currentDeployment?: {
28
28
  id: string;
29
29
  } | null;
30
30
  name?: string;
31
- }
32
- export interface TailorKitAppsSnapshot {
33
- apps: TailorKitApp[];
34
- error: Error | null;
35
- status: "error" | "idle" | "loading" | "ready";
36
- }
37
- interface TailorKitMetaSnapshot {
38
- assetsBaseUrl: string | null;
39
- error: Error | null;
40
- schema: TailorKitSchemaSpecType | null;
41
- status: "error" | "idle" | "loading" | "ready";
42
- }
43
- export interface CurrentScreenEntry {
44
- context: unknown;
45
- id: symbol;
46
- order: number;
47
- screen: string;
48
- status: "error" | "loading" | "ready";
31
+ preview?: {
32
+ sessionId: string;
33
+ status: "connected" | "offline";
34
+ };
49
35
  }
50
36
  interface AppViewBaseProps {
51
37
  app: TailorKitApp;
52
38
  createIframe?: () => HTMLIFrameElement;
53
39
  fallback?: ReactNode;
54
- runtimeUrl?: string | URL;
55
40
  }
56
- type AppViewScreenProps<TScreens extends Record<string, ScreenDefinition>, TScreen extends ScreenName<TScreens> = ScreenName<TScreens>> = [ScreenName<TScreens>] extends [never] ? {
41
+ type AppViewViewProps<TViews extends Record<string, ViewDefinition>, TView extends ViewName<TViews> = ViewName<TViews>> = [ViewName<TViews>] extends [never] ? {
57
42
  context?: never;
58
- screen?: never;
43
+ view?: never;
59
44
  status?: never;
60
45
  } : {
61
46
  context?: never;
62
- screen?: never;
47
+ view?: never;
63
48
  status?: never;
64
- } | CurrentScreenOptions<TScreens, TScreen>;
65
- export type AppViewProps<TScreens extends Record<string, ScreenDefinition>, TScreen extends ScreenName<TScreens> = ScreenName<TScreens>> = AppViewBaseProps & AppViewScreenProps<TScreens, TScreen>;
66
- export interface TailorKitInstance<TScreens extends Record<string, ScreenDefinition> = Record<string, never>> {
67
- AppView: (props: AppViewProps<TScreens>) => ReactNode;
68
- Root: (props: Omit<Parameters<typeof Root>[0], "tailor">) => ReactNode;
69
- getApp: (id: string) => TailorKitApp | undefined;
70
- getApps: () => TailorKitApp[];
71
- useApps: () => UseAppsResult;
72
- useCurrentScreen: <TScreen extends ScreenName<TScreens>>(options: CurrentScreenOptions<TScreens, TScreen>) => void;
49
+ } | ViewOptions<TViews, TView>;
50
+ export type AppViewProps<TViews extends Record<string, ViewDefinition> = RegisteredViews, TView extends ViewName<TViews> = ViewName<TViews>> = {
51
+ [V in RegisteredSlots]: AppViewBaseProps & {
52
+ slot: V;
53
+ } & AppViewViewProps<TViews, Extract<TView, SlotView<V>>>;
54
+ }[RegisteredSlots];
55
+ export interface Register {
56
+ }
57
+ export type RegisteredViews = Register extends {
58
+ client: TailorKitInstance<infer S>;
59
+ } ? S : Record<`/${string}`, ViewDefinition>;
60
+ type RegisteredSlotMap = Register extends {
61
+ client: {
62
+ readonly $slots?: infer V;
63
+ };
64
+ } ? V : SlotDefinitions;
65
+ export type RegisteredSlots = keyof RegisteredSlotMap & string;
66
+ type SlotView<V extends RegisteredSlots> = RegisteredSlotMap[V] extends {
67
+ views: readonly (infer P)[];
68
+ } ? Extract<P, string> : never;
69
+ export interface TailorKitInstance<TViews extends Record<string, ViewDefinition> = Record<string, ViewDefinition>, TSlots extends SlotDefinitions = SlotDefinitions> {
70
+ readonly $slots?: TSlots;
71
+ readonly $views?: TViews;
72
+ readonly baseUrl: string | URL;
73
+ /**
74
+ * A host-selected, scope-authorized local-development preview session.
75
+ * The host handler resolves this server-side before returning app URLs.
76
+ */
77
+ readonly previewSessionId?: string;
78
+ readonly components: Record<string, unknown>;
79
+ readonly theme: TailorKitTheme;
73
80
  }
74
81
  type PrimitiveRenderers = typeof primitives;
75
82
  type CustomComponentRenderers<TComponents extends Record<string, AnyComponentDefinition>> = {
76
83
  [TName in Exclude<keyof TComponents, keyof PrimitiveRenderers>]?: ComponentRenderer<TComponents[TName]>;
77
84
  };
78
- export declare function components<TComponents extends Record<string, AnyComponentDefinition>>(_schema: TailorKitSchema<TComponents, Record<string, ScreenDefinition>>, customComponents: CustomComponentRenderers<TComponents>): ComponentRenderers<TComponents>;
85
+ export declare function components<TComponents extends Record<string, AnyComponentDefinition>>(_schema: TailorKitSchema<TComponents, Record<string, ViewDefinition>>, customComponents: CustomComponentRenderers<TComponents>): ComponentRenderers<TComponents>;
79
86
  interface TailorKitServerShape {
80
87
  $internal: {
81
88
  schema: {
82
89
  components: Record<string, unknown>;
83
- screens: Record<string, unknown>;
90
+ views: Record<string, unknown>;
84
91
  };
85
92
  };
86
93
  }
@@ -88,30 +95,16 @@ type ServerComponentMap<TTailor extends TailorKitServerShape> = TTailor["$intern
88
95
  type ServerComponents<TTailor extends TailorKitServerShape> = {
89
96
  [TName in keyof ServerComponentMap<TTailor>]: ServerComponentMap<TTailor>[TName] extends AnyComponentDefinition ? ServerComponentMap<TTailor>[TName] : never;
90
97
  };
91
- type ServerScreenMap<TTailor extends TailorKitServerShape> = TTailor["$internal"]["schema"]["screens"];
92
- type ServerScreens<TTailor extends TailorKitServerShape> = {
93
- [TName in keyof ServerScreenMap<TTailor>]: ServerScreenMap<TTailor>[TName] extends ScreenDefinition ? ServerScreenMap<TTailor>[TName] : never;
98
+ type ServerViewMap<TTailor extends TailorKitServerShape> = TTailor["$internal"]["schema"]["views"];
99
+ type ServerViews<TTailor extends TailorKitServerShape> = {
100
+ [TName in keyof ServerViewMap<TTailor>]: ServerViewMap<TTailor>[TName] extends ViewDefinition ? ServerViewMap<TTailor>[TName] : never;
94
101
  };
95
102
  export declare function createTailorKitClient<TTailor extends TailorKitServerShape>(options: {
96
103
  baseUrl: string | URL;
104
+ previewSessionId?: string;
97
105
  components?: CompleteComponentRenderers<ServerComponents<TTailor>>;
98
106
  theme?: TailorKitTheme;
99
- }): TailorKitInstance<ServerScreens<TTailor>>;
100
- export type TailorKitStore = ReturnType<typeof createTailorKitStore>;
101
- declare function createTailorKitStore(baseUrlInput: string | URL): {
102
- baseUrl: URL;
103
- fetchApps: (options?: {
104
- force?: boolean;
105
- }) => Promise<void>;
106
- fetchMeta: () => Promise<void>;
107
- getApp: (id: string) => TailorKitApp | undefined;
108
- getApps: () => TailorKitApp[];
109
- getAppsSnapshot: () => TailorKitAppsSnapshot;
110
- getCurrentScreen: () => CurrentScreenEntry | null;
111
- getMetaSnapshot: () => TailorKitMetaSnapshot;
112
- registerScreen: (entry: Omit<CurrentScreenEntry, "order">) => void;
113
- subscribe: (listener: () => void) => (() => void);
114
- unregisterScreen: (id: symbol) => void;
115
- };
116
- export type { CurrentScreenOptions } from "./hooks/use-current-screen";
117
- //# sourceMappingURL=tailor-kit.d.ts.map
107
+ }): TailorKitInstance<ServerViews<TTailor>, TTailor extends {
108
+ readonly $slots?: infer V extends SlotDefinitions;
109
+ } ? V : SlotDefinitions>;
110
+ export type { ViewOptions } from "./hooks/use-view";
@@ -0,0 +1,14 @@
1
+ import type { ActiveView, ViewStatus } from "@tailorkit/core/views";
2
+ export interface ViewEntry {
3
+ id: symbol;
4
+ view: string;
5
+ context: unknown;
6
+ status: ViewStatus;
7
+ order: number;
8
+ }
9
+ export declare function createViewRegistry(): {
10
+ getSnapshot: () => ActiveView | null;
11
+ subscribe(listener: () => void): () => void;
12
+ register(entry: Omit<ViewEntry, "order">): void;
13
+ unregister(id: symbol): void;
14
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tailorkit/react",
3
- "version": "0.1.0-beta.1",
4
- "license": "AGPL-3.0-only",
3
+ "version": "0.1.0-beta.11",
4
+ "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/AlfieJones/tailorkit.git",
@@ -11,18 +11,8 @@
11
11
  "dist"
12
12
  ],
13
13
  "type": "module",
14
- "imports": {
15
- "#*": [
16
- "./src/*",
17
- "./src/*.ts",
18
- "./src/*.tsx",
19
- "./src/*/index.ts",
20
- "./src/*/index.tsx"
21
- ]
22
- },
23
14
  "exports": {
24
15
  ".": {
25
- "development": "./src/index.ts",
26
16
  "types": "./dist/index.d.ts",
27
17
  "import": "./dist/index.js"
28
18
  }
@@ -33,20 +23,20 @@
33
23
  "dependencies": {
34
24
  "@floating-ui/react-dom": "^2.1.9",
35
25
  "@standard-schema/spec": "^1.1.0",
36
- "@tailorkit/core": "0.1.0-beta.1",
37
- "@tailorkit/sandbox": "0.1.0-beta.1"
26
+ "@tailorkit/core": "0.1.0-beta.11",
27
+ "@tailorkit/sandbox": "0.1.0-beta.11"
38
28
  },
39
29
  "devDependencies": {
40
30
  "@tailorkit/config": "0.0.0",
41
- "@testing-library/react": "^16.3.2",
31
+ "@testing-library/react": "^16.3.3",
42
32
  "@types/node": "26.2.0",
43
- "@types/react": "^19.2.18",
44
- "happy-dom": "^20.11.6",
45
- "react": "^19.2.8",
46
- "react-dom": "^19.2.8",
33
+ "@types/react": "^19.3.0",
34
+ "happy-dom": "^20.14.5",
35
+ "react": "^19.3.0",
36
+ "react-dom": "^19.3.0",
47
37
  "tsup": "^8.5.1",
48
38
  "typescript": "^7.0.2",
49
- "vitest": "^4.1.11"
39
+ "vitest": "^5.0.0"
50
40
  },
51
41
  "peerDependencies": {
52
42
  "react": ">=19.2.6"