1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.docs = exports.contributing = exports.community = exports.blog = void 0;
|
7 | exports.getOS = getOS;
|
8 | exports.setPlatform = setPlatform;
|
9 | exports.setVersion = setVersion;
|
10 | exports.showcase = void 0;
|
11 | function _os() {
|
12 | const data = _interopRequireDefault(require("os"));
|
13 | _os = function () {
|
14 | return data;
|
15 | };
|
16 | return data;
|
17 | }
|
18 | function _assert() {
|
19 | const data = _interopRequireDefault(require("assert"));
|
20 | _assert = function () {
|
21 | return data;
|
22 | };
|
23 | return data;
|
24 | }
|
25 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
26 | function getOS() {
|
27 |
|
28 |
|
29 | switch (_os().default.platform()) {
|
30 | case 'aix':
|
31 | case 'freebsd':
|
32 | case 'linux':
|
33 | case 'openbsd':
|
34 | case 'sunos':
|
35 |
|
36 | return 'linux';
|
37 | case 'darwin':
|
38 | return 'macos';
|
39 | case 'win32':
|
40 | return 'windows';
|
41 | default:
|
42 | return '';
|
43 | }
|
44 | }
|
45 | let _platform = 'android';
|
46 | let _version;
|
47 |
|
48 |
|
49 |
|
50 | function doclink(section, path, hashOrOverrides) {
|
51 | const url = new URL('https://reactnative.dev/');
|
52 |
|
53 |
|
54 | const isObj = typeof hashOrOverrides === 'object';
|
55 | const hash = isObj ? hashOrOverrides.hash : hashOrOverrides;
|
56 | const version = isObj && hashOrOverrides.version ? hashOrOverrides.version : _version;
|
57 | const OS = isObj && hashOrOverrides.os ? hashOrOverrides.os : getOS();
|
58 | const platform = isObj && hashOrOverrides.platform ? hashOrOverrides.platform : _platform;
|
59 | url.pathname = _version ? `${section}/${version}/${path}` : `${section}/${path}`;
|
60 | url.searchParams.set('os', OS);
|
61 | url.searchParams.set('platform', platform);
|
62 | if (isObj) {
|
63 | const otherKeys = Object.keys(hashOrOverrides).filter(key => !['hash', 'version', 'os', 'platform'].includes(key));
|
64 | for (let key of otherKeys) {
|
65 | url.searchParams.set(key, hashOrOverrides[key]);
|
66 | }
|
67 | }
|
68 | if (hash) {
|
69 | _assert().default.doesNotMatch(hash, /#/, "Anchor links should be written withou a '#'");
|
70 | url.hash = hash;
|
71 | }
|
72 | return url.toString();
|
73 | }
|
74 | const docs = doclink.bind(null, 'docs');
|
75 | exports.docs = docs;
|
76 | const contributing = doclink.bind(null, 'contributing');
|
77 | exports.contributing = contributing;
|
78 | const community = doclink.bind(null, 'community');
|
79 | exports.community = community;
|
80 | const showcase = doclink.bind(null, 'showcase');
|
81 | exports.showcase = showcase;
|
82 | const blog = doclink.bind(null, 'blog');
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | exports.blog = blog;
|
88 | function setPlatform(target) {
|
89 | _platform = target;
|
90 | }
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | function setVersion(reactNativeVersion) {
|
96 | _version = reactNativeVersion;
|
97 | }
|
98 |
|
99 |
|
\ | No newline at end of file |