@react-native-oh/react-native-harmony-cli 0.0.40 → 0.0.41
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 +43 -74
- package/dist/autolinking/Autolinking.js +178 -179
- package/dist/codegen/core/CodegenError.js +3 -23
- package/dist/codegen/core/EventUtils.js +3 -3
- package/dist/codegen/core/TypeAnnotationToTS.js +24 -28
- package/dist/codegen/core/UberSchema.js +57 -96
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +28 -41
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +27 -34
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +25 -33
- package/dist/codegen/generators/CppComponentCodeGenerator.js +23 -28
- package/dist/codegen/generators/LibGlueCodeGenerator.js +26 -29
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +25 -30
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
- package/dist/codegen/generators/UberGeneratorV1.js +24 -23
- package/dist/codegen/generators/UberGeneratorV2.js +34 -35
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +50 -24
- package/dist/codegen/templates/BasePackageHTemplate.js +120 -21
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +53 -8
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +75 -27
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +162 -29
- package/dist/codegen/templates/IndexTSTemplate.js +37 -17
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +119 -24
- package/dist/codegen/templates/TurboModuleCppTemplate.js +38 -15
- package/dist/codegen/templates/TurboModuleHTemplate.js +32 -11
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +52 -19
- package/dist/commands/bundle-harmony.js +53 -138
- package/dist/commands/codegen-harmony.js +105 -165
- package/dist/commands/codegen-lib-harmony.js +76 -116
- package/dist/commands/create-metro-host-constants.js +18 -47
- package/dist/commands/init.js +537 -961
- package/dist/commands/link-harmony.js +33 -71
- package/dist/commands/pack-harmony.js +47 -108
- package/dist/commands/run-harmony.js +372 -518
- package/dist/commands/unpack-harmony.js +105 -198
- package/dist/commands/verify-package-harmony.js +54 -108
- package/dist/core/AbsolutePath.js +31 -47
- package/dist/core/CodegenConfig.js +24 -22
- package/dist/core/DescriptiveError.js +18 -37
- package/dist/core/FileSystem.js +14 -18
- package/dist/core/OHPackageJSON5.js +17 -23
- package/dist/core/PackageJSON.js +26 -42
- package/dist/core/ProjectDependenciesManager.js +40 -92
- package/dist/core/ValidationError.js +2 -22
- package/dist/core/fs.js +9 -6
- package/dist/index.js +1 -1
- package/dist/io/CliExecutor.js +46 -98
- package/dist/io/Logger.js +40 -46
- package/dist/io/RealFS.js +35 -88
- package/dist/io/TarGz.js +11 -8
- package/dist/io/__fixtures__.js +79 -141
- package/dist/io/fsUtils.js +13 -12
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +19 -47
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +13 -41
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +8 -38
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +22 -54
- package/dist/package-verifier/verify-package.js +55 -132
- package/dist/simulator/LaunchSimulator.js +224 -301
- package/harmony/rnoh-hvigor-plugin-0.3.0.tgz +0 -0
- package/jest.config.js +12 -12
- package/package.json +78 -78
- package/react-native.config.js +17 -17
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
|
@@ -5,42 +5,137 @@
|
|
|
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
|
|
9
|
-
|
|
10
|
-
if (ar || !(i in from)) {
|
|
11
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
12
|
-
ar[i] = from[i];
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
10
|
};
|
|
17
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
12
|
exports.RNOHGeneratedPackageHTemplate = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
14
|
+
const TEMPLATE = `
|
|
15
|
+
/**
|
|
16
|
+
* This code was generated by "react-native codegen-harmony"
|
|
17
|
+
*
|
|
18
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
19
|
+
* lost once the code is regenerated.
|
|
20
|
+
*
|
|
21
|
+
* @generatorVersion: 1
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#pragma once
|
|
25
|
+
|
|
26
|
+
#include "RNOH/Package.h"
|
|
27
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
28
|
+
{{#turboModules}}
|
|
29
|
+
#include "generated/{{name}}.h"
|
|
30
|
+
{{/turboModules}}
|
|
31
|
+
{{#components}}
|
|
32
|
+
#include "generated/{{name}}ComponentDescriptor.h"
|
|
33
|
+
{{/components}}
|
|
34
|
+
{{#components}}
|
|
35
|
+
#include "generated/{{name}}JSIBinder.h"
|
|
36
|
+
{{/components}}
|
|
37
|
+
|
|
38
|
+
namespace rnoh {
|
|
39
|
+
|
|
40
|
+
class RNOHGeneratedPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
41
|
+
public:
|
|
42
|
+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
43
|
+
{{#turboModules}}
|
|
44
|
+
if (name == "{{name}}") {
|
|
45
|
+
return std::make_shared<{{name}}>(ctx, name);
|
|
46
|
+
}
|
|
47
|
+
{{/turboModules}}
|
|
48
|
+
return nullptr;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
class GeneratedEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
53
|
+
public:
|
|
54
|
+
void handleEvent(Context const &ctx) override {
|
|
55
|
+
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
56
|
+
auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
|
|
57
|
+
|
|
58
|
+
if (eventEmitter == nullptr) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
std::vector<std::string> supportedComponentNames = {
|
|
63
|
+
{{#arkTSComponents}}
|
|
64
|
+
"{{name}}",
|
|
65
|
+
{{/arkTSComponents}}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
std::vector<std::string> supportedEventNames = {
|
|
69
|
+
{{#supportedEvents}}
|
|
70
|
+
"{{name}}",
|
|
71
|
+
{{/supportedEvents}}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
|
|
75
|
+
std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
76
|
+
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
class RNOHGeneratedPackage : public Package {
|
|
82
|
+
public:
|
|
83
|
+
RNOHGeneratedPackage(Package::Context ctx) : Package(ctx){};
|
|
84
|
+
|
|
85
|
+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
86
|
+
return std::make_unique<RNOHGeneratedPackageTurboModuleFactoryDelegate>();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
90
|
+
return {
|
|
91
|
+
{{#components}}
|
|
92
|
+
facebook::react::concreteComponentDescriptorProvider<facebook::react::{{name}}ComponentDescriptor>(),
|
|
93
|
+
{{/components}}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
98
|
+
return {
|
|
99
|
+
{{#components}}
|
|
100
|
+
{"{{name}}", std::make_shared<{{name}}JSIBinder>()},
|
|
101
|
+
{{/components}}
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
106
|
+
return {
|
|
107
|
+
std::make_shared<GeneratedEventEmitRequestHandler>(),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
} // namespace rnoh
|
|
113
|
+
`;
|
|
114
|
+
class RNOHGeneratedPackageHTemplate {
|
|
115
|
+
constructor() {
|
|
23
116
|
this.turboModules = [];
|
|
24
117
|
this.components = [];
|
|
25
118
|
this.supportedEventNames = [];
|
|
26
119
|
}
|
|
27
|
-
|
|
120
|
+
addTurboModule(turboModule) {
|
|
28
121
|
this.turboModules.push(turboModule);
|
|
29
|
-
}
|
|
30
|
-
|
|
122
|
+
}
|
|
123
|
+
addComponent(component) {
|
|
31
124
|
this.components.push(component);
|
|
32
|
-
this.supportedEventNames =
|
|
33
|
-
|
|
34
|
-
|
|
125
|
+
this.supportedEventNames = [
|
|
126
|
+
...this.supportedEventNames,
|
|
127
|
+
...component.supportedEventNames,
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
build() {
|
|
35
131
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
36
132
|
turboModules: this.turboModules,
|
|
37
133
|
components: this.components,
|
|
38
|
-
arkTSComponents: this.components.filter(
|
|
39
|
-
supportedEvents: this.supportedEventNames.map(
|
|
134
|
+
arkTSComponents: this.components.filter((component) => component.isArkTSComponent),
|
|
135
|
+
supportedEvents: this.supportedEventNames.map((eventName) => ({
|
|
40
136
|
name: eventName,
|
|
41
|
-
})
|
|
137
|
+
})),
|
|
42
138
|
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}());
|
|
139
|
+
}
|
|
140
|
+
}
|
|
46
141
|
exports.RNOHGeneratedPackageHTemplate = RNOHGeneratedPackageHTemplate;
|
|
@@ -5,32 +5,55 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.TurboModuleCppTemplate = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
14
|
+
const TEMPLATE = `
|
|
15
|
+
/**
|
|
16
|
+
{{#codegenNoticeLines}}
|
|
17
|
+
* {{{line}}}
|
|
18
|
+
{{/codegenNoticeLines}}
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
#include "{{className}}.h"
|
|
22
|
+
|
|
23
|
+
namespace rnoh {
|
|
24
|
+
using namespace facebook;
|
|
25
|
+
|
|
26
|
+
{{className}}::{{className}}(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
|
|
27
|
+
methodMap_ = {
|
|
28
|
+
{{#methods}}
|
|
29
|
+
ARK_{{asyncMarker}}METHOD_METADATA({{name}}, {{argsCount}}),
|
|
30
|
+
{{/methods}}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
} // namespace rnoh
|
|
35
|
+
`;
|
|
36
|
+
class TurboModuleCppTemplate {
|
|
37
|
+
constructor(name, codegenNoticeLines) {
|
|
14
38
|
this.name = name;
|
|
15
39
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
16
40
|
this.methods = [];
|
|
17
41
|
}
|
|
18
|
-
|
|
42
|
+
addMethod(method) {
|
|
19
43
|
this.methods.push(method);
|
|
20
|
-
}
|
|
21
|
-
|
|
44
|
+
}
|
|
45
|
+
build() {
|
|
22
46
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
23
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
24
|
-
line
|
|
25
|
-
})
|
|
47
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
48
|
+
line,
|
|
49
|
+
})),
|
|
26
50
|
className: this.name,
|
|
27
|
-
methods: this.methods.map(
|
|
51
|
+
methods: this.methods.map((method) => ({
|
|
28
52
|
name: method.name,
|
|
29
53
|
argsCount: method.argsCount,
|
|
30
54
|
asyncMarker: method.isAsync ? 'ASYNC_' : undefined,
|
|
31
|
-
})
|
|
55
|
+
})),
|
|
32
56
|
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
36
59
|
exports.TurboModuleCppTemplate = TurboModuleCppTemplate;
|
|
@@ -5,23 +5,44 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.TurboModuleHTemplate = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
14
|
+
const TEMPLATE = `
|
|
15
|
+
/**
|
|
16
|
+
{{#codegenNoticeLines}}
|
|
17
|
+
* {{{line}}}
|
|
18
|
+
{{/codegenNoticeLines}}
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
#pragma once
|
|
22
|
+
|
|
23
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
24
|
+
|
|
25
|
+
namespace rnoh {
|
|
26
|
+
|
|
27
|
+
class JSI_EXPORT {{className}} : public ArkTSTurboModule {
|
|
28
|
+
public:
|
|
29
|
+
{{className}}(const ArkTSTurboModule::Context ctx, const std::string name);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
} // namespace rnoh
|
|
33
|
+
`;
|
|
34
|
+
class TurboModuleHTemplate {
|
|
35
|
+
constructor(name, codegenNoticeLines) {
|
|
14
36
|
this.name = name;
|
|
15
37
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
16
38
|
}
|
|
17
|
-
|
|
39
|
+
build() {
|
|
18
40
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
19
41
|
className: this.name,
|
|
20
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
21
|
-
line
|
|
22
|
-
})
|
|
42
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
43
|
+
line,
|
|
44
|
+
})),
|
|
23
45
|
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}());
|
|
46
|
+
}
|
|
47
|
+
}
|
|
27
48
|
exports.TurboModuleHTemplate = TurboModuleHTemplate;
|
|
@@ -5,12 +5,46 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.TurboModuleInterfaceTS = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
14
|
+
const TEMPLATE = `
|
|
15
|
+
/**
|
|
16
|
+
{{#codegenNoticeLines}}
|
|
17
|
+
* {{{line}}}
|
|
18
|
+
{{/codegenNoticeLines}}
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { Tag } from "{{{rnohImport}}}"
|
|
22
|
+
|
|
23
|
+
export namespace {{name}} {
|
|
24
|
+
export const NAME = '{{name}}' as const
|
|
25
|
+
|
|
26
|
+
{{#enums}}
|
|
27
|
+
export enum {{name}} {
|
|
28
|
+
{{#members}}
|
|
29
|
+
{{name}} = {{{value}}},
|
|
30
|
+
{{/members}}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
{{/enums}}
|
|
34
|
+
{{#aliases}}
|
|
35
|
+
export type {{name}} = {{{type}}}
|
|
36
|
+
|
|
37
|
+
{{/aliases}}
|
|
38
|
+
export interface Spec {
|
|
39
|
+
{{#methods}}
|
|
40
|
+
{{name}}({{{stringifiedArgs}}}): {{{returnType}}};
|
|
41
|
+
|
|
42
|
+
{{/methods}}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
class TurboModuleInterfaceTS {
|
|
47
|
+
constructor(name, codegenNoticeLines, rnohImport) {
|
|
14
48
|
this.name = name;
|
|
15
49
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
16
50
|
this.rnohImport = rnohImport;
|
|
@@ -18,31 +52,30 @@ var TurboModuleInterfaceTS = /** @class */ (function () {
|
|
|
18
52
|
this.aliases = [];
|
|
19
53
|
this.enumModels = [];
|
|
20
54
|
}
|
|
21
|
-
|
|
55
|
+
addAlias(alias) {
|
|
22
56
|
this.aliases.push(alias);
|
|
23
|
-
}
|
|
24
|
-
|
|
57
|
+
}
|
|
58
|
+
addEnum(enumModel) {
|
|
25
59
|
this.enumModels.push(enumModel);
|
|
26
|
-
}
|
|
27
|
-
|
|
60
|
+
}
|
|
61
|
+
addMethod(method) {
|
|
28
62
|
this.methods.push(method);
|
|
29
|
-
}
|
|
30
|
-
|
|
63
|
+
}
|
|
64
|
+
build() {
|
|
31
65
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
32
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
33
|
-
line
|
|
34
|
-
})
|
|
66
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
67
|
+
line,
|
|
68
|
+
})),
|
|
35
69
|
name: this.name,
|
|
36
70
|
aliases: this.aliases,
|
|
37
71
|
enums: this.enumModels,
|
|
38
72
|
rnohImport: this.rnohImport,
|
|
39
|
-
methods: this.methods.map(
|
|
73
|
+
methods: this.methods.map((method) => ({
|
|
40
74
|
name: method.name,
|
|
41
75
|
stringifiedArgs: method.stringifiedArgs,
|
|
42
76
|
returnType: method.returnType,
|
|
43
|
-
})
|
|
77
|
+
})),
|
|
44
78
|
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
48
81
|
exports.TurboModuleInterfaceTS = TurboModuleInterfaceTS;
|
|
@@ -5,17 +5,6 @@
|
|
|
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
|
-
};
|
|
19
8
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
20
9
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
10
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -25,44 +14,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
25
14
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
15
|
});
|
|
27
16
|
};
|
|
28
|
-
var
|
|
29
|
-
|
|
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
|
-
}
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
54
19
|
};
|
|
55
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
21
|
exports.commandBundleHarmony = void 0;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
22
|
+
const fs_1 = __importDefault(require("fs"));
|
|
23
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
24
|
+
const metro_1 = __importDefault(require("metro"));
|
|
25
|
+
const Server_1 = __importDefault(require("metro/src/Server"));
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
27
|
+
const assetResolver_1 = require("../assetResolver");
|
|
28
|
+
const io_1 = require("../io");
|
|
29
|
+
const ARK_RESOURCE_PATH = './harmony/entry/src/main/resources/rawfile';
|
|
30
|
+
const ASSETS_DEFAULT_DEST_PATH = './harmony/entry/src/main/resources/rawfile/assets';
|
|
66
31
|
exports.commandBundleHarmony = {
|
|
67
32
|
name: 'bundle-harmony',
|
|
68
33
|
description: 'Creates JS bundle, creates a special cpp header containing the JS code, copies assets directory to the project.',
|
|
@@ -70,7 +35,7 @@ exports.commandBundleHarmony = {
|
|
|
70
35
|
{
|
|
71
36
|
name: '--dev [boolean]',
|
|
72
37
|
description: 'If false, warnings are disabled and the bundle is minified',
|
|
73
|
-
parse:
|
|
38
|
+
parse: (val) => val !== 'false',
|
|
74
39
|
default: true,
|
|
75
40
|
},
|
|
76
41
|
{
|
|
@@ -99,109 +64,59 @@ exports.commandBundleHarmony = {
|
|
|
99
64
|
{
|
|
100
65
|
name: '--minify [boolean]',
|
|
101
66
|
description: 'Allows overriding whether bundle is minified',
|
|
102
|
-
parse:
|
|
67
|
+
parse: (val) => val !== 'false',
|
|
103
68
|
},
|
|
104
69
|
],
|
|
105
|
-
func:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
metroConfig = _a.sent();
|
|
122
|
-
return [4 /*yield*/, createBundle(metroConfig, buildOptions)];
|
|
123
|
-
case 2:
|
|
124
|
-
bundle = _a.sent();
|
|
125
|
-
return [4 /*yield*/, saveBundle(bundle, args.bundleOutput, args.sourcemapOutput)];
|
|
126
|
-
case 3:
|
|
127
|
-
_a.sent();
|
|
128
|
-
return [4 /*yield*/, retrieveAssetsData(metroConfig, buildOptions)];
|
|
129
|
-
case 4:
|
|
130
|
-
assets = _a.sent();
|
|
131
|
-
(0, assetResolver_1.copyAssets)(logger, assets, args.assetsDest);
|
|
132
|
-
return [2 /*return*/];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}); },
|
|
70
|
+
func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
const logger = new io_1.Logger();
|
|
72
|
+
const buildOptions = {
|
|
73
|
+
entry: args.entryFile,
|
|
74
|
+
platform: 'harmony',
|
|
75
|
+
minify: args.minify !== undefined ? args.minify : !args.dev,
|
|
76
|
+
dev: args.dev,
|
|
77
|
+
sourceMap: args.sourcemapOutput,
|
|
78
|
+
sourceMapUrl: args.sourcemapOutput,
|
|
79
|
+
};
|
|
80
|
+
const metroConfig = yield loadMetroConfig(args.config);
|
|
81
|
+
const bundle = yield createBundle(metroConfig, buildOptions);
|
|
82
|
+
yield saveBundle(bundle, args.bundleOutput, args.sourcemapOutput);
|
|
83
|
+
const assets = yield retrieveAssetsData(metroConfig, buildOptions);
|
|
84
|
+
(0, assetResolver_1.copyAssets)(logger, assets, args.assetsDest);
|
|
85
|
+
}),
|
|
136
86
|
};
|
|
137
87
|
function loadMetroConfig(configPath) {
|
|
138
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
case 0:
|
|
143
|
-
if (!configPath) return [3 /*break*/, 2];
|
|
144
|
-
return [4 /*yield*/, metro_1.default.loadConfig({ config: configPath })];
|
|
145
|
-
case 1:
|
|
146
|
-
_a = _b.sent();
|
|
147
|
-
return [3 /*break*/, 4];
|
|
148
|
-
case 2: return [4 /*yield*/, metro_1.default.loadConfig()];
|
|
149
|
-
case 3:
|
|
150
|
-
_a = _b.sent();
|
|
151
|
-
_b.label = 4;
|
|
152
|
-
case 4: return [2 /*return*/, _a];
|
|
153
|
-
}
|
|
154
|
-
});
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
return configPath
|
|
90
|
+
? yield metro_1.default.loadConfig({ config: configPath })
|
|
91
|
+
: yield metro_1.default.loadConfig();
|
|
155
92
|
});
|
|
156
93
|
}
|
|
157
94
|
function createBundle(metroConfig, buildOptions) {
|
|
158
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
case 1:
|
|
163
|
-
// casting needed as Metro.runBuild returns Promise<{code: string, map: string}>
|
|
164
|
-
// despite being typed as Promise<void>
|
|
165
|
-
return [2 /*return*/, (_a.sent())];
|
|
166
|
-
}
|
|
167
|
-
});
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
// casting needed as Metro.runBuild returns Promise<{code: string, map: string}>
|
|
97
|
+
// despite being typed as Promise<void>
|
|
98
|
+
return (yield metro_1.default.runBuild(metroConfig, buildOptions));
|
|
168
99
|
});
|
|
169
100
|
}
|
|
170
101
|
function saveBundle(bundle, bundleOutput, sourceMapOutput) {
|
|
171
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (sourceMapOutput) {
|
|
180
|
-
fs_1.default.writeFileSync(sourceMapOutput, bundle.map);
|
|
181
|
-
console.log("[CREATED] ".concat(sourceMapOutput));
|
|
182
|
-
}
|
|
183
|
-
return [2 /*return*/];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
yield fs_extra_1.default.ensureDir(path_1.default.dirname(bundleOutput));
|
|
104
|
+
fs_1.default.writeFileSync(bundleOutput, bundle.code);
|
|
105
|
+
console.log(`[CREATED] ${bundleOutput}`);
|
|
106
|
+
if (sourceMapOutput) {
|
|
107
|
+
fs_1.default.writeFileSync(sourceMapOutput, bundle.map);
|
|
108
|
+
console.log(`[CREATED] ${sourceMapOutput}`);
|
|
109
|
+
}
|
|
186
110
|
});
|
|
187
111
|
}
|
|
188
112
|
function retrieveAssetsData(metroConfig, buildOptions) {
|
|
189
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
_a.trys.push([1, , 3, 4]);
|
|
198
|
-
return [4 /*yield*/, metroServer.getAssets(__assign(__assign(__assign({}, Server_1.default.DEFAULT_BUNDLE_OPTIONS), buildOptions), { entryFile: buildOptions.entry }))];
|
|
199
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
200
|
-
case 3:
|
|
201
|
-
metroServer.end();
|
|
202
|
-
return [7 /*endfinally*/];
|
|
203
|
-
case 4: return [2 /*return*/];
|
|
204
|
-
}
|
|
205
|
-
});
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const metroServer = new Server_1.default(metroConfig);
|
|
115
|
+
try {
|
|
116
|
+
return yield metroServer.getAssets(Object.assign(Object.assign(Object.assign({}, Server_1.default.DEFAULT_BUNDLE_OPTIONS), buildOptions), { entryFile: buildOptions.entry }));
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
metroServer.end();
|
|
120
|
+
}
|
|
206
121
|
});
|
|
207
122
|
}
|