@luma-ai/react 0.1.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.
- package/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/chunks/src-dnp1waFV.js +3100 -0
- package/dist/chunks/src-dnp1waFV.js.map +1 -0
- package/dist/config-CCT7m9eE.d.ts +102 -0
- package/dist/index-BdkoFDyP.d.ts +189 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/next.d.ts +7 -0
- package/dist/next.js +23 -0
- package/dist/next.js.map +1 -0
- package/dist/react-router.d.ts +10 -0
- package/dist/react-router.js +26 -0
- package/dist/react-router.js.map +1 -0
- package/dist/server.d.ts +33 -0
- package/dist/server.js +277 -0
- package/dist/server.js.map +1 -0
- package/dist/tanstack.d.ts +7 -0
- package/dist/tanstack.js +22 -0
- package/dist/tanstack.js.map +1 -0
- package/docs/actions.md +71 -0
- package/docs/ai-agents.md +71 -0
- package/docs/data-sources.md +90 -0
- package/docs/hooks.md +44 -0
- package/docs/index.md +67 -0
- package/docs/keyless.md +43 -0
- package/docs/options.md +78 -0
- package/docs/privacy.md +55 -0
- package/docs/server.md +110 -0
- package/docs/troubleshooting.md +94 -0
- package/package.json +120 -0
- package/skills/luma-ai-react/SKILL.md +121 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region ../assistant-contract/src/site.d.ts
|
|
3
|
+
declare const siteToolNames: readonly ["siteInfo", "searchSite", "searchProducts", "getProduct", "inspectPage", "showGuide", "navigate", "runAction"];
|
|
4
|
+
type SiteToolName = (typeof siteToolNames)[number];
|
|
5
|
+
declare const siteContextSchema: z.ZodObject<{
|
|
6
|
+
version: z.ZodLiteral<1>;
|
|
7
|
+
origin: z.ZodURL;
|
|
8
|
+
capabilities: z.ZodArray<z.ZodEnum<{
|
|
9
|
+
getProduct: "getProduct";
|
|
10
|
+
inspectPage: "inspectPage";
|
|
11
|
+
navigate: "navigate";
|
|
12
|
+
runAction: "runAction";
|
|
13
|
+
searchProducts: "searchProducts";
|
|
14
|
+
searchSite: "searchSite";
|
|
15
|
+
showGuide: "showGuide";
|
|
16
|
+
siteInfo: "siteInfo";
|
|
17
|
+
}>>;
|
|
18
|
+
features: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
19
|
+
guideTour: "guideTour";
|
|
20
|
+
}>>>;
|
|
21
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
description: z.ZodString;
|
|
24
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
25
|
+
confirm: z.ZodBoolean;
|
|
26
|
+
}, z.core.$strip>>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
type SiteContext = z.infer<typeof siteContextSchema>;
|
|
29
|
+
type SiteDestination = {
|
|
30
|
+
id: string;
|
|
31
|
+
title: string;
|
|
32
|
+
url: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
};
|
|
35
|
+
type SiteProduct = SiteDestination & {
|
|
36
|
+
productId: number | string;
|
|
37
|
+
image: string | null;
|
|
38
|
+
price: string;
|
|
39
|
+
currency: string;
|
|
40
|
+
inStock: boolean;
|
|
41
|
+
type: string;
|
|
42
|
+
attributes: Record<string, string[]>;
|
|
43
|
+
variations?: Array<{
|
|
44
|
+
id: number | string;
|
|
45
|
+
attributes: Record<string, string>;
|
|
46
|
+
price: string;
|
|
47
|
+
inStock: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/core/actions.d.ts
|
|
52
|
+
/** An app action the assistant may propose, such as adding a product to the cart. */
|
|
53
|
+
type LumaActionDefinition<Input = unknown> = {
|
|
54
|
+
name: string;
|
|
55
|
+
/** Tells the model when to use the action. */
|
|
56
|
+
description: string;
|
|
57
|
+
/** Short Persian label shown to the visitor, e.g. "افزودن به سبد خرید". */
|
|
58
|
+
title?: string;
|
|
59
|
+
/** When true (default) the visitor approves every run. */
|
|
60
|
+
confirm: boolean;
|
|
61
|
+
input: z.ZodType<Input>;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Define an action once and share it between the server handler (which declares it to the
|
|
65
|
+
* assistant) and the page component that runs it with useLumaAction.
|
|
66
|
+
*/
|
|
67
|
+
declare function defineAction<Schema extends z.ZodType>(definition: {
|
|
68
|
+
name: string;
|
|
69
|
+
description: string;
|
|
70
|
+
title?: string;
|
|
71
|
+
confirm?: boolean;
|
|
72
|
+
input: Schema;
|
|
73
|
+
}): LumaActionDefinition<z.output<Schema>>;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/core/config.d.ts
|
|
76
|
+
type ChatPosition = "bottom-left" | "bottom-right";
|
|
77
|
+
type ChatSize = "sm" | "md" | "lg" | "xl";
|
|
78
|
+
type IconSize = "sm" | "md" | "lg" | "xl";
|
|
79
|
+
/** Visual options shared by the WordPress plugin settings and LumaProvider props. */
|
|
80
|
+
type LumaAppearance = {
|
|
81
|
+
position?: ChatPosition;
|
|
82
|
+
size?: ChatSize;
|
|
83
|
+
/** Overrides the assistant name from the dashboard. */
|
|
84
|
+
title?: string;
|
|
85
|
+
subtitle?: string;
|
|
86
|
+
placeholder?: string;
|
|
87
|
+
paddingBottom?: number;
|
|
88
|
+
paddingSide?: number;
|
|
89
|
+
iconSize?: IconSize;
|
|
90
|
+
mobileEnabled?: boolean;
|
|
91
|
+
mobileSize?: ChatSize | "full";
|
|
92
|
+
mobilePaddingBottom?: number;
|
|
93
|
+
mobilePaddingSide?: number;
|
|
94
|
+
mobileIconSize?: IconSize;
|
|
95
|
+
};
|
|
96
|
+
declare const API_BASE_URLS: {
|
|
97
|
+
readonly internal: "https://ir.lumai.ir/api";
|
|
98
|
+
readonly direct: "https://dash.lumai.ir/api";
|
|
99
|
+
};
|
|
100
|
+
type LumaServer = keyof typeof API_BASE_URLS;
|
|
101
|
+
//#endregion
|
|
102
|
+
export { SiteContext as a, defineAction as i, LumaServer as n, SiteProduct as o, LumaActionDefinition as r, SiteToolName as s, LumaAppearance as t };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { a as SiteContext, n as LumaServer, o as SiteProduct, r as LumaActionDefinition, t as LumaAppearance } from "./config-CCT7m9eE.js";
|
|
2
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
//#region src/core/policy.d.ts
|
|
4
|
+
/** Where the assistant may look and which URLs it may open on this website. */
|
|
5
|
+
type SitePolicy = {
|
|
6
|
+
/** Pages with no inspection, guides or navigation (for example an admin area). */
|
|
7
|
+
restrictedPaths: RegExp[];
|
|
8
|
+
/** State-changing URLs the assistant must never open, such as logout. */
|
|
9
|
+
blockedPaths: RegExp[];
|
|
10
|
+
/** Query parameters that make a URL state-changing or secret-bearing. */
|
|
11
|
+
blockedParams: string[];
|
|
12
|
+
/** Regions whose text and controls are never read. */
|
|
13
|
+
privateSelector: string;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/core/data-sources.d.ts
|
|
17
|
+
/** A page the assistant may suggest. Relative URLs resolve against this site. */
|
|
18
|
+
type LumaLink = {
|
|
19
|
+
title: string;
|
|
20
|
+
url: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
/** Stable ID; derived from the URL when omitted. */
|
|
23
|
+
id?: string;
|
|
24
|
+
};
|
|
25
|
+
type LumaSiteInfo = {
|
|
26
|
+
name?: string;
|
|
27
|
+
language?: string;
|
|
28
|
+
currency?: string;
|
|
29
|
+
menus?: LumaLink[];
|
|
30
|
+
/** Public page directory. Also used for searchSite when no search function is given. */
|
|
31
|
+
pages?: LumaLink[];
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
type LumaProduct = Omit<SiteProduct, "id" | "image" | "currency" | "type" | "attributes" | "price"> & {
|
|
35
|
+
id?: string;
|
|
36
|
+
image?: string | null;
|
|
37
|
+
price: string | number;
|
|
38
|
+
currency?: string;
|
|
39
|
+
type?: string;
|
|
40
|
+
attributes?: Record<string, string[]>;
|
|
41
|
+
};
|
|
42
|
+
/** Extra fields (e.g. a price note) are passed to the assistant as-is. */
|
|
43
|
+
type LumaSearchResult<T> = {
|
|
44
|
+
items: T[];
|
|
45
|
+
hasMore?: boolean;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
};
|
|
48
|
+
type LumaDataSourceContext = {
|
|
49
|
+
sessionId: string;
|
|
50
|
+
signal: AbortSignal;
|
|
51
|
+
};
|
|
52
|
+
type LumaProductQuery = {
|
|
53
|
+
query: string;
|
|
54
|
+
minPrice?: number | null;
|
|
55
|
+
maxPrice?: number | null;
|
|
56
|
+
category?: string | null;
|
|
57
|
+
inStock: boolean;
|
|
58
|
+
page: number;
|
|
59
|
+
};
|
|
60
|
+
/** Live data the assistant reads from your app. Every function runs in the visitor's browser. */
|
|
61
|
+
type LumaDataSources = {
|
|
62
|
+
site?: LumaSiteInfo | ((context: LumaDataSourceContext) => LumaSiteInfo | Promise<LumaSiteInfo>);
|
|
63
|
+
searchSite?: (input: {
|
|
64
|
+
query: string;
|
|
65
|
+
page: number;
|
|
66
|
+
}, context: LumaDataSourceContext) => Promise<LumaSearchResult<LumaLink>>;
|
|
67
|
+
searchProducts?: (input: LumaProductQuery, context: LumaDataSourceContext) => Promise<LumaSearchResult<LumaProduct>>;
|
|
68
|
+
getProduct?: (input: {
|
|
69
|
+
productId: number | string;
|
|
70
|
+
}, context: LumaDataSourceContext) => Promise<LumaProduct | null>;
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/core/navigation.d.ts
|
|
74
|
+
/** How the assistant opens pages on this website. */
|
|
75
|
+
type LumaNavigation = {
|
|
76
|
+
/** Open a same-origin URL that already passed the site policy. */
|
|
77
|
+
navigate: (url: string) => void;
|
|
78
|
+
/** True when navigate keeps this document (client-side routing). */
|
|
79
|
+
client?: boolean;
|
|
80
|
+
};
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/core/site-runtime.d.ts
|
|
83
|
+
type Landmark = {
|
|
84
|
+
path: string;
|
|
85
|
+
selector: string;
|
|
86
|
+
label: string;
|
|
87
|
+
fingerprint: string;
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/provider.d.ts
|
|
91
|
+
type LumaProviderProps = LumaAppearance & {
|
|
92
|
+
children?: ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* Your backend route made with createLumaSessionHandler. Recommended: the API key stays on
|
|
95
|
+
* your server.
|
|
96
|
+
*/
|
|
97
|
+
sessionEndpoint?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Assistant ID for client-only apps without a backend. Requires keyless access and this
|
|
100
|
+
* site's domain in the Luma dashboard. Ignored when sessionEndpoint is set.
|
|
101
|
+
*/
|
|
102
|
+
assistantId?: string;
|
|
103
|
+
/** Luma API host: "internal" (ir.lumai.ir, default) or "direct" (dash.lumai.ir). */
|
|
104
|
+
server?: LumaServer;
|
|
105
|
+
/** Overrides the Luma API base URL, e.g. for local development. */
|
|
106
|
+
apiBaseUrl?: string;
|
|
107
|
+
/** Live data the assistant reads from your app. */
|
|
108
|
+
dataSources?: LumaDataSources;
|
|
109
|
+
/** Actions this page tree can run. Required in client-only mode to declare them. */
|
|
110
|
+
actions?: LumaActionDefinition[];
|
|
111
|
+
/** Disable navigation suggestions or on-page guides. Both are on by default. */
|
|
112
|
+
features?: {
|
|
113
|
+
navigation?: boolean;
|
|
114
|
+
guides?: boolean;
|
|
115
|
+
};
|
|
116
|
+
/** Paths where the assistant cannot look, guide or navigate, e.g. "/admin". */
|
|
117
|
+
restrictedPaths?: Array<string | RegExp>;
|
|
118
|
+
/** Extra state-changing paths and query parameters the assistant must never open. */
|
|
119
|
+
blockedPaths?: Array<string | RegExp>;
|
|
120
|
+
blockedParams?: string[];
|
|
121
|
+
/** CSS selectors of regions whose content is never read, in addition to data-luma-private. */
|
|
122
|
+
privateSelectors?: string[];
|
|
123
|
+
/** Hide the widget (for example on some routes) while keeping hooks working. */
|
|
124
|
+
disabled?: boolean;
|
|
125
|
+
/** Client-side router integration. Set by the next, react-router and tanstack entries. */
|
|
126
|
+
navigator?: LumaNavigation;
|
|
127
|
+
/** @internal Host-provided values used by the WordPress plugin. */
|
|
128
|
+
host?: {
|
|
129
|
+
chatEndpoint?: string;
|
|
130
|
+
siteContext?: SiteContext;
|
|
131
|
+
landmarks?: Landmark[];
|
|
132
|
+
restricted?: boolean;
|
|
133
|
+
policy?: SitePolicy;
|
|
134
|
+
storageScope?: string;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Adds the Luma assistant to every page below it and enables useLuma, useLumaContext and
|
|
139
|
+
* useLumaAction. Place it once, near the root of your app.
|
|
140
|
+
*/
|
|
141
|
+
declare function LumaProvider(props: LumaProviderProps): import("react").JSX.Element;
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/core/controller.d.ts
|
|
144
|
+
type LumaStatus = "connecting" | "ready" | "busy" | "error" | "disabled";
|
|
145
|
+
type LumaState = {
|
|
146
|
+
isOpen: boolean;
|
|
147
|
+
status: LumaStatus;
|
|
148
|
+
};
|
|
149
|
+
type LumaActionHandler<Input = unknown> = (input: Input) => unknown | Promise<unknown>;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/hooks.d.ts
|
|
152
|
+
/** Control the assistant from your own UI, e.g. an "Ask about this product" button. */
|
|
153
|
+
declare function useLuma(): {
|
|
154
|
+
isOpen: boolean;
|
|
155
|
+
status: LumaStatus;
|
|
156
|
+
open: () => void;
|
|
157
|
+
close: () => void;
|
|
158
|
+
toggle: () => void;
|
|
159
|
+
/** Opens the chat and sends text. Returns false while a reply is in progress. */
|
|
160
|
+
ask: (text: string) => boolean;
|
|
161
|
+
newChat: () => void | undefined;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Share structured state of the current page with the assistant (included when it inspects
|
|
165
|
+
* the page). Keep it small and free of secrets; it leaves the browser.
|
|
166
|
+
*/
|
|
167
|
+
declare function useLumaContext(name: string, value: unknown): void;
|
|
168
|
+
/**
|
|
169
|
+
* Let the assistant run an action on this page. The handler receives validated input; its
|
|
170
|
+
* JSON-serializable return value is reported to the assistant. Define the action at module
|
|
171
|
+
* level with defineAction so its identity is stable.
|
|
172
|
+
*/
|
|
173
|
+
declare function useLumaAction<Input>(definition: LumaActionDefinition<Input>, handler: LumaActionHandler<Input>): void;
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/markers.d.ts
|
|
176
|
+
/** Content inside is invisible to the assistant: never read, never targeted by guides. */
|
|
177
|
+
declare function LumaPrivate(props: HTMLAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/core/markers.d.ts
|
|
180
|
+
/** Name an unlabeled section so the assistant can find it and guide visitors to it. */
|
|
181
|
+
declare const lumaLabel: (label: string) => {
|
|
182
|
+
"data-luma-label": string;
|
|
183
|
+
};
|
|
184
|
+
/** Spread on an element whose content the assistant must never read. */
|
|
185
|
+
declare const lumaPrivate: () => {
|
|
186
|
+
"data-luma-private": string;
|
|
187
|
+
};
|
|
188
|
+
//#endregion
|
|
189
|
+
export { LumaProductQuery as _, useLumaAction as a, LumaState as c, LumaProviderProps as d, LumaNavigation as f, LumaProduct as g, LumaLink as h, useLuma as i, LumaStatus as l, LumaDataSources as m, lumaPrivate as n, useLumaContext as o, LumaDataSourceContext as p, LumaPrivate as r, LumaActionHandler as s, lumaLabel as t, LumaProvider as u, LumaSearchResult as v, LumaSiteInfo as y };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { i as defineAction, n as LumaServer, r as LumaActionDefinition, t as LumaAppearance } from "./config-CCT7m9eE.js";
|
|
2
|
+
import { _ as LumaProductQuery, a as useLumaAction, c as LumaState, d as LumaProviderProps, f as LumaNavigation, g as LumaProduct, h as LumaLink, i as useLuma, l as LumaStatus, m as LumaDataSources, n as lumaPrivate, o as useLumaContext, p as LumaDataSourceContext, r as LumaPrivate, s as LumaActionHandler, t as lumaLabel, u as LumaProvider, v as LumaSearchResult, y as LumaSiteInfo } from "./index-BdkoFDyP.js";
|
|
3
|
+
export { type LumaActionDefinition, type LumaActionHandler, type LumaAppearance, type LumaDataSourceContext, type LumaDataSources, type LumaLink, type LumaNavigation, LumaPrivate, type LumaProduct, type LumaProductQuery, LumaProvider, type LumaProviderProps, type LumaSearchResult, type LumaServer, type LumaSiteInfo, type LumaState, type LumaStatus, defineAction, lumaLabel, lumaPrivate, useLuma, useLumaAction, useLumaContext };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as useLumaAction, i as useLuma, l as defineAction, n as lumaPrivate, o as useLumaContext, r as LumaPrivate, s as LumaProvider, t as lumaLabel } from "./chunks/src-dnp1waFV.js";
|
|
3
|
+
export { LumaPrivate, LumaProvider, defineAction, lumaLabel, lumaPrivate, useLuma, useLumaAction, useLumaContext };
|
package/dist/next.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { i as defineAction, n as LumaServer, r as LumaActionDefinition, t as LumaAppearance } from "./config-CCT7m9eE.js";
|
|
2
|
+
import { _ as LumaProductQuery, a as useLumaAction, c as LumaState, d as LumaProviderProps, f as LumaNavigation, g as LumaProduct, h as LumaLink, i as useLuma, l as LumaStatus, m as LumaDataSources, n as lumaPrivate, o as useLumaContext, p as LumaDataSourceContext, r as LumaPrivate, s as LumaActionHandler, t as lumaLabel, v as LumaSearchResult, y as LumaSiteInfo } from "./index-BdkoFDyP.js";
|
|
3
|
+
//#region src/next.d.ts
|
|
4
|
+
/** LumaProvider for the Next.js App Router: navigation and guides use client-side routing. */
|
|
5
|
+
export declare function LumaProvider(props: Omit<LumaProviderProps, "navigator">): import("react").JSX.Element;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type LumaActionDefinition, type LumaActionHandler, type LumaAppearance, type LumaDataSourceContext, type LumaDataSources, type LumaLink, type LumaNavigation, LumaPrivate, type LumaProduct, type LumaProductQuery, type LumaProviderProps, type LumaSearchResult, type LumaServer, type LumaSiteInfo, type LumaState, type LumaStatus, defineAction, lumaLabel, lumaPrivate, useLuma, useLumaAction, useLumaContext };
|
package/dist/next.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as useLumaAction, c as routerPath, i as useLuma, l as defineAction, n as lumaPrivate, o as useLumaContext, r as LumaPrivate, s as LumaProvider$1, t as lumaLabel } from "./chunks/src-dnp1waFV.js";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useRouter } from "next/navigation";
|
|
6
|
+
//#region src/next.tsx
|
|
7
|
+
var basePath = typeof process !== "undefined" && process.env.__NEXT_ROUTER_BASEPATH || "";
|
|
8
|
+
/** LumaProvider for the Next.js App Router: navigation and guides use client-side routing. */
|
|
9
|
+
function LumaProvider(props) {
|
|
10
|
+
const router = useRouter();
|
|
11
|
+
const navigator = useMemo(() => ({
|
|
12
|
+
client: true,
|
|
13
|
+
navigate: (url) => router.push(routerPath(url, basePath))
|
|
14
|
+
}), [router]);
|
|
15
|
+
return /* @__PURE__ */ jsx(LumaProvider$1, {
|
|
16
|
+
...props,
|
|
17
|
+
navigator
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { LumaPrivate, LumaProvider, defineAction, lumaLabel, lumaPrivate, useLuma, useLumaAction, useLumaContext };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=next.js.map
|
package/dist/next.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.js","names":["BaseProvider"],"sources":["../src/next.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useRouter } from \"next/navigation\";\nimport { LumaProvider as BaseProvider, type LumaProviderProps } from \"./provider\";\nimport { routerPath, type LumaNavigation } from \"./core/navigation\";\n\n// Library entry: re-export the full client API next to the router-aware provider.\n// oxlint-disable-next-line react/only-export-components\nexport * from \"./index\";\n\n// Next inlines its configured basePath here; router.push adds it back.\nconst basePath =\n (typeof process !== \"undefined\" && process.env.__NEXT_ROUTER_BASEPATH) || \"\";\n\n/** LumaProvider for the Next.js App Router: navigation and guides use client-side routing. */\nexport function LumaProvider(props: Omit<LumaProviderProps, \"navigator\">) {\n const router = useRouter();\n const navigator = useMemo<LumaNavigation>(\n () => ({ client: true, navigate: (url) => router.push(routerPath(url, basePath)) }),\n [router],\n );\n return <BaseProvider {...props} navigator={navigator} />;\n}\n"],"mappings":";;;;;;AAUA,IAAM,WACH,OAAO,YAAY,eAAe,QAAQ,IAAI,0BAA2B;;AAG5E,SAAgB,aAAa,OAA6C;CACxE,MAAM,SAAS,UAAU;CACzB,MAAM,YAAY,eACT;EAAE,QAAQ;EAAM,WAAW,QAAQ,OAAO,KAAK,WAAW,KAAK,QAAQ,CAAC;CAAE,IACjF,CAAC,MAAM,CACT;CACA,OAAO,oBAACA,gBAAD;EAAc,GAAI;EAAkB;CAAY,CAAA;AACzD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { i as defineAction, n as LumaServer, r as LumaActionDefinition, t as LumaAppearance } from "./config-CCT7m9eE.js";
|
|
2
|
+
import { _ as LumaProductQuery, a as useLumaAction, c as LumaState, d as LumaProviderProps, f as LumaNavigation, g as LumaProduct, h as LumaLink, i as useLuma, l as LumaStatus, m as LumaDataSources, n as lumaPrivate, o as useLumaContext, p as LumaDataSourceContext, r as LumaPrivate, s as LumaActionHandler, t as lumaLabel, v as LumaSearchResult, y as LumaSiteInfo } from "./index-BdkoFDyP.js";
|
|
3
|
+
//#region src/react-router.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* LumaProvider for React Router 7/8 (framework, data or declarative mode). Render it inside
|
|
6
|
+
* the router, e.g. in the root route component.
|
|
7
|
+
*/
|
|
8
|
+
export declare function LumaProvider(props: Omit<LumaProviderProps, "navigator">): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type LumaActionDefinition, type LumaActionHandler, type LumaAppearance, type LumaDataSourceContext, type LumaDataSources, type LumaLink, type LumaNavigation, LumaPrivate, type LumaProduct, type LumaProductQuery, type LumaProviderProps, type LumaSearchResult, type LumaServer, type LumaSiteInfo, type LumaState, type LumaStatus, defineAction, lumaLabel, lumaPrivate, useLuma, useLumaAction, useLumaContext };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as useLumaAction, c as routerPath, i as useLuma, l as defineAction, n as lumaPrivate, o as useLumaContext, r as LumaPrivate, s as LumaProvider$1, t as lumaLabel } from "./chunks/src-dnp1waFV.js";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useHref, useNavigate } from "react-router";
|
|
6
|
+
//#region src/react-router.tsx
|
|
7
|
+
/**
|
|
8
|
+
* LumaProvider for React Router 7/8 (framework, data or declarative mode). Render it inside
|
|
9
|
+
* the router, e.g. in the root route component.
|
|
10
|
+
*/
|
|
11
|
+
function LumaProvider(props) {
|
|
12
|
+
const navigate = useNavigate();
|
|
13
|
+
const basename = useHref("/");
|
|
14
|
+
const navigator = useMemo(() => ({
|
|
15
|
+
client: true,
|
|
16
|
+
navigate: (url) => void navigate(routerPath(url, basename))
|
|
17
|
+
}), [navigate, basename]);
|
|
18
|
+
return /* @__PURE__ */ jsx(LumaProvider$1, {
|
|
19
|
+
...props,
|
|
20
|
+
navigator
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { LumaPrivate, LumaProvider, defineAction, lumaLabel, lumaPrivate, useLuma, useLumaAction, useLumaContext };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=react-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-router.js","names":["BaseProvider"],"sources":["../src/react-router.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useHref, useNavigate } from \"react-router\";\nimport { LumaProvider as BaseProvider, type LumaProviderProps } from \"./provider\";\nimport { routerPath, type LumaNavigation } from \"./core/navigation\";\n\n// Library entry: re-export the full client API next to the router-aware provider.\n// oxlint-disable-next-line react/only-export-components\nexport * from \"./index\";\n\n/**\n * LumaProvider for React Router 7/8 (framework, data or declarative mode). Render it inside\n * the router, e.g. in the root route component.\n */\nexport function LumaProvider(props: Omit<LumaProviderProps, \"navigator\">) {\n const navigate = useNavigate();\n // navigate() prepends the basename itself.\n const basename = useHref(\"/\");\n const navigator = useMemo<LumaNavigation>(\n () => ({ client: true, navigate: (url) => void navigate(routerPath(url, basename)) }),\n [navigate, basename],\n );\n return <BaseProvider {...props} navigator={navigator} />;\n}\n"],"mappings":";;;;;;;;;;AAaA,SAAgB,aAAa,OAA6C;CACxE,MAAM,WAAW,YAAY;CAE7B,MAAM,WAAW,QAAQ,GAAG;CAC5B,MAAM,YAAY,eACT;EAAE,QAAQ;EAAM,WAAW,QAAQ,KAAK,SAAS,WAAW,KAAK,QAAQ,CAAC;CAAE,IACnF,CAAC,UAAU,QAAQ,CACrB;CACA,OAAO,oBAACA,gBAAD;EAAc,GAAI;EAAkB;CAAY,CAAA;AACzD"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { i as defineAction, n as LumaServer, r as LumaActionDefinition, s as SiteToolName } from "./config-CCT7m9eE.js";
|
|
2
|
+
//#region src/server.d.ts
|
|
3
|
+
export type LumaSessionHandlerOptions = {
|
|
4
|
+
/** Luma API key. Keep it in a server-only environment variable. */
|
|
5
|
+
apiKey: string;
|
|
6
|
+
assistantId: string;
|
|
7
|
+
/** Luma API host: "internal" (ir.lumai.ir, default) or "direct" (dash.lumai.ir). */
|
|
8
|
+
server?: LumaServer;
|
|
9
|
+
/** Overrides the API base URL this server calls, e.g. for local development. */
|
|
10
|
+
apiBaseUrl?: string;
|
|
11
|
+
/** API base URL visitors' browsers use for chat, when it differs from apiBaseUrl. */
|
|
12
|
+
browserApiBaseUrl?: string;
|
|
13
|
+
/** Public site URL. Defaults to the request's host; set it behind proxies that rewrite Host. */
|
|
14
|
+
siteUrl?: string;
|
|
15
|
+
/** Owner allowlist of assistant tools. Defaults to all; the page requests what it can run. */
|
|
16
|
+
capabilities?: SiteToolName[];
|
|
17
|
+
/** Actions the assistant may propose; pages run them with useLumaAction. */
|
|
18
|
+
actions?: LumaActionDefinition[];
|
|
19
|
+
/**
|
|
20
|
+
* Your own visitor check or rate limit. Return false (403) or a Response to reject.
|
|
21
|
+
* Sessions spend this assistant's credits, so limit them per visitor in production.
|
|
22
|
+
*/
|
|
23
|
+
authorize?: (request: Request) => boolean | Response | Promise<boolean | Response>;
|
|
24
|
+
fetch?: typeof fetch;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Creates the POST handler that starts visitor sessions for LumaProvider's sessionEndpoint.
|
|
28
|
+
* It uses the Fetch API, so it works as a Next.js route handler, a TanStack Start server
|
|
29
|
+
* route, a React Router action, or in any runtime with Request/Response.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createLumaSessionHandler(options: LumaSessionHandlerOptions): (request: Request) => Promise<Response>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { type LumaActionDefinition, defineAction };
|