Skip to content

Commit e370b64

Browse files
authored
[core-amqp,service-bus] add react-native mappings (Azure#23524)
- for entry point, and - for runtime info
1 parent 98508cf commit e370b64

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

sdk/core/core-amqp/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"./dist-esm/src/util/runtimeInfo.js": "./dist-esm/src/util/runtimeInfo.browser.js",
2626
"buffer": "buffer"
2727
},
28+
"react-native": {
29+
"./dist/index.js": "dist-esm/src/index.js",
30+
"./dist-esm/src/util/runtimeInfo.js": "./dist-esm/src/util/runtimeInfo.native.js"
31+
},
2832
"files": [
2933
"dist/",
3034
"dist-esm/src/",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
/*
5+
* NOTE: When moving this file, please update "react-native" section in package.json.
6+
*/
7+
const { Platform } = require("react-native"); // eslint-disable-line import/no-extraneous-dependencies, @typescript-eslint/no-require-imports
8+
9+
/**
10+
* Returns information about the platform this function is being run on.
11+
* @internal
12+
*/
13+
export function getPlatformInfo(): string {
14+
return `(${Platform.OS}-${Platform.Version})`;
15+
}
16+
17+
/**
18+
* Returns information about Node.js this function is being run on.
19+
* @internal
20+
*/
21+
export function getFrameworkInfo(): string {
22+
const { major, minor, patch } = Platform.constants.reactNativeVersion;
23+
return `react-native/${major}.${minor}.${patch}`;
24+
}

sdk/servicebus/service-bus/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"buffer": "buffer",
2626
"./dist-esm/src/util/runtimeInfo.js": "./dist-esm/src/util/runtimeInfo.browser.js"
2727
},
28+
"react-native": {
29+
"./dist/index.js": "dist-esm/src/index.js",
30+
"./dist-esm/src/util/runtimeInfo.js": "./dist-esm/src/util/runtimeInfo.native.js"
31+
},
2832
"types": "./types/latest/service-bus.d.ts",
2933
"typesVersions": {
3034
"<3.6": {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
/*
5+
* NOTE: When moving this file, please update "react-native" section in package.json.
6+
*/
7+
const { Platform } = require("react-native"); // eslint-disable-line import/no-extraneous-dependencies, @typescript-eslint/no-require-imports
8+
9+
/**
10+
* Returns information about the platform this function is being run on.
11+
* @hidden
12+
* @internal
13+
*/
14+
export function getRuntimeInfo(): string {
15+
const { major, minor, patch } = Platform.constants.reactNativeVersion;
16+
const runtimeInfo = {
17+
key: "react-native",
18+
value: `${major}.${minor}.${patch}`,
19+
};
20+
21+
const osInfo = {
22+
key: "OS",
23+
value: `${Platform.OS}-${Platform.Version}`,
24+
};
25+
26+
return `${runtimeInfo.key}/${runtimeInfo.value} ${osInfo.key}/${osInfo.value}`;
27+
}

0 commit comments

Comments
 (0)