How to use the metro/src/lib/RamBundleParser function in metro

To help you get started, we’ve selected a few metro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github callstack / haul / e2e / utils / validators.ts View on Github external
export function validateAppBundle(
  bundleBuffer: Buffer,
  options: ValidationOptions = {}
) {
  if (options.isIndexedRAMBundle) {
    const parser = new RamBundleParser(bundleBuffer);
    expect(parser.getStartupCode().length).toBeGreaterThan(0);
    const [, mainModuleId] = parser
      .getStartupCode()
      .match(/mainModuleId: (\d+)/) || ['', '-1'];
    expect(parser.getModule(parseInt(mainModuleId, 10)).length).toBeGreaterThan(
      0
    );
    expect(
      bundleBuffer.toString().includes("preloadBundleNames: [ 'base_dll' ]")
    ).toBe(true);
  }
  expect(bundleBuffer.toString()).toMatch(/this\["\w+"\] =/);
}
github callstack / haul / e2e / utils / validators.ts View on Github external
export function validateBaseBundle(
  bundleBuffer: Buffer,
  options: ValidationOptions = {}
) {
  if (options.isIndexedRAMBundle) {
    const parser = new RamBundleParser(bundleBuffer);
    expect(parser.getStartupCode().length).toBeGreaterThan(0);
    const [, mainModuleId] = parser
      .getStartupCode()
      .match(/mainModuleId: (\d+)/) || ['', '-1'];
    expect(parser.getModule(parseInt(mainModuleId, 10)).length).toBeGreaterThan(
      0
    );
  }
  if (options.platform === 'windows') {
    expect(bundleBuffer.toString().includes('react-native-windows')).toBe(true);
    expect(bundleBuffer.toString().includes("OS: 'windows',")).toBe(true);
  } else if (options.platform) {
    expect(bundleBuffer.toString().includes('react-native')).toBe(true);
    expect(bundleBuffer.toString().includes(`OS: '${options.platform}',`)).toBe(
      true
    );