Create a js framework syntax hml in HarmonyOS v3

Channel:
Subscribers:
15,200
Published on ● Video Link: https://www.youtube.com/watch?v=5zkPGEIjtyY



Category:
Guide
Duration: 2:11
20 views
0


Here's how to Create a js framework syntax hml in HarmonyOS v3.

i. HarmonyOS is a relatively new operating system from Huawei with limited information available publicly so far.

However, based on my general web development knowledge, below is one hypothetical approach to get you started:

1. Review the HarmonyOS documentation on UI framework and JavaScript runtime capabilities. Identify the core APIs needed.

2. Define simple tag-based syntax for your HML, like `angled-bracket-hereviewangled-bracket-here`, `angled-bracket-heretextangled-bracket-here`, `angled-bracket-hereimageangled-bracket-here` etc.

3. Build a JavaScript-based HML parser that takes template strings as input.

4. The parser would convert HML tags to HarmonyOS JavaScript calls to create components.

5. For example, `angled-bracket-hereviewangled-bracket-here` could become:

```js
var view = new HMOS.View()
view.setId('view1')
// set other params
HMOS.addComponent(view)
```

6. Generate HarmonyOS native layout code for each component behind the scenes.

7. Expose additional methods like `updateView`, `removeComponent` etc.

8. Write a renderer to take the in-memory representation and render UI.

This gives a starting point, but without direct HarmonyOS experience I can't provide a full implementable example. I'd recommend studying their official docs and samples more to build out the syntax and integration properly.

ii. here is my best guess at what a typical HML page structure might look like in HarmonyOS v3:

```html
angled-bracket-herepageangled-bracket-here
angled-bracket-here!-- Page Header --angled-bracket-here
angled-bracket-hereheaderangled-bracket-here
angled-bracket-hereimage logoangled-bracket-hereangled-bracket-here/imageangled-bracket-here
angled-bracket-heretext titleangled-bracket-hereangled-bracket-here/textangled-bracket-here
angled-bracket-here/headerangled-bracket-here

angled-bracket-here-- Page Body --angled-bracket-here
angled-bracket-hereviewangled-bracket-here
angled-bracket-here!-- Components like images, texts, lists etc --angled-bracket-here
angled-bracket-here/viewangled-bracket-here

angled-bracket-here!-- Page Footer--angled-bracket-here
angled-bracket-herefooterangled-bracket-here
angled-bracket-heremenuangled-bracket-here
angled-bracket-here!-- Menu Items --angled-bracket-here
angled-bracket-here/menuangled-bracket-here
angled-bracket-here/footerangled-bracket-here

angled-bracket-here/pageangled-bracket-here
```

The outer `angled-bracket-herepageangled-bracket-here` component likely defines a full screen view. Inside, you would have logical sections like `angled-bracket-hereheaderangled-bracket-here` and `angled-bracket-herefooteangled-bracket-hereangled-bracket-here` for common elements.

The main content would go in a `angled-bracket-hereviewangled-bracket-here` container where you could have multiple components like `angled-bracket-hereimageangled-bracket-here`, `angled-bracket-heretextangled-bracket-here`, `angled-bracket-herelistangled-bracket-here` etc based on HML's syntax.

This is just a hypothetical guess without seeing concrete HML examples. I'd recommend checking HarmonyOS developer documentation for actual component names, attributes, and coding styles they recommend for HML framework.

iii. Here are a few key points about the relationship between HarmonyOS and Linux:

- HarmonyOS is a mobile operating system developed by Huawei as an alternative to Android. It is designed primarily for smartphones, wearables, and IoT devices.

- Under the hood, HarmonyOS uses a Linux kernel similar to Android. However, its architecture and software stack above the kernel level are different from Android.

- Huawei has contributed code to the Linux kernel over the years, even during the development of HarmonyOS. This implies continued engagement with the Linux ecosystem.

- HarmonyOS does not use the Android runtime. Instead it uses its own distributed OS kernel and distributed virtual machine. This allows it to adapt to different types of devices.

- The Ark Compiler that converts higher level languages to machine code in HarmonyOS is modeled after the LLVM compiler infrastructure commonly used in Linux environments.

- HarmonyOS has similarities to microkernel based operating systems like Google's Fuchsia which also leverage a Linux kernel.

- While not a full Linux distribution, HarmonyOS incorporates and builds upon various open source Linux technologies even as it diverges into its own OS vision. The extent of shared code and compatibility remains to be seen.

In summary, while HarmonyOS is not Linux, the two have a close technology relationship and shared lineages stemming from Huawei's use of Linux kernels and various open source components in developing HarmonyOS.

Learn more@ https://www.youtube.com/c/ITGuides/search?query=HarmonyOS.