miniapp icon indicating copy to clipboard operation
miniapp copied to clipboard

Common APIs

Open Cyanyan121 opened this issue 3 years ago • 3 comments

Nowadays, different vendors have different categories, development guidelines, and implementations for developing Miniapp APIs. The cost of writing multiple sets of code for different vendors is obviously very high for developers. Therefore, it is necessary to define a standard set of APIs for Miniapp to help improve the cross-platform capability of Miniapp, improving developer efficiency.

The specification may contain:

  • Define the Miniapp Object Model to provide APIs for Miniapp;
  • Document the common set of Miniapp APIs by referring to the current specifications of Web APIs;
  • Document the usage of Miniapp APIs, such as synchronous APIs and asynchronous APIs.

Cyanyan121 avatar Feb 17 '22 10:02 Cyanyan121

A short draft of Miniapp Common APIs is prepared for CG discussion.

Miniapp Object Model

Abstract

MAOM (Miniapp Object Model) is an object model for Miniapp that provides the JavaScript interface. This document specifics a set of standard common APIs for Miniapp, and the implementation can help to improve the cross-platform capability of Miniapp, improving developer efficiency.

1. Introduction

1.1 Background

Miniapp is a concept of light software application based on Web technology that runs on userAgent, combined with native application technology implementations. As described in the MiniApp Standardization White Paper, the logic layer is separated from the view layer. The Logic layer is implemented with JavaScript Worker. The Miniapp interface is rendered by mature Web technologies, and the client-side native capabilities are integrated into an interface for developers to invoke.

1.2 An Overview of MiniApp Object Model

MAOM provides rich native APIs for developers to easily and quickly invoke these APIs to complete related tasks, such as obtaining system information, local storage, payment service, etc.

1.3 Summarize of MiniApp Object Model

MAOM can be classified into three core object models: HOSTOM (Host Object Model), APPOM (App Object Model), PAGEOM (Page Object Model).

HOSTOM(Host Object Model) HOSTOM (Host Object Model) is the host capability object model that provides a rich set of userAgent capabilities to develop Miniapp with native application experience. It provides API categories including: data storage, payment services, media, device adaptation, network communication, graphics and layout, user interaction, sensing, security and privacy, performance tuning, routing, and interface.

APPOM(App Object Model) APPOM (App Object Model) is the application object model that provides APIs to listen to the global application lifecycle of Miniapp. Developers use the APPOM APIs to register Miniapp instances, bind the global application lifecycle event handlers, error listening and page non-existence event handlers. It provides API categories including: lifecycle event handlers, error event handlers, and page non-existence event handlers.

PAGEOM(Page Object Model) PAGEOM (Page Object Model) is the page object model that provides APIs for listening to the lifecycle of Miniapp pages. Each page needs to register a page instance through the PAGEOM API to specify the page's initial data, lifecycle event handlers, and page event handlers. It provides API categories including: page lifecycle event handlers, page event handlers.

2. HOSTOM

2.1 Data Storage

2.2 Device Adaptation

2.3 Media

2.4 Network and Communications

2.5 Payment and Services

2.6 Graphic and Layout

2.7 User Interaction

2.8 Sensors and Local Interactions

2.9 Security and Privacy

2.10 Performance and Tuning

2.11 Router

3. APPOM

4. PAGEOM

Cyanyan121 avatar Feb 17 '22 11:02 Cyanyan121

There is some overlap between this issue and #177, maybe we can work on it together?

xfq avatar Feb 18 '22 06:02 xfq

There is some overlap between this issue and #177, maybe we can work on it together?

I agree. It will be great to merge these issues.

Cyanyan121 avatar Mar 02 '22 10:03 Cyanyan121