devfab 2.1.0 → 2.2.1

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.
@@ -2130,7 +2130,12 @@
2130
2130
  domain = [];
2131
2131
  }
2132
2132
  if (Array.isArray(domain) && Array.isArray(deps)) {
2133
- domain = domain.join('/');
2133
+ // domain = domain.join('/')
2134
+ var domainList = domain;
2135
+ domain = '';
2136
+ domainList.forEach(function (item) {
2137
+ domain += "".concat(item.substr(0, 1) === '/' ? '' : '/').concat(item);
2138
+ });
2134
2139
  }
2135
2140
  var newdeps = domain ? [] : deps;
2136
2141
  if (typeof domain === 'string' && domain && Array.isArray(deps)) {
@@ -2155,7 +2160,12 @@
2155
2160
  domain = [];
2156
2161
  }
2157
2162
  if (Array.isArray(domain) && Array.isArray(deps)) {
2158
- domain = domain.join('/');
2163
+ // domain = domain.join('/')
2164
+ var domainList = domain;
2165
+ domain = '';
2166
+ domainList.forEach(function (item) {
2167
+ domain += "".concat(item.substr(0, 1) === '/' ? '' : '/').concat(item);
2168
+ });
2159
2169
  }
2160
2170
  var newdeps = domain ? [] : deps;
2161
2171
  if (typeof domain === 'string' && domain && Array.isArray(deps)) {
@@ -2492,127 +2502,6 @@
2492
2502
  }]);
2493
2503
  }();
2494
2504
 
2495
- /**
2496
- * 全局污染检测:加载前后 diff window 的 key 集合。
2497
- *
2498
- * 为什么需要:二开脚本直接跑在宿主 window 上,A 客户的脚本改了一个全局变量,
2499
- * B 客户就跟着崩,而且现场无法归因。真做 iframe / Proxy 沙箱成本极高,
2500
- * 但「加载完能告诉你动了哪些全局」只需要几十行,能挡住大半这类事故。
2501
- *
2502
- * 边界(这是观测,不是隔离):
2503
- * - 事后告警,不阻止副作用——脚本已经执行过了;
2504
- * - 并发加载时窗口会重叠,归因以「最后完成的一批」结算,可能不准;
2505
- * - 只比较可枚举自有属性的**引用**,`window.foo.bar = 1` 这类深层改动检测不到。
2506
- */
2507
-
2508
- /** 默认盯防的 key:出现即说明宿主的关键设施被动过 */
2509
- var DEFAULT_WATCH = ['$', 'jQuery', 'define', 'require', 'requirejs', 'devfab', '__devfab'];
2510
- var GlobalGuard = /*#__PURE__*/function () {
2511
- function GlobalGuard(options) {
2512
- _classCallCheck(this, GlobalGuard);
2513
- var o = options || {};
2514
- this.maxPollution = o.maxPollution === undefined ? 3 : Number(o.maxPollution);
2515
- this.watch = [].concat(o.watch || DEFAULT_WATCH);
2516
- this.target = o.target || (typeof window !== 'undefined' ? window : null);
2517
- this.enabled = o.enabled === undefined ? true : !!o.enabled;
2518
- this._pending = 0;
2519
- this._before = null;
2520
- this.lastWarnings = [];
2521
- }
2522
- return _createClass(GlobalGuard, [{
2523
- key: "_snapshot",
2524
- value: function _snapshot() {
2525
- var map = new Map();
2526
- var target = this.target;
2527
- if (!target) return map;
2528
- Object.keys(target).forEach(function (key) {
2529
- map.set(key, target[key]);
2530
- });
2531
- return map;
2532
- }
2533
- }, {
2534
- key: "_diff",
2535
- value: function _diff() {
2536
- var _this = this;
2537
- var before = this._before;
2538
- var after = this._snapshot();
2539
- var warnings = [];
2540
- if (!before) return warnings;
2541
- after.forEach(function (value, key) {
2542
- var watched = _this.watch.indexOf(key) !== -1;
2543
- if (!before.has(key)) {
2544
- warnings.push({
2545
- type: 'added',
2546
- key: key,
2547
- watched: watched
2548
- });
2549
- return;
2550
- }
2551
- if (before.get(key) !== value) {
2552
- warnings.push({
2553
- type: 'overwritten',
2554
- key: key,
2555
- watched: watched
2556
- });
2557
- }
2558
- });
2559
- // 命中盯防名单,或新增数量超过阈值,才认为「值得提醒」。
2560
- // 1~2 个自有全局是正常写法,全报会把信号淹掉。
2561
- var watchedCount = warnings.filter(function (item) {
2562
- return item.watched;
2563
- }).length;
2564
- var addedCount = warnings.filter(function (item) {
2565
- return item.type === 'added';
2566
- }).length;
2567
- if (!watchedCount && addedCount <= this.maxPollution) return [];
2568
- return warnings;
2569
- }
2570
-
2571
- /**
2572
- * 开始观测。返回的 `end()` 幂等,重复调用只有第一次有效,
2573
- * 这样超时分支和 errback 分支可以都调,不会把计数搞负。
2574
- */
2575
- }, {
2576
- key: "begin",
2577
- value: function begin() {
2578
- var _this2 = this;
2579
- if (!this.enabled || !this.target) {
2580
- return {
2581
- end: function end() {
2582
- return [];
2583
- }
2584
- };
2585
- }
2586
- this._pending++;
2587
- if (this._pending === 1) this._before = this._snapshot();
2588
- var done = false;
2589
- return {
2590
- end: function end() {
2591
- if (done) return [];
2592
- done = true;
2593
- _this2._pending--;
2594
- // 还有并发批次没结束,交给最后结束的那一批结算
2595
- if (_this2._pending > 0) return [];
2596
- var warnings = _this2._diff();
2597
- _this2._before = null;
2598
- _this2.lastWarnings = warnings;
2599
- return warnings;
2600
- }
2601
- };
2602
- }
2603
- }, {
2604
- key: "configure",
2605
- value: function configure(options) {
2606
- var o = options || {};
2607
- if (o.enabled !== undefined) this.enabled = !!o.enabled;
2608
- if (o.maxPollution !== undefined) this.maxPollution = Number(o.maxPollution);
2609
- if (o.watch !== undefined) this.watch = [].concat(o.watch || []);
2610
- if (o.target !== undefined) this.target = o.target || null;
2611
- return this;
2612
- }
2613
- }]);
2614
- }();
2615
-
2616
2505
  /** 加载超时:RequireJS 自己的 waitSeconds 默认 30s,这个定时器是更早的兜底 */
2617
2506
  var CODE_TIMEOUT = 504;
2618
2507
 
@@ -2635,10 +2524,8 @@
2635
2524
  var path = _path;
2636
2525
  var files = _files;
2637
2526
  var callback = _callback;
2638
- // 单参形式:(files, callback) 或 (files)。判据是「第一个是数组、第二个不是数组」,
2639
- // 放宽到非函数是因为 loadModules([url]) 这种不带回调的调用很常见。
2640
2527
  if (Array.isArray(_path) && !Array.isArray(_files)) {
2641
- path = params === null || params === void 0 ? void 0 : params.path;
2528
+ path = undefined;
2642
2529
  files = _path;
2643
2530
  callback = typeof _files === 'function' ? _files : _callback;
2644
2531
  }
@@ -2647,8 +2534,7 @@
2647
2534
  var result = {
2648
2535
  code: 0,
2649
2536
  message: '',
2650
- data: [],
2651
- warnings: []
2537
+ data: []
2652
2538
  };
2653
2539
  if (params.type === 'require' && typeof params.require !== 'function' || params.type === 'define' && typeof params.define !== 'function' //
2654
2540
  ) {
@@ -2688,64 +2574,44 @@
2688
2574
  version: '',
2689
2575
  timeout: 15000,
2690
2576
  retry: 0,
2691
- strict: false,
2692
2577
  baseUrl: ''
2693
2578
  };
2694
2579
  var BaseFileRequire = /*#__PURE__*/function () {
2695
- /**
2696
- * args 只接受**参数与策略**,不接受加载器覆盖:
2697
- * - 加载策略:`version` / `timeout` / `retry` / `strict` / `baseUrl` / `manifest`
2698
- * / `origins` / `lockVersion` / `verifyHash` / `pollution` / `watch` / `maxPollution`
2699
- * - 通道与时钟:`importer`(ESM 通道用的 import 函数)、`setTimeout` / `clearTimeout`
2700
- *
2701
- * 刻意**不再接受** `define` / `require` / `undef` / `requireConfig`:
2702
- * 这四个是 AMD 加载器本体,AMD 通道只走内嵌的 RequireJS 2.3.2。以前允许覆盖的
2703
- * 后果是「宿主传了自己的 require,但 undef 仍取内嵌的那份」,两套注册表混用,
2704
- * 而且被覆盖时是静默的。要换通道请用 `loadModules()`,不要替换加载器。
2705
- *
2706
- * 其余配置一律走 `configure(options)` 在运行时改。
2707
- */
2708
2580
  function BaseFileRequire(args) {
2709
- var _this$__require;
2710
2581
  _classCallCheck(this, BaseFileRequire);
2711
- var o = args || {};
2712
- // 只有显式传参才写全局。模块加载时会 new 一次单例,若无条件写 false,
2713
- // 宿主在 import 之前设好的 `window.__devfab.debug` 会被抹掉。
2714
- if (o.debug !== undefined) this.debug = !!o.debug;
2715
- this.__rootPath = undefined;
2716
- this.__define = __requirejs.define;
2717
- this.__require = __requirejs.require;
2718
- this.__undef = typeof ((_this$__require = this.__require) === null || _this$__require === void 0 ? void 0 : _this$__require.undef) === 'function' ? this.__require.undef : null;
2719
- this.__requireConfig = this._pickRequireConfig(this.__require);
2720
- this.__import = o.importer || null;
2721
- this._setTimer = o.setTimeout || function (fn, ms) {
2722
- return setTimeout(fn, ms);
2723
- };
2724
- this._clearTimer = o.clearTimeout || function (id) {
2725
- return clearTimeout(id);
2726
- };
2727
- this.options = {
2728
- version: o.version ? String(o.version) : DEFAULT_OPTIONS.version,
2729
- timeout: o.timeout === undefined ? DEFAULT_OPTIONS.timeout : Math.max(0, toNumber(o.timeout, 0)),
2730
- retry: o.retry === undefined ? DEFAULT_OPTIONS.retry : Math.max(0, toNumber(o.retry, 0)),
2731
- strict: !!o.strict,
2732
- baseUrl: o.baseUrl || DEFAULT_OPTIONS.baseUrl
2733
- };
2734
- this.policy = new LoadPolicy(o);
2735
- this.guard = new GlobalGuard(this._guardOptions(o));
2736
- if (this.options.version) this._applyUrlArgs();
2582
+ this.__init(args);
2737
2583
  }
2738
-
2739
- /**
2740
- * 调试开关的**唯一来源**是 `window.__devfab.debug`。
2741
- *
2742
- * 为什么做成访问器:这个开关被三处读——加载器这里、`_utils/models/_extend.js` 的
2743
- * 扩展脚本装配、`_utils/string.js` 的 isDebug。以前各读各的(实例字段 /
2744
- * `window.__devfab.debug` / `window.devfab.debug`),宿主开了一个另两个不生效,
2745
- * 排查时看起来像「日志不打印」。统一读写同一个位置后,`FileRequire.configure({debug:true})`、
2746
- * `FileRequire.debug = true`、`window.__devfab.debug = true` 三句话效果完全一致。
2747
- */
2748
2584
  return _createClass(BaseFileRequire, [{
2585
+ key: "__init",
2586
+ value: function __init(args) {
2587
+ var o = args || {};
2588
+ if (o.debug !== undefined) this.debug = !!o.debug;
2589
+ var require = __requirejs.require;
2590
+ this.__data = {
2591
+ /* --- 加载器句柄与通道:AMD 通道只走内嵌 RequireJS --- */
2592
+ define: __requirejs.define,
2593
+ require: require,
2594
+ undef: typeof (require === null || require === void 0 ? void 0 : require.undef) === 'function' ? require.undef : null,
2595
+ requireConfig: this._pickRequireConfig(require),
2596
+ importImpl: o.importer || null,
2597
+ setTimer: o.setTimeout || function (fn, ms) {
2598
+ return setTimeout(fn, ms);
2599
+ },
2600
+ clearTimer: o.clearTimeout || function (id) {
2601
+ return clearTimeout(id);
2602
+ },
2603
+ /* --- 配置与策略 --- */
2604
+ options: {
2605
+ version: o.version ? String(o.version) : DEFAULT_OPTIONS.version,
2606
+ timeout: o.timeout === undefined ? DEFAULT_OPTIONS.timeout : Math.max(0, toNumber(o.timeout, 0)),
2607
+ retry: o.retry === undefined ? DEFAULT_OPTIONS.retry : Math.max(0, toNumber(o.retry, 0)),
2608
+ baseUrl: o.baseUrl || DEFAULT_OPTIONS.baseUrl
2609
+ },
2610
+ policy: new LoadPolicy(o)
2611
+ };
2612
+ if (this.__data.options.version) this._applyUrlArgs();
2613
+ }
2614
+ }, {
2749
2615
  key: "debug",
2750
2616
  get: function get() {
2751
2617
  var ns = typeof window !== 'undefined' ? window.__devfab : null;
@@ -2766,48 +2632,26 @@
2766
2632
  value: function _pickRequireConfig(loader) {
2767
2633
  return loader && typeof loader.config === 'function' ? loader.config.bind(loader) : null;
2768
2634
  }
2769
- }, {
2770
- key: "_guardOptions",
2771
- value: function _guardOptions(o) {
2772
- if (o.pollution === false) {
2773
- return {
2774
- enabled: false,
2775
- target: o.target
2776
- };
2777
- }
2778
- if (o.pollution && _typeof(o.pollution) === 'object') {
2779
- return Object.assign({
2780
- target: o.target
2781
- }, o.pollution);
2782
- }
2783
- return {
2784
- target: o.target,
2785
- watch: o.watch,
2786
- maxPollution: o.maxPollution,
2787
- enabled: o.pollution === undefined ? true : !!o.pollution
2788
- };
2789
- }
2790
2635
 
2791
2636
  /* ------------------------------ 配置 ------------------------------ */
2792
2637
 
2793
2638
  /** 运行时增量配置(宿主切版本、换清单、改重试次数都走这里)
2794
- * 加载策略:版本、超时、重试、清单、白名单、全局污染检测
2639
+ * 加载策略:版本、超时、重试、清单、白名单
2795
2640
  */
2796
2641
  }, {
2797
2642
  key: "configure",
2798
2643
  value: function configure(options) {
2799
2644
  var o = options || {};
2645
+ var _this$__data = this.__data,
2646
+ config = _this$__data.options,
2647
+ policy = _this$__data.policy;
2800
2648
  if (o.debug !== undefined) this.debug = !!o.debug;
2801
2649
  if (o.version !== undefined) this.setVersion(o.version);
2802
- if (o.timeout !== undefined) this.options.timeout = Math.max(0, toNumber(o.timeout, this.options.timeout));
2803
- if (o.retry !== undefined) this.options.retry = Math.max(0, toNumber(o.retry, this.options.retry));
2804
- if (o.strict !== undefined) this.options.strict = !!o.strict;
2805
- if (o.baseUrl !== undefined) this.options.baseUrl = o.baseUrl || '';
2650
+ if (o.timeout !== undefined) config.timeout = Math.max(0, toNumber(o.timeout, config.timeout));
2651
+ if (o.retry !== undefined) config.retry = Math.max(0, toNumber(o.retry, config.retry));
2652
+ if (o.baseUrl !== undefined) config.baseUrl = o.baseUrl || '';
2806
2653
  if (o.manifest !== undefined || o.origins !== undefined || o.lockVersion !== undefined || o.verifyHash !== undefined || o.fetch !== undefined) {
2807
- this.policy.configure(o);
2808
- }
2809
- if (o.pollution !== undefined) this.guard.configure(this._guardOptions(o));else if (o.watch !== undefined || o.maxPollution !== undefined || o.target !== undefined) {
2810
- this.guard.configure(o);
2654
+ policy.configure(o);
2811
2655
  }
2812
2656
  return this;
2813
2657
  }
@@ -2822,19 +2666,22 @@
2822
2666
  }, {
2823
2667
  key: "setVersion",
2824
2668
  value: function setVersion(version) {
2825
- this.options.version = version ? String(version) : '';
2669
+ this.__data.options.version = version ? String(version) : '';
2826
2670
  this._applyUrlArgs();
2827
2671
  return this;
2828
2672
  }
2829
2673
  }, {
2830
2674
  key: "_applyUrlArgs",
2831
2675
  value: function _applyUrlArgs() {
2832
- if (typeof this.__requireConfig !== 'function') {
2676
+ var _this$__data2 = this.__data,
2677
+ requireConfig = _this$__data2.requireConfig,
2678
+ options = _this$__data2.options;
2679
+ if (typeof requireConfig !== 'function') {
2833
2680
  return false;
2834
2681
  }
2835
2682
  try {
2836
- this.__requireConfig({
2837
- urlArgs: this.options.version ? "v=".concat(encodeURIComponent(this.options.version)) : ''
2683
+ requireConfig({
2684
+ urlArgs: options.version ? "v=".concat(encodeURIComponent(options.version)) : ''
2838
2685
  });
2839
2686
  return true;
2840
2687
  } catch (err) {
@@ -2844,19 +2691,23 @@
2844
2691
  }, {
2845
2692
  key: "getVersion",
2846
2693
  value: function getVersion() {
2847
- return this.options.version;
2694
+ return this.__data.options.version;
2848
2695
  }
2849
2696
 
2850
2697
  /** 策略 + 兜底配置摘要,宿主启动时打一行日志排查效率最高 */
2851
2698
  }, {
2852
2699
  key: "describe",
2853
2700
  value: function describe() {
2854
- return Object.assign({}, this.options, {
2701
+ var _this$__data3 = this.__data,
2702
+ options = _this$__data3.options,
2703
+ policy = _this$__data3.policy,
2704
+ undef = _this$__data3.undef,
2705
+ importImpl = _this$__data3.importImpl;
2706
+ return Object.assign({}, options, {
2855
2707
  debug: this.debug,
2856
- policy: this.policy.describe(),
2857
- pollutionGuard: this.guard.enabled,
2858
- canUndef: typeof this.__undef === 'function',
2859
- canNativeImport: typeof (this.__import || nativeImport) === 'function'
2708
+ policy: policy.describe(),
2709
+ canUndef: typeof undef === 'function',
2710
+ canNativeImport: typeof (importImpl || nativeImport) === 'function'
2860
2711
  });
2861
2712
  }
2862
2713
 
@@ -2865,8 +2716,7 @@
2865
2716
  key: "_define",
2866
2717
  value: function _define(_path, _files, _callback) {
2867
2718
  var params = {
2868
- path: this.__rootPath,
2869
- define: this.__define,
2719
+ define: this.__data.define,
2870
2720
  type: 'define'
2871
2721
  };
2872
2722
  var _parseArgs = parseArgs(_path, _files, _callback, params),
@@ -2878,28 +2728,16 @@
2878
2728
  callback === null || callback === void 0 || callback(result);
2879
2729
  return;
2880
2730
  }
2881
- this.__define(path, files, callback);
2882
- }
2883
- }, {
2884
- key: "_mergeWarnings",
2885
- value: function _mergeWarnings(prev, next) {
2886
- var list = (prev || []).slice();
2887
- (next || []).forEach(function (item) {
2888
- var exists = list.some(function (one) {
2889
- return one.type === item.type && one.key === item.key;
2890
- });
2891
- if (!exists) list.push(item);
2892
- });
2893
- return list;
2731
+ this.__data.define(path, files, callback);
2894
2732
  }
2895
2733
  }, {
2896
2734
  key: "_undefModules",
2897
2735
  value: function _undefModules(moduleIds) {
2898
- var _this = this;
2899
- if (typeof this.__undef !== 'function') return;
2736
+ var undef = this.__data.undef;
2737
+ if (typeof undef !== 'function') return;
2900
2738
  moduleIds.forEach(function (id) {
2901
2739
  try {
2902
- _this.__undef(id);
2740
+ undef(id);
2903
2741
  } catch (err) {
2904
2742
  // undef 只对曾经顶层 require 过的模块有效;抛错说明它还没进注册表,忽略即可
2905
2743
  }
@@ -2907,18 +2745,22 @@
2907
2745
  }
2908
2746
 
2909
2747
  /**
2910
- * 统一加载入口:策略校验 -> 观测 -> 计时 / 重试 -> 结算。
2748
+ * 统一加载入口:策略校验 -> 计时 / 重试 -> 结算。
2911
2749
  * 默认配置(version 空、retry 0、timeout 15s)下的行为与原来一致,
2912
- * 只是多了一个「更早失败」的兜底和 warnings 字段。
2750
+ * 只是多了一个「更早失败」的兜底。
2913
2751
  */
2914
2752
  }, {
2915
2753
  key: "_load",
2916
2754
  value: function _load(_path, _files, _callback) {
2917
- var _this2 = this;
2918
- var config = this.options;
2755
+ var _this = this;
2756
+ var _this$__data4 = this.__data,
2757
+ config = _this$__data4.options,
2758
+ policy = _this$__data4.policy,
2759
+ require = _this$__data4.require,
2760
+ setTimer = _this$__data4.setTimer,
2761
+ clearTimer = _this$__data4.clearTimer;
2919
2762
  var params = {
2920
- path: this.__rootPath,
2921
- require: this.__require,
2763
+ require: require,
2922
2764
  type: 'require'
2923
2765
  };
2924
2766
  var _parseArgs2 = parseArgs(_path, _files, _callback, params),
@@ -2932,7 +2774,7 @@
2932
2774
  return;
2933
2775
  }
2934
2776
  var moduleIds = toModuleIds(path, files);
2935
- var denied = this.policy.checkModules(moduleIds);
2777
+ var denied = policy.checkModules(moduleIds);
2936
2778
  if (denied) {
2937
2779
  result.code = denied.code;
2938
2780
  result.message = denied.message;
@@ -2942,40 +2784,26 @@
2942
2784
  var settled = false;
2943
2785
  var attempt = 0;
2944
2786
  var timer = null;
2945
- var scoop = null;
2946
- var closeScoop = function closeScoop() {
2947
- if (!scoop) return;
2948
- result.warnings = _this2._mergeWarnings(result.warnings, scoop.end());
2949
- scoop = null;
2950
- };
2951
2787
  var finish = function finish() {
2952
2788
  if (settled) return;
2953
2789
  settled = true;
2954
2790
  if (timer !== null) {
2955
- _this2._clearTimer(timer);
2791
+ clearTimer(timer);
2956
2792
  timer = null;
2957
2793
  }
2958
- closeScoop();
2959
- if (config.strict && result.warnings.length) {
2960
- result.code = 500;
2961
- result.message = "Global pollution detection failed\uFF1A".concat(result.warnings.map(function (item) {
2962
- return "".concat(item.type, ":").concat(item.key);
2963
- }).join(', '));
2964
- }
2965
2794
  callback === null || callback === void 0 || callback(result);
2966
2795
  };
2967
2796
  var start = function start() {
2968
2797
  attempt++;
2969
- scoop = _this2.guard.begin();
2970
2798
  if (config.timeout > 0) {
2971
- timer = _this2._setTimer(function () {
2799
+ timer = setTimer(function () {
2972
2800
  if (settled) return;
2973
2801
  var err = new Error("load timeout after ".concat(config.timeout, "ms: ").concat(filesStr));
2974
2802
  err.__devfabTimeout = true;
2975
2803
  retryOrFail(err, "files load timeout after ".concat(config.timeout, "ms, the files: ").concat(filesStr));
2976
2804
  }, config.timeout);
2977
2805
  }
2978
- _this2.__require(path, files, function () {
2806
+ require(path, files, function () {
2979
2807
  for (var _len = arguments.length, contents = new Array(_len), _key = 0; _key < _len; _key++) {
2980
2808
  contents[_key] = arguments[_key];
2981
2809
  }
@@ -2988,13 +2816,12 @@
2988
2816
  var retryOrFail = function retryOrFail(err, message) {
2989
2817
  if (settled) return;
2990
2818
  if (timer !== null) {
2991
- _this2._clearTimer(timer);
2819
+ clearTimer(timer);
2992
2820
  timer = null;
2993
2821
  }
2994
2822
  if (attempt <= config.retry) {
2995
- closeScoop();
2996
2823
  // 不 undef 就会复用上一次的失败状态,重试形同虚设
2997
- _this2._undefModules(moduleIds);
2824
+ _this._undefModules(moduleIds);
2998
2825
  start();
2999
2826
  return;
3000
2827
  }
@@ -3027,7 +2854,8 @@
3027
2854
  value: function resolveUrl(rel) {
3028
2855
  var raw = String(rel == null ? '' : rel);
3029
2856
  if (/^[a-z][a-z0-9+.-]*:/i.test(raw) || /^\/\//.test(raw)) return raw;
3030
- var base = this.options.baseUrl || (typeof document !== 'undefined' && document.baseURI ? document.baseURI : '');
2857
+ var baseUrl = this.__data.options.baseUrl;
2858
+ var base = baseUrl || (typeof document !== 'undefined' && document.baseURI ? document.baseURI : '');
3031
2859
  if (!base) return raw;
3032
2860
  try {
3033
2861
  return new URL(raw, base).href;
@@ -3038,9 +2866,11 @@
3038
2866
  }, {
3039
2867
  key: "_importOne",
3040
2868
  value: function _importOne(moduleId) {
3041
- var _this3 = this;
2869
+ var _this$__data5 = this.__data,
2870
+ policy = _this$__data5.policy,
2871
+ importImpl = _this$__data5.importImpl;
3042
2872
  var url = this.resolveUrl(moduleId);
3043
- var originDenied = this.policy.checkOrigin(url);
2873
+ var originDenied = policy.checkOrigin(url);
3044
2874
  if (originDenied) {
3045
2875
  return Promise.resolve({
3046
2876
  ok: false,
@@ -3048,10 +2878,10 @@
3048
2878
  message: originDenied.message
3049
2879
  });
3050
2880
  }
3051
- var entry = this.policy.entryOf(moduleId);
2881
+ var entry = policy.entryOf(moduleId);
3052
2882
  var expected = entry && entry.sha256;
3053
2883
  var run = function run() {
3054
- var importer = _this3.__import || nativeImport;
2884
+ var importer = importImpl || nativeImport;
3055
2885
  if (typeof importer !== 'function') {
3056
2886
  return Promise.resolve({
3057
2887
  ok: false,
@@ -3076,7 +2906,7 @@
3076
2906
  });
3077
2907
  };
3078
2908
  if (!expected) return run();
3079
- return this.policy.verify(url, expected).then(function (verified) {
2909
+ return policy.verify(url, expected).then(function (verified) {
3080
2910
  if (!verified.ok) {
3081
2911
  return {
3082
2912
  ok: false,
@@ -3098,9 +2928,9 @@
3098
2928
  }, {
3099
2929
  key: "loadModules",
3100
2930
  value: function loadModules(_path, _files, _callback) {
3101
- var _this4 = this;
2931
+ var _this2 = this;
2932
+ var policy = this.__data.policy;
3102
2933
  var params = {
3103
- path: this.__rootPath,
3104
2934
  type: 'module'
3105
2935
  };
3106
2936
  var _parseArgs3 = parseArgs(_path, _files, _callback, params),
@@ -3114,7 +2944,7 @@
3114
2944
  callback === null || callback === void 0 || callback(r);
3115
2945
  return r;
3116
2946
  };
3117
- var denied = this.policy.checkModules(moduleIds);
2947
+ var denied = policy.checkModules(moduleIds);
3118
2948
  if (denied) {
3119
2949
  result.code = denied.code;
3120
2950
  result.message = denied.message;
@@ -3123,11 +2953,9 @@
3123
2953
  if (!files.length) {
3124
2954
  return Promise.resolve(settle(result));
3125
2955
  }
3126
- var scoop = this.guard.begin();
3127
2956
  return Promise.all(moduleIds.map(function (id) {
3128
- return _this4._importOne(id);
2957
+ return _this2._importOne(id);
3129
2958
  })).then(function (list) {
3130
- result.warnings = scoop.end();
3131
2959
  var failed = list.filter(function (item) {
3132
2960
  return !item.ok;
3133
2961
  });
@@ -3226,9 +3054,7 @@
3226
3054
 
3227
3055
  exports.CODE_POLICY = CODE_POLICY;
3228
3056
  exports.CODE_TIMEOUT = CODE_TIMEOUT;
3229
- exports.DEFAULT_WATCH = DEFAULT_WATCH;
3230
3057
  exports.FileRequire = FileRequire;
3231
- exports.GlobalGuard = GlobalGuard;
3232
3058
  exports.LoadPolicy = LoadPolicy;
3233
3059
  exports["default"] = FileRequire;
3234
3060