devfab 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/devfab.js CHANGED
@@ -2734,127 +2734,6 @@
2734
2734
  }]);
2735
2735
  }();
2736
2736
 
2737
- /**
2738
- * 全局污染检测:加载前后 diff window 的 key 集合。
2739
- *
2740
- * 为什么需要:二开脚本直接跑在宿主 window 上,A 客户的脚本改了一个全局变量,
2741
- * B 客户就跟着崩,而且现场无法归因。真做 iframe / Proxy 沙箱成本极高,
2742
- * 但「加载完能告诉你动了哪些全局」只需要几十行,能挡住大半这类事故。
2743
- *
2744
- * 边界(这是观测,不是隔离):
2745
- * - 事后告警,不阻止副作用——脚本已经执行过了;
2746
- * - 并发加载时窗口会重叠,归因以「最后完成的一批」结算,可能不准;
2747
- * - 只比较可枚举自有属性的**引用**,`window.foo.bar = 1` 这类深层改动检测不到。
2748
- */
2749
-
2750
- /** 默认盯防的 key:出现即说明宿主的关键设施被动过 */
2751
- var DEFAULT_WATCH = ['$', 'jQuery', 'define', 'require', 'requirejs', 'devfab', '__devfab'];
2752
- var GlobalGuard = /*#__PURE__*/function () {
2753
- function GlobalGuard(options) {
2754
- _classCallCheck(this, GlobalGuard);
2755
- var o = options || {};
2756
- this.maxPollution = o.maxPollution === undefined ? 3 : Number(o.maxPollution);
2757
- this.watch = [].concat(o.watch || DEFAULT_WATCH);
2758
- this.target = o.target || (typeof window !== 'undefined' ? window : null);
2759
- this.enabled = o.enabled === undefined ? true : !!o.enabled;
2760
- this._pending = 0;
2761
- this._before = null;
2762
- this.lastWarnings = [];
2763
- }
2764
- return _createClass(GlobalGuard, [{
2765
- key: "_snapshot",
2766
- value: function _snapshot() {
2767
- var map = new Map();
2768
- var target = this.target;
2769
- if (!target) return map;
2770
- Object.keys(target).forEach(function (key) {
2771
- map.set(key, target[key]);
2772
- });
2773
- return map;
2774
- }
2775
- }, {
2776
- key: "_diff",
2777
- value: function _diff() {
2778
- var _this = this;
2779
- var before = this._before;
2780
- var after = this._snapshot();
2781
- var warnings = [];
2782
- if (!before) return warnings;
2783
- after.forEach(function (value, key) {
2784
- var watched = _this.watch.indexOf(key) !== -1;
2785
- if (!before.has(key)) {
2786
- warnings.push({
2787
- type: 'added',
2788
- key: key,
2789
- watched: watched
2790
- });
2791
- return;
2792
- }
2793
- if (before.get(key) !== value) {
2794
- warnings.push({
2795
- type: 'overwritten',
2796
- key: key,
2797
- watched: watched
2798
- });
2799
- }
2800
- });
2801
- // 命中盯防名单,或新增数量超过阈值,才认为「值得提醒」。
2802
- // 1~2 个自有全局是正常写法,全报会把信号淹掉。
2803
- var watchedCount = warnings.filter(function (item) {
2804
- return item.watched;
2805
- }).length;
2806
- var addedCount = warnings.filter(function (item) {
2807
- return item.type === 'added';
2808
- }).length;
2809
- if (!watchedCount && addedCount <= this.maxPollution) return [];
2810
- return warnings;
2811
- }
2812
-
2813
- /**
2814
- * 开始观测。返回的 `end()` 幂等,重复调用只有第一次有效,
2815
- * 这样超时分支和 errback 分支可以都调,不会把计数搞负。
2816
- */
2817
- }, {
2818
- key: "begin",
2819
- value: function begin() {
2820
- var _this2 = this;
2821
- if (!this.enabled || !this.target) {
2822
- return {
2823
- end: function end() {
2824
- return [];
2825
- }
2826
- };
2827
- }
2828
- this._pending++;
2829
- if (this._pending === 1) this._before = this._snapshot();
2830
- var done = false;
2831
- return {
2832
- end: function end() {
2833
- if (done) return [];
2834
- done = true;
2835
- _this2._pending--;
2836
- // 还有并发批次没结束,交给最后结束的那一批结算
2837
- if (_this2._pending > 0) return [];
2838
- var warnings = _this2._diff();
2839
- _this2._before = null;
2840
- _this2.lastWarnings = warnings;
2841
- return warnings;
2842
- }
2843
- };
2844
- }
2845
- }, {
2846
- key: "configure",
2847
- value: function configure(options) {
2848
- var o = options || {};
2849
- if (o.enabled !== undefined) this.enabled = !!o.enabled;
2850
- if (o.maxPollution !== undefined) this.maxPollution = Number(o.maxPollution);
2851
- if (o.watch !== undefined) this.watch = [].concat(o.watch || []);
2852
- if (o.target !== undefined) this.target = o.target || null;
2853
- return this;
2854
- }
2855
- }]);
2856
- }();
2857
-
2858
2737
  /** 加载超时:RequireJS 自己的 waitSeconds 默认 30s,这个定时器是更早的兜底 */
2859
2738
  var CODE_TIMEOUT = 504;
2860
2739
 
@@ -2877,10 +2756,8 @@
2877
2756
  var path = _path;
2878
2757
  var files = _files;
2879
2758
  var callback = _callback;
2880
- // 单参形式:(files, callback) 或 (files)。判据是「第一个是数组、第二个不是数组」,
2881
- // 放宽到非函数是因为 loadModules([url]) 这种不带回调的调用很常见。
2882
2759
  if (Array.isArray(_path) && !Array.isArray(_files)) {
2883
- path = params === null || params === void 0 ? void 0 : params.path;
2760
+ path = undefined;
2884
2761
  files = _path;
2885
2762
  callback = typeof _files === 'function' ? _files : _callback;
2886
2763
  }
@@ -2889,8 +2766,7 @@
2889
2766
  var result = {
2890
2767
  code: 0,
2891
2768
  message: '',
2892
- data: [],
2893
- warnings: []
2769
+ data: []
2894
2770
  };
2895
2771
  if (params.type === 'require' && typeof params.require !== 'function' || params.type === 'define' && typeof params.define !== 'function' //
2896
2772
  ) {
@@ -2930,64 +2806,44 @@
2930
2806
  version: '',
2931
2807
  timeout: 15000,
2932
2808
  retry: 0,
2933
- strict: false,
2934
2809
  baseUrl: ''
2935
2810
  };
2936
2811
  var BaseFileRequire = /*#__PURE__*/function () {
2937
- /**
2938
- * args 只接受**参数与策略**,不接受加载器覆盖:
2939
- * - 加载策略:`version` / `timeout` / `retry` / `strict` / `baseUrl` / `manifest`
2940
- * / `origins` / `lockVersion` / `verifyHash` / `pollution` / `watch` / `maxPollution`
2941
- * - 通道与时钟:`importer`(ESM 通道用的 import 函数)、`setTimeout` / `clearTimeout`
2942
- *
2943
- * 刻意**不再接受** `define` / `require` / `undef` / `requireConfig`:
2944
- * 这四个是 AMD 加载器本体,AMD 通道只走内嵌的 RequireJS 2.3.2。以前允许覆盖的
2945
- * 后果是「宿主传了自己的 require,但 undef 仍取内嵌的那份」,两套注册表混用,
2946
- * 而且被覆盖时是静默的。要换通道请用 `loadModules()`,不要替换加载器。
2947
- *
2948
- * 其余配置一律走 `configure(options)` 在运行时改。
2949
- */
2950
2812
  function BaseFileRequire(args) {
2951
- var _this$__require;
2952
2813
  _classCallCheck(this, BaseFileRequire);
2953
- var o = args || {};
2954
- // 只有显式传参才写全局。模块加载时会 new 一次单例,若无条件写 false,
2955
- // 宿主在 import 之前设好的 `window.__devfab.debug` 会被抹掉。
2956
- if (o.debug !== undefined) this.debug = !!o.debug;
2957
- this.__rootPath = undefined;
2958
- this.__define = __requirejs.define;
2959
- this.__require = __requirejs.require;
2960
- this.__undef = typeof ((_this$__require = this.__require) === null || _this$__require === void 0 ? void 0 : _this$__require.undef) === 'function' ? this.__require.undef : null;
2961
- this.__requireConfig = this._pickRequireConfig(this.__require);
2962
- this.__import = o.importer || null;
2963
- this._setTimer = o.setTimeout || function (fn, ms) {
2964
- return setTimeout(fn, ms);
2965
- };
2966
- this._clearTimer = o.clearTimeout || function (id) {
2967
- return clearTimeout(id);
2968
- };
2969
- this.options = {
2970
- version: o.version ? String(o.version) : DEFAULT_OPTIONS.version,
2971
- timeout: o.timeout === undefined ? DEFAULT_OPTIONS.timeout : Math.max(0, toNumber(o.timeout, 0)),
2972
- retry: o.retry === undefined ? DEFAULT_OPTIONS.retry : Math.max(0, toNumber(o.retry, 0)),
2973
- strict: !!o.strict,
2974
- baseUrl: o.baseUrl || DEFAULT_OPTIONS.baseUrl
2975
- };
2976
- this.policy = new LoadPolicy(o);
2977
- this.guard = new GlobalGuard(this._guardOptions(o));
2978
- if (this.options.version) this._applyUrlArgs();
2814
+ this.__init(args);
2979
2815
  }
2980
-
2981
- /**
2982
- * 调试开关的**唯一来源**是 `window.__devfab.debug`。
2983
- *
2984
- * 为什么做成访问器:这个开关被三处读——加载器这里、`_utils/models/_extend.js` 的
2985
- * 扩展脚本装配、`_utils/string.js` 的 isDebug。以前各读各的(实例字段 /
2986
- * `window.__devfab.debug` / `window.devfab.debug`),宿主开了一个另两个不生效,
2987
- * 排查时看起来像「日志不打印」。统一读写同一个位置后,`FileRequire.configure({debug:true})`、
2988
- * `FileRequire.debug = true`、`window.__devfab.debug = true` 三句话效果完全一致。
2989
- */
2990
2816
  return _createClass(BaseFileRequire, [{
2817
+ key: "__init",
2818
+ value: function __init(args) {
2819
+ var o = args || {};
2820
+ if (o.debug !== undefined) this.debug = !!o.debug;
2821
+ var require = __requirejs.require;
2822
+ this.__data = {
2823
+ /* --- 加载器句柄与通道:AMD 通道只走内嵌 RequireJS --- */
2824
+ define: __requirejs.define,
2825
+ require: require,
2826
+ undef: typeof (require === null || require === void 0 ? void 0 : require.undef) === 'function' ? require.undef : null,
2827
+ requireConfig: this._pickRequireConfig(require),
2828
+ importImpl: o.importer || null,
2829
+ setTimer: o.setTimeout || function (fn, ms) {
2830
+ return setTimeout(fn, ms);
2831
+ },
2832
+ clearTimer: o.clearTimeout || function (id) {
2833
+ return clearTimeout(id);
2834
+ },
2835
+ /* --- 配置与策略 --- */
2836
+ options: {
2837
+ version: o.version ? String(o.version) : DEFAULT_OPTIONS.version,
2838
+ timeout: o.timeout === undefined ? DEFAULT_OPTIONS.timeout : Math.max(0, toNumber(o.timeout, 0)),
2839
+ retry: o.retry === undefined ? DEFAULT_OPTIONS.retry : Math.max(0, toNumber(o.retry, 0)),
2840
+ baseUrl: o.baseUrl || DEFAULT_OPTIONS.baseUrl
2841
+ },
2842
+ policy: new LoadPolicy(o)
2843
+ };
2844
+ if (this.__data.options.version) this._applyUrlArgs();
2845
+ }
2846
+ }, {
2991
2847
  key: "debug",
2992
2848
  get: function get() {
2993
2849
  var ns = typeof window !== 'undefined' ? window.__devfab : null;
@@ -3008,48 +2864,26 @@
3008
2864
  value: function _pickRequireConfig(loader) {
3009
2865
  return loader && typeof loader.config === 'function' ? loader.config.bind(loader) : null;
3010
2866
  }
3011
- }, {
3012
- key: "_guardOptions",
3013
- value: function _guardOptions(o) {
3014
- if (o.pollution === false) {
3015
- return {
3016
- enabled: false,
3017
- target: o.target
3018
- };
3019
- }
3020
- if (o.pollution && _typeof(o.pollution) === 'object') {
3021
- return Object.assign({
3022
- target: o.target
3023
- }, o.pollution);
3024
- }
3025
- return {
3026
- target: o.target,
3027
- watch: o.watch,
3028
- maxPollution: o.maxPollution,
3029
- enabled: o.pollution === undefined ? true : !!o.pollution
3030
- };
3031
- }
3032
2867
 
3033
2868
  /* ------------------------------ 配置 ------------------------------ */
3034
2869
 
3035
2870
  /** 运行时增量配置(宿主切版本、换清单、改重试次数都走这里)
3036
- * 加载策略:版本、超时、重试、清单、白名单、全局污染检测
2871
+ * 加载策略:版本、超时、重试、清单、白名单
3037
2872
  */
3038
2873
  }, {
3039
2874
  key: "configure",
3040
2875
  value: function configure(options) {
3041
2876
  var o = options || {};
2877
+ var _this$__data = this.__data,
2878
+ config = _this$__data.options,
2879
+ policy = _this$__data.policy;
3042
2880
  if (o.debug !== undefined) this.debug = !!o.debug;
3043
2881
  if (o.version !== undefined) this.setVersion(o.version);
3044
- if (o.timeout !== undefined) this.options.timeout = Math.max(0, toNumber(o.timeout, this.options.timeout));
3045
- if (o.retry !== undefined) this.options.retry = Math.max(0, toNumber(o.retry, this.options.retry));
3046
- if (o.strict !== undefined) this.options.strict = !!o.strict;
3047
- if (o.baseUrl !== undefined) this.options.baseUrl = o.baseUrl || '';
2882
+ if (o.timeout !== undefined) config.timeout = Math.max(0, toNumber(o.timeout, config.timeout));
2883
+ if (o.retry !== undefined) config.retry = Math.max(0, toNumber(o.retry, config.retry));
2884
+ if (o.baseUrl !== undefined) config.baseUrl = o.baseUrl || '';
3048
2885
  if (o.manifest !== undefined || o.origins !== undefined || o.lockVersion !== undefined || o.verifyHash !== undefined || o.fetch !== undefined) {
3049
- this.policy.configure(o);
3050
- }
3051
- if (o.pollution !== undefined) this.guard.configure(this._guardOptions(o));else if (o.watch !== undefined || o.maxPollution !== undefined || o.target !== undefined) {
3052
- this.guard.configure(o);
2886
+ policy.configure(o);
3053
2887
  }
3054
2888
  return this;
3055
2889
  }
@@ -3064,19 +2898,22 @@
3064
2898
  }, {
3065
2899
  key: "setVersion",
3066
2900
  value: function setVersion(version) {
3067
- this.options.version = version ? String(version) : '';
2901
+ this.__data.options.version = version ? String(version) : '';
3068
2902
  this._applyUrlArgs();
3069
2903
  return this;
3070
2904
  }
3071
2905
  }, {
3072
2906
  key: "_applyUrlArgs",
3073
2907
  value: function _applyUrlArgs() {
3074
- if (typeof this.__requireConfig !== 'function') {
2908
+ var _this$__data2 = this.__data,
2909
+ requireConfig = _this$__data2.requireConfig,
2910
+ options = _this$__data2.options;
2911
+ if (typeof requireConfig !== 'function') {
3075
2912
  return false;
3076
2913
  }
3077
2914
  try {
3078
- this.__requireConfig({
3079
- urlArgs: this.options.version ? "v=".concat(encodeURIComponent(this.options.version)) : ''
2915
+ requireConfig({
2916
+ urlArgs: options.version ? "v=".concat(encodeURIComponent(options.version)) : ''
3080
2917
  });
3081
2918
  return true;
3082
2919
  } catch (err) {
@@ -3086,19 +2923,23 @@
3086
2923
  }, {
3087
2924
  key: "getVersion",
3088
2925
  value: function getVersion() {
3089
- return this.options.version;
2926
+ return this.__data.options.version;
3090
2927
  }
3091
2928
 
3092
2929
  /** 策略 + 兜底配置摘要,宿主启动时打一行日志排查效率最高 */
3093
2930
  }, {
3094
2931
  key: "describe",
3095
2932
  value: function describe() {
3096
- return Object.assign({}, this.options, {
2933
+ var _this$__data3 = this.__data,
2934
+ options = _this$__data3.options,
2935
+ policy = _this$__data3.policy,
2936
+ undef = _this$__data3.undef,
2937
+ importImpl = _this$__data3.importImpl;
2938
+ return Object.assign({}, options, {
3097
2939
  debug: this.debug,
3098
- policy: this.policy.describe(),
3099
- pollutionGuard: this.guard.enabled,
3100
- canUndef: typeof this.__undef === 'function',
3101
- canNativeImport: typeof (this.__import || nativeImport) === 'function'
2940
+ policy: policy.describe(),
2941
+ canUndef: typeof undef === 'function',
2942
+ canNativeImport: typeof (importImpl || nativeImport) === 'function'
3102
2943
  });
3103
2944
  }
3104
2945
 
@@ -3107,8 +2948,7 @@
3107
2948
  key: "_define",
3108
2949
  value: function _define(_path, _files, _callback) {
3109
2950
  var params = {
3110
- path: this.__rootPath,
3111
- define: this.__define,
2951
+ define: this.__data.define,
3112
2952
  type: 'define'
3113
2953
  };
3114
2954
  var _parseArgs = parseArgs(_path, _files, _callback, params),
@@ -3120,28 +2960,16 @@
3120
2960
  callback === null || callback === void 0 || callback(result);
3121
2961
  return;
3122
2962
  }
3123
- this.__define(path, files, callback);
3124
- }
3125
- }, {
3126
- key: "_mergeWarnings",
3127
- value: function _mergeWarnings(prev, next) {
3128
- var list = (prev || []).slice();
3129
- (next || []).forEach(function (item) {
3130
- var exists = list.some(function (one) {
3131
- return one.type === item.type && one.key === item.key;
3132
- });
3133
- if (!exists) list.push(item);
3134
- });
3135
- return list;
2963
+ this.__data.define(path, files, callback);
3136
2964
  }
3137
2965
  }, {
3138
2966
  key: "_undefModules",
3139
2967
  value: function _undefModules(moduleIds) {
3140
- var _this = this;
3141
- if (typeof this.__undef !== 'function') return;
2968
+ var undef = this.__data.undef;
2969
+ if (typeof undef !== 'function') return;
3142
2970
  moduleIds.forEach(function (id) {
3143
2971
  try {
3144
- _this.__undef(id);
2972
+ undef(id);
3145
2973
  } catch (err) {
3146
2974
  // undef 只对曾经顶层 require 过的模块有效;抛错说明它还没进注册表,忽略即可
3147
2975
  }
@@ -3149,18 +2977,22 @@
3149
2977
  }
3150
2978
 
3151
2979
  /**
3152
- * 统一加载入口:策略校验 -> 观测 -> 计时 / 重试 -> 结算。
2980
+ * 统一加载入口:策略校验 -> 计时 / 重试 -> 结算。
3153
2981
  * 默认配置(version 空、retry 0、timeout 15s)下的行为与原来一致,
3154
- * 只是多了一个「更早失败」的兜底和 warnings 字段。
2982
+ * 只是多了一个「更早失败」的兜底。
3155
2983
  */
3156
2984
  }, {
3157
2985
  key: "_load",
3158
2986
  value: function _load(_path, _files, _callback) {
3159
- var _this2 = this;
3160
- var config = this.options;
2987
+ var _this = this;
2988
+ var _this$__data4 = this.__data,
2989
+ config = _this$__data4.options,
2990
+ policy = _this$__data4.policy,
2991
+ require = _this$__data4.require,
2992
+ setTimer = _this$__data4.setTimer,
2993
+ clearTimer = _this$__data4.clearTimer;
3161
2994
  var params = {
3162
- path: this.__rootPath,
3163
- require: this.__require,
2995
+ require: require,
3164
2996
  type: 'require'
3165
2997
  };
3166
2998
  var _parseArgs2 = parseArgs(_path, _files, _callback, params),
@@ -3174,7 +3006,7 @@
3174
3006
  return;
3175
3007
  }
3176
3008
  var moduleIds = toModuleIds(path, files);
3177
- var denied = this.policy.checkModules(moduleIds);
3009
+ var denied = policy.checkModules(moduleIds);
3178
3010
  if (denied) {
3179
3011
  result.code = denied.code;
3180
3012
  result.message = denied.message;
@@ -3184,40 +3016,26 @@
3184
3016
  var settled = false;
3185
3017
  var attempt = 0;
3186
3018
  var timer = null;
3187
- var scoop = null;
3188
- var closeScoop = function closeScoop() {
3189
- if (!scoop) return;
3190
- result.warnings = _this2._mergeWarnings(result.warnings, scoop.end());
3191
- scoop = null;
3192
- };
3193
3019
  var finish = function finish() {
3194
3020
  if (settled) return;
3195
3021
  settled = true;
3196
3022
  if (timer !== null) {
3197
- _this2._clearTimer(timer);
3023
+ clearTimer(timer);
3198
3024
  timer = null;
3199
3025
  }
3200
- closeScoop();
3201
- if (config.strict && result.warnings.length) {
3202
- result.code = 500;
3203
- result.message = "Global pollution detection failed\uFF1A".concat(result.warnings.map(function (item) {
3204
- return "".concat(item.type, ":").concat(item.key);
3205
- }).join(', '));
3206
- }
3207
3026
  callback === null || callback === void 0 || callback(result);
3208
3027
  };
3209
3028
  var start = function start() {
3210
3029
  attempt++;
3211
- scoop = _this2.guard.begin();
3212
3030
  if (config.timeout > 0) {
3213
- timer = _this2._setTimer(function () {
3031
+ timer = setTimer(function () {
3214
3032
  if (settled) return;
3215
3033
  var err = new Error("load timeout after ".concat(config.timeout, "ms: ").concat(filesStr));
3216
3034
  err.__devfabTimeout = true;
3217
3035
  retryOrFail(err, "files load timeout after ".concat(config.timeout, "ms, the files: ").concat(filesStr));
3218
3036
  }, config.timeout);
3219
3037
  }
3220
- _this2.__require(path, files, function () {
3038
+ require(path, files, function () {
3221
3039
  for (var _len = arguments.length, contents = new Array(_len), _key = 0; _key < _len; _key++) {
3222
3040
  contents[_key] = arguments[_key];
3223
3041
  }
@@ -3230,13 +3048,12 @@
3230
3048
  var retryOrFail = function retryOrFail(err, message) {
3231
3049
  if (settled) return;
3232
3050
  if (timer !== null) {
3233
- _this2._clearTimer(timer);
3051
+ clearTimer(timer);
3234
3052
  timer = null;
3235
3053
  }
3236
3054
  if (attempt <= config.retry) {
3237
- closeScoop();
3238
3055
  // 不 undef 就会复用上一次的失败状态,重试形同虚设
3239
- _this2._undefModules(moduleIds);
3056
+ _this._undefModules(moduleIds);
3240
3057
  start();
3241
3058
  return;
3242
3059
  }
@@ -3269,7 +3086,8 @@
3269
3086
  value: function resolveUrl(rel) {
3270
3087
  var raw = String(rel == null ? '' : rel);
3271
3088
  if (/^[a-z][a-z0-9+.-]*:/i.test(raw) || /^\/\//.test(raw)) return raw;
3272
- var base = this.options.baseUrl || (typeof document !== 'undefined' && document.baseURI ? document.baseURI : '');
3089
+ var baseUrl = this.__data.options.baseUrl;
3090
+ var base = baseUrl || (typeof document !== 'undefined' && document.baseURI ? document.baseURI : '');
3273
3091
  if (!base) return raw;
3274
3092
  try {
3275
3093
  return new URL(raw, base).href;
@@ -3280,9 +3098,11 @@
3280
3098
  }, {
3281
3099
  key: "_importOne",
3282
3100
  value: function _importOne(moduleId) {
3283
- var _this3 = this;
3101
+ var _this$__data5 = this.__data,
3102
+ policy = _this$__data5.policy,
3103
+ importImpl = _this$__data5.importImpl;
3284
3104
  var url = this.resolveUrl(moduleId);
3285
- var originDenied = this.policy.checkOrigin(url);
3105
+ var originDenied = policy.checkOrigin(url);
3286
3106
  if (originDenied) {
3287
3107
  return Promise.resolve({
3288
3108
  ok: false,
@@ -3290,10 +3110,10 @@
3290
3110
  message: originDenied.message
3291
3111
  });
3292
3112
  }
3293
- var entry = this.policy.entryOf(moduleId);
3113
+ var entry = policy.entryOf(moduleId);
3294
3114
  var expected = entry && entry.sha256;
3295
3115
  var run = function run() {
3296
- var importer = _this3.__import || nativeImport;
3116
+ var importer = importImpl || nativeImport;
3297
3117
  if (typeof importer !== 'function') {
3298
3118
  return Promise.resolve({
3299
3119
  ok: false,
@@ -3318,7 +3138,7 @@
3318
3138
  });
3319
3139
  };
3320
3140
  if (!expected) return run();
3321
- return this.policy.verify(url, expected).then(function (verified) {
3141
+ return policy.verify(url, expected).then(function (verified) {
3322
3142
  if (!verified.ok) {
3323
3143
  return {
3324
3144
  ok: false,
@@ -3340,9 +3160,9 @@
3340
3160
  }, {
3341
3161
  key: "loadModules",
3342
3162
  value: function loadModules(_path, _files, _callback) {
3343
- var _this4 = this;
3163
+ var _this2 = this;
3164
+ var policy = this.__data.policy;
3344
3165
  var params = {
3345
- path: this.__rootPath,
3346
3166
  type: 'module'
3347
3167
  };
3348
3168
  var _parseArgs3 = parseArgs(_path, _files, _callback, params),
@@ -3356,7 +3176,7 @@
3356
3176
  callback === null || callback === void 0 || callback(r);
3357
3177
  return r;
3358
3178
  };
3359
- var denied = this.policy.checkModules(moduleIds);
3179
+ var denied = policy.checkModules(moduleIds);
3360
3180
  if (denied) {
3361
3181
  result.code = denied.code;
3362
3182
  result.message = denied.message;
@@ -3365,11 +3185,9 @@
3365
3185
  if (!files.length) {
3366
3186
  return Promise.resolve(settle(result));
3367
3187
  }
3368
- var scoop = this.guard.begin();
3369
3188
  return Promise.all(moduleIds.map(function (id) {
3370
- return _this4._importOne(id);
3189
+ return _this2._importOne(id);
3371
3190
  })).then(function (list) {
3372
- result.warnings = scoop.end();
3373
3191
  var failed = list.filter(function (item) {
3374
3192
  return !item.ok;
3375
3193
  });