@react-native-oh/react-native-harmony-cli 0.0.36 → 0.0.40
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/README.md +11 -11
- package/dist/assetResolver.js +74 -43
- package/dist/autolinking/Autolinking.js +183 -179
- package/dist/codegen/core/CodegenError.js +23 -3
- package/dist/codegen/core/EventUtils.js +3 -3
- package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
- package/dist/codegen/core/UberSchema.js +96 -57
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +42 -28
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
- package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
- package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
- package/dist/codegen/generators/UberGeneratorV1.js +24 -18
- package/dist/codegen/generators/UberGeneratorV2.js +36 -28
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
- package/dist/codegen/templates/BasePackageHTemplate.js +21 -109
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -53
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
- package/dist/codegen/templates/IndexTSTemplate.js +17 -37
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -108
- package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
- package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
- package/dist/commands/bundle-harmony.js +138 -53
- package/dist/commands/codegen-harmony.js +175 -104
- package/dist/commands/codegen-lib-harmony.js +116 -76
- package/dist/commands/create-metro-host-constants.js +47 -18
- package/dist/commands/init.js +961 -537
- package/dist/commands/link-harmony.js +71 -33
- package/dist/commands/pack-harmony.js +108 -47
- package/dist/commands/run-harmony.js +520 -352
- package/dist/commands/unpack-harmony.js +198 -105
- package/dist/commands/verify-package-harmony.js +108 -54
- package/dist/core/AbsolutePath.js +47 -31
- package/dist/core/CodegenConfig.js +22 -24
- package/dist/core/DescriptiveError.js +37 -18
- package/dist/core/FileSystem.js +18 -14
- package/dist/core/OHPackageJSON5.js +23 -17
- package/dist/core/PackageJSON.js +42 -26
- package/dist/core/ProjectDependenciesManager.js +96 -46
- package/dist/core/ValidationError.js +22 -2
- package/dist/core/fs.js +6 -9
- package/dist/index.js +1 -1
- package/dist/io/CliExecutor.js +98 -46
- package/dist/io/Logger.js +46 -40
- package/dist/io/RealFS.js +88 -35
- package/dist/io/TarGz.js +8 -11
- package/dist/io/__fixtures__.js +141 -79
- package/dist/io/fsUtils.js +12 -13
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
- package/dist/package-verifier/verify-package.js +132 -55
- package/dist/simulator/LaunchSimulator.js +395 -0
- package/dist/simulator/index.js +23 -0
- package/jest.config.js +12 -12
- package/package.json +78 -70
- package/react-native.config.js +17 -17
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
- package/.prettierrc +0 -6
- package/src/assetResolver.ts +0 -134
- package/src/autolinking/Autolinking.test.ts +0 -483
- package/src/autolinking/Autolinking.ts +0 -382
- package/src/autolinking/index.ts +0 -8
- package/src/codegen/core/CodeGenerator.ts +0 -16
- package/src/codegen/core/CodegenError.ts +0 -10
- package/src/codegen/core/EventUtils.ts +0 -23
- package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
- package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
- package/src/codegen/core/UberSchema.ts +0 -152
- package/src/codegen/core/index.ts +0 -12
- package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -120
- package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
- package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
- package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
- package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
- package/src/codegen/generators/UberGeneratorV1.ts +0 -75
- package/src/codegen/generators/UberGeneratorV2.ts +0 -114
- package/src/codegen/generators/index.ts +0 -15
- package/src/codegen/index.ts +0 -9
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
- package/src/codegen/templates/BasePackageHTemplate.ts +0 -147
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
- package/src/codegen/templates/IndexTSTemplate.ts +0 -62
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -138
- package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
- package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
- package/src/codegen/templates/index.ts +0 -16
- package/src/commands/bundle-harmony.ts +0 -134
- package/src/commands/codegen-harmony.ts +0 -297
- package/src/commands/codegen-lib-harmony.ts +0 -389
- package/src/commands/create-metro-host-constants.ts +0 -55
- package/src/commands/index.ts +0 -16
- package/src/commands/init.ts +0 -755
- package/src/commands/link-harmony.ts +0 -102
- package/src/commands/pack-harmony.ts +0 -128
- package/src/commands/run-harmony.ts +0 -478
- package/src/commands/types.ts +0 -21
- package/src/commands/unpack-harmony.ts +0 -238
- package/src/commands/verify-package-harmony.ts +0 -113
- package/src/core/AbsolutePath.ts +0 -66
- package/src/core/CodegenConfig.ts +0 -67
- package/src/core/DescriptiveError.ts +0 -68
- package/src/core/FileSystem.ts +0 -57
- package/src/core/OHPackageJSON5.ts +0 -30
- package/src/core/PackageJSON.ts +0 -104
- package/src/core/ProjectDependenciesManager.ts +0 -103
- package/src/core/ValidationError.ts +0 -8
- package/src/core/ValueObject.ts +0 -9
- package/src/core/fs.ts +0 -38
- package/src/core/index.ts +0 -17
- package/src/index.ts +0 -33
- package/src/io/CliExecutor.ts +0 -69
- package/src/io/Logger.ts +0 -112
- package/src/io/RealFS.ts +0 -62
- package/src/io/TarGz.ts +0 -33
- package/src/io/__fixtures__.ts +0 -139
- package/src/io/fsUtils.ts +0 -44
- package/src/io/index.ts +0 -11
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
- package/src/package-verifier/checks/index.ts +0 -11
- package/src/package-verifier/index.ts +0 -9
- package/src/package-verifier/types.ts +0 -19
- package/src/package-verifier/verify-package.ts +0 -123
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
+
var __assign = (this && this.__assign) || function () {
|
|
9
|
+
__assign = Object.assign || function(t) {
|
|
10
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11
|
+
s = arguments[i];
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
}
|
|
15
|
+
return t;
|
|
16
|
+
};
|
|
17
|
+
return __assign.apply(this, arguments);
|
|
18
|
+
};
|
|
8
19
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
20
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
21
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -14,183 +25,168 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
25
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
26
|
});
|
|
16
27
|
};
|
|
17
|
-
var
|
|
18
|
-
|
|
28
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
29
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
30
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
31
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
32
|
+
function step(op) {
|
|
33
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
34
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
35
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
36
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
37
|
+
switch (op[0]) {
|
|
38
|
+
case 0: case 1: t = op; break;
|
|
39
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
40
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
41
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42
|
+
default:
|
|
43
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
44
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
45
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
46
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
47
|
+
if (t[2]) _.ops.pop();
|
|
48
|
+
_.trys.pop(); continue;
|
|
49
|
+
}
|
|
50
|
+
op = body.call(thisArg, _);
|
|
51
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
52
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
|
+
}
|
|
19
54
|
};
|
|
20
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
56
|
exports.Autolinking = void 0;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* This file was generated by RNOH autolinking.
|
|
29
|
-
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
{{#libraries}}
|
|
33
|
-
import {{etsRNOHPackageClassName}} from '{{{ohPackageName}}}';
|
|
34
|
-
{{/libraries}}
|
|
35
|
-
|
|
36
|
-
export function createRNOHPackages(ctx: RNPackageContext): RNOHPackage[] {
|
|
37
|
-
return [
|
|
38
|
-
{{#libraries}}
|
|
39
|
-
new {{etsRNOHPackageClassName}}(ctx),
|
|
40
|
-
{{/libraries}}
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
`.trimStart();
|
|
44
|
-
const CPP_RNOH_PACKAGES_FACTORY_TEMPLATE = `
|
|
45
|
-
/*
|
|
46
|
-
* This file was generated by RNOH autolinking.
|
|
47
|
-
* DO NOT modify it manually, your changes WILL be overwritten.
|
|
48
|
-
*/
|
|
49
|
-
// clang-format off
|
|
50
|
-
#pragma once
|
|
51
|
-
#include "RNOH/Package.h"
|
|
52
|
-
{{#libraries}}
|
|
53
|
-
#include "{{etsRNOHPackageClassName}}.h"
|
|
54
|
-
{{/libraries}}
|
|
55
|
-
|
|
56
|
-
std::vector<rnoh::Package::Shared> createRNOHPackages(const rnoh::Package::Context &ctx) {
|
|
57
|
-
return {
|
|
58
|
-
{{#libraries}}
|
|
59
|
-
std::make_shared<rnoh::{{cppRNOHPackageClassName}}>(ctx),
|
|
60
|
-
{{/libraries}}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
`.trimStart();
|
|
64
|
-
const CMAKE_AUTOLINKING_TEMPLATE = `
|
|
65
|
-
# This file was generated by RNOH autolinking.
|
|
66
|
-
# DO NOT modify it manually, your changes WILL be overwritten.
|
|
67
|
-
cmake_minimum_required(VERSION 3.5)
|
|
68
|
-
|
|
69
|
-
# @api
|
|
70
|
-
function(autolink_libraries target)
|
|
71
|
-
{{#libraries}}
|
|
72
|
-
add_subdirectory("\${OH_MODULES_DIR}/{{{ohPackageName}}}/src/main/cpp" ./{{cmakeLibraryTargetName}})
|
|
73
|
-
{{/libraries}}
|
|
74
|
-
|
|
75
|
-
set(AUTOLINKED_LIBRARIES
|
|
76
|
-
{{#libraries}}
|
|
77
|
-
{{cmakeLibraryTargetName}}
|
|
78
|
-
{{/libraries}}
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
foreach(lib \${AUTOLINKED_LIBRARIES})
|
|
82
|
-
target_link_libraries(\${target} PUBLIC \${lib})
|
|
83
|
-
endforeach()
|
|
84
|
-
endfunction()
|
|
85
|
-
`.trimStart();
|
|
86
|
-
class Autolinking {
|
|
87
|
-
constructor(fs, logger) {
|
|
57
|
+
var json5_1 = require("json5");
|
|
58
|
+
var core_1 = require("../core");
|
|
59
|
+
var mustache_1 = require("mustache");
|
|
60
|
+
var case_1 = require("case");
|
|
61
|
+
var node_path_1 = require("node:path");
|
|
62
|
+
var ETS_RNOH_PACKAGES_FACTORY_TEMPLATE = "\n/*\n * This file was generated by RNOH autolinking.\n * DO NOT modify it manually, your changes WILL be overwritten.\n */\nimport type { RNPackageContext, RNOHPackage } from '@rnoh/react-native-openharmony';\n{{#libraries}}\nimport {{etsRNOHPackageClassName}} from '{{{ohPackageName}}}';\n{{/libraries}}\n\nexport function createRNOHPackages(ctx: RNPackageContext): RNOHPackage[] {\n return [\n{{#libraries}}\n new {{etsRNOHPackageClassName}}(ctx),\n{{/libraries}}\n ];\n}\n".trimStart();
|
|
63
|
+
var CPP_RNOH_PACKAGES_FACTORY_TEMPLATE = "\n/*\n * This file was generated by RNOH autolinking.\n * DO NOT modify it manually, your changes WILL be overwritten.\n */\n// clang-format off\n#pragma once\n#include \"RNOH/Package.h\"\n{{#libraries}}\n#include \"{{cppRNOHPackageClassName}}.h\"\n{{/libraries}}\n\nstd::vector<rnoh::Package::Shared> createRNOHPackages(const rnoh::Package::Context &ctx) {\n return {\n{{#libraries}}\n std::make_shared<rnoh::{{cppRNOHPackageClassName}}>(ctx),\n{{/libraries}}\n };\n}\n".trimStart();
|
|
64
|
+
var CMAKE_AUTOLINKING_TEMPLATE = "\n# This file was generated by RNOH autolinking.\n# DO NOT modify it manually, your changes WILL be overwritten.\ncmake_minimum_required(VERSION 3.5)\n\n# @actor RNOH_APP\nfunction(autolink_libraries target)\n{{#libraries}}\n add_subdirectory(\"${OH_MODULES_DIR}/{{{ohPackageName}}}/src/main/cpp\" ./{{cmakeLibraryTargetName}})\n{{/libraries}}\n\n set(AUTOLINKED_LIBRARIES\n{{#libraries}}\n {{cmakeLibraryTargetName}}\n{{/libraries}}\n )\n\n foreach(lib ${AUTOLINKED_LIBRARIES})\n target_link_libraries(${target} PUBLIC ${lib})\n endforeach()\nendfunction()\n".trimStart();
|
|
65
|
+
var Autolinking = /** @class */ (function () {
|
|
66
|
+
function Autolinking(fs, logger) {
|
|
88
67
|
this.fs = fs;
|
|
89
68
|
this.logger = logger;
|
|
90
69
|
}
|
|
91
|
-
prepareInput(config) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function
|
|
70
|
+
Autolinking.prototype.prepareInput = function (config) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var harmonyProjectPath, nodeModuleHarPaths, autolinkableLibraries, projectRootPath, skippedLibraryNpmPackageNames, ohPackagePath, ohPackageContent, cppRNOHPackagesFactoryPath, cmakeAutolinkingPath;
|
|
93
73
|
var _a;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
74
|
+
return __generator(this, function (_b) {
|
|
75
|
+
switch (_b.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
if (config.includedNpmPackageNames.size > 0 &&
|
|
78
|
+
config.excludedNpmPackageNames.size > 0) {
|
|
79
|
+
throw new core_1.DescriptiveError({
|
|
80
|
+
whatHappened: 'Tried to exclude and include npm packages.',
|
|
81
|
+
whatCanUserDo: ['Include or exclude npm packages, but not both.'],
|
|
82
|
+
extraData: {
|
|
83
|
+
includedNpmPackageNamesCount: config.includedNpmPackageNames.size,
|
|
84
|
+
excludedNpmPackageNamesCount: config.excludedNpmPackageNames.size,
|
|
85
|
+
includedNpmPackageNames: config.includedNpmPackageNames,
|
|
86
|
+
excludedNpmPackageNames: config.excludedNpmPackageNames,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
harmonyProjectPath = (_a = config.harmonyProjectPath) !== null && _a !== void 0 ? _a : new core_1.AbsolutePath('./');
|
|
91
|
+
nodeModuleHarPaths = [];
|
|
92
|
+
autolinkableLibraries = [];
|
|
93
|
+
projectRootPath = config.nodeModulesPath.copyWithNewSegment('..');
|
|
94
|
+
skippedLibraryNpmPackageNames = [];
|
|
95
|
+
return [4 /*yield*/, new core_1.ProjectDependenciesManager(this.fs, projectRootPath).forEachAsync(function (dependency) {
|
|
96
|
+
var _a;
|
|
97
|
+
var harFilePaths = dependency.getHarFilePaths();
|
|
98
|
+
if (harFilePaths.length === 0) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
nodeModuleHarPaths.push.apply(nodeModuleHarPaths, harFilePaths);
|
|
102
|
+
var packageJson = dependency.readPackageJSON();
|
|
103
|
+
var providedAutolinkingConfig = (_a = packageJson.harmony) === null || _a === void 0 ? void 0 : _a.autolinking;
|
|
104
|
+
if (providedAutolinkingConfig === undefined ||
|
|
105
|
+
providedAutolinkingConfig === null ||
|
|
106
|
+
(config.excludedNpmPackageNames.has(packageJson.name) &&
|
|
107
|
+
config.excludedNpmPackageNames.size > 0) ||
|
|
108
|
+
(!config.includedNpmPackageNames.has(packageJson.name) &&
|
|
109
|
+
config.includedNpmPackageNames.size > 0) ||
|
|
110
|
+
harFilePaths.length !== 1) {
|
|
111
|
+
skippedLibraryNpmPackageNames.push(packageJson.name);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
var autolinkingConfig = providedAutolinkingConfig === true ? {} : providedAutolinkingConfig;
|
|
115
|
+
autolinkableLibraries.push({
|
|
116
|
+
npmPackageName: packageJson.name,
|
|
117
|
+
etsRNOHPackageClassName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.etsPackageClassName,
|
|
118
|
+
cppRNOHPackageClassName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.cppPackageClassName,
|
|
119
|
+
cmakeLibraryTargetName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.cmakeLibraryTargetName,
|
|
120
|
+
ohPackageName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.ohPackageName,
|
|
121
|
+
harFilePathRelativeToHarmony: harFilePaths[0]
|
|
122
|
+
.relativeTo(harmonyProjectPath)
|
|
123
|
+
.toString(),
|
|
124
|
+
});
|
|
125
|
+
})];
|
|
126
|
+
case 1:
|
|
127
|
+
_b.sent();
|
|
128
|
+
ohPackagePath = harmonyProjectPath.copyWithNewSegment(config.ohPackagePathRelativeToHarmony);
|
|
129
|
+
return [4 /*yield*/, this.fs.readText(ohPackagePath)];
|
|
130
|
+
case 2:
|
|
131
|
+
ohPackageContent = _b.sent();
|
|
132
|
+
cppRNOHPackagesFactoryPath = harmonyProjectPath.copyWithNewSegment(config.cppRNOHPackagesFactoryPathRelativeToHarmony);
|
|
133
|
+
cmakeAutolinkingPath = harmonyProjectPath.copyWithNewSegment(config.cmakeAutolinkPathRelativeToHarmony);
|
|
134
|
+
return [2 /*return*/, {
|
|
135
|
+
projectRootPath: projectRootPath,
|
|
136
|
+
skippedLibraryNpmPackageNames: skippedLibraryNpmPackageNames,
|
|
137
|
+
etsRNOHPackagesFactoryPath: harmonyProjectPath.copyWithNewSegment(config.etsRNOHPackagesFactoryPathRelativeToHarmony),
|
|
138
|
+
cppRNOHPackagesFactoryPath: cppRNOHPackagesFactoryPath,
|
|
139
|
+
cmakeAutolinkingPath: cmakeAutolinkingPath,
|
|
140
|
+
ohPackagePathAndContent: [ohPackagePath, ohPackageContent],
|
|
141
|
+
autolinkableLibraries: autolinkableLibraries,
|
|
142
|
+
nodeModuleHarFilePathsRelativeToHarmony: nodeModuleHarPaths.map(function (p) {
|
|
143
|
+
return p.relativeTo(harmonyProjectPath).toString();
|
|
144
|
+
}),
|
|
145
|
+
}];
|
|
129
146
|
}
|
|
130
|
-
const autolinkingConfig = providedAutolinkingConfig === true ? {} : providedAutolinkingConfig;
|
|
131
|
-
autolinkableLibraries.push({
|
|
132
|
-
npmPackageName: packageJson.name,
|
|
133
|
-
etsRNOHPackageClassName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.etsPackageClassName,
|
|
134
|
-
cppRNOHPackageClassName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.cppPackageClassName,
|
|
135
|
-
cmakeLibraryTargetName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.cmakeLibraryTargetName,
|
|
136
|
-
ohPackageName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.ohPackageName,
|
|
137
|
-
harFilePathRelativeToHarmony: harFilePath
|
|
138
|
-
.relativeTo(harmonyProjectPath)
|
|
139
|
-
.toString(),
|
|
140
|
-
});
|
|
141
147
|
});
|
|
142
|
-
const ohPackagePath = harmonyProjectPath.copyWithNewSegment(config.ohPackagePathRelativeToHarmony);
|
|
143
|
-
const ohPackageContent = yield this.fs.readText(ohPackagePath);
|
|
144
|
-
const cppRNOHPackagesFactoryPath = harmonyProjectPath.copyWithNewSegment(config.cppRNOHPackagesFactoryPathRelativeToHarmony);
|
|
145
|
-
const cmakeAutolinkingPath = harmonyProjectPath.copyWithNewSegment(config.cmakeAutolinkPathRelativeToHarmony);
|
|
146
|
-
return {
|
|
147
|
-
projectRootPath,
|
|
148
|
-
skippedLibraryNpmPackageNames,
|
|
149
|
-
etsRNOHPackagesFactoryPath: harmonyProjectPath.copyWithNewSegment(config.etsRNOHPackagesFactoryPathRelativeToHarmony),
|
|
150
|
-
cppRNOHPackagesFactoryPath,
|
|
151
|
-
cmakeAutolinkingPath: cmakeAutolinkingPath,
|
|
152
|
-
ohPackagePathAndContent: [ohPackagePath, ohPackageContent],
|
|
153
|
-
autolinkableLibraries,
|
|
154
|
-
nodeModuleHarFilePathsRelativeToHarmony: nodeModuleHarPaths.map((p) => p.relativeTo(harmonyProjectPath).toString()),
|
|
155
|
-
};
|
|
156
148
|
});
|
|
157
|
-
}
|
|
158
|
-
evaluate(input) {
|
|
159
|
-
|
|
149
|
+
};
|
|
150
|
+
Autolinking.prototype.evaluate = function (input) {
|
|
151
|
+
var _this = this;
|
|
152
|
+
var autolinkableLibraries = input.autolinkableLibraries.map(function (lib) {
|
|
160
153
|
var _a, _b, _c, _d;
|
|
161
|
-
return
|
|
154
|
+
return __assign(__assign({}, lib), { etsRNOHPackageClassName: (_a = lib.etsRNOHPackageClassName) !== null && _a !== void 0 ? _a : _this.npmPackageNameToRNOHPackageClassName(lib.npmPackageName), cppRNOHPackageClassName: (_b = lib.cppRNOHPackageClassName) !== null && _b !== void 0 ? _b : _this.npmPackageNameToRNOHPackageClassName(lib.npmPackageName), cmakeLibraryTargetName: (_c = lib.cmakeLibraryTargetName) !== null && _c !== void 0 ? _c : _this.npmPackageNameToCMakeLibraryTargetName(lib.npmPackageName), ohPackageName: (_d = lib.ohPackageName) !== null && _d !== void 0 ? _d : _this.npmPackageNameToOHPackageName(lib.npmPackageName) });
|
|
162
155
|
});
|
|
163
|
-
autolinkableLibraries.sort((a, b)
|
|
156
|
+
autolinkableLibraries.sort(function (a, b) {
|
|
164
157
|
if (a.npmPackageName < b.npmPackageName)
|
|
165
158
|
return -1;
|
|
166
159
|
if (a.npmPackageName > b.npmPackageName)
|
|
167
160
|
return 1;
|
|
168
161
|
return 0;
|
|
169
162
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
Object.entries(ohPackage.dependencies).forEach((
|
|
174
|
-
|
|
163
|
+
var ohPackage = json5_1.default.parse(input.ohPackagePathAndContent[1]);
|
|
164
|
+
var autolinkableHarFilePathsRelativeToHarmony = autolinkableLibraries.map(function (lib) { return lib.harFilePathRelativeToHarmony; });
|
|
165
|
+
var unmanagedNativeDependencySpecifierByName = {};
|
|
166
|
+
Object.entries(ohPackage.dependencies).forEach(function (_a) {
|
|
167
|
+
var name = _a[0], dependencySpecifier = _a[1];
|
|
168
|
+
if (!(dependencySpecifier.includes('file:') &&
|
|
169
|
+
dependencySpecifier.includes('node_modules'))) {
|
|
175
170
|
unmanagedNativeDependencySpecifierByName[name] = dependencySpecifier;
|
|
176
171
|
}
|
|
177
172
|
else {
|
|
178
|
-
|
|
179
|
-
if (!autolinkableHarFilePathsRelativeToHarmony.includes(harFilePathRelativeToHarmony) &&
|
|
180
|
-
input.nodeModuleHarFilePathsRelativeToHarmony.includes(harFilePathRelativeToHarmony)) {
|
|
173
|
+
var harFilePathRelativeToHarmony = dependencySpecifier.replace('file:', '');
|
|
174
|
+
if (!autolinkableHarFilePathsRelativeToHarmony.includes(node_path_1.default.normalize(harFilePathRelativeToHarmony)) &&
|
|
175
|
+
input.nodeModuleHarFilePathsRelativeToHarmony.includes(node_path_1.default.normalize(harFilePathRelativeToHarmony))) {
|
|
181
176
|
unmanagedNativeDependencySpecifierByName[name] =
|
|
182
177
|
dependencySpecifier;
|
|
183
178
|
}
|
|
184
179
|
}
|
|
185
180
|
});
|
|
186
|
-
|
|
187
|
-
for (
|
|
181
|
+
var managedNativeDependencySpecifierByName = {};
|
|
182
|
+
for (var _i = 0, autolinkableLibraries_1 = autolinkableLibraries; _i < autolinkableLibraries_1.length; _i++) {
|
|
183
|
+
var library = autolinkableLibraries_1[_i];
|
|
188
184
|
managedNativeDependencySpecifierByName[library.ohPackageName] =
|
|
189
|
-
|
|
185
|
+
"file:".concat(library.harFilePathRelativeToHarmony).split(node_path_1.default.sep).join('/');
|
|
190
186
|
}
|
|
191
187
|
return {
|
|
192
188
|
skippedLibraryNpmPackageNames: input.skippedLibraryNpmPackageNames,
|
|
193
|
-
linkedLibraryNpmPackageNames: autolinkableLibraries.map((lib)
|
|
189
|
+
linkedLibraryNpmPackageNames: autolinkableLibraries.map(function (lib) { return lib.npmPackageName; }),
|
|
194
190
|
projectRootPath: input.projectRootPath,
|
|
195
191
|
cppRNOHPackagesFactoryPathAndContent: [
|
|
196
192
|
input.cppRNOHPackagesFactoryPath,
|
|
@@ -212,62 +208,70 @@ class Autolinking {
|
|
|
212
208
|
],
|
|
213
209
|
ohPackagePathAndContent: [
|
|
214
210
|
input.ohPackagePathAndContent[0],
|
|
215
|
-
json5_1.default.stringify(
|
|
211
|
+
json5_1.default.stringify(__assign(__assign({}, ohPackage), { dependencies: __assign(__assign({}, unmanagedNativeDependencySpecifierByName), managedNativeDependencySpecifierByName) }), { space: 2, quote: '"' }) + '\n',
|
|
216
212
|
],
|
|
217
213
|
};
|
|
218
|
-
}
|
|
219
|
-
npmPackageNameToRNOHPackageClassName(fullNpmPackageName) {
|
|
214
|
+
};
|
|
215
|
+
Autolinking.prototype.npmPackageNameToRNOHPackageClassName = function (fullNpmPackageName) {
|
|
220
216
|
if (fullNpmPackageName.startsWith('@')) {
|
|
221
|
-
|
|
217
|
+
var _a = fullNpmPackageName
|
|
222
218
|
.replace('@', '')
|
|
223
|
-
.split('/');
|
|
219
|
+
.split('/'), scopeName = _a[0], packageName = _a[1];
|
|
224
220
|
return case_1.default.pascal(scopeName) + case_1.default.pascal(packageName) + 'Package';
|
|
225
221
|
}
|
|
226
222
|
return case_1.default.pascal(fullNpmPackageName) + 'Package';
|
|
227
|
-
}
|
|
228
|
-
npmPackageNameToCMakeLibraryTargetName(fullNpmPackageName) {
|
|
223
|
+
};
|
|
224
|
+
Autolinking.prototype.npmPackageNameToCMakeLibraryTargetName = function (fullNpmPackageName) {
|
|
229
225
|
if (fullNpmPackageName.startsWith('@')) {
|
|
230
|
-
|
|
226
|
+
var _a = fullNpmPackageName
|
|
231
227
|
.replace('@', '')
|
|
232
|
-
.split('/');
|
|
228
|
+
.split('/'), scopeName = _a[0], packageName = _a[1];
|
|
233
229
|
return 'rnoh__' + case_1.default.snake(scopeName) + '__' + case_1.default.snake(packageName);
|
|
234
230
|
}
|
|
235
231
|
return 'rnoh__' + case_1.default.snake(fullNpmPackageName);
|
|
236
|
-
}
|
|
237
|
-
npmPackageNameToOHPackageName(fullNpmPackageName) {
|
|
232
|
+
};
|
|
233
|
+
Autolinking.prototype.npmPackageNameToOHPackageName = function (fullNpmPackageName) {
|
|
238
234
|
if (fullNpmPackageName.startsWith('@')) {
|
|
239
|
-
|
|
235
|
+
var _a = fullNpmPackageName
|
|
240
236
|
.replace('@', '')
|
|
241
|
-
.split('/');
|
|
237
|
+
.split('/'), scopeName = _a[0], packageName = _a[1];
|
|
242
238
|
return '@rnoh/' + case_1.default.kebab(scopeName) + '--' + case_1.default.kebab(packageName);
|
|
243
239
|
}
|
|
244
240
|
return '@rnoh/' + case_1.default.kebab(fullNpmPackageName);
|
|
245
|
-
}
|
|
246
|
-
saveAndLogOutput(output) {
|
|
247
|
-
|
|
241
|
+
};
|
|
242
|
+
Autolinking.prototype.saveAndLogOutput = function (output) {
|
|
243
|
+
var _this = this;
|
|
244
|
+
var pathAndContentPairs = [];
|
|
248
245
|
pathAndContentPairs.push(output.etsRNOHPackagesFactoryPathAndContent);
|
|
249
246
|
pathAndContentPairs.push(output.cppRNOHPackagesFactoryPathAndContent);
|
|
250
247
|
pathAndContentPairs.push(output.cmakeAutolinkingPathAndContent);
|
|
251
248
|
pathAndContentPairs.push(output.ohPackagePathAndContent);
|
|
252
|
-
pathAndContentPairs.forEach((
|
|
253
|
-
|
|
249
|
+
pathAndContentPairs.forEach(function (_a) {
|
|
250
|
+
var path = _a[0], content = _a[1];
|
|
251
|
+
_this.fs.writeTextSync(path, content);
|
|
254
252
|
});
|
|
255
|
-
output.linkedLibraryNpmPackageNames.forEach((npmPackageName)
|
|
256
|
-
|
|
253
|
+
output.linkedLibraryNpmPackageNames.forEach(function (npmPackageName) {
|
|
254
|
+
_this.logger.debug(function (styles) { return "[".concat(styles.green(styles.bold('link')), "] ").concat(npmPackageName); });
|
|
257
255
|
});
|
|
258
|
-
output.skippedLibraryNpmPackageNames.forEach((npmPackageName)
|
|
259
|
-
|
|
256
|
+
output.skippedLibraryNpmPackageNames.forEach(function (npmPackageName) {
|
|
257
|
+
_this.logger.debug(function (styles) { return "[".concat(styles.yellow(styles.bold('skip')), "] ").concat(npmPackageName); });
|
|
260
258
|
});
|
|
261
|
-
this.logger.debug(()
|
|
262
|
-
|
|
263
|
-
.map((
|
|
259
|
+
this.logger.debug(function () { return ''; });
|
|
260
|
+
var sortedPathsRelativeToRoot = pathAndContentPairs
|
|
261
|
+
.map(function (_a) {
|
|
262
|
+
var path = _a[0];
|
|
263
|
+
return path.relativeTo(output.projectRootPath).toString();
|
|
264
|
+
})
|
|
264
265
|
.sort();
|
|
265
|
-
sortedPathsRelativeToRoot.forEach((pathStr)
|
|
266
|
-
|
|
266
|
+
sortedPathsRelativeToRoot.forEach(function (pathStr) {
|
|
267
|
+
_this.logger.debug(function (styles) { return styles.gray("\u2022 ".concat(pathStr)); });
|
|
267
268
|
});
|
|
268
|
-
this.logger.debug(()
|
|
269
|
-
this.logger.info(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
269
|
+
this.logger.debug(function () { return ''; });
|
|
270
|
+
this.logger.info(function (styles) {
|
|
271
|
+
return "updated ".concat(styles.green(styles.bold(sortedPathsRelativeToRoot.length)), " file(s), linked ").concat(styles.green(styles.bold(output.linkedLibraryNpmPackageNames.length)), " libraries, skipped ").concat(styles.yellow(styles.bold(output.skippedLibraryNpmPackageNames.length)), " libraries");
|
|
272
|
+
});
|
|
273
|
+
this.logger.debug(function () { return ''; });
|
|
274
|
+
};
|
|
275
|
+
return Autolinking;
|
|
276
|
+
}());
|
|
273
277
|
exports.Autolinking = Autolinking;
|
|
@@ -5,9 +5,29 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
+
var __extends = (this && this.__extends) || (function () {
|
|
9
|
+
var extendStatics = function (d, b) {
|
|
10
|
+
extendStatics = Object.setPrototypeOf ||
|
|
11
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
12
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
13
|
+
return extendStatics(d, b);
|
|
14
|
+
};
|
|
15
|
+
return function (d, b) {
|
|
16
|
+
if (typeof b !== "function" && b !== null)
|
|
17
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
18
|
+
extendStatics(d, b);
|
|
19
|
+
function __() { this.constructor = d; }
|
|
20
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
21
|
+
};
|
|
22
|
+
})();
|
|
8
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
24
|
exports.CodegenError = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
25
|
+
var core_1 = require("../../core");
|
|
26
|
+
var CodegenError = /** @class */ (function (_super) {
|
|
27
|
+
__extends(CodegenError, _super);
|
|
28
|
+
function CodegenError() {
|
|
29
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
30
|
+
}
|
|
31
|
+
return CodegenError;
|
|
32
|
+
}(core_1.DescriptiveError));
|
|
13
33
|
exports.CodegenError = CodegenError;
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createEventNameFromEventHandlerName = createEventNameFromEventHandlerName;
|
|
10
|
-
|
|
10
|
+
var CodegenError_1 = require("./CodegenError");
|
|
11
11
|
function createEventNameFromEventHandlerName(eventHandlerName) {
|
|
12
|
-
|
|
12
|
+
var eventName = eventHandlerName.replace('on', '');
|
|
13
13
|
if (eventName.length === 0) {
|
|
14
14
|
throw new CodegenError_1.CodegenError({
|
|
15
|
-
whatHappened:
|
|
15
|
+
whatHappened: "Received invalid event handler name: ".concat(eventHandlerName),
|
|
16
16
|
whatCanUserDo: [
|
|
17
17
|
'Change your event listener name to match naming convention "onEventName" e.g. "onPress"',
|
|
18
18
|
],
|
|
@@ -9,11 +9,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.TypeAnnotationToTS = void 0;
|
|
10
10
|
exports.getStringifiedTSDefaultValueFromPropTypeAnnotation = getStringifiedTSDefaultValueFromPropTypeAnnotation;
|
|
11
11
|
exports.wrapWithQuotes = wrapWithQuotes;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
var TypeAnnotationToTS = /** @class */ (function () {
|
|
13
|
+
function TypeAnnotationToTS(aliasPrefix) {
|
|
14
|
+
if (aliasPrefix === void 0) { aliasPrefix = ''; }
|
|
14
15
|
this.aliasPrefix = aliasPrefix;
|
|
15
16
|
}
|
|
16
|
-
convert(typeAnnotation) {
|
|
17
|
+
TypeAnnotationToTS.prototype.convert = function (typeAnnotation) {
|
|
18
|
+
var _this = this;
|
|
17
19
|
if (!typeAnnotation) {
|
|
18
20
|
return 'unknown';
|
|
19
21
|
}
|
|
@@ -56,7 +58,7 @@ class TypeAnnotationToTS {
|
|
|
56
58
|
}
|
|
57
59
|
case 'StringEnumTypeAnnotation':
|
|
58
60
|
return typeAnnotation.options
|
|
59
|
-
.map((option)
|
|
61
|
+
.map(function (option) {
|
|
60
62
|
if (typeof option !== 'string') {
|
|
61
63
|
return option;
|
|
62
64
|
}
|
|
@@ -66,11 +68,11 @@ class TypeAnnotationToTS {
|
|
|
66
68
|
case 'StringTypeAnnotation':
|
|
67
69
|
return 'string';
|
|
68
70
|
case 'FunctionTypeAnnotation':
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.map((param)
|
|
71
|
+
var params = typeAnnotation.params, returnTypeAnnotation = typeAnnotation.returnTypeAnnotation;
|
|
72
|
+
var stringifiedArgs = params
|
|
73
|
+
.map(function (param) { return "".concat(param.name, ": ").concat(_this.convert(param.typeAnnotation)); })
|
|
72
74
|
.join(', ');
|
|
73
|
-
return
|
|
75
|
+
return "(".concat(stringifiedArgs, ") => ").concat(this.convert(returnTypeAnnotation));
|
|
74
76
|
case 'EnumDeclaration':
|
|
75
77
|
return typeAnnotation.name;
|
|
76
78
|
case 'GenericObjectTypeAnnotation':
|
|
@@ -82,20 +84,20 @@ class TypeAnnotationToTS {
|
|
|
82
84
|
case 'NumberTypeAnnotation':
|
|
83
85
|
return 'number';
|
|
84
86
|
case 'NullableTypeAnnotation':
|
|
85
|
-
return
|
|
87
|
+
return "null | ".concat(this.convert(typeAnnotation.typeAnnotation));
|
|
86
88
|
case 'ObjectTypeAnnotation':
|
|
87
89
|
return this.convertObjectTypeAnnotation(typeAnnotation);
|
|
88
90
|
case 'PromiseTypeAnnotation':
|
|
89
|
-
return
|
|
91
|
+
return "Promise<".concat(this.convert(typeAnnotation.elementType), ">");
|
|
90
92
|
case 'VoidTypeAnnotation':
|
|
91
93
|
return 'void';
|
|
92
94
|
case 'ArrayTypeAnnotation':
|
|
93
|
-
return
|
|
95
|
+
return "".concat(this.convert(typeAnnotation.elementType), "[]");
|
|
94
96
|
default:
|
|
95
97
|
return 'unknown';
|
|
96
98
|
}
|
|
97
|
-
}
|
|
98
|
-
convertUnionMemberAnnotation(memberAnnotation) {
|
|
99
|
+
};
|
|
100
|
+
TypeAnnotationToTS.prototype.convertUnionMemberAnnotation = function (memberAnnotation) {
|
|
99
101
|
switch (memberAnnotation) {
|
|
100
102
|
case 'NumberTypeAnnotation':
|
|
101
103
|
return 'number';
|
|
@@ -104,20 +106,22 @@ class TypeAnnotationToTS {
|
|
|
104
106
|
case 'StringTypeAnnotation':
|
|
105
107
|
return 'string';
|
|
106
108
|
}
|
|
107
|
-
}
|
|
108
|
-
convertObjectTypeAnnotation(objectTypeAnnotation) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
};
|
|
110
|
+
TypeAnnotationToTS.prototype.convertObjectTypeAnnotation = function (objectTypeAnnotation) {
|
|
111
|
+
var _this = this;
|
|
112
|
+
var props = objectTypeAnnotation.properties
|
|
113
|
+
.map(function (prop) {
|
|
114
|
+
var maybeOptionalSymbol = prop.optional ? '?' : '';
|
|
115
|
+
return "".concat(prop.name).concat(maybeOptionalSymbol, ": ").concat(_this.convert(prop.typeAnnotation));
|
|
113
116
|
})
|
|
114
117
|
.join(', ');
|
|
115
118
|
if (props.length === 0) {
|
|
116
119
|
return '{}';
|
|
117
120
|
}
|
|
118
|
-
return
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
+
return "{".concat(props, "}");
|
|
122
|
+
};
|
|
123
|
+
return TypeAnnotationToTS;
|
|
124
|
+
}());
|
|
121
125
|
exports.TypeAnnotationToTS = TypeAnnotationToTS;
|
|
122
126
|
function getStringifiedTSDefaultValueFromPropTypeAnnotation(propTypeAnnotation) {
|
|
123
127
|
if ('default' in propTypeAnnotation && propTypeAnnotation.default !== null) {
|
|
@@ -130,9 +134,9 @@ function getStringifiedTSDefaultValueFromPropTypeAnnotation(propTypeAnnotation)
|
|
|
130
134
|
}
|
|
131
135
|
function wrapWithQuotes(str) {
|
|
132
136
|
if (str.includes("'")) {
|
|
133
|
-
return
|
|
137
|
+
return "\"".concat(str, "\"");
|
|
134
138
|
}
|
|
135
139
|
else {
|
|
136
|
-
return
|
|
140
|
+
return "'".concat(str, "'");
|
|
137
141
|
}
|
|
138
142
|
}
|