hcordova 1.0.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 +204 -0
- package/README.md +346 -0
- package/bin/hcordova +27 -0
- package/package.json +39 -0
- package/src/base-cli.js +1181 -0
- package/src/utils/DependencyChecker.js +382 -0
- package/src/utils/PlatformProject.js +452 -0
- package/src/utils/PluginConfigParser.js +408 -0
- package/src/utils/PluginDownloader.js +181 -0
- package/src/utils/PluginHandler.js +1097 -0
- package/src/utils/VariableValidator.js +369 -0
- package/src/utils/args-processor.js +79 -0
- package/templates/project/AppScope/app.json5 +10 -0
- package/templates/project/AppScope/resources/base/element/string.json +8 -0
- package/templates/project/AppScope/resources/base/media/background.png +0 -0
- package/templates/project/AppScope/resources/base/media/foreground.png +0 -0
- package/templates/project/AppScope/resources/base/media/layered_image.json +7 -0
- package/templates/project/build-profile.json5 +46 -0
- package/templates/project/code-linter.json5 +32 -0
- package/templates/project/entry/build-profile.json5 +28 -0
- package/templates/project/entry/hvigorfile.ts +6 -0
- package/templates/project/entry/obfuscation-rules.txt +23 -0
- package/templates/project/entry/oh-package.json5 +12 -0
- package/templates/project/entry/src/main/ets/entryability/EntryAbility.ets +62 -0
- package/templates/project/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +32 -0
- package/templates/project/entry/src/main/ets/pages/Index.ets +40 -0
- package/templates/project/entry/src/main/module.json5 +52 -0
- package/templates/project/entry/src/main/resources/base/element/color.json +8 -0
- package/templates/project/entry/src/main/resources/base/element/float.json +8 -0
- package/templates/project/entry/src/main/resources/base/element/string.json +16 -0
- package/templates/project/entry/src/main/resources/base/media/background.png +0 -0
- package/templates/project/entry/src/main/resources/base/media/foreground.png +0 -0
- package/templates/project/entry/src/main/resources/base/media/layered_image.json +7 -0
- package/templates/project/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/templates/project/entry/src/main/resources/base/profile/backup_config.json +3 -0
- package/templates/project/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/templates/project/entry/src/main/resources/dark/element/color.json +8 -0
- package/templates/project/entry/src/main/resources/rawfile/config.xml +26 -0
- package/templates/project/entry/src/main/resources/rawfile/www/cordova.js +1925 -0
- package/templates/project/entry/src/main/resources/rawfile/www/css/index.css +158 -0
- package/templates/project/entry/src/main/resources/rawfile/www/img/cordova.png +0 -0
- package/templates/project/entry/src/main/resources/rawfile/www/img/logo.png +0 -0
- package/templates/project/entry/src/main/resources/rawfile/www/index.html +110 -0
- package/templates/project/entry/src/main/resources/rawfile/www/js/index.js +68 -0
- package/templates/project/entry/src/mock/mock-config.json5 +2 -0
- package/templates/project/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/templates/project/entry/src/ohosTest/ets/test/List.test.ets +5 -0
- package/templates/project/entry/src/ohosTest/module.json5 +13 -0
- package/templates/project/entry/src/test/List.test.ets +5 -0
- package/templates/project/entry/src/test/LocalUnit.test.ets +33 -0
- package/templates/project/hvigor/hvigor-config.json5 +22 -0
- package/templates/project/hvigorfile.ts +6 -0
- package/templates/project/local.properties +9 -0
- package/templates/project/oh-package-lock.json5 +27 -0
- package/templates/project/oh-package.json5 +10 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
|
|
18
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
19
|
+
import { window } from '@kit.ArkUI';
|
|
20
|
+
import { webview } from '@kit.ArkWeb';
|
|
21
|
+
|
|
22
|
+
const DOMAIN = 0x0000;
|
|
23
|
+
|
|
24
|
+
export default class EntryAbility extends UIAbility {
|
|
25
|
+
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
|
26
|
+
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
|
|
27
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
|
|
28
|
+
webview.WebviewController.initializeWebEngine();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
onDestroy(): void {
|
|
32
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
onWindowStageCreate(windowStage: window.WindowStage): void {
|
|
36
|
+
// Main window is created, set main page for this ability
|
|
37
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
|
38
|
+
|
|
39
|
+
windowStage.loadContent('pages/Index', (err) => {
|
|
40
|
+
if (err.code) {
|
|
41
|
+
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
onWindowStageDestroy(): void {
|
|
49
|
+
// Main window is destroyed, release UI related resources
|
|
50
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
onForeground(): void {
|
|
54
|
+
// Ability has brought to foreground
|
|
55
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
onBackground(): void {
|
|
59
|
+
// Ability has back to background
|
|
60
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
18
|
+
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
|
|
19
|
+
|
|
20
|
+
const DOMAIN = 0x0000;
|
|
21
|
+
|
|
22
|
+
export default class EntryBackupAbility extends BackupExtensionAbility {
|
|
23
|
+
async onBackup() {
|
|
24
|
+
hilog.info(DOMAIN, 'testTag', 'onBackup ok');
|
|
25
|
+
await Promise.resolve();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async onRestore(bundleVersion: BundleVersion) {
|
|
29
|
+
hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
|
|
30
|
+
await Promise.resolve();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { MainPage, pageBackPress, pageHideEvent, pageShowEvent} from '@magongshou/harmony-cordova/Index';
|
|
18
|
+
|
|
19
|
+
@Entry
|
|
20
|
+
@Component
|
|
21
|
+
struct Index {
|
|
22
|
+
onPageShow(){
|
|
23
|
+
pageShowEvent(); //页面显示通知cordova
|
|
24
|
+
}
|
|
25
|
+
onBackPress() {
|
|
26
|
+
pageBackPress(); //拦截返回键由cordova处理
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
onPageHide() {
|
|
30
|
+
pageHideEvent(); //页面隐藏通知cordova
|
|
31
|
+
}
|
|
32
|
+
build() {
|
|
33
|
+
RelativeContainer() {
|
|
34
|
+
//默认加载rawfile/www/index.html
|
|
35
|
+
MainPage();
|
|
36
|
+
}
|
|
37
|
+
.height('100%')
|
|
38
|
+
.width('100%')
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"module": {
|
|
3
|
+
"name": "entry",
|
|
4
|
+
"type": "entry",
|
|
5
|
+
"description": "$string:module_desc",
|
|
6
|
+
"mainElement": "EntryAbility",
|
|
7
|
+
"deviceTypes": [
|
|
8
|
+
"phone",
|
|
9
|
+
"tablet",
|
|
10
|
+
"2in1"
|
|
11
|
+
],
|
|
12
|
+
"deliveryWithInstall": true,
|
|
13
|
+
"installationFree": false,
|
|
14
|
+
"pages": "$profile:main_pages",
|
|
15
|
+
"abilities": [
|
|
16
|
+
{
|
|
17
|
+
"name": "EntryAbility",
|
|
18
|
+
"srcEntry": "./ets/entryability/EntryAbility.ets",
|
|
19
|
+
"description": "$string:EntryAbility_desc",
|
|
20
|
+
"icon": "$media:layered_image",
|
|
21
|
+
"label": "$string:EntryAbility_label",
|
|
22
|
+
"startWindowIcon": "$media:startIcon",
|
|
23
|
+
"startWindowBackground": "$color:start_window_background",
|
|
24
|
+
"exported": true,
|
|
25
|
+
"skills": [
|
|
26
|
+
{
|
|
27
|
+
"entities": [
|
|
28
|
+
"entity.system.home"
|
|
29
|
+
],
|
|
30
|
+
"actions": [
|
|
31
|
+
"action.system.home"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"extensionAbilities": [
|
|
38
|
+
{
|
|
39
|
+
"name": "EntryBackupAbility",
|
|
40
|
+
"srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
|
|
41
|
+
"type": "backup",
|
|
42
|
+
"exported": false,
|
|
43
|
+
"metadata": [
|
|
44
|
+
{
|
|
45
|
+
"name": "ohos.extension.backup",
|
|
46
|
+
"resource": "$profile:backup_config"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
+
<!--
|
|
3
|
+
Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
-->
|
|
17
|
+
<widget id="{{PACKAGE_NAME}}" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
|
18
|
+
<name>{{PROJECT_NAME}}</name>
|
|
19
|
+
<description>Sample Apache Cordova App</description>
|
|
20
|
+
<author email="dev@cordova.apache.org" href="https://cordova.apache.org">
|
|
21
|
+
Apache Cordova Team
|
|
22
|
+
</author>
|
|
23
|
+
<content src="index.html" />
|
|
24
|
+
<allow-intent href="http://*/*" />
|
|
25
|
+
<allow-intent href="https://*/*" />
|
|
26
|
+
</widget>
|