github lynx-family/lynx-stack @lynx-js/web-worker-runtime@0.8.0

latest releases: @lynx-js/offscreen-document@0.1.4, @lynx-js/cache-events-webpack-plugin@0.0.2, @lynx-js/web-constants@0.16.0...
5 months ago

Minor Changes

  • refactor: remove web-elements/lazy and loadNewTag (#123)

    • remove @lynx-js/web-elements/lazy
    • remove loadElement
    • remove loadNewTag callback

    This is a breaking change

    Now we removed the default lazy loading preinstalled in web-core

    Please add the following statement in your web project

    import "@lynx-js/web-elements/all";
    

Patch Changes

  • feat: add pixelRatio of SystemInfo, now you can use SystemInfo.pixelRatio. (#150)

  • feat: add two prop of lynx-view about napiLoader: (#173)

    • napiModulesMap: [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.

    • onNapiModulesCall: [optional] the NapiModule value handler.

    Warning: This is the internal implementation of @lynx-js/lynx-core. In most cases, this API is not required for projects.

    1. The napiModulesMap value should be a esm url which export default a function with two parameters:
    • NapiModules: oriented napiModulesMap, which you can use to call other Napi-Modules

    • NapiModulesCall: trigger onNapiModulesCall

    example:

    const color_environment = URL.createObjectURL(
      new Blob(
        [
          `export default function(NapiModules, NapiModulesCall) {
      return {
        getColor() {
          NapiModules.color_methods.getColor({ color: 'green' }, color => {
            console.log(color);
          });
        },
        ColorEngine: class ColorEngine {
          getColor(name) {
            NapiModules.color_methods.getColor({ color: 'green' }, color => {
              console.log(color);
            });
          }
        },
      };
    };`,
        ],
        { type: 'text/javascript' },
      ),
    );
    
    const color_methods = URL.createObjectURL(
      new Blob(
        [
          `export default function(NapiModules, NapiModulesCall) {
      return {
        async getColor(data, callback) {
          const color = await NapiModulesCall('getColor', data);
          callback(color);
        },
      };
    };`,
        ],
        { type: 'text/javascript' },
      ),
    );
    
    lynxView.napiModuleMap = {
      color_environment: color_environment,
      color_methods: color_methods,
    };
    1. The onNapiModulesCall function has three parameters:
    • name: the first parameter of NapiModulesCall, the function name
    • data: the second parameter of NapiModulesCall, data
    • moduleName: the module-name of the called napi-module
    lynxView.onNapiModulesCall = (name, data, moduleName) => {
      if (name === 'getColor' && moduleName === 'color_methods') {
        return data.color;
      }
    };
  • Updated dependencies [e9e8370, ec4e1ce, f0a717c, 63fab7b]:

    • @lynx-js/web-mainthread-apis@0.8.0
    • @lynx-js/web-constants@0.8.0
    • @lynx-js/web-worker-rpc@0.8.0

Don't miss a new lynx-stack release

NewReleases is sending notifications on new releases.