@robylon/react-native-sdk 2.0.21-dev.2 → 2.0.21-staging.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/.npmignore.development +18 -0
- package/.npmignore.production +8 -0
- package/.npmignore.staging +7 -0
- package/babel.config.js +17 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/versions/version.staging.js +1 -1
- package/lib/commonjs/versions/version.staging.js.map +1 -1
- package/lib/module/openChatbot.js +1 -2
- package/lib/module/openChatbot.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/versions/version.staging.js +1 -1
- package/lib/module/versions/version.staging.js.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/lib/typescript/versions/version.staging.d.ts +1 -1
- package/lib/typescript/versions/version.staging.d.ts.map +1 -1
- package/package.json +3 -3
- package/scripts/create-branch.js +577 -0
- package/scripts/create-version-tag.js +29 -0
- package/scripts/get-next-version.js +29 -0
- package/scripts/husky-setup.js +32 -0
- package/scripts/prevent-direct-branch.js +37 -0
- package/scripts/publish-version.js +13 -0
- package/scripts/release.js +77 -0
- package/scripts/setup-git-hooks.js +18 -0
- package/scripts/update-version.js +28 -0
- package/scripts/validate-branch-name.sh +65 -0
- package/scripts/validate-publish.js +48 -0
- package/src/ChatbotWebview.tsx +44 -0
- package/src/Chatbotsdk.tsx +775 -0
- package/src/FloatingButton.tsx +88 -0
- package/src/LoadingIndicator.tsx +11 -0
- package/src/Toast.tsx +65 -0
- package/src/components/DebugButton.tsx +46 -0
- package/src/components/ErrorBoundary.tsx +38 -0
- package/src/config.ts +4 -0
- package/src/constants/errorConstants.ts +21 -0
- package/src/constants.ts +4 -0
- package/src/global.d.ts +11 -0
- package/src/hooks/useChatbotEvents.ts +93 -0
- package/src/index.tsx +10 -0
- package/src/openChatbot.ts +11 -0
- package/src/openChatbot.tsx +0 -0
- package/src/services/ErrorTrackingService.ts +217 -0
- package/src/types/events.ts +25 -0
- package/src/types/react-native-flipper-performance-plugin.d.ts +3 -0
- package/src/types/react-native-globals.d.ts +10 -0
- package/src/utils/cookieUtils.ts +7 -0
- package/src/utils/debugConfig.ts +56 -0
- package/src/utils/debugMenu.ts +14 -0
- package/src/utils/errorHandler.ts +58 -0
- package/src/utils/logger.ts +14 -0
- package/src/utils/systemInfo.ts +84 -0
- package/src/utils/webViewStorage.ts +62 -0
- package/src/version.ts +2 -0
- package/src/versions/version.dev.ts +2 -0
- package/src/versions/version.production.ts +2 -0
- package/src/versions/version.staging.ts +2 -0
- package/tsconfig.build.json +16 -0
- package/tsconfig.json +26 -0
- package/usage/react-native-ios-docs.md +0 -185
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
|
|
3
|
+
// Get command line arguments passed by Git
|
|
4
|
+
// In post-checkout hook, Git passes 3 arguments:
|
|
5
|
+
// 1. Previous HEAD ref
|
|
6
|
+
// 2. New HEAD ref
|
|
7
|
+
// 3. Flag (1 for branch checkout, 0 for file checkout)
|
|
8
|
+
const [prevHead, newHead, checkoutFlag] = process.argv.slice(2);
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
// Get the current branch name
|
|
12
|
+
const currentBranch = execSync("git rev-parse --abbrev-ref HEAD")
|
|
13
|
+
.toString()
|
|
14
|
+
.trim();
|
|
15
|
+
|
|
16
|
+
// Only check for branch creation (when prevHead and newHead are different and checkoutFlag is 1)
|
|
17
|
+
const isBranchCreation = prevHead !== newHead && checkoutFlag === "1";
|
|
18
|
+
|
|
19
|
+
// Check if this was a direct branch creation
|
|
20
|
+
if (
|
|
21
|
+
isBranchCreation && // Only check actual branch creation
|
|
22
|
+
!currentBranch.includes("temp-version-update")
|
|
23
|
+
) {
|
|
24
|
+
// If we moved from one branch to a new one, it was likely created directly
|
|
25
|
+
if (!process.env.BRANCH_CREATION_ALLOWED) {
|
|
26
|
+
console.error("\n❌ Direct branch creation is not allowed.");
|
|
27
|
+
console.error("Please use: npm run branch");
|
|
28
|
+
console.error(
|
|
29
|
+
"This ensures proper version control and naming conventions."
|
|
30
|
+
);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} catch (error) {
|
|
35
|
+
// If we can't determine, let it pass
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
|
|
3
|
+
// Get current branch name
|
|
4
|
+
const branch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
|
|
5
|
+
|
|
6
|
+
// If we're on a release branch, don't increment version
|
|
7
|
+
if (branch.startsWith("release/v")) {
|
|
8
|
+
console.log("On release branch - skipping version increment");
|
|
9
|
+
process.exit(0);
|
|
10
|
+
} else {
|
|
11
|
+
// For other branches, increment patch version
|
|
12
|
+
execSync("npm version patch", { stdio: "inherit" });
|
|
13
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const readline = require("readline");
|
|
3
|
+
|
|
4
|
+
const rl = readline.createInterface({
|
|
5
|
+
input: process.stdin,
|
|
6
|
+
output: process.stdout,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const release = async () => {
|
|
10
|
+
try {
|
|
11
|
+
// 1. Validate current branch is a release branch
|
|
12
|
+
const currentBranch = execSync("git rev-parse --abbrev-ref HEAD")
|
|
13
|
+
.toString()
|
|
14
|
+
.trim();
|
|
15
|
+
|
|
16
|
+
if (!currentBranch.startsWith("release/v")) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"Release process must be started from a release branch.\n" +
|
|
19
|
+
`Current branch: ${currentBranch}\n` +
|
|
20
|
+
"Expected format: release/v{version}"
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 2. Check if version is already published
|
|
25
|
+
const version = currentBranch.split("/v")[1];
|
|
26
|
+
const publishedVersions = execSync(
|
|
27
|
+
"npm view @robylon/web-react-sdk versions --json"
|
|
28
|
+
).toString();
|
|
29
|
+
|
|
30
|
+
if (publishedVersions.includes(version)) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`Version ${version} is already published to npm.\n` +
|
|
33
|
+
"Please create a new release branch with a different version."
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 3. Confirm release process
|
|
38
|
+
console.log("\n📦 Starting release process for version", version);
|
|
39
|
+
console.log("\nThis will:");
|
|
40
|
+
console.log("1. Publish to npm");
|
|
41
|
+
console.log("2. Create git tag");
|
|
42
|
+
console.log("3. Merge to main");
|
|
43
|
+
|
|
44
|
+
const proceed = await new Promise((resolve) =>
|
|
45
|
+
rl.question("\nProceed with release? (y/N): ", resolve)
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (proceed.toLowerCase() !== "y") {
|
|
49
|
+
throw new Error("Release cancelled by user");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 4. Run publish
|
|
53
|
+
console.log("\n🚀 Publishing to npm...");
|
|
54
|
+
execSync("npm run publish:production", { stdio: "inherit" });
|
|
55
|
+
|
|
56
|
+
// 5. Merge to main
|
|
57
|
+
console.log("\n🔄 Merging to main...");
|
|
58
|
+
execSync("git checkout main");
|
|
59
|
+
execSync("git pull origin main");
|
|
60
|
+
execSync(
|
|
61
|
+
`git merge ${currentBranch} --no-ff -m "chore: release version ${version}"`
|
|
62
|
+
);
|
|
63
|
+
execSync("git push origin main");
|
|
64
|
+
|
|
65
|
+
console.log("\n✅ Release completed successfully!");
|
|
66
|
+
console.log(`Version ${version} is now available on npm`);
|
|
67
|
+
console.log("Changes have been merged to main");
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error("\n❌ Release failed:");
|
|
70
|
+
console.error(error.message);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
} finally {
|
|
73
|
+
rl.close();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
release();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { execSync } = require("child_process");
|
|
4
|
+
|
|
5
|
+
// Create .git/hooks directory if it doesn't exist
|
|
6
|
+
const hooksDir = path.join(__dirname, "../.git/hooks");
|
|
7
|
+
if (!fs.existsSync(hooksDir)) {
|
|
8
|
+
fs.mkdirSync(hooksDir, { recursive: true });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Copy the validate-branch-name script
|
|
12
|
+
const sourcePath = path.join(__dirname, "validate-branch-name.sh");
|
|
13
|
+
const targetPath = path.join(hooksDir, "commit-msg");
|
|
14
|
+
|
|
15
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
16
|
+
fs.chmodSync(targetPath, "755");
|
|
17
|
+
|
|
18
|
+
console.log("Git hooks installed successfully!");
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
function updateVersion(env) {
|
|
5
|
+
const packageJson = require("../package.json");
|
|
6
|
+
const version = packageJson.version;
|
|
7
|
+
|
|
8
|
+
const content = `// This file is auto-generated. Do not modify it manually.
|
|
9
|
+
export const SDK_VERSION = '${version}';\n`;
|
|
10
|
+
|
|
11
|
+
const versionFile = path.join(__dirname, `../src/versions/version.${env}.ts`);
|
|
12
|
+
fs.writeFileSync(versionFile, content);
|
|
13
|
+
|
|
14
|
+
// Create/update the main version file that imports the correct version
|
|
15
|
+
const mainVersionContent = `// This file is auto-generated. Do not modify it manually.
|
|
16
|
+
export { SDK_VERSION } from './versions/version.${env}';\n`;
|
|
17
|
+
|
|
18
|
+
fs.writeFileSync(
|
|
19
|
+
path.join(__dirname, "../src/version.ts"),
|
|
20
|
+
mainVersionContent
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
console.log(`Updated ${env} SDK_VERSION to ${version}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Get environment from command line argument or default to 'staging'
|
|
27
|
+
const env = process.argv[2] || "staging";
|
|
28
|
+
updateVersion(env);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
echo "DEBUG: Script executed from: $0"
|
|
4
|
+
echo "DEBUG: PWD: $(pwd)"
|
|
5
|
+
|
|
6
|
+
# Get the full version including staging suffix if present
|
|
7
|
+
FULL_VERSION=$(node -p "require('./package.json').version")
|
|
8
|
+
|
|
9
|
+
# Check if this is a staging version before any other operations
|
|
10
|
+
if [[ $FULL_VERSION == *"-staging."* ]]; then
|
|
11
|
+
echo "Staging version detected. Skipping branch name validation."
|
|
12
|
+
exit 0
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
# Get base version without pre-release tags (e.g., 1.1.14 from 1.1.14-staging.0)
|
|
16
|
+
BASE_VERSION=$(echo $FULL_VERSION | cut -d'-' -f1)
|
|
17
|
+
|
|
18
|
+
# Get the branch name
|
|
19
|
+
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
|
|
20
|
+
|
|
21
|
+
# Get latest published version from npm
|
|
22
|
+
LATEST_VERSION=$(npm view @robylon/web-react-sdk version 2>/dev/null || echo "0.0.0")
|
|
23
|
+
|
|
24
|
+
# Regular expression for valid branch names
|
|
25
|
+
FEATURE_PATTERN="^feature/v[0-9]+\.[0-9]+\.[0-9]+/[a-z0-9-]+$"
|
|
26
|
+
RELEASE_PATTERN="^release/v${BASE_VERSION}$"
|
|
27
|
+
HOTFIX_PATTERN="^hotfix/v[0-9]+\.[0-9]+\.[0-9]+(-patch\.[0-9]+)?$"
|
|
28
|
+
|
|
29
|
+
echo "Validating branch: $BRANCH_NAME"
|
|
30
|
+
echo "Current version: $BASE_VERSION"
|
|
31
|
+
echo "Latest published version: $LATEST_VERSION"
|
|
32
|
+
|
|
33
|
+
# For release branches, ensure version matches branch exactly
|
|
34
|
+
if [[ $BRANCH_NAME =~ ^release/v ]]; then
|
|
35
|
+
# Extract version from branch name
|
|
36
|
+
BRANCH_VERSION=$(echo $BRANCH_NAME | sed 's/release\/v//')
|
|
37
|
+
|
|
38
|
+
# Check if branch version matches package version
|
|
39
|
+
if [[ "$BRANCH_VERSION" != "$BASE_VERSION" ]]; then
|
|
40
|
+
echo "Error: Release branch version ($BRANCH_VERSION) must match package.json version ($BASE_VERSION)"
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Check if trying to publish a version behind latest
|
|
45
|
+
if [[ $(node -p "require('semver').lt('$BASE_VERSION', '$LATEST_VERSION')") == "true" ]]; then
|
|
46
|
+
echo "Error: Cannot publish version $BASE_VERSION as it is behind the latest published version $LATEST_VERSION"
|
|
47
|
+
exit 1
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
echo "✅ Valid release branch name and version"
|
|
51
|
+
exit 0
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# Validate other branch types
|
|
55
|
+
if [[ $BRANCH_NAME =~ $FEATURE_PATTERN ]] || [[ $BRANCH_NAME =~ $HOTFIX_PATTERN ]]; then
|
|
56
|
+
echo "✅ Valid branch name"
|
|
57
|
+
exit 0
|
|
58
|
+
else
|
|
59
|
+
echo "Error: Invalid branch name format."
|
|
60
|
+
echo "Branch names must follow these formats:"
|
|
61
|
+
echo "- For feature branches: feature/v{version}/{feature-name}"
|
|
62
|
+
echo "- For release branches: release/v{version}"
|
|
63
|
+
echo "- For hotfix branches: hotfix/v{version}-patch.{number}"
|
|
64
|
+
exit 1
|
|
65
|
+
fi
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
|
|
3
|
+
const validatePublish = () => {
|
|
4
|
+
try {
|
|
5
|
+
// Get current branch
|
|
6
|
+
const currentBranch = execSync("git rev-parse --abbrev-ref HEAD")
|
|
7
|
+
.toString()
|
|
8
|
+
.trim();
|
|
9
|
+
console.log("Validating branch:", currentBranch);
|
|
10
|
+
|
|
11
|
+
if (!currentBranch.startsWith("release/v")) {
|
|
12
|
+
throw new Error("Publishing is only allowed from release branches");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Get version from branch name
|
|
16
|
+
const branchVersion = currentBranch.split("/v")[1];
|
|
17
|
+
|
|
18
|
+
// Get version from package.json
|
|
19
|
+
const packageVersion = require("../package.json").version;
|
|
20
|
+
console.log("Current version:", packageVersion);
|
|
21
|
+
|
|
22
|
+
// Get latest published version
|
|
23
|
+
const latestVersion = execSync("npm view @robylon/react-native-sdk version")
|
|
24
|
+
.toString()
|
|
25
|
+
.trim();
|
|
26
|
+
console.log("Latest published version:", latestVersion);
|
|
27
|
+
|
|
28
|
+
// Ensure branch version matches package.json version
|
|
29
|
+
if (branchVersion !== packageVersion) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Release branch version (${branchVersion}) must match package.json version (${packageVersion})`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Validate version is greater than latest published
|
|
36
|
+
const semver = require("semver");
|
|
37
|
+
if (!semver.gt(packageVersion, latestVersion)) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`New version (${packageVersion}) must be greater than latest published version (${latestVersion})`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error("Error:", error.message);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
validatePublish();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// File: src/ChatbotWebview.tsx
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import { WebView } from "react-native-webview";
|
|
5
|
+
import { BASE_CHATBOT_URL } from "./constants";
|
|
6
|
+
import LoadingIndicator from "./LoadingIndicator";
|
|
7
|
+
|
|
8
|
+
interface ChatbotWebviewProps {
|
|
9
|
+
chatbotId: string;
|
|
10
|
+
additionalParams?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const constructUrl = (
|
|
14
|
+
chatbotId: string,
|
|
15
|
+
additionalParams: Record<string, string> = {}
|
|
16
|
+
): string => {
|
|
17
|
+
const params = new URLSearchParams({ id: chatbotId, ...additionalParams });
|
|
18
|
+
return `${BASE_CHATBOT_URL}?${params.toString()}`;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const ChatbotWebview: React.FC<ChatbotWebviewProps> = ({
|
|
22
|
+
chatbotId,
|
|
23
|
+
additionalParams,
|
|
24
|
+
}) => {
|
|
25
|
+
const [url, setUrl] = useState<string>("");
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setUrl(constructUrl(chatbotId, additionalParams));
|
|
29
|
+
}, [chatbotId, additionalParams]);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<View style={{ flex: 1 }}>
|
|
33
|
+
{url ? (
|
|
34
|
+
<WebView
|
|
35
|
+
source={{ uri: url }}
|
|
36
|
+
startInLoadingState={true}
|
|
37
|
+
renderLoading={() => <LoadingIndicator />}
|
|
38
|
+
/>
|
|
39
|
+
) : (
|
|
40
|
+
<LoadingIndicator />
|
|
41
|
+
)}
|
|
42
|
+
</View>
|
|
43
|
+
);
|
|
44
|
+
};
|