🚸 (share) Use custom domain host when possible in embed instruction
Closes #464
This commit is contained in:
@ -2,6 +2,7 @@ import { CodeEditor } from '@/components/inputs/CodeEditor'
|
|||||||
import { TextLink } from '@/components/TextLink'
|
import { TextLink } from '@/components/TextLink'
|
||||||
import { useEditor } from '@/features/editor/providers/EditorProvider'
|
import { useEditor } from '@/features/editor/providers/EditorProvider'
|
||||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
|
import { parseApiHost } from '@/features/publish/components/embeds/snippetParsers'
|
||||||
import {
|
import {
|
||||||
Code,
|
Code,
|
||||||
ListItem,
|
ListItem,
|
||||||
@ -10,7 +11,6 @@ import {
|
|||||||
StackProps,
|
StackProps,
|
||||||
Text,
|
Text,
|
||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import { env, getViewerUrl } from '@typebot.io/lib'
|
|
||||||
|
|
||||||
export const ApiPreviewInstructions = (props: StackProps) => {
|
export const ApiPreviewInstructions = (props: StackProps) => {
|
||||||
const { typebot } = useTypebot()
|
const { typebot } = useTypebot()
|
||||||
@ -60,9 +60,9 @@ export const ApiPreviewInstructions = (props: StackProps) => {
|
|||||||
<CodeEditor
|
<CodeEditor
|
||||||
isReadOnly
|
isReadOnly
|
||||||
lang={'shell'}
|
lang={'shell'}
|
||||||
value={`${
|
value={`${parseApiHost(
|
||||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
typebot?.customDomain
|
||||||
}/api/v1/sendMessage`}
|
)}/api/v1/sendMessage`}
|
||||||
/>
|
/>
|
||||||
<Text>with the following JSON body:</Text>
|
<Text>with the following JSON body:</Text>
|
||||||
<CodeEditor isReadOnly lang={'json'} value={startParamsBody} />
|
<CodeEditor isReadOnly lang={'json'} value={startParamsBody} />
|
||||||
@ -80,9 +80,9 @@ export const ApiPreviewInstructions = (props: StackProps) => {
|
|||||||
<CodeEditor
|
<CodeEditor
|
||||||
isReadOnly
|
isReadOnly
|
||||||
lang={'shell'}
|
lang={'shell'}
|
||||||
value={`${
|
value={`${parseApiHost(
|
||||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
typebot?.customDomain
|
||||||
}/api/v1/sendMessage`}
|
)}/api/v1/sendMessage`}
|
||||||
/>
|
/>
|
||||||
<Text>With the following JSON body:</Text>
|
<Text>With the following JSON body:</Text>
|
||||||
<CodeEditor isReadOnly lang={'json'} value={replyBody} />
|
<CodeEditor isReadOnly lang={'json'} value={replyBody} />
|
||||||
|
@ -16,8 +16,9 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
Stack,
|
Stack,
|
||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import { env, getViewerUrl } from '@typebot.io/lib'
|
|
||||||
import { ModalProps } from '../EmbedButton'
|
import { ModalProps } from '../EmbedButton'
|
||||||
|
import { parseApiHost } from '../snippetParsers/shared'
|
||||||
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
|
|
||||||
export const ApiModal = ({
|
export const ApiModal = ({
|
||||||
isPublished,
|
isPublished,
|
||||||
@ -25,6 +26,7 @@ export const ApiModal = ({
|
|||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
}: ModalProps): JSX.Element => {
|
}: ModalProps): JSX.Element => {
|
||||||
|
const { typebot } = useTypebot()
|
||||||
const startParamsBody = `{
|
const startParamsBody = `{
|
||||||
"startParams": {
|
"startParams": {
|
||||||
"typebot": "${publicId}",
|
"typebot": "${publicId}",
|
||||||
@ -57,9 +59,9 @@ export const ApiModal = ({
|
|||||||
<CodeEditor
|
<CodeEditor
|
||||||
isReadOnly
|
isReadOnly
|
||||||
lang={'shell'}
|
lang={'shell'}
|
||||||
value={`${
|
value={`${parseApiHost(
|
||||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
typebot?.customDomain
|
||||||
}/api/v1/sendMessage`}
|
)}/api/v1/sendMessage`}
|
||||||
/>
|
/>
|
||||||
<Text>with the following JSON body:</Text>
|
<Text>with the following JSON body:</Text>
|
||||||
<CodeEditor isReadOnly lang={'json'} value={startParamsBody} />
|
<CodeEditor isReadOnly lang={'json'} value={startParamsBody} />
|
||||||
@ -77,9 +79,9 @@ export const ApiModal = ({
|
|||||||
<CodeEditor
|
<CodeEditor
|
||||||
isReadOnly
|
isReadOnly
|
||||||
lang={'shell'}
|
lang={'shell'}
|
||||||
value={`${
|
value={`${parseApiHost(
|
||||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
typebot?.customDomain
|
||||||
}/api/v1/sendMessage`}
|
)}/api/v1/sendMessage`}
|
||||||
/>
|
/>
|
||||||
<Text>With the following JSON body:</Text>
|
<Text>With the following JSON body:</Text>
|
||||||
<CodeEditor isReadOnly lang={'json'} value={replyBody} />
|
<CodeEditor isReadOnly lang={'json'} value={replyBody} />
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import prettier from 'prettier/standalone'
|
import prettier from 'prettier/standalone'
|
||||||
import parserHtml from 'prettier/parser-html'
|
import parserHtml from 'prettier/parser-html'
|
||||||
import { parseInitBubbleCode, typebotImportCode } from '../../snippetParsers'
|
import {
|
||||||
|
parseApiHost,
|
||||||
|
parseInitBubbleCode,
|
||||||
|
typebotImportCode,
|
||||||
|
} from '../../snippetParsers'
|
||||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
||||||
import { BubbleProps } from '@typebot.io/js'
|
import { BubbleProps } from '@typebot.io/js'
|
||||||
import { env, getViewerUrl } from '@typebot.io/lib'
|
|
||||||
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
|
||||||
|
|
||||||
type Props = Pick<BubbleProps, 'theme' | 'previewMessage'>
|
type Props = Pick<BubbleProps, 'theme' | 'previewMessage'>
|
||||||
|
|
||||||
@ -17,9 +19,7 @@ export const JavascriptBubbleSnippet = ({ theme, previewMessage }: Props) => {
|
|||||||
|
|
||||||
${parseInitBubbleCode({
|
${parseInitBubbleCode({
|
||||||
typebot: typebot?.publicId ?? '',
|
typebot: typebot?.publicId ?? '',
|
||||||
apiHost: isCloudProdInstance
|
apiHost: parseApiHost(typebot?.customDomain),
|
||||||
? undefined
|
|
||||||
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
|
|
||||||
theme: {
|
theme: {
|
||||||
...theme,
|
...theme,
|
||||||
chatWindow: {
|
chatWindow: {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
import parserHtml from 'prettier/parser-html'
|
import parserHtml from 'prettier/parser-html'
|
||||||
import prettier from 'prettier/standalone'
|
import prettier from 'prettier/standalone'
|
||||||
import { parseInitPopupCode, typebotImportCode } from '../../snippetParsers'
|
import {
|
||||||
|
parseApiHost,
|
||||||
|
parseInitPopupCode,
|
||||||
|
typebotImportCode,
|
||||||
|
} from '../../snippetParsers'
|
||||||
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
||||||
import { PopupProps } from '@typebot.io/js'
|
import { PopupProps } from '@typebot.io/js'
|
||||||
import { env, getViewerUrl } from '@typebot.io/lib'
|
|
||||||
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
|
||||||
|
|
||||||
type Props = Pick<PopupProps, 'autoShowDelay'>
|
type Props = Pick<PopupProps, 'autoShowDelay'>
|
||||||
|
|
||||||
@ -14,9 +16,7 @@ export const JavascriptPopupSnippet = ({ autoShowDelay }: Props) => {
|
|||||||
const snippet = prettier.format(
|
const snippet = prettier.format(
|
||||||
createSnippet({
|
createSnippet({
|
||||||
typebot: typebot?.publicId ?? '',
|
typebot: typebot?.publicId ?? '',
|
||||||
apiHost: isCloudProdInstance
|
apiHost: parseApiHost(typebot?.customDomain),
|
||||||
? undefined
|
|
||||||
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
|
|
||||||
autoShowDelay,
|
autoShowDelay,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import parserHtml from 'prettier/parser-html'
|
import parserHtml from 'prettier/parser-html'
|
||||||
import prettier from 'prettier/standalone'
|
import prettier from 'prettier/standalone'
|
||||||
import { parseInitStandardCode, typebotImportCode } from '../../snippetParsers'
|
import {
|
||||||
|
parseApiHost,
|
||||||
|
parseInitStandardCode,
|
||||||
|
typebotImportCode,
|
||||||
|
} from '../../snippetParsers'
|
||||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
||||||
import { env, getViewerUrl } from '@typebot.io/lib'
|
|
||||||
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
widthLabel?: string
|
widthLabel?: string
|
||||||
@ -18,7 +20,7 @@ export const JavascriptStandardSnippet = ({
|
|||||||
const { typebot } = useTypebot()
|
const { typebot } = useTypebot()
|
||||||
|
|
||||||
const snippet = prettier.format(
|
const snippet = prettier.format(
|
||||||
`${parseStandardHeadCode(typebot?.publicId)}
|
`${parseStandardHeadCode(typebot?.publicId, typebot?.customDomain)}
|
||||||
${parseStandardElementCode(widthLabel, heightLabel)}`,
|
${parseStandardElementCode(widthLabel, heightLabel)}`,
|
||||||
{
|
{
|
||||||
parser: 'html',
|
parser: 'html',
|
||||||
@ -29,15 +31,16 @@ export const JavascriptStandardSnippet = ({
|
|||||||
return <CodeEditor value={snippet} lang="html" isReadOnly />
|
return <CodeEditor value={snippet} lang="html" isReadOnly />
|
||||||
}
|
}
|
||||||
|
|
||||||
export const parseStandardHeadCode = (publicId?: string | null) =>
|
export const parseStandardHeadCode = (
|
||||||
|
publicId?: string | null,
|
||||||
|
customDomain?: string | null
|
||||||
|
) =>
|
||||||
prettier.format(
|
prettier.format(
|
||||||
`<script type="module">${typebotImportCode};
|
`<script type="module">${typebotImportCode};
|
||||||
|
|
||||||
${parseInitStandardCode({
|
${parseInitStandardCode({
|
||||||
typebot: publicId ?? '',
|
typebot: publicId ?? '',
|
||||||
apiHost: isCloudProdInstance
|
apiHost: parseApiHost(customDomain),
|
||||||
? undefined
|
|
||||||
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
|
|
||||||
})}</script>`,
|
})}</script>`,
|
||||||
{ parser: 'html', plugins: [parserHtml] }
|
{ parser: 'html', plugins: [parserHtml] }
|
||||||
)
|
)
|
||||||
|
@ -4,14 +4,13 @@ import { Stack, Text } from '@chakra-ui/react'
|
|||||||
import { BubbleProps } from '@typebot.io/js'
|
import { BubbleProps } from '@typebot.io/js'
|
||||||
import { Typebot } from '@typebot.io/schemas'
|
import { Typebot } from '@typebot.io/schemas'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { env, getViewerUrl } from '@typebot.io/lib'
|
|
||||||
import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings'
|
import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings'
|
||||||
import {
|
import {
|
||||||
parseInlineScript,
|
parseInlineScript,
|
||||||
parseInitBubbleCode,
|
parseInitBubbleCode,
|
||||||
typebotImportCode,
|
typebotImportCode,
|
||||||
|
parseApiHost,
|
||||||
} from '../../../snippetParsers'
|
} from '../../../snippetParsers'
|
||||||
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
|
||||||
|
|
||||||
export const parseDefaultBubbleTheme = (typebot?: Typebot) => ({
|
export const parseDefaultBubbleTheme = (typebot?: Typebot) => ({
|
||||||
button: {
|
button: {
|
||||||
@ -37,9 +36,7 @@ export const ScriptBubbleInstructions = () => {
|
|||||||
|
|
||||||
${parseInitBubbleCode({
|
${parseInitBubbleCode({
|
||||||
typebot: typebot?.publicId ?? '',
|
typebot: typebot?.publicId ?? '',
|
||||||
apiHost: isCloudProdInstance
|
apiHost: parseApiHost(typebot?.customDomain),
|
||||||
? undefined
|
|
||||||
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
|
|
||||||
theme,
|
theme,
|
||||||
previewMessage,
|
previewMessage,
|
||||||
})}`
|
})}`
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
||||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
|
||||||
import { Stack, Text } from '@chakra-ui/react'
|
import { Stack, Text } from '@chakra-ui/react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { env, getViewerUrl } from '@typebot.io/lib'
|
|
||||||
import { PopupSettings } from '../../../settings/PopupSettings'
|
import { PopupSettings } from '../../../settings/PopupSettings'
|
||||||
import { parseInitPopupCode } from '../../../snippetParsers'
|
import { parseInitPopupCode } from '../../../snippetParsers'
|
||||||
import {
|
import {
|
||||||
|
parseApiHost,
|
||||||
parseInlineScript,
|
parseInlineScript,
|
||||||
typebotImportCode,
|
typebotImportCode,
|
||||||
} from '../../../snippetParsers/shared'
|
} from '../../../snippetParsers/shared'
|
||||||
@ -20,9 +19,7 @@ export const ScriptPopupInstructions = () => {
|
|||||||
|
|
||||||
${parseInitPopupCode({
|
${parseInitPopupCode({
|
||||||
typebot: typebot?.publicId ?? '',
|
typebot: typebot?.publicId ?? '',
|
||||||
apiHost: isCloudProdInstance
|
apiHost: parseApiHost(typebot?.customDomain),
|
||||||
? undefined
|
|
||||||
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
|
|
||||||
autoShowDelay: inputValue,
|
autoShowDelay: inputValue,
|
||||||
})}`
|
})}`
|
||||||
)
|
)
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
||||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
|
||||||
import { Stack, Code, Text } from '@chakra-ui/react'
|
import { Stack, Code, Text } from '@chakra-ui/react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { env, getViewerUrl } from '@typebot.io/lib'
|
|
||||||
import { StandardSettings } from '../../../settings/StandardSettings'
|
import { StandardSettings } from '../../../settings/StandardSettings'
|
||||||
import { parseInitStandardCode } from '../../../snippetParsers/standard'
|
import { parseInitStandardCode } from '../../../snippetParsers/standard'
|
||||||
import { parseStandardElementCode } from '../../Javascript/JavascriptStandardSnippet'
|
import { parseStandardElementCode } from '../../Javascript/JavascriptStandardSnippet'
|
||||||
import {
|
import {
|
||||||
|
parseApiHost,
|
||||||
parseInlineScript,
|
parseInlineScript,
|
||||||
typebotImportCode,
|
typebotImportCode,
|
||||||
} from '../../../snippetParsers/shared'
|
} from '../../../snippetParsers/shared'
|
||||||
@ -31,9 +30,7 @@ export const ScriptStandardInstructions = () => {
|
|||||||
|
|
||||||
${parseInitStandardCode({
|
${parseInitStandardCode({
|
||||||
typebot: typebot?.publicId ?? '',
|
typebot: typebot?.publicId ?? '',
|
||||||
apiHost: isCloudProdInstance
|
apiHost: parseApiHost(typebot?.customDomain),
|
||||||
? undefined
|
|
||||||
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
|
|
||||||
})}`)
|
})}`)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -12,10 +12,8 @@ import {
|
|||||||
import { BubbleProps } from '@typebot.io/js'
|
import { BubbleProps } from '@typebot.io/js'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings'
|
import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings'
|
||||||
import { parseInitBubbleCode } from '../../../snippetParsers'
|
import { parseApiHost, parseInitBubbleCode } from '../../../snippetParsers'
|
||||||
import { parseDefaultBubbleTheme } from '../../Javascript/instructions/JavascriptBubbleInstructions'
|
import { parseDefaultBubbleTheme } from '../../Javascript/instructions/JavascriptBubbleInstructions'
|
||||||
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
|
||||||
import { env, getViewerUrl } from '@typebot.io/lib'
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
publicId: string
|
publicId: string
|
||||||
@ -31,9 +29,7 @@ export const WordpressBubbleInstructions = ({ publicId }: Props) => {
|
|||||||
|
|
||||||
const initCode = parseInitBubbleCode({
|
const initCode = parseInitBubbleCode({
|
||||||
typebot: publicId,
|
typebot: publicId,
|
||||||
apiHost: isCloudProdInstance
|
apiHost: parseApiHost(typebot?.customDomain),
|
||||||
? undefined
|
|
||||||
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
|
|
||||||
theme: {
|
theme: {
|
||||||
...theme,
|
...theme,
|
||||||
chatWindow: {
|
chatWindow: {
|
||||||
|
@ -11,20 +11,21 @@ import {
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { PopupSettings } from '../../../settings/PopupSettings'
|
import { PopupSettings } from '../../../settings/PopupSettings'
|
||||||
import { parseInitPopupCode } from '../../../snippetParsers/popup'
|
import { parseInitPopupCode } from '../../../snippetParsers/popup'
|
||||||
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
import { parseApiHost } from '../../../snippetParsers'
|
||||||
import { env, getViewerUrl } from '@typebot.io/lib'
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
publicId: string
|
publicId: string
|
||||||
|
customDomain?: string
|
||||||
}
|
}
|
||||||
export const WordpressPopupInstructions = ({ publicId }: Props) => {
|
export const WordpressPopupInstructions = ({
|
||||||
|
publicId,
|
||||||
|
customDomain,
|
||||||
|
}: Props) => {
|
||||||
const [autoShowDelay, setAutoShowDelay] = useState<number>()
|
const [autoShowDelay, setAutoShowDelay] = useState<number>()
|
||||||
|
|
||||||
const initCode = parseInitPopupCode({
|
const initCode = parseInitPopupCode({
|
||||||
typebot: publicId,
|
typebot: publicId,
|
||||||
apiHost: isCloudProdInstance
|
apiHost: parseApiHost(customDomain),
|
||||||
? undefined
|
|
||||||
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
|
|
||||||
autoShowDelay,
|
autoShowDelay,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import { BotProps } from '@typebot.io/js'
|
import { BotProps } from '@typebot.io/js'
|
||||||
import parserBabel from 'prettier/parser-babel'
|
import parserBabel from 'prettier/parser-babel'
|
||||||
import prettier from 'prettier/standalone'
|
import prettier from 'prettier/standalone'
|
||||||
import { isDefined } from '@typebot.io/lib'
|
import { env, getViewerUrl, isDefined } from '@typebot.io/lib'
|
||||||
|
import { Typebot } from '@typebot.io/schemas'
|
||||||
|
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
||||||
|
import packageJson from '../../../../../../../../packages/embeds/js/package.json'
|
||||||
|
|
||||||
export const parseStringParam = (fieldName: string, fieldValue?: string) =>
|
export const parseStringParam = (fieldName: string, fieldValue?: string) =>
|
||||||
fieldValue ? `${fieldName}: "${fieldValue}",` : ``
|
fieldValue ? `${fieldName}: "${fieldValue}",` : ``
|
||||||
@ -31,7 +34,9 @@ export const parseReactBotProps = ({ typebot, apiHost }: BotProps) => {
|
|||||||
return `${typebotLine} ${apiHostLine}`
|
return `${typebotLine} ${apiHostLine}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export const typebotImportCode = `import Typebot from 'https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0/dist/web.js'`
|
export const typebotImportCode = isCloudProdInstance
|
||||||
|
? `import Typebot from 'https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0/dist/web.js'`
|
||||||
|
: `import Typebot from 'https://cdn.jsdelivr.net/npm/@typebot.io/js@${packageJson.version}/dist/web.js'`
|
||||||
|
|
||||||
export const parseInlineScript = (script: string) =>
|
export const parseInlineScript = (script: string) =>
|
||||||
prettier.format(
|
prettier.format(
|
||||||
@ -41,3 +46,12 @@ export const parseInlineScript = (script: string) =>
|
|||||||
document.body.append(typebotInitScript);`,
|
document.body.append(typebotInitScript);`,
|
||||||
{ parser: 'babel', plugins: [parserBabel] }
|
{ parser: 'babel', plugins: [parserBabel] }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
export const parseApiHost = (
|
||||||
|
customDomain: Typebot['customDomain'] | undefined
|
||||||
|
) => {
|
||||||
|
if (customDomain) return new URL(`https://${customDomain}`).origin
|
||||||
|
return isCloudProdInstance
|
||||||
|
? undefined
|
||||||
|
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
||||||
|
}
|
||||||
|
@ -1614,6 +1614,9 @@
|
|||||||
},
|
},
|
||||||
"isCode": {
|
"isCode": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"isExecutedOnClient": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
@ -1275,6 +1275,9 @@
|
|||||||
},
|
},
|
||||||
"isCode": {
|
"isCode": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"isExecutedOnClient": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
@ -3820,92 +3823,171 @@
|
|||||||
{
|
{
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "object",
|
"anyOf": [
|
||||||
"properties": {
|
{
|
||||||
"scriptToExecute": {
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"content": {
|
"scriptToExecute": {
|
||||||
"type": "string"
|
"type": "object",
|
||||||
},
|
"properties": {
|
||||||
"args": {
|
"content": {
|
||||||
"type": "array",
|
"type": "string"
|
||||||
"items": {
|
},
|
||||||
"type": "object",
|
"args": {
|
||||||
"properties": {
|
"type": "array",
|
||||||
"id": {
|
"items": {
|
||||||
"type": "string"
|
"type": "object",
|
||||||
},
|
"properties": {
|
||||||
"value": {
|
"id": {
|
||||||
"anyOf": [
|
"type": "string"
|
||||||
{
|
},
|
||||||
|
"value": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "string"
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "number"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean"
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"nullable": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
},
|
"nullable": true
|
||||||
{
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id"
|
||||||
],
|
],
|
||||||
"nullable": true
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"required": [
|
},
|
||||||
"id"
|
"required": [
|
||||||
],
|
"content",
|
||||||
"additionalProperties": false
|
"args"
|
||||||
}
|
],
|
||||||
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"content",
|
"scriptToExecute"
|
||||||
"args"
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"redirect": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"url": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"isNewTab": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"isNewTab"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"redirect"
|
||||||
],
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
]
|
||||||
"required": [
|
|
||||||
"scriptToExecute"
|
|
||||||
],
|
|
||||||
"additionalProperties": false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"redirect": {
|
"chatwoot": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"url": {
|
"scriptToExecute": {
|
||||||
"type": "string"
|
"type": "object",
|
||||||
},
|
"properties": {
|
||||||
"isNewTab": {
|
"content": {
|
||||||
"type": "boolean"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"args": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"nullable": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nullable": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"content",
|
||||||
|
"args"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"isNewTab"
|
"scriptToExecute"
|
||||||
],
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"redirect"
|
"chatwoot"
|
||||||
],
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
@ -3914,75 +3996,30 @@
|
|||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"chatwoot": {
|
"googleAnalytics": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"scriptToExecute": {
|
"trackingId": {
|
||||||
"type": "object",
|
"type": "string"
|
||||||
"properties": {
|
},
|
||||||
"content": {
|
"category": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"args": {
|
"action": {
|
||||||
"type": "array",
|
"type": "string"
|
||||||
"items": {
|
},
|
||||||
"type": "object",
|
"label": {
|
||||||
"properties": {
|
"type": "string"
|
||||||
"id": {
|
},
|
||||||
"type": "string"
|
"value": {
|
||||||
},
|
"type": "number"
|
||||||
"value": {
|
|
||||||
"anyOf": [
|
|
||||||
{
|
|
||||||
"anyOf": [
|
|
||||||
{
|
|
||||||
"anyOf": [
|
|
||||||
{
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "number"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"nullable": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"additionalProperties": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"content",
|
|
||||||
"args"
|
|
||||||
],
|
|
||||||
"additionalProperties": false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
|
||||||
"scriptToExecute"
|
|
||||||
],
|
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"chatwoot"
|
"googleAnalytics"
|
||||||
],
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
@ -3991,30 +4028,21 @@
|
|||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"googleAnalytics": {
|
"wait": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"trackingId": {
|
"secondsToWaitFor": {
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"category": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"action": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"label": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"required": [
|
||||||
|
"secondsToWaitFor"
|
||||||
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"googleAnalytics"
|
"wait"
|
||||||
],
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
@ -4023,21 +4051,75 @@
|
|||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"wait": {
|
"setVariable": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"secondsToWaitFor": {
|
"scriptToExecute": {
|
||||||
"type": "number"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"content": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"args": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"nullable": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nullable": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"content",
|
||||||
|
"args"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"secondsToWaitFor"
|
"scriptToExecute"
|
||||||
],
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"wait"
|
"setVariable"
|
||||||
],
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.0.36",
|
"version": "0.0.37",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.0.36",
|
"version": "0.0.37",
|
||||||
"description": "React library to display typebots on your website",
|
"description": "React library to display typebots on your website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
Reference in New Issue
Block a user