@react-analyzer/shared 0.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Rel1cx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,40 @@
1
+ import { Context } from 'tsl';
2
+
3
+ /**
4
+ * @internal
5
+ */
6
+ declare const getId: () => string;
7
+
8
+ /**
9
+ * @internal
10
+ */
11
+ declare const _require: NodeJS.Require;
12
+
13
+ /**
14
+ * The NPM scope for this project.
15
+ */
16
+ declare const NPM_SCOPE = "@react-analyzer";
17
+ /**
18
+ * The GitHub repository for this project.
19
+ */
20
+ declare const GITHUB_URL = "https://github.com/react-analyzer/react-analyzer";
21
+ /**
22
+ * The URL to the project's website.
23
+ */
24
+ declare const WEBSITE_URL = "https://react-analyzer.xyz";
25
+
26
+ interface AnalyzerOptions {
27
+ version: string;
28
+ }
29
+ declare const DEFAULT_ANALYZER_OPTIONS: {
30
+ readonly version: "19.1.0";
31
+ };
32
+ declare function getAnalyzerOptions(context: Omit<Context, "data">): AnalyzerOptions;
33
+
34
+ declare function getCommandLineOptions(): {
35
+ project?: string;
36
+ };
37
+
38
+ declare function getReactVersion(fallback: string): string;
39
+
40
+ export { type AnalyzerOptions, DEFAULT_ANALYZER_OPTIONS, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, getAnalyzerOptions, getCommandLineOptions, getId, getReactVersion };
package/dist/index.js ADDED
@@ -0,0 +1,44 @@
1
+ import module from 'module';
2
+ import path from 'path';
3
+ import { identity } from '@react-analyzer/eff';
4
+ import { getTsconfig } from 'get-tsconfig';
5
+ import { match, P } from 'ts-pattern';
6
+ import { parseArgs } from 'util';
7
+
8
+ // src/_id.ts
9
+ var id = 0n;
10
+ var getId = () => (id++).toString();
11
+ var _require = module.createRequire(process.cwd() + path.sep);
12
+
13
+ // src/constants.ts
14
+ var NPM_SCOPE = "@react-analyzer";
15
+ var GITHUB_URL = "https://github.com/react-analyzer/react-analyzer";
16
+ var WEBSITE_URL = "https://react-analyzer.xyz";
17
+ function getCommandLineOptions() {
18
+ const { values } = parseArgs({
19
+ options: { project: { type: "string", short: "p" } }
20
+ });
21
+ return values;
22
+ }
23
+
24
+ // src/get-analyzer-options.ts
25
+ var DEFAULT_ANALYZER_OPTIONS = {
26
+ version: "19.1.0"
27
+ };
28
+ function getAnalyzerOptions(context) {
29
+ const { project = "tsconfig.json" } = getCommandLineOptions();
30
+ const options = getTsconfig(project)?.config["react"];
31
+ return {
32
+ ...DEFAULT_ANALYZER_OPTIONS,
33
+ ...match(options).with({ version: P.string }, identity).otherwise(() => ({}))
34
+ };
35
+ }
36
+ function getReactVersion(fallback) {
37
+ try {
38
+ return match(_require("react")).with({ version: P.select(P.string) }, identity).otherwise(() => fallback);
39
+ } catch {
40
+ return fallback;
41
+ }
42
+ }
43
+
44
+ export { DEFAULT_ANALYZER_OPTIONS, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, getAnalyzerOptions, getCommandLineOptions, getId, getReactVersion };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@react-analyzer/shared",
3
+ "version": "0.0.0-next.0",
4
+ "description": "React Analyzer Shared constants and functions.",
5
+ "homepage": "https://github.com/Rel1cx/react-analyzer",
6
+ "bugs": {
7
+ "url": "https://github.com/Rel1cx/react-analyzer/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Rel1cx/react-analyzer.git",
12
+ "directory": "packages/shared"
13
+ },
14
+ "license": "MIT",
15
+ "author": "Rel1cx<dokimondex@gmail.com>",
16
+ "sideEffects": false,
17
+ "type": "module",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "./package.json"
28
+ ],
29
+ "dependencies": {
30
+ "get-tsconfig": "^4.10.1",
31
+ "ts-pattern": "^5.7.1",
32
+ "@react-analyzer/eff": "0.0.0-next.0",
33
+ "@react-analyzer/kit": "0.0.0-next.0"
34
+ },
35
+ "devDependencies": {
36
+ "@tsconfig/node22": "^22.0.2",
37
+ "@types/node": "^24.0.10",
38
+ "tsup": "^8.5.0",
39
+ "type-fest": "^4.41.0",
40
+ "@local/configs": "0.0.0"
41
+ },
42
+ "engines": {
43
+ "bun": ">=1.2.18",
44
+ "node": ">=22.17.0"
45
+ },
46
+ "scripts": {
47
+ "build": "tsup --dts-resolve",
48
+ "build:docs": "typedoc",
49
+ "lint:publish": "publint",
50
+ "lint:ts": "tsl"
51
+ }
52
+ }