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 |
|
27 |
|
28 | function getOS() {
|
29 |
|
30 |
|
31 | switch (_os().default.platform()) {
|
32 | case 'aix':
|
33 | case 'freebsd':
|
34 | case 'linux':
|
35 | case 'openbsd':
|
36 | case 'sunos':
|
37 |
|
38 | return 'linux';
|
39 | case 'darwin':
|
40 | return 'macos';
|
41 | case 'win32':
|
42 | return 'windows';
|
43 | default:
|
44 | return '';
|
45 | }
|
46 | }
|
47 | let _platform = null;
|
48 | let _version;
|
49 |
|
50 |
|
51 |
|
52 | function doclink(section, path, platform, hashOrOverrides) {
|
53 | const url = new URL('https://reactnative.dev/');
|
54 |
|
55 |
|
56 | const isObj = typeof hashOrOverrides === 'object';
|
57 | const hash = isObj ? hashOrOverrides.hash : hashOrOverrides;
|
58 | const version = isObj && hashOrOverrides.version ? hashOrOverrides.version : _version;
|
59 | const OS = isObj && hashOrOverrides.os ? hashOrOverrides.os : getOS();
|
60 | url.pathname = _version ? `${section}/${version}/${path}` : `${section}/${path}`;
|
61 | url.searchParams.set('os', OS);
|
62 | if (platform === 'inherit') {
|
63 | _assert().default.ok(_platform !== null, `Please report this CLI error: link.setPlatform('ios'|'android'|'none') was expected to be set before using link.${section}(${path}, 'inherit').`);
|
64 | }
|
65 | const plat = platform === 'inherit' ? _platform : platform ?? _platform;
|
66 | if (plat !== 'none') {
|
67 | url.searchParams.set('platform', plat);
|
68 | }
|
69 | if (isObj) {
|
70 | const otherKeys = Object.keys(hashOrOverrides).filter(key => !['hash', 'version', 'os'].includes(key));
|
71 | for (let key of otherKeys) {
|
72 | url.searchParams.set(key, hashOrOverrides[key]);
|
73 | }
|
74 | }
|
75 | if (hash) {
|
76 | _assert().default.doesNotMatch(hash, /#/, "Anchor links should be written without a '#'");
|
77 | url.hash = hash;
|
78 | }
|
79 | return url.toString();
|
80 | }
|
81 | const docs = doclink.bind(null, 'docs');
|
82 | exports.docs = docs;
|
83 | const contributing = doclink.bind(null, 'contributing');
|
84 | exports.contributing = contributing;
|
85 | const community = doclink.bind(null, 'community');
|
86 | exports.community = community;
|
87 | const showcase = doclink.bind(null, 'showcase');
|
88 | exports.showcase = showcase;
|
89 | const blog = doclink.bind(null, 'blog');
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | exports.blog = blog;
|
95 | function setPlatform(target) {
|
96 | _platform = target;
|
97 | }
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | function setVersion(reactNativeVersion) {
|
103 | _version = reactNativeVersion;
|
104 | }
|
105 |
|
106 |
|
\ | No newline at end of file |