diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 834d3c7..c324c87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,10 +35,11 @@ jobs: - uses: actions/setup-node@v4 with: node-version: '20' - - run: npm ci --ignore-scripts + - run: npm install --ignore-scripts - run: npm run build - run: npm run lint - run: npm test + - run: npm run typecheck --workspace=@screeb/react-native flutter: name: Flutter package @@ -60,6 +61,7 @@ jobs: run: git config --global --add safe.directory "$FLUTTER_ROOT" - run: cd packages/sdk-flutter && flutter pub get - run: cd packages/sdk-flutter && flutter analyze + - run: cd packages/sdk-flutter && flutter test maui-android: name: .NET MAUI Android SDK diff --git a/.github/workflows/publish-svelte.yml b/.github/workflows/publish-svelte.yml new file mode 100644 index 0000000..4034898 --- /dev/null +++ b/.github/workflows/publish-svelte.yml @@ -0,0 +1,23 @@ +name: Publish @screeb/sdk-svelte + +on: + push: + tags: + - '@screeb/sdk-svelte@*' + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + registry-url: 'https://registry.npmjs.org' + - run: npm install -g npm@latest + - run: npm install --ignore-scripts + - run: npm run build + - run: npm publish --workspace=packages/sdk-svelte --access public --provenance diff --git a/examples/example-angular/package.json b/examples/example-angular/package.json index ae44394..5b2f61e 100644 --- a/examples/example-angular/package.json +++ b/examples/example-angular/package.json @@ -19,7 +19,7 @@ "scripts": { "build": "tsc && vite build", "clean": "rm -Rf dist", - "lint": "eslint .", + "lint": "eslint \"src/**/*.ts\"", "start": "vite" }, "dependencies": { @@ -37,10 +37,8 @@ "@typescript-eslint/eslint-plugin": "^6.7.5", "eslint": "^8.51.0", "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jest": "^27.4.2", "eslint-plugin-jsx-a11y": "^6.7.1", "eslint-plugin-prettier": "^5.0.1", - "jest": "^29.7.0", "typescript": "^5.2.2", "vite": "^4.4.11" } diff --git a/examples/example-browser/package.json b/examples/example-browser/package.json index 325bc27..4955afe 100644 --- a/examples/example-browser/package.json +++ b/examples/example-browser/package.json @@ -19,7 +19,7 @@ "scripts": { "build": "vite build", "clean": "rm -Rf dist", - "lint": "eslint .", + "lint": "eslint \"src/**/*.{ts,js}\"", "start": "vite" }, "dependencies": { @@ -32,11 +32,9 @@ "@typescript-eslint/eslint-plugin": "^6.7.5", "eslint": "^8.51.0", "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jest": "^27.4.2", "eslint-plugin-jsx-a11y": "^6.7.1", "eslint-plugin-prettier": "^5.0.1", "eslint-plugin-svelte": "^2.34.0", - "jest": "^29.7.0", "svelte": "^4.2.1", "svelte-check": "^3.5.2", "tslib": "^2.6.2", diff --git a/examples/example-expo/README.md b/examples/example-expo/README.md index e06d562..f263aa8 100644 --- a/examples/example-expo/README.md +++ b/examples/example-expo/README.md @@ -1,55 +1,41 @@ -# Welcome to your Expo app 👋 +# `@screeb/react-native` Expo example -This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app). +Minimal Expo app used to validate the Screeb React Native SDK with a generated native project. -> Screeb SDK documentation: [developers.screeb.app/sdk-react-native/install](https://developers.screeb.app/sdk-react-native/install) +> Documentation: [developers.screeb.app/sdk-react-native/install](https://developers.screeb.app/sdk-react-native/install) -## Get started +## Run -1. Install dependencies from the repository root (all workspaces share the same lockfile). +Install dependencies from the repository root: - ```bash - npm install - ``` - -2. Recreate the native project (new architecture is enabled by default and Screeb is autolinked via `react-native.config.js`). - - ```bash - npm run prebuild --workspace=example-expo - npm run ios --workspace=example-expo # or npm run android --workspace=example-expo - ``` - -3. Start the Metro server. - - ```bash - npm run example:expo --workspace=@screeb/react-native - ``` - -The generated build installs a fully native binary; Expo Go cannot load the Screeb TurboModule. Always launch the app produced by `expo run:ios` / `expo run:android` after the `prebuild` step. -If native sources fall out of sync, re-run `npm run prebuild --workspace=example-expo -- --clean` to regenerate the iOS and Android folders from scratch. - -You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction). - -## Get a fresh project +```bash +npm install +``` -When you're ready, run: +Recreate the native project: ```bash -npm run reset-project --workspace=example-expo +npm run prebuild --workspace=example-expo ``` -This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing. +Run the native app: -## Learn more +```bash +npm run ios --workspace=example-expo +# or +npm run android --workspace=example-expo +``` -To learn more about developing your project with Expo, look at the following resources: +Start Metro from the React Native SDK workspace: -- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides). -- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web. +```bash +npm run example:expo --workspace=@screeb/react-native +``` -## Join the community +Expo Go cannot load the Screeb TurboModule. Use the app produced by `expo run:ios` or `expo run:android`. -Join our community of developers creating universal apps. +If native sources fall out of sync, regenerate them with: -- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute. -- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions. +```bash +npm run prebuild --workspace=example-expo -- --clean +``` diff --git a/examples/example-expo/app.json b/examples/example-expo/app.json index 83ffbac..06686df 100644 --- a/examples/example-expo/app.json +++ b/examples/example-expo/app.json @@ -4,47 +4,23 @@ "slug": "example-expo", "version": "1.0.0", "orientation": "portrait", - "icon": "./assets/images/icon.png", "scheme": "exampleexpo", - "userInterfaceStyle": "automatic", "newArchEnabled": true, "ios": { "supportsTablet": true, "bundleIdentifier": "com.anonymous.example-expo" }, "android": { - "adaptiveIcon": { - "backgroundColor": "#E6F4FE", - "foregroundImage": "./assets/images/android-icon-foreground.png", - "backgroundImage": "./assets/images/android-icon-background.png", - "monochromeImage": "./assets/images/android-icon-monochrome.png" - }, "edgeToEdgeEnabled": true, "predictiveBackGestureEnabled": false, "package": "com.anonymous.exampleexpo" }, - "web": { - "output": "static", - "favicon": "./assets/images/favicon.png" - }, "plugins": [ - "expo-router", - [ - "expo-splash-screen", - { - "image": "./assets/images/splash-icon.png", - "imageWidth": 200, - "resizeMode": "contain", - "backgroundColor": "#ffffff", - "dark": { - "backgroundColor": "#000000" - } - } - ] + "./plugins/withScreebLocalSdk", + "expo-router" ], "experiments": { - "typedRoutes": true, - "reactCompiler": true + "typedRoutes": true } } } diff --git a/examples/example-expo/app/_layout.tsx b/examples/example-expo/app/_layout.tsx index f518c9b..a9aa203 100644 --- a/examples/example-expo/app/_layout.tsx +++ b/examples/example-expo/app/_layout.tsx @@ -1,24 +1,11 @@ -import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native'; -import { Stack } from 'expo-router'; -import { StatusBar } from 'expo-status-bar'; -import 'react-native-reanimated'; - -import { useColorScheme } from '@/hooks/use-color-scheme'; - -export const unstable_settings = { - anchor: '(tabs)', -}; +import { Stack } from "expo-router"; +import { StatusBar } from "expo-status-bar"; export default function RootLayout() { - const colorScheme = useColorScheme(); - return ( - - - - - + <> + - + ); } diff --git a/examples/example-expo/app/index.tsx b/examples/example-expo/app/index.tsx new file mode 100644 index 0000000..b190994 --- /dev/null +++ b/examples/example-expo/app/index.tsx @@ -0,0 +1,150 @@ +import * as Screeb from "@screeb/react-native"; +import { useEffect } from "react"; +import { + Alert, + Button, + ScrollView, + StyleSheet, + Text, + View, +} from "react-native"; + +const PROJECT_TOKEN = "0e2b609a-8dce-4695-a80f-966fbfa87a88"; +const RESPONDENT_ID = "0021de43-6e44-443c-9903-2ab99f9c4233"; +const SURVEY_ID = "8dd42ae1-f716-429c-9843-fad62adf2ac4"; +const USER_PROPERTIES = { + locale: "fr-FR", + premium: true, +}; + +const initScreeb = async () => { + try { + await Screeb.initSdk( + PROJECT_TOKEN, + RESPONDENT_ID, + USER_PROPERTIES, + { + onReady: (payload: unknown) => { + console.log("Screeb ready", payload); + }, + onSurveyDisplayAllowed: () => { + console.log("Survey display allowed"); + return true; + }, + version: "1.0.0", + }, + {}, + ); + } catch (error) { + console.error("Failed to init Screeb", error); + Alert.alert("Screeb init failed", "Check the Metro logs for details."); + } +}; + +export default function ScreebExpoExample() { + useEffect(() => { + initScreeb(); + }, []); + + return ( + + @screeb/react-native + Expo + + Minimal Expo development build for exercising the Screeb React Native + wrapper. + + + +