@gfean/react-native-bundle-drop 0.1.31

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.
Files changed (47) hide show
  1. package/BundleDrop.podspec +23 -0
  2. package/CLIENT_README.md +139 -0
  3. package/README.md +91 -0
  4. package/android/build.gradle +79 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +3 -0
  7. package/android/src/main/AndroidManifestNew.xml +2 -0
  8. package/android/src/main/java/com/bundledrop/BundleDropModule.kt +148 -0
  9. package/android/src/main/java/com/bundledrop/BundleDropPackage.kt +16 -0
  10. package/ios/BundleDropBridge.m +16 -0
  11. package/ios/BundleDropLocator.swift +34 -0
  12. package/ios/BundleDropModule.swift +58 -0
  13. package/lib/CLI/cli.d.ts +2 -0
  14. package/lib/CLI/cli.js +122 -0
  15. package/lib/CLI/scripts/init-config.d.ts +17 -0
  16. package/lib/CLI/scripts/init-config.js +106 -0
  17. package/lib/CLI/scripts/init-native-config.d.ts +2 -0
  18. package/lib/CLI/scripts/init-native-config.js +137 -0
  19. package/lib/CLI/scripts/login-cli.d.ts +2 -0
  20. package/lib/CLI/scripts/login-cli.js +56 -0
  21. package/lib/CLI/scripts/upload-cli.d.ts +8 -0
  22. package/lib/CLI/scripts/upload-cli.js +248 -0
  23. package/lib/CLI/utils/ui.d.ts +8 -0
  24. package/lib/CLI/utils/ui.js +16 -0
  25. package/lib/bundleInfo.d.ts +14 -0
  26. package/lib/bundleInfo.js +34 -0
  27. package/lib/image-manifest.d.ts +1 -0
  28. package/lib/image-manifest.js +4 -0
  29. package/lib/index.d.ts +51 -0
  30. package/lib/index.js +415 -0
  31. package/lib/injectImageResolver.d.ts +2 -0
  32. package/lib/injectImageResolver.js +121 -0
  33. package/lib/loadConfig.d.ts +17 -0
  34. package/lib/loadConfig.js +33 -0
  35. package/lib/patchImageAutoResolve.d.ts +1 -0
  36. package/lib/patchImageAutoResolve.js +25 -0
  37. package/lib/scripts/bundle.d.ts +2 -0
  38. package/lib/scripts/bundle.js +163 -0
  39. package/lib/scripts/download-bundle.d.ts +2 -0
  40. package/lib/scripts/download-bundle.js +79 -0
  41. package/lib/scripts/upload-bundle.d.ts +2 -0
  42. package/lib/scripts/upload-bundle.js +290 -0
  43. package/lib/types.d.ts +1 -0
  44. package/lib/types.js +2 -0
  45. package/lib/useBundleDrop.d.ts +40 -0
  46. package/lib/useBundleDrop.js +131 -0
  47. package/package.json +66 -0
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useBundleDrop = useBundleDrop;
4
+ const react_1 = require("react");
5
+ const index_1 = require("./index");
6
+ function useBundleDrop(options) {
7
+ const channelName = options?.channelName || 'General';
8
+ const [status, setStatus] = (0, react_1.useState)('Click the button to check for updates');
9
+ const [installedInfo, setInstalledInfo] = (0, react_1.useState)(null);
10
+ const [pendingApply, setPendingApply] = (0, react_1.useState)(false);
11
+ const [hasBundle, setHasBundle] = (0, react_1.useState)(false);
12
+ const [isBusy, setIsBusy] = (0, react_1.useState)(false);
13
+ const refresh = (0, react_1.useCallback)(async () => {
14
+ const state = await (0, index_1.getUpdateState)();
15
+ setInstalledInfo(state.info || null);
16
+ setPendingApply(state.pendingApply);
17
+ setHasBundle(state.hasBundle);
18
+ }, []);
19
+ const withBusy = (0, react_1.useCallback)(async (fn) => {
20
+ setIsBusy(true);
21
+ try {
22
+ await fn();
23
+ await refresh();
24
+ }
25
+ finally {
26
+ setIsBusy(false);
27
+ }
28
+ }, [refresh]);
29
+ const checkLatest = (0, react_1.useCallback)(async () => {
30
+ await withBusy(async () => {
31
+ const res = await (0, index_1.checkForUpdate)(channelName, msg => setStatus(msg));
32
+ if (!res) {
33
+ setStatus('⚠️ Unable to check for updates. Try again.');
34
+ return;
35
+ }
36
+ if (res.upToDate) {
37
+ setStatus('✅ You have the latest version');
38
+ return;
39
+ }
40
+ if (res.incompatible) {
41
+ setStatus('⛔️ No compatible update for this binary');
42
+ return;
43
+ }
44
+ const nextLabel = res.bundleVersion
45
+ ? `⬇️ Update available${res.bundleVersion ? ` (v${res.bundleVersion})` : ''}`
46
+ : '⬇️ Update available';
47
+ setStatus(nextLabel);
48
+ });
49
+ }, [channelName, withBusy]);
50
+ const downloadImmediate = (0, react_1.useCallback)(async () => {
51
+ await withBusy(async () => {
52
+ await (0, index_1.restartAppAndInstallUpdate)(msg => setStatus(msg), {
53
+ channelName,
54
+ applyBehavior: 'immediate',
55
+ });
56
+ });
57
+ }, [channelName, withBusy]);
58
+ const downloadForNextLaunch = (0, react_1.useCallback)(async () => {
59
+ await withBusy(async () => {
60
+ const check = await (0, index_1.checkForUpdate)(channelName, msg => setStatus(msg));
61
+ if (check?.upToDate) {
62
+ setStatus('✅ You have the latest version');
63
+ return;
64
+ }
65
+ if (check?.incompatible) {
66
+ setStatus('⛔️ No compatible update for this binary');
67
+ return;
68
+ }
69
+ await (0, index_1.downloadUpdate)({ channelName, applyBehavior: 'on-next-launch' }, msg => setStatus(msg));
70
+ setStatus('✅ Update downloaded. It will apply on next launch.');
71
+ });
72
+ }, [channelName, withBusy]);
73
+ const downloadManual = (0, react_1.useCallback)(async () => {
74
+ await withBusy(async () => {
75
+ const check = await (0, index_1.checkForUpdate)(channelName, msg => setStatus(msg));
76
+ if (check?.upToDate) {
77
+ setStatus('✅ You have the latest version');
78
+ return;
79
+ }
80
+ if (check?.incompatible) {
81
+ setStatus('⛔️ No compatible update for this binary');
82
+ return;
83
+ }
84
+ await (0, index_1.downloadUpdate)({ channelName, applyBehavior: 'manual' }, msg => setStatus(msg));
85
+ setStatus('✅ Update downloaded. Tap Apply to reload when ready.');
86
+ });
87
+ }, [channelName, withBusy]);
88
+ const applyPending = (0, react_1.useCallback)(async () => {
89
+ await withBusy(async () => {
90
+ const applied = await (0, index_1.applyReadyUpdate)(msg => setStatus(msg));
91
+ if (applied) {
92
+ setStatus('✅ Update applied, reloading...');
93
+ }
94
+ });
95
+ }, [withBusy]);
96
+ // Optional auto-init to mimic Expo/CodePush style.
97
+ (0, react_1.useEffect)(() => {
98
+ if (options?.autoInit && options.policy && options.policy !== 'manual') {
99
+ const run = async () => {
100
+ try {
101
+ await (0, index_1.initUpdateManager)({
102
+ channelName,
103
+ policy: options.policy,
104
+ onStatusUpdate: msg => setStatus(msg),
105
+ checkOnly: options.checkOnly,
106
+ });
107
+ }
108
+ finally {
109
+ await refresh();
110
+ }
111
+ };
112
+ run();
113
+ }
114
+ else {
115
+ refresh();
116
+ }
117
+ }, [channelName, options?.autoInit, options?.policy, options?.checkOnly, refresh]);
118
+ return {
119
+ status,
120
+ isBusy,
121
+ installedInfo,
122
+ pendingApply,
123
+ hasBundle,
124
+ checkLatest,
125
+ downloadImmediate,
126
+ downloadForNextLaunch,
127
+ downloadManual,
128
+ applyPending,
129
+ refresh,
130
+ };
131
+ }
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@gfean/react-native-bundle-drop",
3
+ "version": "0.1.31",
4
+ "description": "react native ota by gFean",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "author": " <> ()",
8
+ "license": "UNLICENSED",
9
+ "homepage": "#readme",
10
+ "scripts": {
11
+ "clean": "rimraf lib dist",
12
+ "build": "tsc -p tsconfig.json && node scripts/make-cli-executable.js",
13
+ "prepublishOnly": "yarn clean && yarn build"
14
+ },
15
+ "create-react-native-library": {
16
+ "type": "legacy-module",
17
+ "languages": "kotlin-swift",
18
+ "version": "0.49.6"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^24.10.1",
22
+ "@types/react": "^18.2.66",
23
+ "@types/react-native": "^0.73.0",
24
+ "rimraf": "^6.0.1",
25
+ "ts-node": "^10.9.2",
26
+ "typescript": "^5.8.3"
27
+ },
28
+ "bin": {
29
+ "bundle-drop": "lib/CLI/cli.js"
30
+ },
31
+ "files": [
32
+ "lib",
33
+ "android/src/**",
34
+ "android/build.gradle",
35
+ "android/gradle.properties",
36
+ "android/gradle/wrapper/**",
37
+ "android/gradlew",
38
+ "android/gradlew.bat",
39
+ "ios/*.{m,h,mm,swift}",
40
+ "BundleDrop.podspec",
41
+ "react-native.config.js",
42
+ "README.md",
43
+ "CLIENT_README.md"
44
+ ],
45
+ "dependencies": {
46
+ "adm-zip": "^0.5.16",
47
+ "archiver": "^7.0.1",
48
+ "axios": "^1.8.4",
49
+ "chalk": "4",
50
+ "commander": "^13.1.0",
51
+ "fflate": "^0.8.2",
52
+ "figures": "3",
53
+ "form-data": "^4.0.2",
54
+ "formdata-node": "^6.0.3",
55
+ "fs-extra": "^11.2.0",
56
+ "plist": "^3.1.0",
57
+ "prompts": "^2.4.2",
58
+ "react-native-fs": "^2.20.0",
59
+ "react-native-zip-archive": "^7.0.1",
60
+ "undici": "^7.8.0"
61
+ },
62
+ "publishConfig": {
63
+ "access": "restricted"
64
+ },
65
+ "packageManager": "yarn@3.8.3+sha512.154080e749d50325f4df31bc341cd5ea2dc2c3ca9b2cfb8591c831ddefc8025084d9500223f61f4f73086f6d9faa746cbbf39bb988b41dfc042907687e8e7d7a"
66
+ }