2021-01-01 23:21:54 +00:00
|
|
|
(function (global, factory) {
|
|
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
|
|
typeof define === 'function' && define.amd ? define('umd', factory) :
|
|
|
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.umd = factory());
|
|
|
|
}(this, (function () { 'use strict';
|
|
|
|
|
2021-01-02 04:25:14 +00:00
|
|
|
function Anchor(opts = {}) {
|
2021-01-02 03:34:37 +00:00
|
|
|
const NAMESPACE = `_${Math.random().toString(36).slice(-6)}_`.toUpperCase();
|
2021-01-01 23:21:54 +00:00
|
|
|
|
2021-01-02 04:25:14 +00:00
|
|
|
const GLOBAL = opts.global || {};
|
2021-01-01 23:21:54 +00:00
|
|
|
|
2021-01-02 03:34:37 +00:00
|
|
|
const register = function register(key, value) {
|
|
|
|
if (GLOBAL[NAMESPACE] && !GLOBAL[NAMESPACE][key]) {
|
|
|
|
return GLOBAL[NAMESPACE][key] = value;
|
2021-01-01 23:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2021-01-02 03:34:37 +00:00
|
|
|
}.bind(GLOBAL[NAMESPACE]);
|
2021-01-01 23:21:54 +00:00
|
|
|
|
2021-01-02 04:25:14 +00:00
|
|
|
function build(opts, register) {
|
2021-01-02 03:34:37 +00:00
|
|
|
if (GLOBAL[NAMESPACE]) {
|
2021-01-01 23:21:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-02 04:25:14 +00:00
|
|
|
GLOBAL[NAMESPACE] = opts.register || {};
|
2021-01-02 03:34:37 +00:00
|
|
|
GLOBAL[NAMESPACE]['register'] = register;
|
2021-01-01 23:21:54 +00:00
|
|
|
|
2021-01-02 04:25:14 +00:00
|
|
|
(opts.mixins || []).forEach((mixin) => Object.assign(GLOBAL[NAMESPACE], mixin));
|
2021-01-01 23:21:54 +00:00
|
|
|
|
2021-01-02 03:34:37 +00:00
|
|
|
return GLOBAL[NAMESPACE];
|
2021-01-01 23:21:54 +00:00
|
|
|
}
|
2021-01-02 04:25:14 +00:00
|
|
|
return build(opts || {}, register);
|
2021-01-01 23:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Anchor;
|
|
|
|
|
|
|
|
})));
|