Advanced Topics
Write Once deploy on multiple API_LEVEL as minimum.
You write using API_LEVEL 3.0 then you can Change min API level of your project on the fly just with one command and same codebase.
***** Although the functionality is almost complete. Testing is not yet complete and expect to find bugs/issues. You can consider this library in beta.
***** Please report any issues found here or create a pull request. Thanks in advance
npm i zeppos-cross-api
npx zeppos-cross-api --api-level=X.0
where X is 1, 2 or 3 according to your project ( you still write your code using API_LEVEL 3) and can change the min API again as easily as running above command again with new API_LEVEL
then replace each instance of '@zepos' with 'zeppos-cross-api' and you good to go
use try and catch with new functionality with sensible fallbacks for new APIs see status for details. for example
try {
const player = create(id.PLAYER)
} catch (error) {
do something else
}
In addition to the modules in 3.0 There is four 5 new modules (sources here and here):
data-conversion
contains very usefull functions likestr2bin
to convert fromstring
toArrayBuffer
andbin2str
for viceversa.device-polyfill
import in your app.js if you want to usepromises
andsetTimeout
/setInterval
without worrying about api levelzml-base-app
modified version of ZML base appzml-base-page
modified version of ZML base pagezml-base-side
modified version of ZML base side
zml is recommended for usage for fetch, httprequest and other side service APIs but take care that
- Image Convert
- Download
- FileTransfer
are only avaliable in 3.0+ and would throw unsupported exception in other api levels.
For each of non-supported function we either have
- ERROR => function throws an error
- NOOP => function does nothing
For each module of each API_LEVEL there is 5 level of support:
- π© FULL
- π§ PARTIAL
- π₯ NONE (ALL are ERROR)
- π₯ NONE* (ALL are NOOP)
- N/A (not yet implemented)
Module | 3.0 | 2.0 | 1.0 |
---|---|---|---|
@zos/alarm | π© FULL | π§ PARTIAL | π§ PARTIAL |
@zos/app | π© FULL | π§ PARTIAL | π§ PARTIAL |
@zos/app-service | π© FULL | π₯ NONE | π₯ NONE |
@zos/ble | π© FULL | π§ PARTIAL | π§ PARTIAL |
@zos/device | π© FULL | π© FULL | π© FULL |
@zos/display | π© FULL | π§ PARTIAL | π§ PARTIAL |
@zos/fs | π© FULL | π© FULL | π© FULL |
@zos/i18n | π© FULL | π© FULL | π₯ NONE |
@zos/interaction | π© FULL | π© FULL | π© FULL |
@zos/media | π© FULL | π₯ NONE | π₯ NONE |
@zos/notification | π© FULL | π₯ NONE* | π₯ NONE* |
@zos/page | π© FULL | π© FULL | π§ PARTIAL |
@zos/router | π© FULL | π§ PARTIAL | π§ PARTIAL |
@zos/sensor | π© FULL | π§ PARTIAL | π§ PARTIAL |
@zos/settings | π© FULL | π§ PARTIAL | π§ PARTIAL |
@zos/storage | π© FULL | π§ PARTIAL | π§ PARTIAL |
@zos/ui | π© FULL | π§ PARTIAL | π§ PARTIAL |
@zos/user | π© FULL | π§ PARTIAL | π§ PARTIAL |
@zos/utils | π© FULL | π© FULL | π© FULL |
Listing unsupported function only for π§ PARTIAL and π₯ NONE*
API_LEVEL 2.0 and 1.0:
- repeat_type in set => ERROR
API_LEVEL 2.0 and 1.0:
- emitCustomSystemEvent => ERROR
API_LEVEL 2.0 and 1.0:
- mstBuildProfile => ERROR
- mstConnect => ERROR
- DestroyProfileInstance => ERROR
- mstDisconnect => ERROR
- mstGetConnIdByRemoteAddr => ERROR
- mstGetProfileInstance => ERROR
- mstOffAllCb => ERROR
- mstOnCharaNotification => ERROR
- mstOnCharaReadComplete => ERROR
- mstOnCharaValueArrived => ERROR
- mstOnCharaWriteComplete => ERROR
- mstOnDescValueArrived => ERROR
- mstOnDescWriteComplete => ERROR
- mstOnPrepare => ERROR
- mstOnServiceChangeBegin => ERROR
- mstOnServiceChangeEnd => ERROR
- mstPair => ERROR
- mstPrepare => ERROR
- mstReadCharacteristic => ERROR
- mstReadDescriptor => ERROR
- mstStartScan => ERROR
- mstStopScan => ERROR
- mstWriteCharacteristic => ERROR
- mstWriteDescriptor => ERROR
API_LEVEL 2.0 and 1.0:
- getSettings => ERROR
API_LEVEL 1.0 only:
- pauseDropWristScreenOff => NOOP (but return non-zero indicating non-sucess code)
- resetDropWristScreenOff => NOOP (but return non-zero indicating non-sucess code)
- pausePalmScreenOff => NOOP (but return non-zero indicating non-sucess code)
- resetPalmScreenOff => NOOP (but return non-zero indicating non-sucess code)
API_LEVEL 2.0 and 1.0:
- notify => NOOP (return 0 for non success)
- cancel => NOOP
- getAllNotifications => NOOP (return empty array)
API_LEVEL 1.0:
- setScrollLock => ERROR
API_LEVEL 2.0 and 1.0:
- ALL SYSTEM_APP constants are undefined
- checkSystemApp => NOOP
Sensor | 3.0 | 2.0 | 1.0 |
---|---|---|---|
Accelerometer | π© FULL | π₯ MISSING | π₯ MISSING |
Barometer | π© FULL | π© FULL | π₯ MISSING |
Battery | π© FULL | π© FULL | π© FULL |
BloodOxygen | π© FULL | π§ PARTIAL | π§ PARTIAL |
Calorie | π© FULL | π© FULL | π© FULL |
Compass | π© FULL | π₯ MISSING | π₯ MISSING |
Distance | π© FULL | π© FULL | π© FULL |
FatBurning | π© FULL | π© FULL | π© FULL |
Geolocation | π© FULL | π§ PARTIAL | π₯ MISSING |
Gyroscope | π© FULL | π₯ MISSING | π₯ MISSING |
HeartRate | π© FULL | π§ PARTIAL | π§ PARTIAL |
Pai | π© FULL | π© FULL | π© FULL |
Screen | π© FULL | π₯ MISSING | π₯ MISSING |
Sleep | π© FULL | π§ PARTIAL | π§ PARTIAL |
Stand | π© FULL | π© FULL | π© FULL |
Step | π© FULL | π© FULL | π© FULL |
Stress | π© FULL | π§ PARTIAL | π§ PARTIAL |
Time | π© FULL | π§ PARTIAL | π§ PARTIAL |
Vibrator | π© FULL | π© FULL | π© FULL |
Wear | π© FULL | π© FULL | π© FULL |
Weather | π© FULL | π© FULL | π© FULL |
Workout | π© FULL | π₯ MISSING | π₯ MISSING |
WorldClock | π© FULL | π₯ MISSING | π© FULL |
API_LEVEL 2.0 and 1.0:
- getSystemMode => ERROR
API_LEVEL 1.0:
- getImageInfo => ERROR
- redraw => NOOP
- setAppWidgetSize => ERROR
- getAppWidgetSize => ERROR
As for Wdigets: (Warning: They wont throw an error but they will return undefined
for createWidget
):
Not Found in 2.0 and 1.0:
Not found in 1.0:
API_LEVEL 2.0 and 1.0:
- addHealthData => ERROR
- Zepp OS 3.0 - Framework
- rollup
- modified version of prepare_all.py, app.json and other files from ZeppOS-Toolbox by melianmiko
- @mahmoudbahaa - Idea & Initial work
See also the list of contributors who participated in this project.
- Hat tip to anyone whose code was used
This project is under license from Apache License V2. For more details, see the LICENSE file.