From 9cfb657bfc5524d9b0abe7a33ae194b6a1ca56ca Mon Sep 17 00:00:00 2001 From: Sumasree8 Date: Sat, 8 Aug 2026 13:15:23 +0530 Subject: [PATCH 1/2] refactor: rename __tests__ to tests and test-example to example --- .github/ISSUE_TEMPLATE/documentation_issue.md | 2 +- .github/ISSUE_TEMPLATE/question_support.md | 2 +- .gitignore | 14 +- CHANGELOG.md | 2 +- README.md | 6 +- {test-example => example}/.bundle/config | 0 {test-example => example}/.env.example | 0 {test-example => example}/.gitignore | 0 {test-example => example}/.watchmanconfig | 0 {test-example => example}/Gemfile | 0 {test-example => example}/Gemfile.lock | 0 {test-example => example}/README.md | 4 +- .../android/app/build.gradle | 2 +- .../android/app/debug.keystore | Bin .../android/app/gradle.lockfile | 0 .../android/app/proguard-rules.pro | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../main/java/uploads/example/MainActivity.kt | 0 .../java/uploads/example/MainApplication.kt | 0 .../res/drawable/rn_edit_text_material.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../res/mipmap-hdpi/ic_launcher_round.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../res/mipmap-mdpi/ic_launcher_round.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../res/mipmap-xhdpi/ic_launcher_round.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin .../app/src/main/res/values/strings.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../android/build.gradle | 0 .../android/gradle.properties | 0 .../android/gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 {test-example => example}/android/gradlew | 0 {test-example => example}/android/gradlew.bat | 0 .../android/settings-gradle.lockfile | 0 .../android/settings.gradle | 0 {test-example => example}/app.json | 0 {test-example => example}/babel.config.js | 0 {test-example => example}/index.js | 0 {test-example => example}/ios/.xcode.env | 0 {test-example => example}/ios/Podfile | 0 {test-example => example}/ios/Podfile.lock | 0 .../UploadsExample.xcodeproj/project.pbxproj | 0 .../xcschemes/UploadsExample.xcscheme | 0 .../contents.xcworkspacedata | 0 .../ios/UploadsExample/AppDelegate.swift | 0 .../AppIcon.appiconset/Contents.json | 0 .../upload_example_1024_logo.png | Bin .../Images.xcassets/Contents.json | 0 .../ios/UploadsExample/Info.plist | 0 .../UploadsExample/LaunchScreen.storyboard | 0 .../ios/UploadsExample/PrivacyInfo.xcprivacy | 0 {test-example => example}/jest.config.js | 0 {test-example => example}/metro.config.js | 0 {test-example => example}/package.json | 0 .../react-native.config.js | 0 {test-example => example}/src/App.tsx | 0 .../src/Constants/ApiKeys.ts | 0 .../src/Services/ApiService.ts | 0 package-lock.json | 196 +++++++++--------- package.json | 10 +- {__tests__ => tests}/ChunkEngine.test.ts | 0 {__tests__ => tests}/EventEmitter.test.ts | 0 {__tests__ => tests}/FastPixUpload.test.ts | 4 +- {__tests__ => tests}/NetworkMonitor.test.ts | 0 {__tests__ => tests}/UploadEngine.test.ts | 0 {__tests__ => tests}/validation.test.ts | 0 tsconfig.build.json | 2 +- tsconfig.json | 2 +- turbo.json | 18 +- 74 files changed, 132 insertions(+), 132 deletions(-) rename {test-example => example}/.bundle/config (100%) rename {test-example => example}/.env.example (100%) rename {test-example => example}/.gitignore (100%) rename {test-example => example}/.watchmanconfig (100%) rename {test-example => example}/Gemfile (100%) rename {test-example => example}/Gemfile.lock (100%) rename {test-example => example}/README.md (92%) rename {test-example => example}/android/app/build.gradle (99%) rename {test-example => example}/android/app/debug.keystore (100%) rename {test-example => example}/android/app/gradle.lockfile (100%) rename {test-example => example}/android/app/proguard-rules.pro (100%) rename {test-example => example}/android/app/src/main/AndroidManifest.xml (100%) rename {test-example => example}/android/app/src/main/java/uploads/example/MainActivity.kt (100%) rename {test-example => example}/android/app/src/main/java/uploads/example/MainApplication.kt (100%) rename {test-example => example}/android/app/src/main/res/drawable/rn_edit_text_material.xml (100%) rename {test-example => example}/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {test-example => example}/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png (100%) rename {test-example => example}/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {test-example => example}/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png (100%) rename {test-example => example}/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {test-example => example}/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png (100%) rename {test-example => example}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {test-example => example}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png (100%) rename {test-example => example}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename {test-example => example}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png (100%) rename {test-example => example}/android/app/src/main/res/values/strings.xml (100%) rename {test-example => example}/android/app/src/main/res/values/styles.xml (100%) rename {test-example => example}/android/build.gradle (100%) rename {test-example => example}/android/gradle.properties (100%) rename {test-example => example}/android/gradle/wrapper/gradle-wrapper.jar (100%) rename {test-example => example}/android/gradle/wrapper/gradle-wrapper.properties (100%) rename {test-example => example}/android/gradlew (100%) rename {test-example => example}/android/gradlew.bat (100%) rename {test-example => example}/android/settings-gradle.lockfile (100%) rename {test-example => example}/android/settings.gradle (100%) rename {test-example => example}/app.json (100%) rename {test-example => example}/babel.config.js (100%) rename {test-example => example}/index.js (100%) rename {test-example => example}/ios/.xcode.env (100%) rename {test-example => example}/ios/Podfile (100%) rename {test-example => example}/ios/Podfile.lock (100%) rename {test-example => example}/ios/UploadsExample.xcodeproj/project.pbxproj (100%) rename {test-example => example}/ios/UploadsExample.xcodeproj/xcshareddata/xcschemes/UploadsExample.xcscheme (100%) rename {test-example => example}/ios/UploadsExample.xcworkspace/contents.xcworkspacedata (100%) rename {test-example => example}/ios/UploadsExample/AppDelegate.swift (100%) rename {test-example => example}/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/Contents.json (100%) rename {test-example => example}/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/upload_example_1024_logo.png (100%) rename {test-example => example}/ios/UploadsExample/Images.xcassets/Contents.json (100%) rename {test-example => example}/ios/UploadsExample/Info.plist (100%) rename {test-example => example}/ios/UploadsExample/LaunchScreen.storyboard (100%) rename {test-example => example}/ios/UploadsExample/PrivacyInfo.xcprivacy (100%) rename {test-example => example}/jest.config.js (100%) rename {test-example => example}/metro.config.js (100%) rename {test-example => example}/package.json (100%) rename {test-example => example}/react-native.config.js (100%) rename {test-example => example}/src/App.tsx (100%) rename {test-example => example}/src/Constants/ApiKeys.ts (100%) rename {test-example => example}/src/Services/ApiService.ts (100%) rename {__tests__ => tests}/ChunkEngine.test.ts (100%) rename {__tests__ => tests}/EventEmitter.test.ts (100%) rename {__tests__ => tests}/FastPixUpload.test.ts (99%) rename {__tests__ => tests}/NetworkMonitor.test.ts (100%) rename {__tests__ => tests}/UploadEngine.test.ts (100%) rename {__tests__ => tests}/validation.test.ts (100%) diff --git a/.github/ISSUE_TEMPLATE/documentation_issue.md b/.github/ISSUE_TEMPLATE/documentation_issue.md index 68aa804..70f0cb8 100644 --- a/.github/ISSUE_TEMPLATE/documentation_issue.md +++ b/.github/ISSUE_TEMPLATE/documentation_issue.md @@ -40,7 +40,7 @@ Include replacement text or code examples if applicable. - [ ] CHANGELOG.md - [ ] API Reference / Configuration Parameters - [ ] Lifecycle Events Reference -- [ ] Example app (`test-example/`) +- [ ] Example app (`example/`) - [ ] Code examples - [ ] Other (describe): diff --git a/.github/ISSUE_TEMPLATE/question_support.md b/.github/ISSUE_TEMPLATE/question_support.md index c3e6bfd..cfae1d7 100644 --- a/.github/ISSUE_TEMPLATE/question_support.md +++ b/.github/ISSUE_TEMPLATE/question_support.md @@ -84,7 +84,7 @@ If relevant, paste your current upload configuration. - [ ] API Reference / Configuration Parameters - [ ] Lifecycle Events Reference - [ ] Troubleshooting section -- [ ] Example app (`test-example/`) +- [ ] Example app (`example/`) - [ ] GitHub Issues - [ ] Other (describe): diff --git a/.gitignore b/.gitignore index 8d64791..ca14576 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,7 @@ project.xcworkspace **/.xcode.env.local # Example App -test-example/.env +example/.env # Android/IJ # @@ -55,15 +55,15 @@ android.iml # Cocoapods # -test-example/ios/Pods +example/ios/Pods # Ruby -test-example/vendor/ +example/vendor/ # node.js # node_modules/ -test-example/node_modules/ +example/node_modules/ npm-debug.log # BUCK @@ -88,12 +88,12 @@ android/keystores/debug.keystore # generated by bob , Compilation Outputs lib/ dist/ -test-example/ios/build/ +example/ios/build/ # test coverage reports (generated by jest --coverage) coverage/ -test-example/android/build/ -test-example/android/app/build/ +example/android/build/ +example/android/app/build/ # --- Diagnostic and Log Files --- npm-debug.log* diff --git a/CHANGELOG.md b/CHANGELOG.md index 3417f18..2d75826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ chunked uploads for large files on Android and iOS. `on()`/`off()` subscription and `state`, `progress`, and `stateHistory` getters. - **`enableLogs`** option for SDK-internal debug logging (with URL/path masking). -- Example React Native app under `test-example/` demonstrating picking, upload, +- Example React Native app under `example/` demonstrating picking, upload, progress, pause/resume/abort, retries, and network recovery. - Jest test suite covering the core engine, chunking, network monitor, event emitter, and validation, with coverage measured in CI. diff --git a/README.md b/README.md index 444b5fe..7941dae 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ A signed URL is a pre-authenticated URL that allows secure, direct uploads to Fa ### Sample Code: Generating a Signed URL -Here is a self-contained service that calls the FastPix Direct Upload API and returns a signed URL. It uses `axios` and `base-64` for the Basic Auth header (the same approach used by the bundled example app in [`test-example/src/Services/ApiService.ts`](test-example/src/Services/ApiService.ts)): +Here is a self-contained service that calls the FastPix Direct Upload API and returns a signed URL. It uses `axios` and `base-64` for the Basic Auth header (the same approach used by the bundled example app in [`example/src/Services/ApiService.ts`](example/src/Services/ApiService.ts)): > This is **your** backend/service code, not part of the SDK. Install its helpers with `npm install axios base-64`. On a Node backend you can drop `base-64` and use `Buffer.from(...).toString("base64")` instead. @@ -218,7 +218,7 @@ await upload.resume(); // re-syncs the server offset, then continues ### Full React component: progress bar with pause / resume / abort -A complete, copy-paste example wiring the resumable lifecycle to UI controls. The same flow is implemented end-to-end in the bundled [`test-example/`](test-example/) app. +A complete, copy-paste example wiring the resumable lifecycle to UI controls. The same flow is implemented end-to-end in the bundled [`example/`](example/) app. ```jsx import React, { useEffect, useRef, useState } from "react"; @@ -551,7 +551,7 @@ The example demonstrates: * Network recovery * Error handling -Refer to the **`test-example/`** directory for the complete implementation. +Refer to the **`example/`** directory for the complete implementation. ## Troubleshooting diff --git a/test-example/.bundle/config b/example/.bundle/config similarity index 100% rename from test-example/.bundle/config rename to example/.bundle/config diff --git a/test-example/.env.example b/example/.env.example similarity index 100% rename from test-example/.env.example rename to example/.env.example diff --git a/test-example/.gitignore b/example/.gitignore similarity index 100% rename from test-example/.gitignore rename to example/.gitignore diff --git a/test-example/.watchmanconfig b/example/.watchmanconfig similarity index 100% rename from test-example/.watchmanconfig rename to example/.watchmanconfig diff --git a/test-example/Gemfile b/example/Gemfile similarity index 100% rename from test-example/Gemfile rename to example/Gemfile diff --git a/test-example/Gemfile.lock b/example/Gemfile.lock similarity index 100% rename from test-example/Gemfile.lock rename to example/Gemfile.lock diff --git a/test-example/README.md b/example/README.md similarity index 92% rename from test-example/README.md rename to example/README.md index cc612c3..cc7b0fa 100644 --- a/test-example/README.md +++ b/example/README.md @@ -35,7 +35,7 @@ cd .. # repository root npm install # installs the SDK + this example, and builds the SDK ``` -After this, most packages live in `/node_modules`, and `test-example/node_modules` +After this, most packages live in `/node_modules`, and `example/node_modules` will look almost empty. That is expected — the Android and Metro configs resolve packages through Node, so they find them wherever npm hoisted them. @@ -112,7 +112,7 @@ npm run ios | Symptom | Cause | Fix | | ------- | ----- | --- | -| `Included build '.../node_modules/@react-native/gradle-plugin' does not exist` | Ran `npm install` inside `test-example/` only, or `node` is not on the `PATH` of the process running Gradle (typical for Android Studio + `nvm`). | Run `npm install` from the repo root; launch Android Studio from a terminal or symlink node. | +| `Included build '.../node_modules/@react-native/gradle-plugin' does not exist` | Ran `npm install` inside `example/` only, or `node` is not on the `PATH` of the process running Gradle (typical for Android Studio + `nvm`). | Run `npm install` from the repo root; launch Android Studio from a terminal or symlink node. | | `CreateUploadError` / network error while online | No `.env` file, or Metro cached the old (empty) values. | `cp .env.example .env`, fill all three values, then `npm start -- --reset-cache`. | | `HTTP 401` from the upload API | Wrong `Access_Token_Id` / `Secret_Key`. | Regenerate credentials in the FastPix Dashboard. | | `HTTP 404` from the upload API | `Base_Api_Url` includes a path such as `/upload`. | Set the base URL only: `https://api.fastpix.io/v1/on-demand`. | diff --git a/test-example/android/app/build.gradle b/example/android/app/build.gradle similarity index 99% rename from test-example/android/app/build.gradle rename to example/android/app/build.gradle index 19c5159..0baaed7 100644 --- a/test-example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -12,7 +12,7 @@ dependencyLocking { react { /* Folders */ // Resolved through node so this works with npm workspaces, where the - // dependencies are hoisted to the monorepo root instead of test-example/node_modules. + // dependencies are hoisted to the monorepo root instead of example/node_modules. root = file("../../") reactNativeDir = file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile() codegenDir = file(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile() diff --git a/test-example/android/app/debug.keystore b/example/android/app/debug.keystore similarity index 100% rename from test-example/android/app/debug.keystore rename to example/android/app/debug.keystore diff --git a/test-example/android/app/gradle.lockfile b/example/android/app/gradle.lockfile similarity index 100% rename from test-example/android/app/gradle.lockfile rename to example/android/app/gradle.lockfile diff --git a/test-example/android/app/proguard-rules.pro b/example/android/app/proguard-rules.pro similarity index 100% rename from test-example/android/app/proguard-rules.pro rename to example/android/app/proguard-rules.pro diff --git a/test-example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml similarity index 100% rename from test-example/android/app/src/main/AndroidManifest.xml rename to example/android/app/src/main/AndroidManifest.xml diff --git a/test-example/android/app/src/main/java/uploads/example/MainActivity.kt b/example/android/app/src/main/java/uploads/example/MainActivity.kt similarity index 100% rename from test-example/android/app/src/main/java/uploads/example/MainActivity.kt rename to example/android/app/src/main/java/uploads/example/MainActivity.kt diff --git a/test-example/android/app/src/main/java/uploads/example/MainApplication.kt b/example/android/app/src/main/java/uploads/example/MainApplication.kt similarity index 100% rename from test-example/android/app/src/main/java/uploads/example/MainApplication.kt rename to example/android/app/src/main/java/uploads/example/MainApplication.kt diff --git a/test-example/android/app/src/main/res/drawable/rn_edit_text_material.xml b/example/android/app/src/main/res/drawable/rn_edit_text_material.xml similarity index 100% rename from test-example/android/app/src/main/res/drawable/rn_edit_text_material.xml rename to example/android/app/src/main/res/drawable/rn_edit_text_material.xml diff --git a/test-example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from test-example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/test-example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png similarity index 100% rename from test-example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png rename to example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png diff --git a/test-example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from test-example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/test-example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png similarity index 100% rename from test-example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png rename to example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png diff --git a/test-example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from test-example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/test-example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png similarity index 100% rename from test-example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png rename to example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/test-example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from test-example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/test-example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png similarity index 100% rename from test-example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png rename to example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/test-example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from test-example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/test-example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png similarity index 100% rename from test-example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png rename to example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/test-example/android/app/src/main/res/values/strings.xml b/example/android/app/src/main/res/values/strings.xml similarity index 100% rename from test-example/android/app/src/main/res/values/strings.xml rename to example/android/app/src/main/res/values/strings.xml diff --git a/test-example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml similarity index 100% rename from test-example/android/app/src/main/res/values/styles.xml rename to example/android/app/src/main/res/values/styles.xml diff --git a/test-example/android/build.gradle b/example/android/build.gradle similarity index 100% rename from test-example/android/build.gradle rename to example/android/build.gradle diff --git a/test-example/android/gradle.properties b/example/android/gradle.properties similarity index 100% rename from test-example/android/gradle.properties rename to example/android/gradle.properties diff --git a/test-example/android/gradle/wrapper/gradle-wrapper.jar b/example/android/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from test-example/android/gradle/wrapper/gradle-wrapper.jar rename to example/android/gradle/wrapper/gradle-wrapper.jar diff --git a/test-example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from test-example/android/gradle/wrapper/gradle-wrapper.properties rename to example/android/gradle/wrapper/gradle-wrapper.properties diff --git a/test-example/android/gradlew b/example/android/gradlew similarity index 100% rename from test-example/android/gradlew rename to example/android/gradlew diff --git a/test-example/android/gradlew.bat b/example/android/gradlew.bat similarity index 100% rename from test-example/android/gradlew.bat rename to example/android/gradlew.bat diff --git a/test-example/android/settings-gradle.lockfile b/example/android/settings-gradle.lockfile similarity index 100% rename from test-example/android/settings-gradle.lockfile rename to example/android/settings-gradle.lockfile diff --git a/test-example/android/settings.gradle b/example/android/settings.gradle similarity index 100% rename from test-example/android/settings.gradle rename to example/android/settings.gradle diff --git a/test-example/app.json b/example/app.json similarity index 100% rename from test-example/app.json rename to example/app.json diff --git a/test-example/babel.config.js b/example/babel.config.js similarity index 100% rename from test-example/babel.config.js rename to example/babel.config.js diff --git a/test-example/index.js b/example/index.js similarity index 100% rename from test-example/index.js rename to example/index.js diff --git a/test-example/ios/.xcode.env b/example/ios/.xcode.env similarity index 100% rename from test-example/ios/.xcode.env rename to example/ios/.xcode.env diff --git a/test-example/ios/Podfile b/example/ios/Podfile similarity index 100% rename from test-example/ios/Podfile rename to example/ios/Podfile diff --git a/test-example/ios/Podfile.lock b/example/ios/Podfile.lock similarity index 100% rename from test-example/ios/Podfile.lock rename to example/ios/Podfile.lock diff --git a/test-example/ios/UploadsExample.xcodeproj/project.pbxproj b/example/ios/UploadsExample.xcodeproj/project.pbxproj similarity index 100% rename from test-example/ios/UploadsExample.xcodeproj/project.pbxproj rename to example/ios/UploadsExample.xcodeproj/project.pbxproj diff --git a/test-example/ios/UploadsExample.xcodeproj/xcshareddata/xcschemes/UploadsExample.xcscheme b/example/ios/UploadsExample.xcodeproj/xcshareddata/xcschemes/UploadsExample.xcscheme similarity index 100% rename from test-example/ios/UploadsExample.xcodeproj/xcshareddata/xcschemes/UploadsExample.xcscheme rename to example/ios/UploadsExample.xcodeproj/xcshareddata/xcschemes/UploadsExample.xcscheme diff --git a/test-example/ios/UploadsExample.xcworkspace/contents.xcworkspacedata b/example/ios/UploadsExample.xcworkspace/contents.xcworkspacedata similarity index 100% rename from test-example/ios/UploadsExample.xcworkspace/contents.xcworkspacedata rename to example/ios/UploadsExample.xcworkspace/contents.xcworkspacedata diff --git a/test-example/ios/UploadsExample/AppDelegate.swift b/example/ios/UploadsExample/AppDelegate.swift similarity index 100% rename from test-example/ios/UploadsExample/AppDelegate.swift rename to example/ios/UploadsExample/AppDelegate.swift diff --git a/test-example/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/Contents.json b/example/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from test-example/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/Contents.json rename to example/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/Contents.json diff --git a/test-example/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/upload_example_1024_logo.png b/example/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/upload_example_1024_logo.png similarity index 100% rename from test-example/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/upload_example_1024_logo.png rename to example/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/upload_example_1024_logo.png diff --git a/test-example/ios/UploadsExample/Images.xcassets/Contents.json b/example/ios/UploadsExample/Images.xcassets/Contents.json similarity index 100% rename from test-example/ios/UploadsExample/Images.xcassets/Contents.json rename to example/ios/UploadsExample/Images.xcassets/Contents.json diff --git a/test-example/ios/UploadsExample/Info.plist b/example/ios/UploadsExample/Info.plist similarity index 100% rename from test-example/ios/UploadsExample/Info.plist rename to example/ios/UploadsExample/Info.plist diff --git a/test-example/ios/UploadsExample/LaunchScreen.storyboard b/example/ios/UploadsExample/LaunchScreen.storyboard similarity index 100% rename from test-example/ios/UploadsExample/LaunchScreen.storyboard rename to example/ios/UploadsExample/LaunchScreen.storyboard diff --git a/test-example/ios/UploadsExample/PrivacyInfo.xcprivacy b/example/ios/UploadsExample/PrivacyInfo.xcprivacy similarity index 100% rename from test-example/ios/UploadsExample/PrivacyInfo.xcprivacy rename to example/ios/UploadsExample/PrivacyInfo.xcprivacy diff --git a/test-example/jest.config.js b/example/jest.config.js similarity index 100% rename from test-example/jest.config.js rename to example/jest.config.js diff --git a/test-example/metro.config.js b/example/metro.config.js similarity index 100% rename from test-example/metro.config.js rename to example/metro.config.js diff --git a/test-example/package.json b/example/package.json similarity index 100% rename from test-example/package.json rename to example/package.json diff --git a/test-example/react-native.config.js b/example/react-native.config.js similarity index 100% rename from test-example/react-native.config.js rename to example/react-native.config.js diff --git a/test-example/src/App.tsx b/example/src/App.tsx similarity index 100% rename from test-example/src/App.tsx rename to example/src/App.tsx diff --git a/test-example/src/Constants/ApiKeys.ts b/example/src/Constants/ApiKeys.ts similarity index 100% rename from test-example/src/Constants/ApiKeys.ts rename to example/src/Constants/ApiKeys.ts diff --git a/test-example/src/Services/ApiService.ts b/example/src/Services/ApiService.ts similarity index 100% rename from test-example/src/Services/ApiService.ts rename to example/src/Services/ApiService.ts diff --git a/package-lock.json b/package-lock.json index 17f2b65..74dde8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "license": "MIT", "workspaces": [ - "test-example" + "example" ], "dependencies": { "@react-native-community/cli": "20.2.0", @@ -49,6 +49,102 @@ "react-native": "*" } }, + "example": { + "name": "react-native-uploads-example", + "version": "0.0.1", + "dependencies": { + "@fastpix/react-native-uploads": "file:..", + "@react-native-community/netinfo": "^12.0.1", + "@release-it/conventional-changelog": "11.0.1", + "axios": "^1.17.0", + "base-64": "^0.1.0", + "react": "19.2.3", + "react-native": "0.85.0", + "react-native-blob-util": "^0.19.0", + "react-native-fs": "^2.20.0", + "react-native-image-picker": "^8.2.1", + "release-it": "20.2.1" + }, + "devDependencies": { + "@babel/core": "^7.25.2", + "@babel/preset-env": "^7.25.3", + "@babel/runtime": "^7.25.0", + "@react-native-community/cli": "^20.2.0", + "@react-native-community/cli-platform-android": "^20.2.0", + "@react-native-community/cli-platform-ios": "^20.2.0", + "@react-native/babel-preset": "0.85.0", + "@react-native/jest-preset": "0.85.0", + "@react-native/metro-config": "0.85.0", + "@react-native/typescript-config": "0.85.0", + "@types/base-64": "^1.0.2", + "@types/react": "^19.2.0", + "react-native-builder-bob": "^0.41.0", + "react-native-dotenv": "^3.4.11", + "react-native-monorepo-config": "^0.3.3" + }, + "engines": { + "node": ">= 22.11.0" + } + }, + "example/node_modules/brace-expansion": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz", + "integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "example/node_modules/glob": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "example/node_modules/minimatch": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", + "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.2" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "example/node_modules/react-native-blob-util": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/react-native-blob-util/-/react-native-blob-util-0.19.11.tgz", + "integrity": "sha512-lxaeDzFLYffR6lbRiOce0oTYO6pE3/PyT8Sa7qiz8B+IT9oe4G85SlVCdl5F9xMJh/Zer2onBLw7u+B1AS+GFA==", + "license": "MIT", + "dependencies": { + "base-64": "0.1.0", + "glob": "^10.3.10" + }, + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/@ark/schema": { "version": "0.56.2", "resolved": "https://registry.npmjs.org/@ark/schema/-/schema-0.56.2.tgz", @@ -13392,7 +13488,7 @@ } }, "node_modules/react-native-uploads-example": { - "resolved": "test-example", + "resolved": "example", "link": true }, "node_modules/react-native/node_modules/commander": { @@ -16004,102 +16100,6 @@ "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" } - }, - "test-example": { - "name": "react-native-uploads-example", - "version": "0.0.1", - "dependencies": { - "@fastpix/react-native-uploads": "file:..", - "@react-native-community/netinfo": "^12.0.1", - "@release-it/conventional-changelog": "11.0.1", - "axios": "^1.17.0", - "base-64": "^0.1.0", - "react": "19.2.3", - "react-native": "0.85.0", - "react-native-blob-util": "^0.19.0", - "react-native-fs": "^2.20.0", - "react-native-image-picker": "^8.2.1", - "release-it": "20.2.1" - }, - "devDependencies": { - "@babel/core": "^7.25.2", - "@babel/preset-env": "^7.25.3", - "@babel/runtime": "^7.25.0", - "@react-native-community/cli": "^20.2.0", - "@react-native-community/cli-platform-android": "^20.2.0", - "@react-native-community/cli-platform-ios": "^20.2.0", - "@react-native/babel-preset": "0.85.0", - "@react-native/jest-preset": "0.85.0", - "@react-native/metro-config": "0.85.0", - "@react-native/typescript-config": "0.85.0", - "@types/base-64": "^1.0.2", - "@types/react": "^19.2.0", - "react-native-builder-bob": "^0.41.0", - "react-native-dotenv": "^3.4.11", - "react-native-monorepo-config": "^0.3.3" - }, - "engines": { - "node": ">= 22.11.0" - } - }, - "test-example/node_modules/brace-expansion": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.2.tgz", - "integrity": "sha512-w5JZcKgdhDOgOwm8H+KgbosopHMuGcl6qbulwjtz3SM7I7P3yW1eAjzMPLrIE+NQ9vjgANKHWeMHnrT0OXW1oA==", - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "test-example/node_modules/glob": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", - "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", - "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", - "license": "ISC", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "test-example/node_modules/minimatch": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", - "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.2" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "test-example/node_modules/react-native-blob-util": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/react-native-blob-util/-/react-native-blob-util-0.19.11.tgz", - "integrity": "sha512-lxaeDzFLYffR6lbRiOce0oTYO6pE3/PyT8Sa7qiz8B+IT9oe4G85SlVCdl5F9xMJh/Zer2onBLw7u+B1AS+GFA==", - "license": "MIT", - "dependencies": { - "base-64": "0.1.0", - "glob": "^10.3.10" - }, - "peerDependencies": { - "react": "*", - "react-native": "*" - } } } } diff --git a/package.json b/package.json index d584679..e99f4a7 100644 --- a/package.json +++ b/package.json @@ -26,14 +26,14 @@ "!android/gradlew", "!android/gradlew.bat", "!android/local.properties", - "!**/__tests__", + "!**/tests", "!**/__fixtures__", "!**/__mocks__", "!**/.*" ], "scripts": { "example": "npm run --workspace react-native-uploads-example", - "clean": "del-cli android/build test-example/android/build test-example/android/app/build test-example/ios/build lib", + "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib", "build": "bob build && tsc --project tsconfig.build.json", "prepare": "npm run build", "typecheck": "tsc --noEmit", @@ -107,7 +107,7 @@ "react-native": "*" }, "workspaces": [ - "test-example" + "example" ], "react-native-builder-bob": { "source": "src", @@ -155,8 +155,8 @@ "/dist/" ], "testMatch": [ - "**/__tests__/**/*.test.ts", - "**/__tests__/**/*.test.tsx" + "**/tests/**/*.test.ts", + "**/tests/**/*.test.tsx" ] }, "create-react-native-library": { diff --git a/__tests__/ChunkEngine.test.ts b/tests/ChunkEngine.test.ts similarity index 100% rename from __tests__/ChunkEngine.test.ts rename to tests/ChunkEngine.test.ts diff --git a/__tests__/EventEmitter.test.ts b/tests/EventEmitter.test.ts similarity index 100% rename from __tests__/EventEmitter.test.ts rename to tests/EventEmitter.test.ts diff --git a/__tests__/FastPixUpload.test.ts b/tests/FastPixUpload.test.ts similarity index 99% rename from __tests__/FastPixUpload.test.ts rename to tests/FastPixUpload.test.ts index e4bb71e..174b655 100644 --- a/__tests__/FastPixUpload.test.ts +++ b/tests/FastPixUpload.test.ts @@ -1,7 +1,7 @@ /** * FastPixUpload.test.ts - * Lives in __tests__/ at the project root. - * All paths are relative to __tests__/, i.e. src is at ../src/ + * Lives in tests/ at the project root. + * All paths are relative to tests/, i.e. src is at ../src/ */ import { FastPixUpload } from '../src/core/FastPixUpload'; diff --git a/__tests__/NetworkMonitor.test.ts b/tests/NetworkMonitor.test.ts similarity index 100% rename from __tests__/NetworkMonitor.test.ts rename to tests/NetworkMonitor.test.ts diff --git a/__tests__/UploadEngine.test.ts b/tests/UploadEngine.test.ts similarity index 100% rename from __tests__/UploadEngine.test.ts rename to tests/UploadEngine.test.ts diff --git a/__tests__/validation.test.ts b/tests/validation.test.ts similarity index 100% rename from __tests__/validation.test.ts rename to tests/validation.test.ts diff --git a/tsconfig.build.json b/tsconfig.build.json index 2c72b5d..2a664b4 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -12,6 +12,6 @@ "node_modules", "lib", "example", - "__tests__", + "tests", ] } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index da593ba..76c80fd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,7 +20,7 @@ "noUnusedParameters": true, "types": ["node","jest"] }, - "include": ["src/**/*","__tests__"], + "include": ["src/**/*","tests"], "exclude": [ "node_modules", "example", diff --git a/turbo.json b/turbo.json index b481bfd..01029ed 100644 --- a/turbo.json +++ b/turbo.json @@ -11,11 +11,11 @@ "!android/build", "src/**/*.ts", "src/**/*.tsx", - "test-example/package.json", - "test-example/android", - "!test-example/android/.gradle", - "!test-example/android/build", - "!test-example/android/app/build" + "example/package.json", + "example/android", + "!example/android/.gradle", + "!example/android/build", + "!example/android/app/build" ], "outputs": [] }, @@ -32,10 +32,10 @@ "ios", "src/**/*.ts", "src/**/*.tsx", - "test-example/package.json", - "test-example/ios", - "!test-example/ios/build", - "!test-example/ios/Pods" + "example/package.json", + "example/ios", + "!example/ios/build", + "!example/ios/Pods" ], "outputs": [] } From 8722c31721155fc9d3eeb831734f8518ce8ddb04 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 14 Aug 2026 17:42:24 +0530 Subject: [PATCH 2/2] Added react-native Expo Example --- .github/ISSUE_TEMPLATE/documentation_issue.md | 2 +- .github/ISSUE_TEMPLATE/question_support.md | 2 +- .gitignore | 24 +- README.md | 9 +- example/expo/.gitignore | 41 + example/expo/App.tsx | 121 + example/expo/README.md | 167 + example/expo/app.json | 33 + .../expo/assets/android-icon-background.png | Bin 0 -> 17549 bytes .../expo/assets/android-icon-foreground.png | Bin 0 -> 78796 bytes .../expo/assets/android-icon-monochrome.png | Bin 0 -> 4140 bytes example/expo/assets/favicon.png | Bin 0 -> 1129 bytes example/expo/assets/icon.png | Bin 0 -> 393493 bytes example/expo/assets/splash-icon.png | Bin 0 -> 17547 bytes example/expo/backend/.env.example | 5 + example/expo/backend/package-lock.json | 828 +++ example/expo/backend/package.json | 13 + example/expo/backend/server.js | 72 + example/expo/index.ts | 8 + example/expo/metro.config.js | 35 + example/expo/package-lock.json | 6107 +++++++++++++++++ example/expo/package.json | 27 + example/expo/tsconfig.json | 6 + .../types/fastpix-react-native-uploads.d.ts | 47 + example/{ => react-native}/.bundle/config | 0 example/{ => react-native}/.env.example | 0 example/{ => react-native}/.gitignore | 0 example/{ => react-native}/.watchmanconfig | 0 example/{ => react-native}/Gemfile | 0 example/{ => react-native}/Gemfile.lock | 0 example/{ => react-native}/README.md | 0 .../android/app/build.gradle | 0 .../android/app/debug.keystore | Bin .../android/app/gradle.lockfile | 0 .../android/app/proguard-rules.pro | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../main/java/uploads/example/MainActivity.kt | 0 .../java/uploads/example/MainApplication.kt | 0 .../res/drawable/rn_edit_text_material.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../res/mipmap-hdpi/ic_launcher_round.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../res/mipmap-mdpi/ic_launcher_round.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../res/mipmap-xhdpi/ic_launcher_round.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin .../app/src/main/res/values/strings.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../{ => react-native}/android/build.gradle | 0 .../android/gradle.properties | 0 .../android/gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 example/{ => react-native}/android/gradlew | 0 .../{ => react-native}/android/gradlew.bat | 0 .../android/settings-gradle.lockfile | 0 .../android/settings.gradle | 0 example/{ => react-native}/app.json | 0 example/{ => react-native}/babel.config.js | 4 +- example/{ => react-native}/index.js | 0 example/{ => react-native}/ios/.xcode.env | 0 example/{ => react-native}/ios/Podfile | 0 example/{ => react-native}/ios/Podfile.lock | 0 .../UploadsExample.xcodeproj/project.pbxproj | 0 .../xcschemes/UploadsExample.xcscheme | 0 .../contents.xcworkspacedata | 0 .../ios/UploadsExample/AppDelegate.swift | 0 .../AppIcon.appiconset/Contents.json | 0 .../upload_example_1024_logo.png | Bin .../Images.xcassets/Contents.json | 0 .../ios/UploadsExample/Info.plist | 0 .../UploadsExample/LaunchScreen.storyboard | 0 .../ios/UploadsExample/PrivacyInfo.xcprivacy | 0 example/{ => react-native}/jest.config.js | 0 example/{ => react-native}/metro.config.js | 2 +- example/{ => react-native}/package.json | 2 +- .../{ => react-native}/react-native.config.js | 0 example/{ => react-native}/src/App.tsx | 0 .../src/Constants/ApiKeys.ts | 0 .../src/Services/ApiService.ts | 0 package-lock.json | 5403 +++++++++++---- package.json | 5 +- turbo.json | 18 +- 85 files changed, 11602 insertions(+), 1379 deletions(-) create mode 100644 example/expo/.gitignore create mode 100644 example/expo/App.tsx create mode 100644 example/expo/README.md create mode 100644 example/expo/app.json create mode 100644 example/expo/assets/android-icon-background.png create mode 100644 example/expo/assets/android-icon-foreground.png create mode 100644 example/expo/assets/android-icon-monochrome.png create mode 100644 example/expo/assets/favicon.png create mode 100644 example/expo/assets/icon.png create mode 100644 example/expo/assets/splash-icon.png create mode 100644 example/expo/backend/.env.example create mode 100644 example/expo/backend/package-lock.json create mode 100644 example/expo/backend/package.json create mode 100644 example/expo/backend/server.js create mode 100644 example/expo/index.ts create mode 100644 example/expo/metro.config.js create mode 100644 example/expo/package-lock.json create mode 100644 example/expo/package.json create mode 100644 example/expo/tsconfig.json create mode 100644 example/expo/types/fastpix-react-native-uploads.d.ts rename example/{ => react-native}/.bundle/config (100%) rename example/{ => react-native}/.env.example (100%) rename example/{ => react-native}/.gitignore (100%) rename example/{ => react-native}/.watchmanconfig (100%) rename example/{ => react-native}/Gemfile (100%) rename example/{ => react-native}/Gemfile.lock (100%) rename example/{ => react-native}/README.md (100%) rename example/{ => react-native}/android/app/build.gradle (100%) rename example/{ => react-native}/android/app/debug.keystore (100%) rename example/{ => react-native}/android/app/gradle.lockfile (100%) rename example/{ => react-native}/android/app/proguard-rules.pro (100%) rename example/{ => react-native}/android/app/src/main/AndroidManifest.xml (100%) rename example/{ => react-native}/android/app/src/main/java/uploads/example/MainActivity.kt (100%) rename example/{ => react-native}/android/app/src/main/java/uploads/example/MainApplication.kt (100%) rename example/{ => react-native}/android/app/src/main/res/drawable/rn_edit_text_material.xml (100%) rename example/{ => react-native}/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename example/{ => react-native}/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png (100%) rename example/{ => react-native}/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename example/{ => react-native}/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png (100%) rename example/{ => react-native}/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename example/{ => react-native}/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png (100%) rename example/{ => react-native}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename example/{ => react-native}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png (100%) rename example/{ => react-native}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename example/{ => react-native}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png (100%) rename example/{ => react-native}/android/app/src/main/res/values/strings.xml (100%) rename example/{ => react-native}/android/app/src/main/res/values/styles.xml (100%) rename example/{ => react-native}/android/build.gradle (100%) rename example/{ => react-native}/android/gradle.properties (100%) rename example/{ => react-native}/android/gradle/wrapper/gradle-wrapper.jar (100%) rename example/{ => react-native}/android/gradle/wrapper/gradle-wrapper.properties (100%) rename example/{ => react-native}/android/gradlew (100%) rename example/{ => react-native}/android/gradlew.bat (100%) rename example/{ => react-native}/android/settings-gradle.lockfile (100%) rename example/{ => react-native}/android/settings.gradle (100%) rename example/{ => react-native}/app.json (100%) rename example/{ => react-native}/babel.config.js (84%) rename example/{ => react-native}/index.js (100%) rename example/{ => react-native}/ios/.xcode.env (100%) rename example/{ => react-native}/ios/Podfile (100%) rename example/{ => react-native}/ios/Podfile.lock (100%) rename example/{ => react-native}/ios/UploadsExample.xcodeproj/project.pbxproj (100%) rename example/{ => react-native}/ios/UploadsExample.xcodeproj/xcshareddata/xcschemes/UploadsExample.xcscheme (100%) rename example/{ => react-native}/ios/UploadsExample.xcworkspace/contents.xcworkspacedata (100%) rename example/{ => react-native}/ios/UploadsExample/AppDelegate.swift (100%) rename example/{ => react-native}/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/Contents.json (100%) rename example/{ => react-native}/ios/UploadsExample/Images.xcassets/AppIcon.appiconset/upload_example_1024_logo.png (100%) rename example/{ => react-native}/ios/UploadsExample/Images.xcassets/Contents.json (100%) rename example/{ => react-native}/ios/UploadsExample/Info.plist (100%) rename example/{ => react-native}/ios/UploadsExample/LaunchScreen.storyboard (100%) rename example/{ => react-native}/ios/UploadsExample/PrivacyInfo.xcprivacy (100%) rename example/{ => react-native}/jest.config.js (100%) rename example/{ => react-native}/metro.config.js (93%) rename example/{ => react-native}/package.json (96%) rename example/{ => react-native}/react-native.config.js (100%) rename example/{ => react-native}/src/App.tsx (100%) rename example/{ => react-native}/src/Constants/ApiKeys.ts (100%) rename example/{ => react-native}/src/Services/ApiService.ts (100%) diff --git a/.github/ISSUE_TEMPLATE/documentation_issue.md b/.github/ISSUE_TEMPLATE/documentation_issue.md index 70f0cb8..e97dc5e 100644 --- a/.github/ISSUE_TEMPLATE/documentation_issue.md +++ b/.github/ISSUE_TEMPLATE/documentation_issue.md @@ -40,7 +40,7 @@ Include replacement text or code examples if applicable. - [ ] CHANGELOG.md - [ ] API Reference / Configuration Parameters - [ ] Lifecycle Events Reference -- [ ] Example app (`example/`) +- [ ] Example app (`example/react-native` or `example/expo`) - [ ] Code examples - [ ] Other (describe): diff --git a/.github/ISSUE_TEMPLATE/question_support.md b/.github/ISSUE_TEMPLATE/question_support.md index cfae1d7..0de144e 100644 --- a/.github/ISSUE_TEMPLATE/question_support.md +++ b/.github/ISSUE_TEMPLATE/question_support.md @@ -84,7 +84,7 @@ If relevant, paste your current upload configuration. - [ ] API Reference / Configuration Parameters - [ ] Lifecycle Events Reference - [ ] Troubleshooting section -- [ ] Example app (`example/`) +- [ ] Example app (`example/react-native` or `example/expo`) - [ ] GitHub Issues - [ ] Other (describe): diff --git a/.gitignore b/.gitignore index ca14576..bef9b86 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,7 @@ project.xcworkspace **/.xcode.env.local # Example App -example/.env +example/react-native/.env # Android/IJ # @@ -55,15 +55,15 @@ android.iml # Cocoapods # -example/ios/Pods +example/react-native/ios/Pods # Ruby -example/vendor/ +example/react-native/vendor/ # node.js # node_modules/ -example/node_modules/ +example/react-native/node_modules/ npm-debug.log # BUCK @@ -88,12 +88,12 @@ android/keystores/debug.keystore # generated by bob , Compilation Outputs lib/ dist/ -example/ios/build/ +example/react-native/ios/build/ # test coverage reports (generated by jest --coverage) coverage/ -example/android/build/ -example/android/app/build/ +example/react-native/android/build/ +example/react-native/android/app/build/ # --- Diagnostic and Log Files --- npm-debug.log* @@ -106,3 +106,13 @@ android/generated # React Native Nitro Modules nitrogen/ + +# Expo example (example/expo) — native dirs are generated by prebuild (CNG) +example/expo/node_modules/ +example/expo/.expo/ +example/expo/dist/ +example/expo/.env +example/expo/ios/ +example/expo/android/ +example/expo/backend/node_modules/ +example/expo/backend/.env diff --git a/README.md b/README.md index 7941dae..d2abe7a 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ A signed URL is a pre-authenticated URL that allows secure, direct uploads to Fa ### Sample Code: Generating a Signed URL -Here is a self-contained service that calls the FastPix Direct Upload API and returns a signed URL. It uses `axios` and `base-64` for the Basic Auth header (the same approach used by the bundled example app in [`example/src/Services/ApiService.ts`](example/src/Services/ApiService.ts)): +Here is a self-contained service that calls the FastPix Direct Upload API and returns a signed URL. It uses `axios` and `base-64` for the Basic Auth header (the same approach used by the bundled example app in [`example/react-native/src/Services/ApiService.ts`](example/react-native/src/Services/ApiService.ts)): > This is **your** backend/service code, not part of the SDK. Install its helpers with `npm install axios base-64`. On a Node backend you can drop `base-64` and use `Buffer.from(...).toString("base64")` instead. @@ -218,7 +218,7 @@ await upload.resume(); // re-syncs the server offset, then continues ### Full React component: progress bar with pause / resume / abort -A complete, copy-paste example wiring the resumable lifecycle to UI controls. The same flow is implemented end-to-end in the bundled [`example/`](example/) app. +A complete, copy-paste example wiring the resumable lifecycle to UI controls. The same flow is implemented end-to-end in the bundled [`example/react-native/`](example/react-native/) app. ```jsx import React, { useEffect, useRef, useState } from "react"; @@ -551,7 +551,10 @@ The example demonstrates: * Network recovery * Error handling -Refer to the **`example/`** directory for the complete implementation. +This repo ships two runnable examples: + +* **[`example/react-native/`](example/react-native)** — full React Native CLI app (logs, chunk stats, configurable options). The complete reference implementation. +* **[`example/expo/`](example/expo)** — a minimal **Expo** app (pick a video, progress bar, pause/resume) with a small backend. Good starting point for Expo projects. ## Troubleshooting diff --git a/example/expo/.gitignore b/example/expo/.gitignore new file mode 100644 index 0000000..d914c32 --- /dev/null +++ b/example/expo/.gitignore @@ -0,0 +1,41 @@ +# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files + +# dependencies +node_modules/ + +# Expo +.expo/ +dist/ +web-build/ +expo-env.d.ts + +# Native +.kotlin/ +*.orig.* +*.jks +*.p8 +*.p12 +*.key +*.mobileprovision + +# Metro +.metro-health-check* + +# debug +npm-debug.* +yarn-debug.* +yarn-error.* + +# macOS +.DS_Store +*.pem + +# local env files +.env*.local + +# typescript +*.tsbuildinfo + +# generated native folders +/ios +/android diff --git a/example/expo/App.tsx b/example/expo/App.tsx new file mode 100644 index 0000000..9bec552 --- /dev/null +++ b/example/expo/App.tsx @@ -0,0 +1,121 @@ +import { FastPixUpload } from "@fastpix/react-native-uploads"; +import * as ImagePicker from "expo-image-picker"; +import { StatusBar } from "expo-status-bar"; +import { useRef, useState } from "react"; +import { Button, StyleSheet, Text, View } from "react-native"; + +// Your backend route that creates a FastPix signed upload URL. +// - iOS Simulator / Android emulator: http://localhost:8787 reaches your Mac. +// (Android emulator: use http://10.0.2.2:8787) +// - Physical device: use your computer's LAN IP, e.g. http://192.168.1.20:8787 +const CREATE_UPLOAD_ENDPOINT = "http://localhost:8787/uploads"; + +type Status = "idle" | "uploading" | "paused" | "success" | "error"; + +// The SDK calls this when an upload starts, so a signed URL is minted per +// upload rather than per app launch. +async function createUploadUrl(): Promise { + const response = await fetch(CREATE_UPLOAD_ENDPOINT, { method: "POST" }); + if (!response.ok) throw new Error("Could not create an upload URL"); + const { uploadUrl } = (await response.json()) as { uploadUrl: string }; + return uploadUrl; +} + +export default function App() { + const uploadRef = useRef(null); + const [status, setStatus] = useState("idle"); + const [percentage, setPercentage] = useState(0); + const [error, setError] = useState(null); + + async function pickAndUpload() { + const result = await ImagePicker.launchImageLibraryAsync({ + mediaTypes: "videos", + }); + if (result.canceled) return; + + setError(null); + setPercentage(0); + + const upload = new FastPixUpload({ + endpoint: createUploadUrl, + fileUri: result.assets[0].uri, + chunkSize: 5 * 1024, // 5 MB, in KB (must be a multiple of 256 KB) + }); + uploadRef.current = upload; + + upload.on("progress", ({ percentage }) => setPercentage(percentage)); + upload.on("success", () => setStatus("success")); + upload.on("error", ({ message }) => { + setError(message); + setStatus("error"); + }); + + setStatus("uploading"); + await upload.start(); + } + + function togglePause() { + const upload = uploadRef.current; + if (!upload) return; + if (status === "uploading") { + upload.pause(); + setStatus("paused"); + } else if (status === "paused") { + upload.resume(); + setStatus("uploading"); + } + } + + const statusLine = + status === "success" + ? "Upload complete" + : status === "error" + ? `Failed: ${error}` + : status === "idle" + ? "Pick a video to start" + : `${percentage}%`; + + return ( + + + FastPix React Native Uploads + +