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

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 (102) hide show
  1. package/README.md +168 -4
  2. package/android/build.gradle +1 -0
  3. package/android/src/main/java/com/bundledrop/BundleDropBoundedDownloader.kt +86 -0
  4. package/android/src/main/java/com/bundledrop/BundleDropModule.kt +69 -0
  5. package/android/src/main/java/com/bundledrop/BundleDropRuntimeCrypto.kt +81 -0
  6. package/ios/BundleDropBridge.m +18 -0
  7. package/ios/BundleDropLocator.swift +48 -2
  8. package/ios/BundleDropModule.swift +75 -0
  9. package/ios/BundleDropRuntimeCrypto.swift +45 -0
  10. package/lib/CLI/cli.d.ts +1 -0
  11. package/lib/CLI/cli.js +166 -79
  12. package/lib/CLI/scripts/aipowered/apply-setup-plan.js +7 -17
  13. package/lib/CLI/scripts/aipowered/backend-client.js +29 -4
  14. package/lib/CLI/scripts/aipowered/code-push-residue.d.ts +5 -0
  15. package/lib/CLI/scripts/aipowered/code-push-residue.js +126 -0
  16. package/lib/CLI/scripts/aipowered/credential-safety.d.ts +1 -0
  17. package/lib/CLI/scripts/aipowered/credential-safety.js +14 -0
  18. package/lib/CLI/scripts/aipowered/diff-preview.js +12 -4
  19. package/lib/CLI/scripts/aipowered/init-project-config.d.ts +4 -0
  20. package/lib/CLI/scripts/aipowered/init-project-config.js +228 -43
  21. package/lib/CLI/scripts/aipowered/scanner.d.ts +1 -0
  22. package/lib/CLI/scripts/aipowered/scanner.js +164 -32
  23. package/lib/CLI/scripts/aipowered/terminal-safety.d.ts +4 -0
  24. package/lib/CLI/scripts/aipowered/terminal-safety.js +124 -0
  25. package/lib/CLI/scripts/aipowered/validate-plan.d.ts +3 -0
  26. package/lib/CLI/scripts/aipowered/validate-plan.js +1080 -19
  27. package/lib/CLI/scripts/bare-metro-config.d.ts +1 -1
  28. package/lib/CLI/scripts/bare-metro-config.js +24 -32
  29. package/lib/CLI/scripts/doctor.js +143 -22
  30. package/lib/CLI/scripts/expo/configure-expo.js +51 -60
  31. package/lib/CLI/scripts/expo/package-manager.d.ts +2 -0
  32. package/lib/CLI/scripts/expo/package-manager.js +63 -25
  33. package/lib/CLI/scripts/init-config.d.ts +7 -7
  34. package/lib/CLI/scripts/init-config.js +246 -32
  35. package/lib/CLI/scripts/login-cli.js +35 -10
  36. package/lib/CLI/scripts/metro-config-authority.d.ts +8 -0
  37. package/lib/CLI/scripts/metro-config-authority.js +303 -0
  38. package/lib/CLI/scripts/native-entrypoint-authority.d.ts +2 -0
  39. package/lib/CLI/scripts/native-entrypoint-authority.js +378 -0
  40. package/lib/CLI/scripts/native-setup-contract.d.ts +2 -2
  41. package/lib/CLI/scripts/native-setup-contract.js +63 -33
  42. package/lib/CLI/scripts/native-startup-validator.d.ts +3 -0
  43. package/lib/CLI/scripts/native-startup-validator.js +964 -0
  44. package/lib/CLI/scripts/safe-file-transaction.d.ts +12 -0
  45. package/lib/CLI/scripts/safe-file-transaction.js +159 -0
  46. package/lib/CLI/scripts/sight-artifacts.d.ts +17 -0
  47. package/lib/CLI/scripts/sight-artifacts.js +204 -0
  48. package/lib/CLI/scripts/sight-cli.d.ts +10 -0
  49. package/lib/CLI/scripts/sight-cli.js +127 -0
  50. package/lib/CLI/scripts/sight-session.d.ts +14 -0
  51. package/lib/CLI/scripts/sight-session.js +192 -0
  52. package/lib/api/clientApi.d.ts +3 -1
  53. package/lib/api/clientApi.js +14 -0
  54. package/lib/api/types.d.ts +39 -0
  55. package/lib/context.d.ts +1 -1
  56. package/lib/index.d.ts +2 -0
  57. package/lib/index.js +3 -1
  58. package/lib/install/installFromZip.d.ts +3 -0
  59. package/lib/install/installFromZip.js +10 -1
  60. package/lib/loadConfig.d.ts +17 -1
  61. package/lib/loadConfig.js +16 -0
  62. package/lib/manager/downloadAndInstall.d.ts +3 -2
  63. package/lib/manager/downloadAndInstall.js +111 -46
  64. package/lib/manager/rollbackState.d.ts +3 -1
  65. package/lib/manager/rollbackState.js +2 -2
  66. package/lib/manager/updateCheck.d.ts +1 -0
  67. package/lib/manager/updateCheck.js +218 -78
  68. package/lib/metro.d.ts +8 -1
  69. package/lib/metro.js +68 -19
  70. package/lib/native/bundleDropNative.js +2 -1
  71. package/lib/native/fs.d.ts +6 -0
  72. package/lib/native/fs.js +24 -0
  73. package/lib/patch-engine/installFromPatchSet.d.ts +2 -0
  74. package/lib/patch-engine/installFromPatchSet.js +14 -3
  75. package/lib/patch-engine/patchTransport.d.ts +2 -0
  76. package/lib/patch-engine/patchTransport.js +9 -0
  77. package/lib/runtime/initState.d.ts +5 -0
  78. package/lib/runtime/initState.js +4 -0
  79. package/lib/runtime/service.js +60 -3
  80. package/lib/runtime-delivery/artifactCapability.d.ts +1 -0
  81. package/lib/runtime-delivery/artifactCapability.js +32 -0
  82. package/lib/runtime-delivery/authorityLeaseVerifier.d.ts +3 -0
  83. package/lib/runtime-delivery/authorityLeaseVerifier.js +106 -0
  84. package/lib/runtime-delivery/bootstrapConfig.d.ts +50 -0
  85. package/lib/runtime-delivery/bootstrapConfig.js +217 -0
  86. package/lib/runtime-delivery/diagnostics.d.ts +17 -0
  87. package/lib/runtime-delivery/diagnostics.js +58 -0
  88. package/lib/runtime-delivery/encoding.d.ts +5 -0
  89. package/lib/runtime-delivery/encoding.js +132 -0
  90. package/lib/runtime-delivery/heartbeat.d.ts +3 -0
  91. package/lib/runtime-delivery/heartbeat.js +88 -0
  92. package/lib/runtime-delivery/localResolver.d.ts +23 -0
  93. package/lib/runtime-delivery/localResolver.js +81 -0
  94. package/lib/runtime-delivery/manifestState.d.ts +9 -0
  95. package/lib/runtime-delivery/manifestState.js +102 -0
  96. package/lib/runtime-delivery/manifestVerifier.d.ts +13 -0
  97. package/lib/runtime-delivery/manifestVerifier.js +329 -0
  98. package/lib/runtime-delivery/runtimeDelivery.d.ts +19 -0
  99. package/lib/runtime-delivery/runtimeDelivery.js +375 -0
  100. package/lib/runtime-delivery/types.d.ts +87 -0
  101. package/lib/runtime-delivery/types.js +6 -0
  102. package/package.json +2 -2
@@ -3,5 +3,5 @@ export declare const ANDROID_BUNDLE_DROP_PATHS = "com.bundledrop.BundleDropNativ
3
3
  export declare const IOS_BUNDLE_DROP_MODULE = "BundleDrop";
4
4
  export declare const IOS_BUNDLE_DROP_LOCATOR_HEADER = "BundleDrop/BundleDropLocator.h";
5
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;
6
+ export declare const stripComments: (content: string) => string;
7
+ export { findMissingBareNativeStartupStructure, hasBareAndroidStartupIntegration, hasBareIosStartupIntegration, } from './native-startup-validator';
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
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;
3
+ exports.hasBareIosStartupIntegration = exports.hasBareAndroidStartupIntegration = exports.findMissingBareNativeStartupStructure = exports.stripComments = 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
4
  exports.ANDROID_BUNDLE_DROP_MODULE = 'com.bundledrop.BundleDropModule';
5
5
  exports.ANDROID_BUNDLE_DROP_PATHS = 'com.bundledrop.BundleDropNativePaths';
6
6
  exports.IOS_BUNDLE_DROP_MODULE = 'BundleDrop';
7
7
  exports.IOS_BUNDLE_DROP_LOCATOR_HEADER = 'BundleDrop/BundleDropLocator.h';
8
- const stripCommentsAndStrings = (content) => {
8
+ const sanitizeSource = (content, preserveStrings) => {
9
9
  let code = '';
10
10
  let state = 'code';
11
11
  let escaped = false;
12
+ let blockCommentDepth = 0;
13
+ let tripleQuoteHashes = '';
12
14
  for (let index = 0; index < content.length; index += 1) {
13
15
  const character = content[index];
14
16
  const nextCharacter = content[index + 1];
@@ -20,24 +22,51 @@ const stripCommentsAndStrings = (content) => {
20
22
  continue;
21
23
  }
22
24
  if (state === 'block-comment') {
25
+ if (character === '/' && nextCharacter === '*') {
26
+ blockCommentDepth += 1;
27
+ index += 1;
28
+ continue;
29
+ }
23
30
  if (character === '*' && nextCharacter === '/') {
24
- state = 'code';
31
+ blockCommentDepth -= 1;
32
+ if (blockCommentDepth === 0)
33
+ state = 'code';
25
34
  index += 1;
26
35
  }
27
36
  continue;
28
37
  }
38
+ if (state === 'triple-double') {
39
+ const closingDelimiter = `"""${tripleQuoteHashes}`;
40
+ if (content.startsWith(closingDelimiter, index)) {
41
+ if (preserveStrings)
42
+ code += closingDelimiter;
43
+ index += closingDelimiter.length - 1;
44
+ state = 'code';
45
+ tripleQuoteHashes = '';
46
+ }
47
+ else if (preserveStrings) {
48
+ code += character;
49
+ }
50
+ continue;
51
+ }
29
52
  if (state !== 'code') {
30
53
  if (escaped) {
54
+ if (preserveStrings)
55
+ code += character;
31
56
  escaped = false;
32
57
  continue;
33
58
  }
34
59
  if (character === '\\') {
60
+ if (preserveStrings)
61
+ code += character;
35
62
  escaped = true;
36
63
  continue;
37
64
  }
38
65
  const closesState = (state === 'single' && character === "'") ||
39
66
  (state === 'double' && character === '"') ||
40
67
  (state === 'template' && character === '`');
68
+ if (preserveStrings)
69
+ code += character;
41
70
  if (closesState)
42
71
  state = 'code';
43
72
  continue;
@@ -49,53 +78,54 @@ const stripCommentsAndStrings = (content) => {
49
78
  }
50
79
  if (character === '/' && nextCharacter === '*') {
51
80
  state = 'block-comment';
81
+ blockCommentDepth = 1;
52
82
  index += 1;
53
83
  continue;
54
84
  }
85
+ const swiftRawTripleQuote = content.slice(index).match(/^(#+)"""/);
86
+ if (character === '"' && content.startsWith('"""', index)) {
87
+ state = 'triple-double';
88
+ tripleQuoteHashes = '';
89
+ if (preserveStrings)
90
+ code += '"""';
91
+ index += 2;
92
+ continue;
93
+ }
94
+ if (swiftRawTripleQuote) {
95
+ state = 'triple-double';
96
+ tripleQuoteHashes = swiftRawTripleQuote[1];
97
+ if (preserveStrings)
98
+ code += swiftRawTripleQuote[0];
99
+ index += swiftRawTripleQuote[0].length - 1;
100
+ continue;
101
+ }
55
102
  if (character === "'") {
56
103
  state = 'single';
104
+ if (preserveStrings)
105
+ code += character;
57
106
  continue;
58
107
  }
59
108
  if (character === '"') {
60
109
  state = 'double';
110
+ if (preserveStrings)
111
+ code += character;
61
112
  continue;
62
113
  }
63
114
  if (character === '`') {
64
115
  state = 'template';
116
+ if (preserveStrings)
117
+ code += character;
65
118
  continue;
66
119
  }
67
120
  code += character;
68
121
  }
69
122
  return code;
70
123
  };
124
+ const stripCommentsAndStrings = (content) => sanitizeSource(content, false);
71
125
  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;
126
+ const stripComments = (content) => sanitizeSource(content, true);
127
+ exports.stripComments = stripComments;
128
+ var native_startup_validator_1 = require("./native-startup-validator");
129
+ Object.defineProperty(exports, "findMissingBareNativeStartupStructure", { enumerable: true, get: function () { return native_startup_validator_1.findMissingBareNativeStartupStructure; } });
130
+ Object.defineProperty(exports, "hasBareAndroidStartupIntegration", { enumerable: true, get: function () { return native_startup_validator_1.hasBareAndroidStartupIntegration; } });
131
+ Object.defineProperty(exports, "hasBareIosStartupIntegration", { enumerable: true, get: function () { return native_startup_validator_1.hasBareIosStartupIntegration; } });
@@ -0,0 +1,3 @@
1
+ export declare const hasBareAndroidStartupIntegration: (code: string) => boolean;
2
+ export declare const hasBareIosStartupIntegration: (filePath: string, code: string) => boolean;
3
+ export declare const findMissingBareNativeStartupStructure: (filePath: string, original: string, updated: string) => string[];