@tailorkit/react 0.1.0-beta.29 → 0.1.0-beta.32
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/LICENSE.md +47 -174
- package/dist/components/context.d.ts +2 -2
- package/dist/hooks/use-apps.d.ts +2 -2
- package/dist/hooks/use-query-result.d.ts +1 -1
- package/dist/hooks/use-view-context.d.ts +2 -2
- package/dist/hooks/use-views.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +254 -145
- package/dist/primitives.d.ts +6 -6
- package/dist/remote-view.d.ts +6 -6
- package/dist/tailorkit.d.ts +10 -11
- package/package.json +34 -9
package/LICENSE.md
CHANGED
|
@@ -6,172 +6,51 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
|
6
6
|
|
|
7
7
|
1. Definitions.
|
|
8
8
|
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
the
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
form, that
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
|
|
31
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
+
|
|
33
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
+
|
|
35
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
+
|
|
37
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
38
|
+
|
|
39
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
+
|
|
41
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
42
|
+
|
|
43
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
175
54
|
|
|
176
55
|
END OF TERMS AND CONDITIONS
|
|
177
56
|
|
|
@@ -188,14 +67,8 @@ APPENDIX: How to apply the Apache License to your work.
|
|
|
188
67
|
|
|
189
68
|
Copyright [yyyy] [name of copyright owner]
|
|
190
69
|
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
70
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
|
194
71
|
|
|
195
72
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
73
|
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
74
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TailorKitStore } from "@tailorkit/client-core";
|
|
2
|
-
import type { TailorKitClientConfig } from "
|
|
2
|
+
import type { TailorKitClientConfig } from "#tailorkit";
|
|
3
3
|
export interface TailorkitContextValue {
|
|
4
4
|
store: TailorKitStore;
|
|
5
5
|
client: TailorKitClientConfig;
|
|
6
6
|
}
|
|
7
7
|
export declare const TailorkitContext: import("react").Context<TailorkitContextValue | null>;
|
|
8
|
-
export declare
|
|
8
|
+
export declare const useTailorkitContext: (component: string, expectedClient?: TailorKitClientConfig) => TailorkitContextValue;
|
package/dist/hooks/use-apps.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { AppsQueryOptions, TailorKitApp, TailorKitStore } from "@tailorkit/
|
|
|
2
2
|
import type { UseQueryResult } from "./use-query-result";
|
|
3
3
|
export type UseAppsOptions<TScopeNames extends string = string> = AppsQueryOptions<TScopeNames>;
|
|
4
4
|
export type UseAppsResult = UseQueryResult<TailorKitApp[]>;
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
5
|
+
export declare const useAppsStore: (store: TailorKitStore, options?: UseAppsOptions) => UseAppsResult;
|
|
6
|
+
export declare const useApps: (options?: UseAppsOptions) => UseAppsResult;
|
|
@@ -6,4 +6,4 @@ export type UseQueryResult<T> = Pick<QueryResult<T>, "data" | "isPending" | "err
|
|
|
6
6
|
/** Fetch fresh data, bypassing the cache's freshness window. */
|
|
7
7
|
fetch: () => Promise<void>;
|
|
8
8
|
};
|
|
9
|
-
export declare
|
|
9
|
+
export declare const useQueryResult: <T>(state: ReadableAtom<QueryResult<T>>) => UseQueryResult<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ViewDefinition } from "@tailorkit/core/schema";
|
|
2
1
|
import type { ViewName, ViewState } from "@tailorkit/client-core";
|
|
2
|
+
import type { ViewDefinition } from "@tailorkit/core/schema";
|
|
3
3
|
export type { ViewName, ViewContext, ViewContextInput, ViewOptions, ViewState, } from "@tailorkit/client-core";
|
|
4
4
|
type DefaultViews = Record<`/${string}`, ViewDefinition>;
|
|
5
5
|
export type UseViewContext<TViews extends Record<string, ViewDefinition>> = <TView extends ViewName<TViews>>(view: TView, options: ViewState<TViews, NoInfer<TView>>) => void;
|
|
6
|
-
export declare
|
|
6
|
+
export declare const useViewContext: <TViews extends Record<string, ViewDefinition> = DefaultViews, TView extends ViewName<TViews> = ViewName<TViews>>(view: TView, options: ViewState<TViews, NoInfer<TView>>) => void;
|
|
@@ -4,4 +4,4 @@ export type { SlotItem } from "@tailorkit/client-core";
|
|
|
4
4
|
export type UseViewsOptions<TScopeNames extends string = string, TSlot extends string = string> = ViewsQueryOptions<TScopeNames, TSlot>;
|
|
5
5
|
export type UseViewsResult<TMultiple extends boolean = boolean> = UseQueryResult<SlotItem<TMultiple>[]>;
|
|
6
6
|
/** Subscribe to the shared views query using React's lifecycle. */
|
|
7
|
-
export declare
|
|
7
|
+
export declare const useViews: (options: UseViewsOptions) => UseViewsResult;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export type { ControlledRenderSlotProps, RenderSlotComponent, RenderSlotContext,
|
|
|
3
3
|
export { components, createClient } from "./tailorkit";
|
|
4
4
|
export type { TailorKitApp, TailorKitClientConfig, TailorKitInstance, TailorKitProviderProps, } from "./tailorkit";
|
|
5
5
|
export type { UseAppsOptions, UseAppsResult } from "./hooks/use-apps";
|
|
6
|
-
export type { SlotItem, UseViewsOptions, UseViewsResult } from "./hooks/use-views";
|
|
7
|
-
export type { UseViewContext, ViewOptions, ViewState } from "./hooks/use-view-context";
|
|
6
|
+
export type { SlotItem, UseViewsOptions, UseViewsResult, } from "./hooks/use-views";
|
|
7
|
+
export type { UseViewContext, ViewOptions, ViewState, } from "./hooks/use-view-context";
|
|
8
8
|
export { primitives } from "./primitives";
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// src/components/render-slot.tsx
|
|
2
2
|
import { useStore as useStore2 } from "@nanostores/react";
|
|
3
3
|
import { createSlotRuntime, buildThemeCss } from "@tailorkit/client-core";
|
|
4
|
-
import { useEffect as useEffect2, useId as useId2, useMemo as useMemo3 } from "react";
|
|
4
|
+
import { useEffect as useEffect2, useId as useId2, useMemo as useMemo3, useState as useState2 } from "react";
|
|
5
5
|
|
|
6
6
|
// src/primitives.tsx
|
|
7
|
-
import { createContext, useContext, useId, useMemo } from "react";
|
|
8
7
|
import { buildPrimitiveCss } from "@tailorkit/client-core";
|
|
8
|
+
import { createContext, useContext, useId, useMemo } from "react";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
var PrimitiveThemeContext = createContext(null);
|
|
11
11
|
var usePrimitiveNodeId = () => {
|
|
@@ -25,8 +25,8 @@ var Primitive = ({
|
|
|
25
25
|
display,
|
|
26
26
|
nodeId,
|
|
27
27
|
props,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
theme: context.theme,
|
|
29
|
+
viewId: context.viewId
|
|
30
30
|
}) : "";
|
|
31
31
|
return /* @__PURE__ */ jsxs(Element, { "data-tailorkit-node": nodeId, children: [
|
|
32
32
|
css === "" ? null : /* @__PURE__ */ jsx("style", { "data-tailorkit-node-style": nodeId, children: css }),
|
|
@@ -34,14 +34,30 @@ var Primitive = ({
|
|
|
34
34
|
] });
|
|
35
35
|
};
|
|
36
36
|
var primitives = {
|
|
37
|
-
Box: ({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
Box: ({
|
|
38
|
+
props,
|
|
39
|
+
children
|
|
40
|
+
}) => /* @__PURE__ */ jsx(Primitive, { display: "block", element: "div", props, children }),
|
|
41
|
+
Flex: ({
|
|
42
|
+
props,
|
|
43
|
+
children
|
|
44
|
+
}) => /* @__PURE__ */ jsx(Primitive, { display: "flex", element: "div", props, children }),
|
|
45
|
+
Grid: ({
|
|
46
|
+
props,
|
|
47
|
+
children
|
|
48
|
+
}) => /* @__PURE__ */ jsx(Primitive, { display: "grid", element: "div", props, children }),
|
|
49
|
+
Inline: ({
|
|
50
|
+
props,
|
|
51
|
+
children
|
|
52
|
+
}) => /* @__PURE__ */ jsx(Primitive, { display: "inline", element: "span", props, children })
|
|
41
53
|
};
|
|
42
54
|
|
|
43
55
|
// src/remote-view.tsx
|
|
44
56
|
import { useStore } from "@nanostores/react";
|
|
57
|
+
import {
|
|
58
|
+
createRemoteViewStore,
|
|
59
|
+
createRemoteElementProps
|
|
60
|
+
} from "@tailorkit/client-core";
|
|
45
61
|
import {
|
|
46
62
|
Component,
|
|
47
63
|
Fragment,
|
|
@@ -50,14 +66,17 @@ import {
|
|
|
50
66
|
memo,
|
|
51
67
|
useContext as useContext2,
|
|
52
68
|
useEffect,
|
|
53
|
-
useMemo as useMemo2
|
|
69
|
+
useMemo as useMemo2,
|
|
70
|
+
useState
|
|
54
71
|
} from "react";
|
|
55
|
-
import { createRemoteViewStore, createRemoteElementProps } from "@tailorkit/client-core";
|
|
56
72
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
57
73
|
var RemoteUIContext = createContext2(null);
|
|
58
74
|
var formatError = (error) => error.message;
|
|
59
75
|
var RemoteErrorBoundary = class extends Component {
|
|
60
|
-
|
|
76
|
+
constructor(props) {
|
|
77
|
+
super(props);
|
|
78
|
+
this.state = { error: null };
|
|
79
|
+
}
|
|
61
80
|
static getDerivedStateFromError(error) {
|
|
62
81
|
return { error };
|
|
63
82
|
}
|
|
@@ -71,7 +90,11 @@ var RemoteErrorBoundary = class extends Component {
|
|
|
71
90
|
return this.props.children;
|
|
72
91
|
}
|
|
73
92
|
};
|
|
74
|
-
|
|
93
|
+
var RemoteRoot = ({ store }) => {
|
|
94
|
+
const rootId = useStore(store.nodes.root);
|
|
95
|
+
return rootId === null ? null : /* @__PURE__ */ jsx2(RemoteView, { nodeId: rootId });
|
|
96
|
+
};
|
|
97
|
+
var RemoteViewHost = ({
|
|
75
98
|
appUrl,
|
|
76
99
|
sourceText,
|
|
77
100
|
toolBridge,
|
|
@@ -79,9 +102,16 @@ function RemoteViewHost({
|
|
|
79
102
|
components: components2,
|
|
80
103
|
createIframe,
|
|
81
104
|
props
|
|
82
|
-
}) {
|
|
105
|
+
}) => {
|
|
83
106
|
const appKey = appUrl.toString();
|
|
84
|
-
const
|
|
107
|
+
const [state, setState] = useState(() => ({
|
|
108
|
+
appKey,
|
|
109
|
+
store: createRemoteViewStore({ components: components2, props })
|
|
110
|
+
}));
|
|
111
|
+
if (state.appKey !== appKey) {
|
|
112
|
+
setState({ appKey, store: createRemoteViewStore({ components: components2, props }) });
|
|
113
|
+
}
|
|
114
|
+
const { store } = state;
|
|
85
115
|
const snapshot = useStore(store.state);
|
|
86
116
|
useEffect(() => {
|
|
87
117
|
store.setComponents(components2);
|
|
@@ -90,33 +120,50 @@ function RemoteViewHost({
|
|
|
90
120
|
store.setProps(props);
|
|
91
121
|
}, [props, store]);
|
|
92
122
|
useEffect(
|
|
93
|
-
() => store.mount({
|
|
123
|
+
() => store.mount({
|
|
124
|
+
appUrl,
|
|
125
|
+
createIframe,
|
|
126
|
+
getBackendSession,
|
|
127
|
+
sourceText,
|
|
128
|
+
toolBridge
|
|
129
|
+
}),
|
|
94
130
|
[appUrl, sourceText, toolBridge, getBackendSession, createIframe, store]
|
|
95
131
|
);
|
|
96
132
|
if (snapshot.status === "error" && snapshot.error) {
|
|
97
133
|
return createElement("div", null, formatError(snapshot.error));
|
|
98
134
|
}
|
|
99
135
|
return /* @__PURE__ */ jsx2(RemoteUIContext.Provider, { value: store, children: /* @__PURE__ */ jsx2(RemoteErrorBoundary, { children: /* @__PURE__ */ jsx2(RemoteRoot, { store }) }, `${appKey}:${snapshot.generation}`) });
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
136
|
+
};
|
|
137
|
+
var RemoteElementViewComponent = ({
|
|
138
|
+
ctx,
|
|
139
|
+
node
|
|
140
|
+
}) => {
|
|
141
|
+
const componentStore = useMemo2(
|
|
142
|
+
() => ctx.selectComponent(node.type),
|
|
143
|
+
[ctx, node.type]
|
|
144
|
+
);
|
|
107
145
|
const component = useStore(componentStore);
|
|
108
|
-
const children = node.children.map((child) =>
|
|
146
|
+
const children = node.children.map((child) => (
|
|
147
|
+
// oxlint-disable-next-line no-use-before-define -- This deferred callback runs after initialization; the definitions are mutually dependent.
|
|
148
|
+
/* @__PURE__ */ jsx2(RemoteView, { nodeId: child.id }, child.id)
|
|
149
|
+
));
|
|
109
150
|
if (component === void 0) {
|
|
110
151
|
throw new Error(`TailorKit component "${node.type}" is not registered.`);
|
|
111
152
|
}
|
|
112
|
-
const props = createRemoteElementProps(node, ctx.dispatch);
|
|
113
|
-
return createElement(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
153
|
+
const props = createRemoteElementProps(node, ctx.dispatch.bind(ctx));
|
|
154
|
+
return createElement(
|
|
155
|
+
/* oxlint-disable typescript/no-unsafe-type-assertion -- The renderer was supplied through the typed component registry; React's createElement overload erases its heterogeneous props. */
|
|
156
|
+
component,
|
|
157
|
+
/* oxlint-enable typescript/no-unsafe-type-assertion */
|
|
158
|
+
props,
|
|
159
|
+
...children
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
var RemoteElementView = memo(RemoteElementViewComponent);
|
|
163
|
+
var RemoteNodeView = ({
|
|
164
|
+
ctx,
|
|
165
|
+
nodeId
|
|
166
|
+
}) => {
|
|
120
167
|
const nodeStore = useMemo2(() => ctx.nodes.selectNode(nodeId), [ctx, nodeId]);
|
|
121
168
|
const node = useStore(nodeStore);
|
|
122
169
|
if (node === null) {
|
|
@@ -125,21 +172,32 @@ function RemoteNodeView({ ctx, nodeId }) {
|
|
|
125
172
|
if (node.kind === "text") {
|
|
126
173
|
return node.text;
|
|
127
174
|
}
|
|
128
|
-
const childElements = node.children.map((child) =>
|
|
175
|
+
const childElements = node.children.map((child) => (
|
|
176
|
+
// oxlint-disable-next-line no-use-before-define -- This deferred callback runs after initialization; the definitions are mutually dependent.
|
|
177
|
+
/* @__PURE__ */ jsx2(RemoteView, { nodeId: child.id }, child.id)
|
|
178
|
+
));
|
|
129
179
|
if (node.kind === "fragment") {
|
|
130
180
|
return createElement(Fragment, { key: node.id }, ...childElements);
|
|
131
181
|
}
|
|
132
182
|
return /* @__PURE__ */ jsx2(RemoteElementView, { node, ctx });
|
|
133
|
-
}
|
|
183
|
+
};
|
|
184
|
+
var RemoteViewComponent = ({ nodeId }) => {
|
|
185
|
+
const ctx = useContext2(RemoteUIContext);
|
|
186
|
+
return ctx === null ? null : /* @__PURE__ */ jsx2(RemoteNodeView, { ctx, nodeId });
|
|
187
|
+
};
|
|
134
188
|
var RemoteView = memo(RemoteViewComponent);
|
|
135
189
|
|
|
136
190
|
// src/components/context.ts
|
|
137
191
|
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
138
|
-
var TailorkitContext = createContext3(
|
|
139
|
-
|
|
192
|
+
var TailorkitContext = createContext3(
|
|
193
|
+
null
|
|
194
|
+
);
|
|
195
|
+
var useTailorkitContext = (component, expectedClient) => {
|
|
140
196
|
const context = useContext3(TailorkitContext);
|
|
141
197
|
if (!context) {
|
|
142
|
-
throw new Error(
|
|
198
|
+
throw new Error(
|
|
199
|
+
`${component} must be rendered inside a TailorKit Provider.`
|
|
200
|
+
);
|
|
143
201
|
}
|
|
144
202
|
if (expectedClient && context.client !== expectedClient) {
|
|
145
203
|
throw new Error(
|
|
@@ -147,32 +205,42 @@ function useTailorkitContext(component, expectedClient) {
|
|
|
147
205
|
);
|
|
148
206
|
}
|
|
149
207
|
return context;
|
|
150
|
-
}
|
|
208
|
+
};
|
|
151
209
|
|
|
152
210
|
// src/components/render-slot.tsx
|
|
153
211
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
154
|
-
|
|
155
|
-
return /* @__PURE__ */ jsx3(SlotRenderer, { mode: "managed", ...props });
|
|
156
|
-
}
|
|
157
|
-
function ControlledRenderSlot(props) {
|
|
158
|
-
return /* @__PURE__ */ jsx3(SlotRenderer, { mode: "controlled", ...props });
|
|
159
|
-
}
|
|
160
|
-
var RenderSlot = Object.assign(ManagedRenderSlot, {
|
|
161
|
-
Controlled: ControlledRenderSlot
|
|
162
|
-
});
|
|
163
|
-
function SlotRenderer(options) {
|
|
212
|
+
var SlotRenderer = (options) => {
|
|
164
213
|
const { store, client } = useTailorkitContext(
|
|
165
214
|
options.mode === "managed" ? "RenderSlot" : "RenderSlot.Controlled"
|
|
166
215
|
);
|
|
167
216
|
const reactId = useId2();
|
|
168
|
-
const
|
|
169
|
-
|
|
217
|
+
const [state, setState] = useState2(() => ({
|
|
218
|
+
runtime: createSlotRuntime(store, options),
|
|
219
|
+
store
|
|
220
|
+
}));
|
|
221
|
+
if (state.store !== store) {
|
|
222
|
+
setState({ runtime: createSlotRuntime(store, options), store });
|
|
223
|
+
}
|
|
224
|
+
const { runtime } = state;
|
|
225
|
+
useEffect2(() => {
|
|
226
|
+
runtime.setInput(options);
|
|
227
|
+
}, [runtime, options]);
|
|
170
228
|
const snapshot = useStore2(runtime.state);
|
|
171
|
-
if (snapshot.status === "hidden") return null;
|
|
172
|
-
if (snapshot.status === "loading") return /* @__PURE__ */ jsx3("div", { role: "status", children: snapshot.message });
|
|
173
|
-
if (snapshot.status === "error") return /* @__PURE__ */ jsx3("div", { role: "alert", children: snapshot.error.message });
|
|
174
229
|
const viewId = `tailorkit-view-${reactId.replaceAll(":", "")}`;
|
|
175
|
-
|
|
230
|
+
const themeContext = useMemo3(
|
|
231
|
+
() => ({ theme: client.theme, viewId }),
|
|
232
|
+
[client.theme, viewId]
|
|
233
|
+
);
|
|
234
|
+
if (snapshot.status === "hidden") {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
if (snapshot.status === "loading") {
|
|
238
|
+
return /* @__PURE__ */ jsx3("output", { children: snapshot.message });
|
|
239
|
+
}
|
|
240
|
+
if (snapshot.status === "error") {
|
|
241
|
+
return /* @__PURE__ */ jsx3("div", { role: "alert", children: snapshot.error.message });
|
|
242
|
+
}
|
|
243
|
+
return /* @__PURE__ */ jsx3(PrimitiveThemeContext.Provider, { value: themeContext, children: /* @__PURE__ */ jsxs2("div", { "data-tailorkit-view": viewId, children: [
|
|
176
244
|
/* @__PURE__ */ jsx3("style", { "data-tailorkit-theme-style": viewId, children: buildThemeCss(viewId, client.theme) }),
|
|
177
245
|
/* @__PURE__ */ jsx3(
|
|
178
246
|
RemoteViewHost,
|
|
@@ -187,7 +255,15 @@ function SlotRenderer(options) {
|
|
|
187
255
|
snapshot.hostKey
|
|
188
256
|
)
|
|
189
257
|
] }) });
|
|
190
|
-
}
|
|
258
|
+
};
|
|
259
|
+
var ManagedRenderSlot = (props) => /* @__PURE__ */ jsx3(SlotRenderer, { mode: "managed", ...props });
|
|
260
|
+
var ControlledRenderSlot = (props) => /* @__PURE__ */ jsx3(SlotRenderer, { mode: "controlled", ...props });
|
|
261
|
+
var RenderSlot = Object.assign(
|
|
262
|
+
ManagedRenderSlot,
|
|
263
|
+
{
|
|
264
|
+
Controlled: ControlledRenderSlot
|
|
265
|
+
}
|
|
266
|
+
);
|
|
191
267
|
|
|
192
268
|
// src/tailorkit.tsx
|
|
193
269
|
import {
|
|
@@ -195,137 +271,170 @@ import {
|
|
|
195
271
|
createComponentRegistry,
|
|
196
272
|
createTailorKitStore
|
|
197
273
|
} from "@tailorkit/client-core";
|
|
198
|
-
import { createElement as createElement2, useEffect as useEffect4, useMemo as useMemo8 } from "react";
|
|
199
|
-
|
|
200
|
-
// src/hooks/use-view-context.ts
|
|
201
|
-
import { useEffect as useEffect3, useMemo as useMemo4 } from "react";
|
|
202
|
-
function useViewContext(view, options) {
|
|
203
|
-
const { store } = useTailorkitContext("useViewContext");
|
|
204
|
-
const id = useMemo4(() => /* @__PURE__ */ Symbol("tailorkit-current-view"), []);
|
|
205
|
-
const { context, loading, error } = options;
|
|
206
|
-
useEffect3(
|
|
207
|
-
() => () => {
|
|
208
|
-
store.views.unregister(id);
|
|
209
|
-
},
|
|
210
|
-
[id, store]
|
|
211
|
-
);
|
|
212
|
-
useEffect3(() => {
|
|
213
|
-
store.views.register({ id, view, context, loading, error });
|
|
214
|
-
}, [id, view, context, loading, error, store]);
|
|
215
|
-
}
|
|
274
|
+
import { createElement as createElement2, useEffect as useEffect4, useMemo as useMemo8, useState as useState3 } from "react";
|
|
216
275
|
|
|
217
276
|
// src/hooks/use-apps.ts
|
|
218
|
-
import {
|
|
219
|
-
import {
|
|
277
|
+
import { createValueMemo, createAppsQuery } from "@tailorkit/client-core";
|
|
278
|
+
import { useMemo as useMemo5 } from "react";
|
|
220
279
|
|
|
221
280
|
// src/hooks/use-query-result.ts
|
|
222
281
|
import { useStore as useStore3 } from "@nanostores/react";
|
|
223
|
-
import { useMemo as
|
|
224
|
-
|
|
282
|
+
import { useMemo as useMemo4 } from "react";
|
|
283
|
+
var useQueryResult = (state) => {
|
|
225
284
|
const result = useStore3(state);
|
|
226
|
-
return
|
|
285
|
+
return useMemo4(
|
|
227
286
|
() => ({
|
|
228
287
|
data: result.data,
|
|
229
|
-
isPending: result.isPending,
|
|
230
288
|
error: result.error,
|
|
231
|
-
|
|
232
|
-
|
|
289
|
+
fetch: result.refetch,
|
|
290
|
+
isPending: result.isPending,
|
|
291
|
+
isRefetching: result.isFetching && !result.isPending
|
|
233
292
|
}),
|
|
234
293
|
[result]
|
|
235
294
|
);
|
|
236
|
-
}
|
|
295
|
+
};
|
|
237
296
|
|
|
238
297
|
// src/hooks/use-apps.ts
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
298
|
+
var useAppsStore = (store, options = {}) => {
|
|
299
|
+
const memoOptions = useMemo5(() => createValueMemo(), []);
|
|
300
|
+
const stableOptions = memoOptions({
|
|
301
|
+
appIds: options.appIds === void 0 ? void 0 : [...new Set(options.appIds)].toSorted(),
|
|
302
|
+
scopes: options.scopes === void 0 ? void 0 : [...new Set(options.scopes)].toSorted()
|
|
303
|
+
});
|
|
304
|
+
const query = useMemo5(
|
|
305
|
+
() => createAppsQuery(store, stableOptions),
|
|
306
|
+
[store, stableOptions]
|
|
307
|
+
);
|
|
245
308
|
return useQueryResult(query.state);
|
|
246
|
-
}
|
|
309
|
+
};
|
|
310
|
+
var useApps = (options = {}) => useAppsStore(useTailorkitContext("useApps").store, options);
|
|
311
|
+
|
|
312
|
+
// src/hooks/use-view-context.ts
|
|
313
|
+
import { useEffect as useEffect3, useMemo as useMemo6 } from "react";
|
|
314
|
+
var useViewContext = (view, options) => {
|
|
315
|
+
const { store } = useTailorkitContext("useViewContext");
|
|
316
|
+
const id = useMemo6(() => /* @__PURE__ */ Symbol("tailorkit-current-view"), []);
|
|
317
|
+
const { context, loading, error } = options;
|
|
318
|
+
useEffect3(
|
|
319
|
+
() => () => {
|
|
320
|
+
store.views.unregister(id);
|
|
321
|
+
},
|
|
322
|
+
[id, store]
|
|
323
|
+
);
|
|
324
|
+
useEffect3(() => {
|
|
325
|
+
store.views.register({ context, error, id, loading, view });
|
|
326
|
+
}, [id, view, context, loading, error, store]);
|
|
327
|
+
};
|
|
247
328
|
|
|
248
329
|
// src/hooks/use-views.ts
|
|
330
|
+
import { createValueMemo as createValueMemo2, createViewsQuery } from "@tailorkit/client-core";
|
|
249
331
|
import { useMemo as useMemo7 } from "react";
|
|
250
|
-
|
|
251
|
-
function useViews(options) {
|
|
332
|
+
var useViews = (options) => {
|
|
252
333
|
const { store } = useTailorkitContext("useViews");
|
|
253
|
-
const
|
|
254
|
-
const
|
|
334
|
+
const memoOptions = useMemo7(() => createValueMemo2(), []);
|
|
335
|
+
const stableOptions = memoOptions({
|
|
336
|
+
appIds: options.appIds === void 0 ? void 0 : [...new Set(options.appIds)].toSorted(),
|
|
337
|
+
scopes: options.scopes === void 0 ? void 0 : [...new Set(options.scopes)].toSorted(),
|
|
338
|
+
slot: options.slot
|
|
339
|
+
});
|
|
340
|
+
const query = useMemo7(
|
|
341
|
+
() => createViewsQuery(store, stableOptions),
|
|
342
|
+
[store, stableOptions]
|
|
343
|
+
);
|
|
255
344
|
return useQueryResult(query.state);
|
|
256
|
-
}
|
|
345
|
+
};
|
|
257
346
|
|
|
258
347
|
// src/tailorkit.tsx
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
props
|
|
273
|
-
children
|
|
274
|
-
|
|
275
|
-
|
|
348
|
+
var components = (_contract, customComponents) => (
|
|
349
|
+
/* oxlint-disable typescript/no-unsafe-type-assertion -- The wrapper preserves the declared component or slot props and changes only the rendering adapter; the generic key-to-props relationship is erased at this boundary. */
|
|
350
|
+
customComponents
|
|
351
|
+
);
|
|
352
|
+
var createReactTailorKitClient = (options) => {
|
|
353
|
+
const wrappedComponents = createComponentRegistry(
|
|
354
|
+
options.components ?? {},
|
|
355
|
+
(renderer) => (
|
|
356
|
+
// oxlint-disable-next-line typescript/promise-function-async -- Client components must render synchronously; ReactNode also permits Promise results for server components.
|
|
357
|
+
function TailorKitComponent({
|
|
358
|
+
children,
|
|
359
|
+
...props
|
|
360
|
+
}) {
|
|
361
|
+
const rendererArgs = { props };
|
|
362
|
+
if (children !== void 0) {
|
|
363
|
+
rendererArgs.children = children;
|
|
364
|
+
}
|
|
365
|
+
return renderer(
|
|
366
|
+
rendererArgs
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
)
|
|
370
|
+
);
|
|
371
|
+
const clientConfig = createTailorKitClientConfig({
|
|
372
|
+
...options,
|
|
373
|
+
components: wrappedComponents
|
|
276
374
|
});
|
|
277
|
-
const
|
|
375
|
+
const ClientRenderSlot = (props) => {
|
|
376
|
+
useTailorkitContext("RenderSlot", client);
|
|
377
|
+
return createElement2(RenderSlot, props);
|
|
378
|
+
};
|
|
278
379
|
const client = {
|
|
279
380
|
...clientConfig,
|
|
280
|
-
Provider: function
|
|
281
|
-
const store =
|
|
381
|
+
Provider: function Provider({ children, apps }) {
|
|
382
|
+
const [store] = useState3(
|
|
282
383
|
() => createTailorKitStore({
|
|
283
|
-
baseUrl: client.baseUrl,
|
|
284
|
-
contract: client.contract,
|
|
285
|
-
tools: client.tools,
|
|
286
384
|
apps,
|
|
385
|
+
assetsBaseUrl: client.assetsBaseUrl,
|
|
386
|
+
baseUrl: client.baseUrl,
|
|
287
387
|
client: clientConfig.fetchClient,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
388
|
+
contract: client.contract,
|
|
389
|
+
tools: client.tools
|
|
390
|
+
})
|
|
291
391
|
);
|
|
292
392
|
useEffect4(() => {
|
|
293
393
|
store.setProvidedApps(apps);
|
|
294
394
|
}, [store, apps]);
|
|
295
|
-
useEffect4(
|
|
296
|
-
|
|
297
|
-
|
|
395
|
+
useEffect4(
|
|
396
|
+
() => () => {
|
|
397
|
+
store.previews.dispose();
|
|
398
|
+
},
|
|
399
|
+
[store]
|
|
400
|
+
);
|
|
401
|
+
const context = useMemo8(() => ({ client, store }), [store]);
|
|
402
|
+
return createElement2(
|
|
403
|
+
TailorkitContext.Provider,
|
|
404
|
+
{ value: context },
|
|
405
|
+
children
|
|
406
|
+
);
|
|
298
407
|
},
|
|
299
|
-
RenderSlot: Object.assign(
|
|
300
|
-
function
|
|
301
|
-
useTailorkitContext("RenderSlot", client);
|
|
302
|
-
return createElement2(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
RenderSlot.Controlled,
|
|
309
|
-
props
|
|
310
|
-
);
|
|
311
|
-
}
|
|
408
|
+
RenderSlot: Object.assign(ClientRenderSlot, {
|
|
409
|
+
Controlled: function Controlled(props) {
|
|
410
|
+
useTailorkitContext("RenderSlot.Controlled", client);
|
|
411
|
+
return createElement2(
|
|
412
|
+
RenderSlot.Controlled,
|
|
413
|
+
/* oxlint-disable typescript/no-unsafe-type-assertion -- The wrapper preserves the declared component or slot props and changes only the rendering adapter; the generic key-to-props relationship is erased at this boundary. */
|
|
414
|
+
props
|
|
415
|
+
/* oxlint-enable typescript/no-unsafe-type-assertion */
|
|
416
|
+
);
|
|
312
417
|
}
|
|
313
|
-
),
|
|
314
|
-
useApps: function
|
|
418
|
+
}),
|
|
419
|
+
useApps: function useApps2(optionsValue) {
|
|
315
420
|
useTailorkitContext("useApps", client);
|
|
316
|
-
return useApps(
|
|
421
|
+
return useApps(optionsValue);
|
|
317
422
|
},
|
|
318
|
-
|
|
319
|
-
useTailorkitContext("useViews", client);
|
|
320
|
-
return useViews(options2);
|
|
321
|
-
},
|
|
322
|
-
useViewContext: function useClientViewContext(view, options2) {
|
|
423
|
+
useViewContext: function useViewContext2(view, optionsValue2) {
|
|
323
424
|
useTailorkitContext("useViewContext", client);
|
|
324
|
-
useViewContext(view,
|
|
425
|
+
useViewContext(view, optionsValue2);
|
|
426
|
+
},
|
|
427
|
+
useViews: function useViews2(optionsValue3) {
|
|
428
|
+
useTailorkitContext("useViews", client);
|
|
429
|
+
return (
|
|
430
|
+
/* oxlint-disable typescript/no-unsafe-type-assertion -- The wrapper preserves the declared component or slot props and changes only the rendering adapter; the generic key-to-props relationship is erased at this boundary. */
|
|
431
|
+
useViews(optionsValue3)
|
|
432
|
+
);
|
|
325
433
|
}
|
|
326
434
|
};
|
|
327
435
|
return client;
|
|
328
|
-
}
|
|
436
|
+
};
|
|
437
|
+
var createClient = (options) => createReactTailorKitClient(options);
|
|
329
438
|
export {
|
|
330
439
|
RenderSlot,
|
|
331
440
|
components,
|
package/dist/primitives.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
-
import type { TailorKitTheme } from "@tailorkit/core/schema";
|
|
3
1
|
import type { PrimitiveProps } from "@tailorkit/client-core";
|
|
2
|
+
import type { TailorKitTheme } from "@tailorkit/core/schema";
|
|
3
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
4
4
|
interface PrimitiveThemeContextValue {
|
|
5
5
|
viewId: string;
|
|
6
6
|
theme: TailorKitTheme;
|
|
7
7
|
}
|
|
8
8
|
export declare const PrimitiveThemeContext: import("react").Context<PrimitiveThemeContextValue | null>;
|
|
9
9
|
export declare const primitives: {
|
|
10
|
-
readonly Box: ({ props, children }: {
|
|
10
|
+
readonly Box: ({ props, children, }: {
|
|
11
11
|
props: PrimitiveProps;
|
|
12
12
|
children?: ReactNode;
|
|
13
13
|
}) => import("react").JSX.Element;
|
|
14
|
-
readonly Flex: ({ props, children }: {
|
|
14
|
+
readonly Flex: ({ props, children, }: {
|
|
15
15
|
props: PrimitiveProps;
|
|
16
16
|
children?: ReactNode;
|
|
17
17
|
}) => import("react").JSX.Element;
|
|
18
|
-
readonly Grid: ({ props, children }: {
|
|
18
|
+
readonly Grid: ({ props, children, }: {
|
|
19
19
|
props: PrimitiveProps;
|
|
20
20
|
children?: ReactNode;
|
|
21
21
|
}) => import("react").JSX.Element;
|
|
22
|
-
readonly Inline: ({ props, children }: {
|
|
22
|
+
readonly Inline: ({ props, children, }: {
|
|
23
23
|
props: PrimitiveProps;
|
|
24
24
|
children?: ReactNode;
|
|
25
25
|
}) => import("react").JSX.Element;
|
package/dist/remote-view.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ToolBridge } from "@tailorkit/app/client";
|
|
2
|
-
import type {
|
|
1
|
+
import type { ToolBridge, Session } from "@tailorkit/app/client";
|
|
2
|
+
import type { RemoteProps } from "@tailorkit/sandbox/protocol";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
4
|
interface RemoteViewHostProps {
|
|
5
5
|
appUrl: string | URL;
|
|
@@ -8,14 +8,14 @@ interface RemoteViewHostProps {
|
|
|
8
8
|
getBackendSession?: (options: {
|
|
9
9
|
refresh: boolean;
|
|
10
10
|
}) => Promise<Session>;
|
|
11
|
-
components:
|
|
11
|
+
components: RemoteProps;
|
|
12
12
|
createIframe?: () => HTMLIFrameElement;
|
|
13
|
-
props?:
|
|
13
|
+
props?: RemoteProps;
|
|
14
14
|
}
|
|
15
|
-
export declare
|
|
15
|
+
export declare const RemoteViewHost: ({ appUrl, sourceText, toolBridge, getBackendSession, components, createIframe, props, }: RemoteViewHostProps) => ReactNode;
|
|
16
16
|
interface RemoteViewProps {
|
|
17
17
|
nodeId: string;
|
|
18
18
|
}
|
|
19
|
-
declare
|
|
19
|
+
declare const RemoteViewComponent: ({ nodeId }: RemoteViewProps) => ReactNode;
|
|
20
20
|
export declare const RemoteView: import("react").MemoExoticComponent<typeof RemoteViewComponent>;
|
|
21
21
|
export {};
|
package/dist/tailorkit.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type { AnyComponentDefinition, ComponentRenderer, ComponentRenderers, CompleteComponentRenderers, TailorKitClientConfig, TailorKitApp, SlotMultiple } from "@tailorkit/client-core";
|
|
2
|
-
export type { TailorKitClientConfig } from "@tailorkit/client-core";
|
|
3
|
-
import type { TailorKitCacheOptions } from "@tailorkit/client-core";
|
|
4
|
-
import type { ReactNode } from "react";
|
|
1
|
+
import type { AnyComponentDefinition, ComponentRenderer, ComponentRenderers, CompleteComponentRenderers, TailorKitClientConfig, TailorKitApp, SlotMultiple, TailorKitCacheOptions } from "@tailorkit/client-core";
|
|
5
2
|
import type { TailorKitTheme, ViewDefinition, SlotDefinitions, TailorKitContract, ToolImplementations } from "@tailorkit/core/schema";
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import type { RenderSlotComponent } from "./components/render-slot";
|
|
8
5
|
import type { UseAppsOptions, UseAppsResult } from "./hooks/use-apps";
|
|
6
|
+
import type { UseViewContext } from "./hooks/use-view-context";
|
|
9
7
|
import type { UseViewsOptions, UseViewsResult } from "./hooks/use-views";
|
|
10
|
-
import type {
|
|
8
|
+
import type { primitives } from "./primitives";
|
|
9
|
+
export type { TailorKitClientConfig } from "@tailorkit/client-core";
|
|
11
10
|
export type { TailorKitApp } from "@tailorkit/client-core";
|
|
12
11
|
export interface TailorKitProviderProps {
|
|
13
12
|
apps?: TailorKitApp[];
|
|
@@ -26,10 +25,10 @@ type PrimitiveRenderers = typeof primitives;
|
|
|
26
25
|
type CustomComponentRenderers<TComponents extends Record<string, AnyComponentDefinition>> = {
|
|
27
26
|
[TName in Exclude<keyof TComponents, keyof PrimitiveRenderers>]?: ComponentRenderer<TComponents[TName], ReactNode>;
|
|
28
27
|
};
|
|
29
|
-
export declare
|
|
28
|
+
export declare const components: <TComponents extends Record<string, AnyComponentDefinition>>(_contract: {
|
|
30
29
|
components: TComponents;
|
|
31
|
-
}, customComponents: CustomComponentRenderers<TComponents>)
|
|
32
|
-
export declare
|
|
30
|
+
}, customComponents: CustomComponentRenderers<TComponents>) => ComponentRenderers<TComponents, ReactNode>;
|
|
31
|
+
export declare const createClient: <const TContract extends TailorKitContract>(options: {
|
|
33
32
|
contract: TContract;
|
|
34
33
|
tools?: ToolImplementations<NoInfer<TContract["tools"]>, "client">;
|
|
35
34
|
baseUrl: string | URL;
|
|
@@ -42,5 +41,5 @@ export declare function createClient<const TContract extends TailorKitContract>(
|
|
|
42
41
|
tools?: ToolImplementations<TContract["tools"], "client">;
|
|
43
42
|
} : {
|
|
44
43
|
tools: ToolImplementations<TContract["tools"], "client">;
|
|
45
|
-
}))
|
|
44
|
+
})) => TailorKitInstance<TContract["views"], TContract["slots"], keyof TContract["scopes"] & string>;
|
|
46
45
|
export type { ViewOptions } from "./hooks/use-view-context";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailorkit/react",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.32",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,6 +11,29 @@
|
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
13
|
"type": "module",
|
|
14
|
+
"imports": {
|
|
15
|
+
"#*": {
|
|
16
|
+
"development": [
|
|
17
|
+
"./src/*",
|
|
18
|
+
"./src/*.ts",
|
|
19
|
+
"./src/*.tsx",
|
|
20
|
+
"./src/*/index.ts",
|
|
21
|
+
"./src/*/index.tsx"
|
|
22
|
+
],
|
|
23
|
+
"types": [
|
|
24
|
+
"./dist/*",
|
|
25
|
+
"./dist/*.d.ts",
|
|
26
|
+
"./dist/*/index.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"default": [
|
|
29
|
+
"./src/*",
|
|
30
|
+
"./src/*.ts",
|
|
31
|
+
"./src/*.tsx",
|
|
32
|
+
"./src/*/index.ts",
|
|
33
|
+
"./src/*/index.tsx"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
14
37
|
"exports": {
|
|
15
38
|
".": {
|
|
16
39
|
"types": "./dist/index.d.ts",
|
|
@@ -24,19 +47,19 @@
|
|
|
24
47
|
"@floating-ui/react-dom": "^2.1.9",
|
|
25
48
|
"@nanostores/react": "2.0.1",
|
|
26
49
|
"@standard-schema/spec": "^1.1.0",
|
|
27
|
-
"@tailorkit/app": "0.1.0-beta.
|
|
28
|
-
"@tailorkit/client-core": "0.1.0-beta.
|
|
29
|
-
"@tailorkit/client-platform": "0.1.0-beta.
|
|
30
|
-
"@tailorkit/core": "0.1.0-beta.
|
|
31
|
-
"@tailorkit/sandbox": "0.1.0-beta.
|
|
32
|
-
"nanostores": "1.5.
|
|
50
|
+
"@tailorkit/app": "0.1.0-beta.32",
|
|
51
|
+
"@tailorkit/client-core": "0.1.0-beta.32",
|
|
52
|
+
"@tailorkit/client-platform": "0.1.0-beta.32",
|
|
53
|
+
"@tailorkit/core": "0.1.0-beta.32",
|
|
54
|
+
"@tailorkit/sandbox": "0.1.0-beta.32",
|
|
55
|
+
"nanostores": "1.5.5"
|
|
33
56
|
},
|
|
34
57
|
"devDependencies": {
|
|
35
58
|
"@tailorkit/config": "0.0.0",
|
|
36
59
|
"@testing-library/react": "^16.3.3",
|
|
37
60
|
"@types/node": "26.6.4",
|
|
38
61
|
"@types/react": "^19.3.0",
|
|
39
|
-
"happy-dom": "^20.14.
|
|
62
|
+
"happy-dom": "^20.14.6",
|
|
40
63
|
"react": "^19.3.0",
|
|
41
64
|
"react-dom": "^19.3.0",
|
|
42
65
|
"tsup": "^8.5.1",
|
|
@@ -48,6 +71,8 @@
|
|
|
48
71
|
"scripts": {
|
|
49
72
|
"build": "tsup src/index.ts --format esm --target node20 --clean && tsc -p tsconfig.build.json",
|
|
50
73
|
"check-types": "tsc --noEmit",
|
|
51
|
-
"test": "vp test run"
|
|
74
|
+
"test": "vp test run",
|
|
75
|
+
"lint": "vp lint .",
|
|
76
|
+
"lint:fix": "vp lint --fix ."
|
|
52
77
|
}
|
|
53
78
|
}
|