Skip to content

Commit

Permalink
Add C api version for native components (#318)
Browse files Browse the repository at this point in the history
#### Summary of Changes
For native components read the C api version information from
the bundle similarly to what we do for "platform" information.
The C api version is specific to each bundle.

If the bundle doesn't contain a C api version, then return "N/A"
and skip this information in the manifest file. Otherwise use
the C api version to populate the manifest inside appPackageManifest.

 #### Description of testing
Checked the changes are backwards compatible by generating a manifest
for a native component without C api version.
Checked that the manifest contains the C api version information
if it is present in the native component.

Signed-off-by: Catalina Mocanu <catalinamocanu@google.com>
  • Loading branch information
catalinamocanu authored Aug 28, 2023
1 parent ce21112 commit 1b65e21
Show file tree
Hide file tree
Showing 8 changed files with 32,912 additions and 18 deletions.
61 changes: 57 additions & 4 deletions src/__snapshots__/appPackageManifest.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,57 @@ Object {
}
`;

exports[`builds a package manifest for native app with platform C API version 1`] = `
Object {
"appId": "b4ae822e-eca9-4fcb-8747-217f2a1f53a1",
"buildId": "0x0f75775f470c1585",
"components": Object {
"watch": Object {
"hera": Object {
"filename": "device-hera.zip",
"platform": Array [
"128.1.1+",
],
"platformCApiVersion": "1.2.3",
},
},
},
"manifestVersion": 6,
"requestedPermissions": Array [],
"sourceMaps": Object {},
}
`;

exports[`builds a package manifest for native app with platform C API version and companinon 1`] = `
Object {
"appId": "b4ae822e-eca9-4fcb-8747-217f2a1f53a1",
"buildId": "0x0f75775f470c1585",
"components": Object {
"companion": Object {
"filename": "companion.zip",
},
"watch": Object {
"hera": Object {
"filename": "device-hera.zip",
"platform": Array [
"128.1.1+",
],
"platformCApiVersion": "1.2.3",
},
},
},
"manifestVersion": 6,
"requestedPermissions": Array [],
"sdkVersion": Object {
"companionApi": "3.5.0",
},
"sourceMaps": Object {
"companion": "sourceMaps/companion/companion.js.json",
"settings": "sourceMaps/settings/settings.js.json",
},
}
`;

exports[`builds a package manifest with a companion 1`] = `
Object {
"appId": "b4ae822e-eca9-4fcb-8747-217f2a1f53a1",
Expand Down Expand Up @@ -256,6 +307,8 @@ Object {
}
`;

exports[`doesn't include platform C api version for non native apps 1`] = `"Unknown bundle component tag: Invalid value undefined supplied to : (({ type: \\"device\\", family: string, platform: Array<string> } & ({ isNative: true, platformCApiVersion: string } | Partial<{ isNative: (true | undefined), platformCApiVersion: undefined }>)) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string, platform: Array<string> } & ({ isNative: true, platformCApiVersion: string } | Partial<{ isNative: (true | undefined), platformCApiVersion: undefined }>))/0: { type: \\"device\\", family: string, platform: Array<string> }/platform: Array<string>"`;
exports[`doesn't include tile data if app type is not APP 1`] = `
Object {
"appId": "b4ae822e-eca9-4fcb-8747-217f2a1f53a1",
Expand All @@ -276,13 +329,13 @@ Object {
}
`;
exports[`emits an error if a component bundle tag has a device type but invalid platform 1`] = `"Unknown bundle component tag: Invalid value \\"1.1.1+\\" supplied to : (({ type: \\"device\\", family: string, platform: Array<string> } & Partial<{ isNative: true }>) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string, platform: Array<string> } & Partial<{ isNative: true }>)/0: { type: \\"device\\", family: string, platform: Array<string> }/platform: Array<string>"`;
exports[`emits an error if a component bundle tag has a device type but invalid platform 1`] = `"Unknown bundle component tag: Invalid value \\"1.1.1+\\" supplied to : (({ type: \\"device\\", family: string, platform: Array<string> } & ({ isNative: true, platformCApiVersion: string } | Partial<{ isNative: (true | undefined), platformCApiVersion: undefined }>)) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string, platform: Array<string> } & ({ isNative: true, platformCApiVersion: string } | Partial<{ isNative: (true | undefined), platformCApiVersion: undefined }>))/0: { type: \\"device\\", family: string, platform: Array<string> }/platform: Array<string>"`;
exports[`emits an error if a component bundle tag has a device type but missing family 1`] = `"Unknown bundle component tag: Invalid value undefined supplied to : (({ type: \\"device\\", family: string, platform: Array<string> } & Partial<{ isNative: true }>) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string, platform: Array<string> } & Partial<{ isNative: true }>)/0: { type: \\"device\\", family: string, platform: Array<string> }/family: string"`;
exports[`emits an error if a component bundle tag has a device type but missing family 1`] = `"Unknown bundle component tag: Invalid value undefined supplied to : (({ type: \\"device\\", family: string, platform: Array<string> } & ({ isNative: true, platformCApiVersion: string } | Partial<{ isNative: (true | undefined), platformCApiVersion: undefined }>)) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string, platform: Array<string> } & ({ isNative: true, platformCApiVersion: string } | Partial<{ isNative: (true | undefined), platformCApiVersion: undefined }>))/0: { type: \\"device\\", family: string, platform: Array<string> }/family: string"`;
exports[`emits an error if a component bundle tag has a device type but missing platform 1`] = `"Unknown bundle component tag: Invalid value undefined supplied to : (({ type: \\"device\\", family: string, platform: Array<string> } & Partial<{ isNative: true }>) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string, platform: Array<string> } & Partial<{ isNative: true }>)/0: { type: \\"device\\", family: string, platform: Array<string> }/platform: Array<string>"`;
exports[`emits an error if a component bundle tag has a device type but missing platform 1`] = `"Unknown bundle component tag: Invalid value undefined supplied to : (({ type: \\"device\\", family: string, platform: Array<string> } & ({ isNative: true, platformCApiVersion: string } | Partial<{ isNative: (true | undefined), platformCApiVersion: undefined }>)) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string, platform: Array<string> } & ({ isNative: true, platformCApiVersion: string } | Partial<{ isNative: (true | undefined), platformCApiVersion: undefined }>))/0: { type: \\"device\\", family: string, platform: Array<string> }/platform: Array<string>"`;
exports[`emits an error if a component bundle tag has an invalid type field 1`] = `"Unknown bundle component tag: Invalid value {\\"type\\":\\"__invalid__\\"} supplied to : (({ type: \\"device\\", family: string, platform: Array<string> } & Partial<{ isNative: true }>) | { type: \\"companion\\" })"`;
exports[`emits an error if a component bundle tag has an invalid type field 1`] = `"Unknown bundle component tag: Invalid value {\\"type\\":\\"__invalid__\\"} supplied to : (({ type: \\"device\\", family: string, platform: Array<string> } & ({ isNative: true, platformCApiVersion: string } | Partial<{ isNative: (true | undefined), platformCApiVersion: undefined }>)) | { type: \\"companion\\" })"`;
exports[`emits an error if both JS and native device components are present 1`] = `"Cannot bundle mixed native/JS device components"`;
Expand Down
Loading

0 comments on commit 1b65e21

Please sign in to comment.