1.0.0-rc.3 • Published 4 years ago

js.license v1.0.0-rc.3

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

license

npm包授权管理

使用示例

现有如下NPM包obj

class _CRS {
    constructor() {
        this._baidu = "baidu";
    }

    ESPG() {
        return "CRS.ESPG";
    }

    get Simple() {
        return "CRS.Simple";
    }

    get Baidu() {
        return this._baidu;
    }

    set Baidu(val) {
        this._baidu = val;
    }
}

const Obj = {
    Map: "Obj.Map",
    Control: function() {
        return "Obj.Control";
    },
    Layers: [1, 2, 3, 4],
    CRS: new _CRS()
};

export default Obj;

发布者

obj授权

import License from "js.license";

// 定义授权清单
const manifest = {
    Control: 1,
    CRS: 1,
    "CRS.Simple": 1,
    "CRS.Baidu": 1,
    "CRS.ESPG": 2,
};

class _CRS { ... }

const Obj = { ... }

var license = new License(manifest);

export default license.proxy(Obj);

License内置了免费版(Free, 0)基础版(Basic, 1)标准版(Standard, 2)高级版(Advanced, 3)四个软件版本。

  • Obj.ControlObj.CRSObj.CRS.SimpleObj.CRS.Baidu可以在Basic(1)版本下访问
  • Obj.CRS.ESPG可以在Standard(2) 版本下访问
  • 对于没有提到的Obj.MapObj.Layer可以在Free(0)版本下访问

使用者

首先从发布者那里拿到licenseKey,否则只能使用免费版。

import Obj from 'obj';

Obj.licenseKey='...'

如果没有拿到licenseKey,使用者只能访问如下的Obj

{
    Map: "Obj.Map",
    Control: {},
    Layers: [1, 2, 3, 4],
    CRS: {}
}

请参考 Github License

1.0.0-rc.3

4 years ago

1.0.0-rc.2

4 years ago

1.0.0-rc.1

4 years ago

1.0.0-rc

4 years ago