@gfean/react-native-bundle-drop 0.4.3 → 0.4.5

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 (115) hide show
  1. package/BundleDropExpo.podspec +21 -0
  2. package/README.md +250 -124
  3. package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +33 -3
  4. package/app.plugin.js +3 -0
  5. package/expo/android/build.gradle +159 -0
  6. package/expo/android/src/main/AndroidManifest.xml +1 -0
  7. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoConfiguration.kt +35 -0
  8. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoIdentityModule.kt +30 -0
  9. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoPackage.kt +29 -0
  10. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoReactNativeHostHandler.kt +16 -0
  11. package/expo/bundle-drop-expo-gradle-plugin/build.gradle +31 -0
  12. package/expo/bundle-drop-expo-gradle-plugin/src/main/groovy/com/bundledrop/gradle/BundleDropExpoPlugin.groovy +83 -0
  13. package/expo/bundle-drop-expo-gradle-plugin/src/main/groovy/com/bundledrop/gradle/GenerateBundleDropBuildIdentityTask.groovy +57 -0
  14. package/expo/ios/Sources/BundleDropExpoIdentity.m +31 -0
  15. package/expo/ios/Sources/BundleDropExpoReactDelegateHandler.swift +24 -0
  16. package/expo-module.config.json +19 -0
  17. package/ios/BundleDropLocator.swift +7 -1
  18. package/lib/CLI/cli.d.ts +1 -2
  19. package/lib/CLI/cli.js +151 -56
  20. package/lib/CLI/logo.js +1 -1
  21. package/lib/CLI/scripts/aipowered/apply-setup-plan.d.ts +12 -0
  22. package/lib/CLI/scripts/aipowered/{apply-plan.js → apply-setup-plan.js} +24 -19
  23. package/lib/CLI/scripts/aipowered/backend-client.d.ts +4 -4
  24. package/lib/CLI/scripts/aipowered/backend-client.js +7 -7
  25. package/lib/CLI/scripts/aipowered/init-project-config.d.ts +17 -0
  26. package/lib/CLI/scripts/aipowered/init-project-config.js +418 -0
  27. package/lib/CLI/scripts/aipowered/scanner.d.ts +10 -3
  28. package/lib/CLI/scripts/aipowered/scanner.js +225 -201
  29. package/lib/CLI/scripts/aipowered/types.d.ts +37 -33
  30. package/lib/CLI/scripts/aipowered/validate-plan.d.ts +9 -2
  31. package/lib/CLI/scripts/aipowered/validate-plan.js +70 -119
  32. package/lib/CLI/scripts/bare-metro-config.d.ts +7 -0
  33. package/lib/CLI/scripts/{init-metro-config.js → bare-metro-config.js} +16 -30
  34. package/lib/CLI/scripts/doctor.d.ts +17 -0
  35. package/lib/CLI/scripts/doctor.js +410 -0
  36. package/lib/CLI/scripts/expo/build-receipt.d.ts +26 -0
  37. package/lib/CLI/scripts/expo/build-receipt.js +223 -0
  38. package/lib/CLI/scripts/expo/configure-expo.d.ts +28 -0
  39. package/lib/CLI/scripts/expo/configure-expo.js +268 -0
  40. package/lib/CLI/scripts/expo/eas-build-proof.d.ts +22 -0
  41. package/lib/CLI/scripts/expo/eas-build-proof.js +116 -0
  42. package/lib/CLI/scripts/expo/package-manager.d.ts +11 -0
  43. package/lib/CLI/scripts/expo/package-manager.js +84 -0
  44. package/lib/CLI/scripts/expo/write-build-receipt.d.ts +25 -0
  45. package/lib/CLI/scripts/expo/write-build-receipt.js +325 -0
  46. package/lib/CLI/scripts/expo/write-eas-build-receipt.d.ts +8 -0
  47. package/lib/CLI/scripts/expo/write-eas-build-receipt.js +71 -0
  48. package/lib/CLI/scripts/init-config.d.ts +18 -1
  49. package/lib/CLI/scripts/init-config.js +29 -8
  50. package/lib/CLI/scripts/login-cli.js +21 -3
  51. package/lib/CLI/scripts/native-setup-contract.d.ts +7 -0
  52. package/lib/CLI/scripts/native-setup-contract.js +101 -0
  53. package/lib/CLI/scripts/post-init.d.ts +6 -1
  54. package/lib/CLI/scripts/post-init.js +6 -33
  55. package/lib/CLI/scripts/upload-cli.d.ts +1 -0
  56. package/lib/CLI/scripts/upload-cli.js +106 -36
  57. package/lib/context.d.ts +0 -2
  58. package/lib/context.js +18 -2
  59. package/lib/expo/buildIdentity.d.ts +15 -0
  60. package/lib/expo/buildIdentity.js +201 -0
  61. package/lib/expo/buildReceipt.d.ts +42 -0
  62. package/lib/expo/buildReceipt.js +272 -0
  63. package/lib/expo/config.d.ts +7 -0
  64. package/lib/expo/config.js +43 -0
  65. package/lib/expo/configCache.d.ts +1 -0
  66. package/lib/expo/configCache.js +20 -0
  67. package/lib/expo/errors.d.ts +6 -0
  68. package/lib/expo/errors.js +11 -0
  69. package/lib/expo/expoUpdatesOwnership.d.ts +13 -0
  70. package/lib/expo/expoUpdatesOwnership.js +22 -0
  71. package/lib/expo/exportExpoProject.d.ts +21 -0
  72. package/lib/expo/exportExpoProject.js +125 -0
  73. package/lib/expo/exportValidation.d.ts +11 -0
  74. package/lib/expo/exportValidation.js +115 -0
  75. package/lib/expo/index.d.ts +18 -0
  76. package/lib/expo/index.js +25 -0
  77. package/lib/expo/localModules.d.ts +4 -0
  78. package/lib/expo/localModules.js +51 -0
  79. package/lib/expo/nativeIdentity.d.ts +1 -0
  80. package/lib/expo/nativeIdentity.js +17 -0
  81. package/lib/expo/projectType.d.ts +7 -0
  82. package/lib/expo/projectType.js +200 -0
  83. package/lib/expo/runtimeVersion.d.ts +13 -0
  84. package/lib/expo/runtimeVersion.js +45 -0
  85. package/lib/expo/types.d.ts +15 -0
  86. package/lib/expo/types.js +2 -0
  87. package/lib/fs/userProperties.d.ts +0 -2
  88. package/lib/fs/userProperties.js +0 -3
  89. package/lib/index.d.ts +1 -1
  90. package/lib/index.js +1 -2
  91. package/lib/loadConfig.d.ts +15 -7
  92. package/lib/loadConfig.js +2 -19
  93. package/lib/metro.d.ts +17 -0
  94. package/lib/metro.js +57 -0
  95. package/lib/native/bundleDropNative.d.ts +2 -0
  96. package/lib/native/bundleDropNative.js +9 -1
  97. package/lib/runtime/service.js +12 -1
  98. package/lib/scripts/bundle.d.ts +2 -2
  99. package/lib/scripts/bundle.js +10 -97
  100. package/lib/scripts/canonicalArtifact.d.ts +30 -0
  101. package/lib/scripts/canonicalArtifact.js +212 -0
  102. package/lib/scripts/exportProject.d.ts +41 -0
  103. package/lib/scripts/exportProject.js +82 -0
  104. package/package.json +51 -46
  105. package/plugin/constants.js +9 -0
  106. package/plugin/expoUpdates.js +131 -0
  107. package/plugin/index.js +11 -0
  108. package/plugin/markers.js +31 -0
  109. package/plugin/withBundleDrop.js +36 -0
  110. package/plugin/xcodeBuildPhase.js +77 -0
  111. package/react-native.config.js +15 -0
  112. package/lib/CLI/scripts/aipowered/apply-plan.d.ts +0 -10
  113. package/lib/CLI/scripts/aipowered/init-native-config.d.ts +0 -2
  114. package/lib/CLI/scripts/aipowered/init-native-config.js +0 -131
  115. package/lib/CLI/scripts/init-metro-config.d.ts +0 -2
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isPatchableNativeEntrypoint = exports.isSafeRelativePath = void 0;
7
- exports.validateChangesBeforeApply = validateChangesBeforeApply;
8
- exports.validateAppliedChanges = validateAppliedChanges;
6
+ exports.isPatchableExpoConfig = exports.isPatchableNativeEntrypoint = exports.isSafeRelativePath = void 0;
7
+ exports.validateSetupChangesBeforeApply = validateSetupChangesBeforeApply;
8
+ exports.validateAppliedSetupChanges = validateAppliedSetupChanges;
9
9
  const crypto_1 = __importDefault(require("crypto"));
10
10
  const fs_extra_1 = __importDefault(require("fs-extra"));
11
11
  const path_1 = __importDefault(require("path"));
12
+ const native_setup_contract_1 = require("../native-setup-contract");
12
13
  const sha256 = (content) => crypto_1.default.createHash('sha256').update(content).digest('hex');
13
14
  const isSafeRelativePath = (value) => {
14
15
  if (!value || value.startsWith('/') || value.includes('\\'))
@@ -20,69 +21,15 @@ exports.isSafeRelativePath = isSafeRelativePath;
20
21
  const isPatchableNativeEntrypoint = (filePath) => /(^|\/)android\/(?:.*\/)?MainApplication\.(kt|java)$/.test(filePath) ||
21
22
  /(^|\/)ios\/(?:.*\/)?AppDelegate\.(swift|m|mm)$/.test(filePath);
22
23
  exports.isPatchableNativeEntrypoint = isPatchableNativeEntrypoint;
23
- const codeLikeContent = (content) => {
24
- let result = '';
25
- let state = 'code';
26
- for (let i = 0; i < content.length; i++) {
27
- const char = content[i];
28
- const next = content[i + 1];
29
- if (state === 'line-comment') {
30
- if (char === '\n') {
31
- state = 'code';
32
- result += char;
33
- }
34
- continue;
35
- }
36
- if (state === 'block-comment') {
37
- if (char === '*' && next === '/') {
38
- state = 'code';
39
- i++;
40
- }
41
- continue;
42
- }
43
- if (state === 'single' || state === 'double' || state === 'template') {
44
- if (char === '\\') {
45
- i++;
46
- continue;
47
- }
48
- if ((state === 'single' && char === "'") ||
49
- (state === 'double' && char === '"') ||
50
- (state === 'template' && char === '`')) {
51
- state = 'code';
52
- }
53
- continue;
54
- }
55
- if (char === '/' && next === '/') {
56
- state = 'line-comment';
57
- i++;
58
- continue;
59
- }
60
- if (char === '/' && next === '*') {
61
- state = 'block-comment';
62
- i++;
63
- continue;
64
- }
65
- if (char === "'") {
66
- state = 'single';
67
- continue;
68
- }
69
- if (char === '"') {
70
- state = 'double';
71
- continue;
72
- }
73
- if (char === '`') {
74
- state = 'template';
75
- continue;
76
- }
77
- result += char;
78
- }
79
- return result;
80
- };
24
+ const isPatchableExpoConfig = (filePath) => filePath === 'app.json' ||
25
+ /^app\.config\.(js|ts|cjs|mjs)$/.test(filePath) ||
26
+ /^metro\.config\.(js|ts|cjs|mjs)$/.test(filePath);
27
+ exports.isPatchableExpoConfig = isPatchableExpoConfig;
81
28
  const hasBalancedPairs = (content) => {
82
29
  const pairs = { ')': '(', '}': '{', ']': '[' };
83
30
  const opens = new Set(Object.values(pairs));
84
31
  const stack = [];
85
- for (const char of codeLikeContent(content)) {
32
+ for (const char of (0, native_setup_contract_1.stripCommentsAndStrings)(content)) {
86
33
  if (opens.has(char))
87
34
  stack.push(char);
88
35
  if (pairs[char] && stack.pop() !== pairs[char])
@@ -91,74 +38,78 @@ const hasBalancedPairs = (content) => {
91
38
  return stack.length === 0;
92
39
  };
93
40
  const hasAndroidBundleDropIntegration = (content) => {
94
- const code = codeLikeContent(content);
95
- 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);
96
42
  };
97
- const hasIosBundleDropIntegration = (content) => {
98
- const code = codeLikeContent(content);
99
- return (/bundleURL[\s\S]{0,2500}BundleDropLocator\.bundleURL\(\)|BundleDropLocator\.bundleURL\(\)[\s\S]{0,2500}bundleURL/.test(code) ||
100
- /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);
101
45
  };
102
- function validateChangesBeforeApply(params) {
46
+ const validateCommonSetupChange = (change, originals, seen) => {
47
+ if (!(0, exports.isSafeRelativePath)(change.file)) {
48
+ throw new Error(`AI setup plan references an unsafe file path: ${change.file}`);
49
+ }
50
+ if (!originals.has(change.file)) {
51
+ throw new Error(`AI setup plan references a file that was not shared: ${change.file}`);
52
+ }
53
+ if (seen.has(change.file)) {
54
+ throw new Error(`AI setup plan contains multiple updates for ${change.file}`);
55
+ }
56
+ seen.add(change.file);
57
+ if (sha256(originals.get(change.file)) !== change.originalSha256) {
58
+ throw new Error(`AI setup plan hash mismatch for ${change.file}`);
59
+ }
60
+ if (!change.updated.trim()) {
61
+ throw new Error(`AI setup plan returned an empty update for ${change.file}`);
62
+ }
63
+ if (change.updated.includes('TODO_BUNDLEDROP') || change.updated.includes('<TODO')) {
64
+ throw new Error(`AI setup plan returned placeholder text in ${change.file}`);
65
+ }
66
+ if (!hasBalancedPairs(change.updated)) {
67
+ throw new Error(`AI setup plan returned unbalanced braces or brackets in ${change.file}`);
68
+ }
69
+ };
70
+ function validateSetupChangesBeforeApply(params) {
103
71
  const seen = new Set();
104
72
  for (const change of params.changes) {
105
- if (!(0, exports.isSafeRelativePath)(change.file)) {
106
- throw new Error(`AI plan references an unsafe file path: ${change.file}`);
73
+ validateCommonSetupChange(change, params.originals, seen);
74
+ if (params.projectType === 'expo') {
75
+ if (!(0, exports.isPatchableExpoConfig)(change.file)) {
76
+ throw new Error(`AI Expo setup may not modify ${change.file}`);
77
+ }
78
+ if (change.file.startsWith('metro.config.') &&
79
+ !change.updated.includes('bundle-drop-config') &&
80
+ !change.updated.includes('withBundleDropExpo')) {
81
+ throw new Error(`AI Expo Metro update is missing the Bundle Drop wrapper: ${change.file}`);
82
+ }
83
+ if ((change.file === 'app.json' || change.file.startsWith('app.config.')) &&
84
+ !change.updated.includes('@gfean/react-native-bundle-drop')) {
85
+ throw new Error(`AI Expo config update is missing the Bundle Drop plugin: ${change.file}`);
86
+ }
87
+ continue;
107
88
  }
108
89
  if (!(0, exports.isPatchableNativeEntrypoint)(change.file)) {
109
- throw new Error(`AI plan references a non-native entrypoint: ${change.file}`);
110
- }
111
- if (!params.originals.has(change.file)) {
112
- throw new Error(`AI plan references a file that was not scanned: ${change.file}`);
113
- }
114
- if (seen.has(change.file)) {
115
- throw new Error(`AI plan contains multiple updates for ${change.file}`);
90
+ throw new Error(`AI bare setup may not modify ${change.file}`);
116
91
  }
117
- seen.add(change.file);
118
- if (sha256(params.originals.get(change.file) || '') !== change.originalSha256) {
119
- throw new Error(`AI plan hash mismatch for ${change.file}`);
120
- }
121
- if (!change.updated.trim()) {
122
- throw new Error(`AI plan returned an empty update for ${change.file}`);
123
- }
124
- if (change.updated.includes('TODO_BUNDLEDROP') || change.updated.includes('<TODO')) {
125
- throw new Error(`AI plan returned placeholder text in ${change.file}`);
126
- }
127
- if (!hasBalancedPairs(change.updated)) {
128
- throw new Error(`AI plan returned unbalanced braces or brackets in ${change.file}`);
129
- }
130
- if ((change.file.startsWith('android/') || change.file.includes('/android/')) &&
131
- !hasAndroidBundleDropIntegration(change.updated)) {
92
+ if (change.file.includes('MainApplication.') && !hasAndroidBundleDropIntegration(change.updated)) {
132
93
  throw new Error(`AI plan Android update does not contain BundleDrop resolver: ${change.file}`);
133
94
  }
134
- if ((change.file.startsWith('ios/') || change.file.includes('/ios/')) &&
135
- !hasIosBundleDropIntegration(change.updated)) {
95
+ if (change.file.includes('AppDelegate.') &&
96
+ !hasIosBundleDropIntegration(change.file, change.updated)) {
136
97
  throw new Error(`AI plan iOS update does not contain BundleDrop locator: ${change.file}`);
137
98
  }
138
99
  }
139
100
  }
140
- function validateAppliedChanges(projectRoot, changes) {
141
- for (const change of changes) {
142
- if (!(0, exports.isSafeRelativePath)(change.file) || !(0, exports.isPatchableNativeEntrypoint)(change.file)) {
143
- throw new Error(`Updated file path is not allowed: ${change.file}`);
144
- }
145
- const content = fs_extra_1.default.readFileSync(path_1.default.join(projectRoot, change.file), 'utf8');
146
- if (!content.trim()) {
147
- throw new Error(`Updated file is empty: ${change.file}`);
148
- }
149
- if (content.includes('TODO_BUNDLEDROP') || content.includes('<TODO')) {
150
- throw new Error(`Updated file contains placeholder text: ${change.file}`);
151
- }
152
- if (!hasBalancedPairs(content)) {
153
- throw new Error(`Updated file has unbalanced braces or brackets: ${change.file}`);
154
- }
155
- if ((change.file.startsWith('android/') || change.file.includes('/android/')) &&
156
- !hasAndroidBundleDropIntegration(content)) {
157
- throw new Error(`Android update does not contain BundleDrop resolver: ${change.file}`);
158
- }
159
- if ((change.file.startsWith('ios/') || change.file.includes('/ios/')) &&
160
- !hasIosBundleDropIntegration(content)) {
161
- throw new Error(`iOS update does not contain BundleDrop locator: ${change.file}`);
162
- }
163
- }
101
+ function validateAppliedSetupChanges(params) {
102
+ const originals = new Map(params.changes.map(change => [
103
+ change.file,
104
+ fs_extra_1.default.readFileSync(path_1.default.join(params.projectRoot, change.file), 'utf8'),
105
+ ]));
106
+ validateSetupChangesBeforeApply({
107
+ projectType: params.projectType,
108
+ originals,
109
+ changes: params.changes.map(change => ({
110
+ ...change,
111
+ originalSha256: sha256(originals.get(change.file)),
112
+ updated: originals.get(change.file),
113
+ })),
114
+ });
164
115
  }
@@ -0,0 +1,7 @@
1
+ export type MetroConfigChange = {
2
+ file: 'metro.config.js';
3
+ original: string | null;
4
+ updated: string;
5
+ reason: string;
6
+ };
7
+ export declare function planBareMetroConfig(projectRoot: string): MetroConfigChange | null;
@@ -3,24 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initMetroConfig = initMetroConfig;
7
- const chalk_1 = __importDefault(require("chalk"));
6
+ exports.planBareMetroConfig = planBareMetroConfig;
8
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
8
  const path_1 = __importDefault(require("path"));
10
- function findProjectRoot(startDir) {
11
- let dir = path_1.default.resolve(startDir);
12
- const MAX_UP = 12;
13
- for (let i = 0; i < MAX_UP; i++) {
14
- if (fs_extra_1.default.existsSync(path_1.default.join(dir, 'package.json'))) {
15
- return dir;
16
- }
17
- const parent = path_1.default.dirname(dir);
18
- if (parent === dir)
19
- break;
20
- dir = parent;
21
- }
22
- return startDir;
23
- }
24
9
  const APPEND_SNIPPET = `
25
10
  // Bundle Drop: ensure bundle.drop.config.js is resolvable from node_modules
26
11
  (() => {
@@ -44,23 +29,24 @@ config.resolver.extraNodeModules = {
44
29
  };
45
30
 
46
31
  module.exports = config;
47
- ${APPEND_SNIPPET}
48
32
  `;
49
- async function initMetroConfig() {
50
- const projectRoot = findProjectRoot(process.cwd());
33
+ function planBareMetroConfig(projectRoot) {
51
34
  const metroPath = path_1.default.join(projectRoot, 'metro.config.js');
52
35
  if (!fs_extra_1.default.existsSync(metroPath)) {
53
- fs_extra_1.default.writeFileSync(metroPath, NEW_METRO_TEMPLATE.trim() + '\n', 'utf8');
54
- console.log(chalk_1.default.green(`✅ Created metro.config.js with Bundle Drop alias at ${metroPath}`));
55
- return;
36
+ return {
37
+ file: 'metro.config.js',
38
+ original: null,
39
+ updated: `${NEW_METRO_TEMPLATE.trim()}\n`,
40
+ reason: 'Create the bare React Native Metro alias for bundle.drop.config.js.',
41
+ };
56
42
  }
57
43
  const content = fs_extra_1.default.readFileSync(metroPath, 'utf8');
58
- if (content.includes('bundle-drop-config')) {
59
- console.log(chalk_1.default.gray('ℹ️ metro.config.js already contains bundle-drop-config alias.'));
60
- return;
61
- }
62
- const updated = `${content.trim()}\n${APPEND_SNIPPET}`;
63
- fs_extra_1.default.writeFileSync(metroPath, updated, 'utf8');
64
- console.log(chalk_1.default.green(`✅ Added bundle-drop-config alias to metro.config.js`));
44
+ if (content.includes('bundle-drop-config'))
45
+ return null;
46
+ return {
47
+ file: 'metro.config.js',
48
+ original: content,
49
+ updated: `${content.trim()}\n${APPEND_SNIPPET}`,
50
+ reason: 'Add the Bundle Drop alias without replacing the existing Metro config.',
51
+ };
65
52
  }
66
- exports.default = initMetroConfig;
@@ -0,0 +1,17 @@
1
+ import type { MobilePlatform, ProjectType } from '../../expo';
2
+ export type DoctorCheck = {
3
+ name: string;
4
+ status: 'pass' | 'warning' | 'error';
5
+ message: string;
6
+ };
7
+ export type DoctorOptions = {
8
+ platform?: MobilePlatform;
9
+ projectType?: ProjectType;
10
+ cwd?: string;
11
+ };
12
+ export declare function inspectProject(options?: DoctorOptions): Promise<{
13
+ projectRoot: string;
14
+ projectType: ProjectType;
15
+ checks: DoctorCheck[];
16
+ }>;
17
+ export declare function runDoctor(options?: DoctorOptions): Promise<void>;