@gfean/react-native-bundle-drop 0.4.4 → 0.4.6

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.
@@ -1,55 +1,12 @@
1
- export type AiInitConfidence = 'high' | 'medium' | 'low';
2
- export type AiInitDecisionType = 'safe_auto_patch' | 'review_only_patch' | 'manual_fallback' | 'skip';
3
- export type AiInitDetected = {
4
- rnVersion: string | null;
5
- androidLanguage: 'kotlin' | 'java' | 'unknown';
6
- iosLanguage: 'swift' | 'objc' | 'unknown';
7
- signals: string[];
8
- existingBundleDrop: boolean;
9
- };
10
- export type AiInitPlanFile = {
11
- path: string;
12
- content: string;
13
- sha256: string;
14
- };
15
- export type AiInitPlanRequest = {
16
- schemaVersion: 1;
17
- orgSlug: string;
18
- projectSlug: string;
19
- detected: AiInitDetected;
20
- files: AiInitPlanFile[];
21
- };
1
+ export type AiSetupConfidence = 'high' | 'medium' | 'low';
2
+ export type AiSetupDecisionType = 'safe_auto_patch' | 'review_only_patch' | 'manual_fallback' | 'skip';
22
3
  export type AiPatchPlan = {
23
4
  file: string;
24
5
  originalSha256: string;
25
6
  updated: string;
26
7
  reason: string;
27
- confidence: AiInitConfidence;
28
- decisionType: AiInitDecisionType;
29
- };
30
- export type AiInitQuestion = {
31
- id: string;
32
- severity: 'info' | 'warning' | 'risky';
33
- file?: string | null;
34
- message: string;
35
- prompt: string;
36
- recommendedChoice: 'yes' | 'no';
37
- yesAction?: AiPatchPlan | null;
38
- noAction?: AiPatchPlan | 'manual_fallback' | 'skip' | null;
39
- };
40
- export type AiInitPlanResponse = {
41
- confidence: AiInitConfidence;
42
- summary: string;
43
- changes: AiPatchPlan[];
44
- questions: AiInitQuestion[];
45
- };
46
- export type AiScannerResult = {
47
- projectRoot: string;
48
- serverUrl: string;
49
- orgSlug: string;
50
- projectSlug: string;
51
- authToken: string;
52
- request: AiInitPlanRequest;
8
+ confidence: AiSetupConfidence;
9
+ decisionType: AiSetupDecisionType;
53
10
  };
54
11
  export type AiSetupProjectType = 'expo' | 'bare';
55
12
  export type AiSetupFileKind = 'package_manifest' | 'bundle_drop_config' | 'expo_app_config' | 'metro_config' | 'android_entrypoint' | 'ios_entrypoint';
@@ -64,7 +21,10 @@ export type AiSetupDetected = {
64
21
  codePushDetected: boolean;
65
22
  signals: string[];
66
23
  };
67
- export type AiSetupPlanFile = AiInitPlanFile & {
24
+ export type AiSetupPlanFile = {
25
+ path: string;
26
+ content: string;
27
+ sha256: string;
68
28
  kind: AiSetupFileKind;
69
29
  };
70
30
  export type AiSetupPlanRequest = {
@@ -77,7 +37,7 @@ export type AiSetupPlanRequest = {
77
37
  };
78
38
  export type AiSetupActionType = 'register_expo_plugin' | 'configure_bundle_drop' | 'preserve_expo_metro' | 'migrate_expo_updates' | 'configure_bare_native' | 'migrate_codepush' | 'require_native_rebuild' | 'run_doctor';
79
39
  export type AiSetupPlanResponse = {
80
- confidence: AiInitConfidence;
40
+ confidence: AiSetupConfidence;
81
41
  summary: string;
82
42
  actions: Array<{
83
43
  type: AiSetupActionType;
@@ -87,6 +47,11 @@ export type AiSetupPlanResponse = {
87
47
  changes: AiPatchPlan[];
88
48
  warnings: string[];
89
49
  };
90
- export type AiSetupScannerResult = Omit<AiScannerResult, 'request'> & {
50
+ export type AiSetupScannerResult = {
51
+ projectRoot: string;
52
+ serverUrl: string;
53
+ orgSlug: string;
54
+ projectSlug: string;
55
+ authToken: string;
91
56
  request: AiSetupPlanRequest;
92
57
  };
@@ -3,11 +3,6 @@ import { AiSetupProjectType } from './types';
3
3
  export declare const isSafeRelativePath: (value: string) => boolean;
4
4
  export declare const isPatchableNativeEntrypoint: (filePath: string) => boolean;
5
5
  export declare const isPatchableExpoConfig: (filePath: string) => boolean;
6
- export declare function validateChangesBeforeApply(params: {
7
- originals: Map<string, string>;
8
- changes: AiPatchPlan[];
9
- }): void;
10
- export declare function validateAppliedChanges(projectRoot: string, changes: AiPatchPlan[]): void;
11
6
  export declare function validateSetupChangesBeforeApply(params: {
12
7
  projectType: AiSetupProjectType;
13
8
  originals: Map<string, string>;
@@ -4,13 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isPatchableExpoConfig = exports.isPatchableNativeEntrypoint = exports.isSafeRelativePath = void 0;
7
- exports.validateChangesBeforeApply = validateChangesBeforeApply;
8
- exports.validateAppliedChanges = validateAppliedChanges;
9
7
  exports.validateSetupChangesBeforeApply = validateSetupChangesBeforeApply;
10
8
  exports.validateAppliedSetupChanges = validateAppliedSetupChanges;
11
9
  const crypto_1 = __importDefault(require("crypto"));
12
10
  const fs_extra_1 = __importDefault(require("fs-extra"));
13
11
  const path_1 = __importDefault(require("path"));
12
+ const native_setup_contract_1 = require("../native-setup-contract");
14
13
  const sha256 = (content) => crypto_1.default.createHash('sha256').update(content).digest('hex');
15
14
  const isSafeRelativePath = (value) => {
16
15
  if (!value || value.startsWith('/') || value.includes('\\'))
@@ -26,69 +25,11 @@ const isPatchableExpoConfig = (filePath) => filePath === 'app.json' ||
26
25
  /^app\.config\.(js|ts|cjs|mjs)$/.test(filePath) ||
27
26
  /^metro\.config\.(js|ts|cjs|mjs)$/.test(filePath);
28
27
  exports.isPatchableExpoConfig = isPatchableExpoConfig;
29
- const codeLikeContent = (content) => {
30
- let result = '';
31
- let state = 'code';
32
- for (let i = 0; i < content.length; i++) {
33
- const char = content[i];
34
- const next = content[i + 1];
35
- if (state === 'line-comment') {
36
- if (char === '\n') {
37
- state = 'code';
38
- result += char;
39
- }
40
- continue;
41
- }
42
- if (state === 'block-comment') {
43
- if (char === '*' && next === '/') {
44
- state = 'code';
45
- i++;
46
- }
47
- continue;
48
- }
49
- if (state === 'single' || state === 'double' || state === 'template') {
50
- if (char === '\\') {
51
- i++;
52
- continue;
53
- }
54
- if ((state === 'single' && char === "'") ||
55
- (state === 'double' && char === '"') ||
56
- (state === 'template' && char === '`')) {
57
- state = 'code';
58
- }
59
- continue;
60
- }
61
- if (char === '/' && next === '/') {
62
- state = 'line-comment';
63
- i++;
64
- continue;
65
- }
66
- if (char === '/' && next === '*') {
67
- state = 'block-comment';
68
- i++;
69
- continue;
70
- }
71
- if (char === "'") {
72
- state = 'single';
73
- continue;
74
- }
75
- if (char === '"') {
76
- state = 'double';
77
- continue;
78
- }
79
- if (char === '`') {
80
- state = 'template';
81
- continue;
82
- }
83
- result += char;
84
- }
85
- return result;
86
- };
87
28
  const hasBalancedPairs = (content) => {
88
29
  const pairs = { ')': '(', '}': '{', ']': '[' };
89
30
  const opens = new Set(Object.values(pairs));
90
31
  const stack = [];
91
- for (const char of codeLikeContent(content)) {
32
+ for (const char of (0, native_setup_contract_1.stripCommentsAndStrings)(content)) {
92
33
  if (opens.has(char))
93
34
  stack.push(char);
94
35
  if (pairs[char] && stack.pop() !== pairs[char])
@@ -97,77 +38,11 @@ const hasBalancedPairs = (content) => {
97
38
  return stack.length === 0;
98
39
  };
99
40
  const hasAndroidBundleDropIntegration = (content) => {
100
- const code = codeLikeContent(content);
101
- return /getJSBundleFile[\s\S]{0,2500}BundleDropModule\.resolveJSBundleFile|BundleDropModule\.resolveJSBundleFile[\s\S]{0,2500}getJSBundleFile/.test(code);
41
+ return (0, native_setup_contract_1.hasBareAndroidStartupIntegration)(content);
102
42
  };
103
- const hasIosBundleDropIntegration = (content) => {
104
- const code = codeLikeContent(content);
105
- return (/bundleURL[\s\S]{0,2500}BundleDropLocator\.bundleURL\(\)|BundleDropLocator\.bundleURL\(\)[\s\S]{0,2500}bundleURL/.test(code) ||
106
- /sourceURLForBridge[\s\S]{0,2500}\[BundleDropLocator bundleURL\]|\[BundleDropLocator bundleURL\][\s\S]{0,2500}sourceURLForBridge/.test(code));
43
+ const hasIosBundleDropIntegration = (filePath, content) => {
44
+ return (0, native_setup_contract_1.hasBareIosStartupIntegration)(filePath, content);
107
45
  };
108
- function validateChangesBeforeApply(params) {
109
- const seen = new Set();
110
- for (const change of params.changes) {
111
- if (!(0, exports.isSafeRelativePath)(change.file)) {
112
- throw new Error(`AI plan references an unsafe file path: ${change.file}`);
113
- }
114
- if (!(0, exports.isPatchableNativeEntrypoint)(change.file)) {
115
- throw new Error(`AI plan references a non-native entrypoint: ${change.file}`);
116
- }
117
- if (!params.originals.has(change.file)) {
118
- throw new Error(`AI plan references a file that was not scanned: ${change.file}`);
119
- }
120
- if (seen.has(change.file)) {
121
- throw new Error(`AI plan contains multiple updates for ${change.file}`);
122
- }
123
- seen.add(change.file);
124
- if (sha256(params.originals.get(change.file) || '') !== change.originalSha256) {
125
- throw new Error(`AI plan hash mismatch for ${change.file}`);
126
- }
127
- if (!change.updated.trim()) {
128
- throw new Error(`AI plan returned an empty update for ${change.file}`);
129
- }
130
- if (change.updated.includes('TODO_BUNDLEDROP') || change.updated.includes('<TODO')) {
131
- throw new Error(`AI plan returned placeholder text in ${change.file}`);
132
- }
133
- if (!hasBalancedPairs(change.updated)) {
134
- throw new Error(`AI plan returned unbalanced braces or brackets in ${change.file}`);
135
- }
136
- if ((change.file.startsWith('android/') || change.file.includes('/android/')) &&
137
- !hasAndroidBundleDropIntegration(change.updated)) {
138
- throw new Error(`AI plan Android update does not contain BundleDrop resolver: ${change.file}`);
139
- }
140
- if ((change.file.startsWith('ios/') || change.file.includes('/ios/')) &&
141
- !hasIosBundleDropIntegration(change.updated)) {
142
- throw new Error(`AI plan iOS update does not contain BundleDrop locator: ${change.file}`);
143
- }
144
- }
145
- }
146
- function validateAppliedChanges(projectRoot, changes) {
147
- for (const change of changes) {
148
- if (!(0, exports.isSafeRelativePath)(change.file) || !(0, exports.isPatchableNativeEntrypoint)(change.file)) {
149
- throw new Error(`Updated file path is not allowed: ${change.file}`);
150
- }
151
- const content = fs_extra_1.default.readFileSync(path_1.default.join(projectRoot, change.file), 'utf8');
152
- if (!content.trim()) {
153
- throw new Error(`Updated file is empty: ${change.file}`);
154
- }
155
- if (content.includes('TODO_BUNDLEDROP') || content.includes('<TODO')) {
156
- throw new Error(`Updated file contains placeholder text: ${change.file}`);
157
- }
158
- if (!hasBalancedPairs(content)) {
159
- throw new Error(`Updated file has unbalanced braces or brackets: ${change.file}`);
160
- }
161
- if ((change.file.startsWith('android/') || change.file.includes('/android/')) &&
162
- !hasAndroidBundleDropIntegration(content)) {
163
- throw new Error(`Android update does not contain BundleDrop resolver: ${change.file}`);
164
- }
165
- if ((change.file.startsWith('ios/') || change.file.includes('/ios/')) &&
166
- !hasIosBundleDropIntegration(content)) {
167
- throw new Error(`iOS update does not contain BundleDrop locator: ${change.file}`);
168
- }
169
- }
170
- }
171
46
  const validateCommonSetupChange = (change, originals, seen) => {
172
47
  if (!(0, exports.isSafeRelativePath)(change.file)) {
173
48
  throw new Error(`AI setup plan references an unsafe file path: ${change.file}`);
@@ -179,7 +54,7 @@ const validateCommonSetupChange = (change, originals, seen) => {
179
54
  throw new Error(`AI setup plan contains multiple updates for ${change.file}`);
180
55
  }
181
56
  seen.add(change.file);
182
- if (sha256(originals.get(change.file) || '') !== change.originalSha256) {
57
+ if (sha256(originals.get(change.file)) !== change.originalSha256) {
183
58
  throw new Error(`AI setup plan hash mismatch for ${change.file}`);
184
59
  }
185
60
  if (!change.updated.trim()) {
@@ -217,7 +92,8 @@ function validateSetupChangesBeforeApply(params) {
217
92
  if (change.file.includes('MainApplication.') && !hasAndroidBundleDropIntegration(change.updated)) {
218
93
  throw new Error(`AI plan Android update does not contain BundleDrop resolver: ${change.file}`);
219
94
  }
220
- if (change.file.includes('AppDelegate.') && !hasIosBundleDropIntegration(change.updated)) {
95
+ if (change.file.includes('AppDelegate.') &&
96
+ !hasIosBundleDropIntegration(change.file, change.updated)) {
221
97
  throw new Error(`AI plan iOS update does not contain BundleDrop locator: ${change.file}`);
222
98
  }
223
99
  }
@@ -232,8 +108,8 @@ function validateAppliedSetupChanges(params) {
232
108
  originals,
233
109
  changes: params.changes.map(change => ({
234
110
  ...change,
235
- originalSha256: sha256(originals.get(change.file) || ''),
236
- updated: originals.get(change.file) || '',
111
+ originalSha256: sha256(originals.get(change.file)),
112
+ updated: originals.get(change.file),
237
113
  })),
238
114
  });
239
115
  }
@@ -5,5 +5,3 @@ export type MetroConfigChange = {
5
5
  reason: string;
6
6
  };
7
7
  export declare function planBareMetroConfig(projectRoot: string): MetroConfigChange | null;
8
- export declare function initMetroConfig(): Promise<void>;
9
- export default initMetroConfig;
@@ -4,24 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.planBareMetroConfig = planBareMetroConfig;
7
- exports.initMetroConfig = initMetroConfig;
8
- const chalk_1 = __importDefault(require("chalk"));
9
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
10
8
  const path_1 = __importDefault(require("path"));
11
- function findProjectRoot(startDir) {
12
- let dir = path_1.default.resolve(startDir);
13
- const MAX_UP = 12;
14
- for (let i = 0; i < MAX_UP; i++) {
15
- if (fs_extra_1.default.existsSync(path_1.default.join(dir, 'package.json'))) {
16
- return dir;
17
- }
18
- const parent = path_1.default.dirname(dir);
19
- if (parent === dir)
20
- break;
21
- dir = parent;
22
- }
23
- return startDir;
24
- }
25
9
  const APPEND_SNIPPET = `
26
10
  // Bundle Drop: ensure bundle.drop.config.js is resolvable from node_modules
27
11
  (() => {
@@ -45,7 +29,6 @@ config.resolver.extraNodeModules = {
45
29
  };
46
30
 
47
31
  module.exports = config;
48
- ${APPEND_SNIPPET}
49
32
  `;
50
33
  function planBareMetroConfig(projectRoot) {
51
34
  const metroPath = path_1.default.join(projectRoot, 'metro.config.js');
@@ -67,20 +50,3 @@ function planBareMetroConfig(projectRoot) {
67
50
  reason: 'Add the Bundle Drop alias without replacing the existing Metro config.',
68
51
  };
69
52
  }
70
- async function initMetroConfig() {
71
- const projectRoot = findProjectRoot(process.cwd());
72
- const metroPath = path_1.default.join(projectRoot, 'metro.config.js');
73
- const change = planBareMetroConfig(projectRoot);
74
- if (!change) {
75
- console.log(chalk_1.default.gray('ℹ️ metro.config.js already contains bundle-drop-config alias.'));
76
- return;
77
- }
78
- if (change.original === null) {
79
- fs_extra_1.default.writeFileSync(metroPath, change.updated, 'utf8');
80
- console.log(chalk_1.default.green(`✅ Created metro.config.js with Bundle Drop alias at ${metroPath}`));
81
- return;
82
- }
83
- fs_extra_1.default.writeFileSync(metroPath, change.updated, 'utf8');
84
- console.log(chalk_1.default.green(`✅ Added bundle-drop-config alias to metro.config.js`));
85
- }
86
- exports.default = initMetroConfig;
@@ -8,6 +8,7 @@ exports.runDoctor = runDoctor;
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
+ const native_setup_contract_1 = require("./native-setup-contract");
11
12
  const expo_1 = require("../../expo");
12
13
  const build_receipt_1 = require("./expo/build-receipt");
13
14
  const scanner_1 = require("./aipowered/scanner");
@@ -244,7 +245,6 @@ const checkBarePackageMetadata = (projectRoot) => {
244
245
  : '';
245
246
  const valid = fs_1.default.existsSync(path_1.default.join(packageRoot, 'BundleDrop.podspec')) &&
246
247
  fs_1.default.existsSync(path_1.default.join(packageRoot, 'android')) &&
247
- reactNativeConfig.includes('BundleDrop.podspec') &&
248
248
  reactNativeConfig.includes('BundleDropPackage');
249
249
  return {
250
250
  name: 'Bare/native autolinking metadata',
@@ -302,10 +302,8 @@ const checkBareStartupIntegration = (projectRoot, platform) => {
302
302
  const hasIntegration = entrypoints.some(filePath => {
303
303
  const content = fs_1.default.readFileSync(filePath, 'utf8');
304
304
  return platform === 'android'
305
- ? content.includes('BundleDropModule.resolveJSBundleFile') ||
306
- content.includes('BundleDropNativePaths.getDownloadedBundlePath')
307
- : content.includes('BundleDropLocator.bundleURL()') ||
308
- content.includes('[BundleDropLocator bundleURL]');
305
+ ? (0, native_setup_contract_1.hasBareAndroidStartupIntegration)(content)
306
+ : (0, native_setup_contract_1.hasBareIosStartupIntegration)(filePath, content);
309
307
  });
310
308
  return {
311
309
  name: `${platform} OTA startup ownership`,
@@ -16,6 +16,7 @@ const init_config_1 = require("./init-config");
16
16
  const post_init_1 = require("./post-init");
17
17
  const expo_1 = require("../../expo");
18
18
  const LOGIN_TIMEOUT_MS = 10 * 60 * 1000;
19
+ const DOCS_INSTALLATION_URL = 'https://bundledrop.app/docs/installation';
19
20
  const getBaseUrl = () => process.env.BUNDLE_DROP_SERVER_URL
20
21
  ? process.env.BUNDLE_DROP_SERVER_URL.replace(/\/$/, '')
21
22
  : 'https://api.bundledrop.app';
@@ -293,6 +294,9 @@ const login = async () => {
293
294
  : error.message;
294
295
  const failureLabel = loginCompleted ? '❌ Setup failed after login:' : '❌ Login failed:';
295
296
  console.error(chalk_1.default.red(failureLabel), message);
297
+ if (loginCompleted) {
298
+ console.error(chalk_1.default.gray(`Manual installation: ${DOCS_INSTALLATION_URL}`));
299
+ }
296
300
  process.exitCode = 1;
297
301
  }
298
302
  finally {
@@ -0,0 +1,7 @@
1
+ export declare const ANDROID_BUNDLE_DROP_MODULE = "com.bundledrop.BundleDropModule";
2
+ export declare const ANDROID_BUNDLE_DROP_PATHS = "com.bundledrop.BundleDropNativePaths";
3
+ export declare const IOS_BUNDLE_DROP_MODULE = "BundleDrop";
4
+ export declare const IOS_BUNDLE_DROP_LOCATOR_HEADER = "BundleDrop/BundleDropLocator.h";
5
+ export declare const stripCommentsAndStrings: (content: string) => string;
6
+ export declare const hasBareAndroidStartupIntegration: (code: string) => boolean;
7
+ export declare const hasBareIosStartupIntegration: (filePath: string, code: string) => boolean;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasBareIosStartupIntegration = exports.hasBareAndroidStartupIntegration = exports.stripCommentsAndStrings = exports.IOS_BUNDLE_DROP_LOCATOR_HEADER = exports.IOS_BUNDLE_DROP_MODULE = exports.ANDROID_BUNDLE_DROP_PATHS = exports.ANDROID_BUNDLE_DROP_MODULE = void 0;
4
+ exports.ANDROID_BUNDLE_DROP_MODULE = 'com.bundledrop.BundleDropModule';
5
+ exports.ANDROID_BUNDLE_DROP_PATHS = 'com.bundledrop.BundleDropNativePaths';
6
+ exports.IOS_BUNDLE_DROP_MODULE = 'BundleDrop';
7
+ exports.IOS_BUNDLE_DROP_LOCATOR_HEADER = 'BundleDrop/BundleDropLocator.h';
8
+ const stripCommentsAndStrings = (content) => {
9
+ let code = '';
10
+ let state = 'code';
11
+ let escaped = false;
12
+ for (let index = 0; index < content.length; index += 1) {
13
+ const character = content[index];
14
+ const nextCharacter = content[index + 1];
15
+ if (state === 'line-comment') {
16
+ if (character === '\n') {
17
+ state = 'code';
18
+ code += character;
19
+ }
20
+ continue;
21
+ }
22
+ if (state === 'block-comment') {
23
+ if (character === '*' && nextCharacter === '/') {
24
+ state = 'code';
25
+ index += 1;
26
+ }
27
+ continue;
28
+ }
29
+ if (state !== 'code') {
30
+ if (escaped) {
31
+ escaped = false;
32
+ continue;
33
+ }
34
+ if (character === '\\') {
35
+ escaped = true;
36
+ continue;
37
+ }
38
+ const closesState = (state === 'single' && character === "'") ||
39
+ (state === 'double' && character === '"') ||
40
+ (state === 'template' && character === '`');
41
+ if (closesState)
42
+ state = 'code';
43
+ continue;
44
+ }
45
+ if (character === '/' && nextCharacter === '/') {
46
+ state = 'line-comment';
47
+ index += 1;
48
+ continue;
49
+ }
50
+ if (character === '/' && nextCharacter === '*') {
51
+ state = 'block-comment';
52
+ index += 1;
53
+ continue;
54
+ }
55
+ if (character === "'") {
56
+ state = 'single';
57
+ continue;
58
+ }
59
+ if (character === '"') {
60
+ state = 'double';
61
+ continue;
62
+ }
63
+ if (character === '`') {
64
+ state = 'template';
65
+ continue;
66
+ }
67
+ code += character;
68
+ }
69
+ return code;
70
+ };
71
+ exports.stripCommentsAndStrings = stripCommentsAndStrings;
72
+ const hasJavaOrKotlinReference = (code, qualifiedName, member) => {
73
+ const escapedName = qualifiedName.replace(/\./g, '\\.');
74
+ return (new RegExp(`\\bimport\\s+${escapedName}\\s*;?`).test(code) ||
75
+ code.includes(`${qualifiedName}.${member}`));
76
+ };
77
+ const hasBareAndroidStartupIntegration = (code) => {
78
+ const nativeCode = (0, exports.stripCommentsAndStrings)(code);
79
+ const usesModuleResolver = nativeCode.includes('getJSBundleFile') &&
80
+ nativeCode.includes('BundleDropModule.resolveJSBundleFile') &&
81
+ hasJavaOrKotlinReference(nativeCode, exports.ANDROID_BUNDLE_DROP_MODULE, 'resolveJSBundleFile');
82
+ const usesNativePaths = nativeCode.includes('BundleDropNativePaths.getDownloadedBundlePath') &&
83
+ hasJavaOrKotlinReference(nativeCode, exports.ANDROID_BUNDLE_DROP_PATHS, 'getDownloadedBundlePath');
84
+ return usesModuleResolver || usesNativePaths;
85
+ };
86
+ exports.hasBareAndroidStartupIntegration = hasBareAndroidStartupIntegration;
87
+ const hasBareIosStartupIntegration = (filePath, code) => {
88
+ const nativeCode = (0, exports.stripCommentsAndStrings)(code);
89
+ if (filePath.endsWith('.swift')) {
90
+ const usesLocator = nativeCode.includes('bundleURL') &&
91
+ nativeCode.includes('BundleDropLocator.bundleURL()');
92
+ return usesLocator &&
93
+ new RegExp(`\\bimport\\s+${exports.IOS_BUNDLE_DROP_MODULE}\\b`).test(nativeCode);
94
+ }
95
+ const usesLocator = (nativeCode.includes('sourceURLForBridge') || nativeCode.includes('bundleURL')) &&
96
+ nativeCode.includes('[BundleDropLocator bundleURL]');
97
+ const escapedHeader = exports.IOS_BUNDLE_DROP_LOCATOR_HEADER.replace(/[/.]/g, '\\$&');
98
+ return usesLocator &&
99
+ new RegExp(`#import\\s*[<\"]${escapedHeader}[>\"]`).test(nativeCode);
100
+ };
101
+ exports.hasBareIosStartupIntegration = hasBareIosStartupIntegration;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gfean/react-native-bundle-drop",
3
- "version": "0.4.4",
4
- "nativeVersion": "0.4.4",
3
+ "version": "0.4.6",
4
+ "nativeVersion": "0.4.5",
5
5
  "description": "Over-the-air updates for Expo and bare React Native apps, with channels, staged rollouts, patch delivery, and rollback.",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "devDependencies": {
57
57
  "@types/adm-zip": "^0.5.8",
58
58
  "@types/jest": "^29.5.14",
59
- "@types/node": "^24.10.1",
59
+ "@types/node": "^24.13.3",
60
60
  "@types/react": "^18.2.66",
61
61
  "@types/react-native": "^0.73.0",
62
62
  "expo-autolinking-sdk55": "npm:expo-modules-autolinking@55.0.8",
@@ -66,11 +66,11 @@
66
66
  "react": "^18.3.1",
67
67
  "react-native": ">=0.71.0",
68
68
  "react-test-renderer": "^18.3.1",
69
- "rimraf": "^6.0.1",
69
+ "rimraf": "^6.1.3",
70
70
  "rn-cli-platform-android-078": "npm:@react-native-community/cli-platform-android@15.0.1",
71
- "ts-jest": "^29.4.4",
71
+ "ts-jest": "^29.4.12",
72
72
  "ts-node": "^10.9.2",
73
- "typescript": "^5.8.3"
73
+ "typescript": "^5.9.3"
74
74
  },
75
75
  "bin": {
76
76
  "bundle-drop": "lib/CLI/cli.js"
@@ -173,8 +173,8 @@
173
173
  "diff": "^9.0.0",
174
174
  "figures": "3",
175
175
  "form-data": "^4.0.6",
176
- "fs-extra": "^11.2.0",
177
- "plist": "^3.1.0",
176
+ "fs-extra": "^11.4.0",
177
+ "plist": "^3.1.1",
178
178
  "prompts": "^2.4.2"
179
179
  },
180
180
  "publishConfig": {
@@ -1,13 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const path = require('path');
4
-
5
3
  module.exports = {
6
4
  dependency: {
7
5
  platforms: {
8
- ios: {
9
- podspecPath: path.join(__dirname, 'BundleDrop.podspec'),
10
- },
11
6
  android: {
12
7
  // Keep this relative. Both the Community CLI and Expo autolinking
13
8
  // resolve sourceDir from the installed package root.
@@ -1,10 +0,0 @@
1
- import { AiPatchPlan } from './types';
2
- export type ApplyResult = {
3
- backupDir: string;
4
- changedFiles: string[];
5
- };
6
- export declare function restoreBackups(result: ApplyResult): void;
7
- export declare function applyPatchPlans(params: {
8
- projectRoot: string;
9
- changes: AiPatchPlan[];
10
- }): ApplyResult;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.restoreBackups = restoreBackups;
7
- exports.applyPatchPlans = applyPatchPlans;
8
- const crypto_1 = __importDefault(require("crypto"));
9
- const fs_extra_1 = __importDefault(require("fs-extra"));
10
- const path_1 = __importDefault(require("path"));
11
- const validate_plan_1 = require("./validate-plan");
12
- const sha256 = (content) => crypto_1.default.createHash('sha256').update(content).digest('hex');
13
- const timestamp = () => new Date().toISOString().replace(/[:.]/g, '-');
14
- function restoreBackups(result) {
15
- for (const relative of result.changedFiles) {
16
- const backupPath = path_1.default.join(result.backupDir, relative);
17
- if (fs_extra_1.default.existsSync(backupPath)) {
18
- fs_extra_1.default.copyFileSync(backupPath, path_1.default.resolve(result.backupDir, '..', '..', relative));
19
- }
20
- }
21
- }
22
- function applyPatchPlans(params) {
23
- const backupDir = path_1.default.join(params.projectRoot, '.bundledrop-backup', timestamp());
24
- const changedFiles = [];
25
- const result = { backupDir, changedFiles };
26
- try {
27
- for (const change of params.changes) {
28
- if (!(0, validate_plan_1.isSafeRelativePath)(change.file) || !(0, validate_plan_1.isPatchableNativeEntrypoint)(change.file)) {
29
- throw new Error(`Refusing to write AI plan outside native entrypoints: ${change.file}`);
30
- }
31
- const targetPath = path_1.default.join(params.projectRoot, change.file);
32
- const original = fs_extra_1.default.readFileSync(targetPath, 'utf8');
33
- if (sha256(original) !== change.originalSha256) {
34
- throw new Error(`File changed since AI scan: ${change.file}`);
35
- }
36
- const backupPath = path_1.default.join(backupDir, change.file);
37
- fs_extra_1.default.ensureDirSync(path_1.default.dirname(backupPath));
38
- fs_extra_1.default.copyFileSync(targetPath, backupPath);
39
- changedFiles.push(change.file);
40
- const tmpPath = `${targetPath}.bundledrop-tmp`;
41
- fs_extra_1.default.writeFileSync(tmpPath, change.updated, 'utf8');
42
- fs_extra_1.default.renameSync(tmpPath, targetPath);
43
- }
44
- return result;
45
- }
46
- catch (error) {
47
- restoreBackups(result);
48
- throw error;
49
- }
50
- }
@@ -1,2 +0,0 @@
1
- export declare function initNativeConfigAi(): Promise<void>;
2
- export default initNativeConfigAi;