目录

ASCF Assistant (VS Code)

To support developers who use Visual Studio Code (VS Code), the ASCF team has developed and maintains the VS Code plugin, ASCF Assistant. It provides one-click project creation, quick conversion, and debugging features to aid in atomic service development.

Before using the VS Code plugin, ensure that DevEco Studio is installed and the necessary environment variables are configured.

Installation

In VS Code, click Extensions. Search for "ASCF Assistant" in the Marketplace and click Install. A successful installation is indicated by the appearance of the atomic service icon in the sidebar.

Click the atomic service icon to start development with ASCF Assistant.

ASCF Assistant 1.0.7 introduces the Developer Home feature. You can click the atomic service icon to access the Developer Home page, facilitating your atomic service development. For details, please refer to Developer Home.

Creating or Importing a Project

[h2]Creating a Project

  1. Click the project creation button.

  2. On the displayed page, configure the project information as prompted to create a project.

  3. Click Industry template and select an industry template for hands-on development. Currently, templates for education, e-commerce, news, reading, and takeaway are available.

  4. Complete the project configuration and click Finish.

    Project Information Description
    App ID App ID. You can find the app ID of your atomic service by signing in to HUAWEI Developers and choosing My Projects > Settings > Regular > App > APP ID.
    Project Name Name of the created project.
    Save Location Path for saving the created project. Ensure that the selected folder is empty.
    Device Types Device types on which the atomic service can run. Currently, the atomic service can run on phones and tablets.

    You can query the app ID in AppGallery Connect. However, the VS Code plugin does not support signature generation for atomic services. You need to configure the signature corresponding to the app ID in the signingConfigs field of the build-profile.json5 file in the root directory of the new project. You can use the signature automatically generated by DevEco Studio or an existing signature.

    Example:

[h2]Importing an ASCF Project

  1. Click the button for opening the ASCF project.

  2. Right-click on a historical record and choose Open ASCF project.

Converting a Mini Program Project to an ASCF Project

  1. Open the new ASCF project and delete the ascf/ascf_src directory.

  2. Click the conversion button and select a mini program project (such as WeChat or Alipay mini program).

    After a successful conversion, you can view the conversion information by clicking the Open Report button in the bottom-right corner.

How to Develop

During development, ASCF Assistant supports the following features to help you develop atomic services more conveniently and efficiently:

Compiling an Atomic Service

You can click the run button at the bottom of VS Code to compile the atomic service. If a device is connected, the atomic service will automatically run on the selected device.

After the build starts, the ASCF Assistant run log panel will open automatically. You can click the gear button to view logs filtered by log level.

ASCF Assistant 1.0.8 and later versions support screen mirroring on devices running HarmonyOS 4 or earlier. Screen mirroring is automatically enabled upon atomic service startup.

  1. macOS does not support screen mirroring.

  2. To disable screen mirroring during runtime, go to Settings and deselect Ascf-plugin: Run And Start Screen Casting.

Function Buttons

In addition to the run buttons, ASCF Assistant also provides other commonly used function buttons.

[h2]Selecting a Device

You can click the device selection button (marked by ① in the figure in Function Buttons; the button shows No Devices when no device is selected) to select the device connected to the computer. If the connected device changes, you need to reselect it. Debugging and running are supported on devices running HarmonyOS 4 or earlier and devices running HarmonyOS 5.0 or later. The device name and OS version are displayed in the device selection list. Select a suitable device for debugging and running.

After the connected device is changed, you need to click the device selection button to change the device before running the atomic service.

[h2]Switching Between Build Environments

You can click the build environment button (marked as ② in the figure in Function Buttons) to switch the build environment.

Both debug and release build environments are supported:

If a device running HarmonyOS 4 or earlier is selected, the following build artifacts are generated:

On devices running HarmonyOS 4 or earlier, you need to download and install Quick App Loader to debug and run the atomic service. You can run the preceding artifact on Quick App Loader using the adb command.

Through a server: Start the server in the preceding artifact directory, replace ${appid} with the app ID of your atomic service, and replace ${app} with the artifact name.

http-server -p 3000
adb reverse tcp:3000 tcp:3000
adb shell am start -a android.intent.action.VIEW -d hap://app/com.atomicservice.${appid} -p com.huawei.fastapp.dev --es pkgUrl http://127.0.0.1:3000/${app}

Through local package pushing: Replace path/to/app with the path of the preceding artifact, ${appid} with the app ID of your atomic service, and ${app} with the artifact name.

adb push path/to/app /data/local/tmp/
adb shell am start -a android.intent.action.VIEW -d hap://app/com.atomicservice.${appid} -p com.huawei.fastapp.dev --es pkgUrl file:///data/local/tmp/${app}

[h2]Enabling/Disabling Hot Reload

You can click the hot reload button (marked by ③ in the figure in Function Buttons) to enable or disable hot reload. Clicking the run button initiates hot reload for compilation.

Currently, hot reload is not supported on devices running HarmonyOS 4 or earlier.

[h2]Enabling HiLog

You can click Start Hilog (marked as ④ in the figure in Function Buttons) to view logs. You can filter log information by log level and search keyword. Features such as log export, word wrap, and clearing window logs are also available. After connecting a device to the computer, you can click to enable HiLog.

After the device is connected to the computer and the ASCF atomic service is started, you can enable HiLog to view logs of the corresponding level.

The buttons in the HiLog window are described as follows:

: starts the log process.

: pauses log output.

: resumes log output.

: saves logs to a file.

: enables word wrap for logs. Otherwise, logs are displayed as raw lines.

: exits the log process.

[h2]Filtering Logs by the Package Name of a Running Atomic Service

For devices running HarmonyOS 5.0 or later, the system queries the running atomic service process based on the bundle name of the project by default and displays the logs of the process. If no matching process is found, Unlimited is automatically selected. To view the startup logs, you need to enable log collection in the Unlimited mode and then run the atomic service.

For devices running HarmonyOS 4 or earlier, the system queries the running atomic service process by default and displays the logs of the process. If no matching process is found, Unlimited is automatically selected. To view the startup logs, you need to enable log collection in the Unlimited mode and then run the compatible atomic service.

[h2]Filtering Logs by Keyword

You can filter logs by keyword.

[h2]Filtering Logs by Log Level

You can filter and view logs by selecting a log level from the drop-down list.

[h2]Filtering Logs by Domain

You can view logs by domain. The default value is 0x006F, indicating service logs output by atomic services. All logs are output when the value is empty. Multiple values can be entered. Use commas (,) to separate the values (for example, 0x006F,0x8BF2).

[h2]Maximum Number of Cached Logs

The default maximum number of cached logs in the memory is 5,000. A larger value can be configured as needed.

  • A large number of logs may affect performance. Therefore, do not set a large value.

  • After the value modification, restart the log process for the modification to take effect.

[h2]Enabling Debugging

You can click to enable or disable debugging. Clicking the debug button starts debugging.

For details, please refer to Debugging with ASCF Assistant.

Atomic Service Icon Generation Tool

The atomic service icon generation tool consists of two parts: the tool integrated in ASCF Assistant (on the IDE side) and the SDK.

IDE tool

Similar to atomic service icon generation in DevEco Studio, you can also generate atomic service icons directly when developing with ASCF Assistant.

The atomic service icon generation tool is supported in ASCF Assistant 1.0.5 and later versions.

  1. After installing ASCF Assistant and opening an ASCF project, right-click any folder in the project and choose Image Asset from the shortcut menu to open the atomic service icon generation tool, as shown in the following figure.

  2. Select an image by following the instructions on the opened page. For details about the image format, please refer to the atomic service icon design specifications.

  3. Select the color of the outer circle line and click the corresponding button to generate the atomic service icon.

SDK

To meet service providers' needs, ASCF provides an SDK version to help them integrate the atomic service icon generation capability.

  1. Install the SDK in the frontend project.

    npm install @atomicservice/as-icon-generator
  2. Use the SDK.

    import { AsIconGenerator } from '@atomicservice/as-icon-generator';
    // Note: srcImg can be either a URL or an image object.
    const img = new Image();
    img.src = 'src/assets/test.jpg';
    const asIconGenerator = new AsIconGenerator({ srcImg: img });
    // Obtain the color.
    const colors = await asIconGenerator.getColors();
    // Note: All available colors need to be displayed on the interface so that users can select a suitable color.
    asIconGenerator.setColor(colors[0]);
    // Generate an image. agc: true indicates that the icon used in AppGallery Connect is also generated.
    const result = await asIconGenerator.generate({ agc: true });
    // result.outputImage
    // result.agcImage

If a cross-origin error occurs during the request for the selected image, the server hosting the source image must be configured to support cross-origin access.

Developer Home

If no ASCF project is open, click the atomic service icon. Then you can create or import an ASCF project, or convert a mini program project into an ASCF project.

Basic information of an atomic service

The basic information module consists of the atomic service icon, AppName, AppID, signature configuration, and runtime version.

  1. Atomic service icon

    The icon in the upper left corner of the Developer Home page is the icon of the current atomic service project. You can click the icon to open the atomic service icon generation tool. Clicking anywhere outside the atomic service icon generation tool page or clicking the close button at the bottom of the tool page exits the tool.

  2. Atomic service name

    AppName indicates the name of the current atomic service project. You can click Edit to change the atomic service name in the dialog that is displayed, and then click Save.

  3. App ID

    AppID indicates the app ID of the current atomic service project.

  4. Atomic service signature configuration

    It indicates whether a debug or release signature has been configured for the current atomic service project.

    It indicates whether a signature has been configured based on the signingConfigs field in the build-profile.json5 file in the root directory of the atomic service project. Signature configurations defined in developer-customized targets are not supported.

    Click Reference to open the signature configuration reference document. Click Configure to open the build-profile.json5 file. After you modify the signingConfigs field and save the file, the signature configuration status on the Developer Home page will be automatically updated.

  5. Runtime version

    It displays the runtime version of the current project.

Shortcut operations

  1. Permission configuration

    Click Permission Configuration to open the permission configuration dialog.

    The application reason and invoking time in the permission modification and application dialog are not mandatory. For details, please refer to Declaring Permissions.

    Select the required permissions in the list of permissions that have not been obtained, and click Apply. In the dialog that is displayed, enter the application reason and invoking time, and click Save to add the permission application configuration.

    Select a permission from the list of obtained permissions and click Modify. In the dialog that is displayed, modify the application reason and invoking time, and click Save to modify the permission application configuration.

    After selecting a permission, click Delete to delete unnecessary permission configuration information.

  2. Package size analysis

    Before using the package size analysis feature, ensure that the project can be compiled properly.

    Click the package size analysis button to start analyzing the package of the current project from multiple dimensions.

    Click Disable service to exit the package size analysis feature.

Basic configuration

  1. Atomic service domain name management

    Clicking Edit Domain Name opens Configuring Server Domain Names on HUAWEI Developers in the browser, where you can view the configuration guide.

  2. Development capabilities

    Clicking the configuration button opens Enabling Huawei Open Capabilities for Your HarmonyOS App on HUAWEI Developers in the browser, where you can view the configuration guide.

Resource center

Click Developer Documentation, API Documentation, Service Provider Development Documentation, Harmony Assistant, or ASCF Community to access the corresponding guide on HUAWEI Developers in a browser.

[h2]Built-in Commands of the ASCF Assistant Plugin

ID Title Description
ascf-plugin.addProject Create ASCF Project Creates an ASCF project.
ascf-plugin.ascfBuild Build ASCF Builds the ASCF project.
ascf-plugin.ascfBuild.clean Clean Cleans the build output.
ascf-plugin.ascfBuild.install Install dependencies Installs dependencies.
ascf-plugin.ascfBuild.stop Stop build ASCF Stops building.
ascf-plugin.ascfBuild.sync Sync Synchronizes project configurations.
ascf-plugin.ascfBuildAndDebug Build and debug ASCF Builds and debugs the ASCF project.
ascf-plugin.ascfBuildAndDebug.stop Stop build ASCF Stops building.
ascf-plugin.ascfBuildApp Build ASCF App Builds the ASCF app.
ascf-plugin.ascfDebugger.start Start Debugger Starts the debugger.
ascf-plugin.ascfDebugger.stop Stop Debugger Stops the debugger.
ascf-plugin.chooseDevice Choose device Selects a device.
ascf-plugin.createAscfComponent New ASCF Component Creates an ASCF component.
ascf-plugin.createAscfPage New ASCF Page Creates an ASCF page.
ascf-plugin.createServiceWidget New ASCF Service Widget Creates an ASCF service widget.
ascf-plugin.deleteRecentProject Remove recent ASCF project Removes the latest ASCF project.
ascf-plugin.hilog Hilog Starts HiLog.
ascf-plugin.hilog.stop Stop Hilog Stops HiLog.
ascf-plugin.importProject Import miniprogram Converts mini program resources.
ascf-plugin.initTypings Init typings Initializes typings.
ascf-plugin.openProject Open ASCF project Imports an ASCF project.
ascf-plugin.openSelectProject Open ASCF project Imports an ASCF project.
ascf-plugin.showConvertReport Show convert report Displays the conversion report.
ascf-plugin.startAbility Start ability Starts an ability.
ascf-plugin.startScreenCast Start ScreenCast Starts screen mirroring.

Plugin Configuration

The ASCF Assistant plugin supports run configuration settings. Click the gear button in the bottom-left corner of VS Code to open the Manage menu, select Settings, and enter ascf-plugin in the search box to configure the plugin behavior.

ID Description Default Value
ascf-plugin.devecoSdkHome DEVECO SDK path. ""
ascf-plugin.forceNewWindow Indicates whether to open a new project in a new window. false
ascf-plugin.hilogDomains HiLog domain ID. "0x006F"

The following GIF image shows how to configure the plugin.