@jsenv/core 24.4.3 → 24.4.4

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.
@@ -599,7 +599,7 @@
599
599
  var autoImportCandidates = {};
600
600
  var systemRegister = systemJSPrototype.register;
601
601
  var inlineScriptCount = 0;
602
- systemJSPrototype.register = function (deps, declare) {
602
+ systemJSPrototype.register = function (deps, declare, autoUrl) {
603
603
  if (hasDocument && document.readyState === 'loading' && typeof deps !== 'string') {
604
604
  var scripts = document.querySelectorAll('script[src]');
605
605
  var lastScript = scripts[scripts.length - 1];
@@ -608,6 +608,9 @@
608
608
  if (lastScript) {
609
609
  lastAutoImportUrl = lastScript.src;
610
610
  }
611
+ else if (autoUrl) {
612
+ lastAutoImportUrl = autoUrl
613
+ }
611
614
  else {
612
615
  inlineScriptCount++
613
616
  lastAutoImportUrl = document.location.href + "__inline_script__" + inlineScriptCount;
@@ -727,84 +730,37 @@
727
730
 
728
731
  }());
729
732
 
730
- (function(){/*
731
- * SystemJS named register extension
732
- * Supports System.register('name', [..deps..], function (_export, _context) { ... })
733
- *
734
- * Names are written to the registry as-is
735
- * System.register('x', ...) can be imported as System.import('x')
736
- */
737
- (function (global) {
738
- var System = global.System;
739
- setRegisterRegistry(System);
740
- var systemJSPrototype = System.constructor.prototype;
741
- var constructor = System.constructor;
742
- var SystemJS = function () {
743
- constructor.call(this);
744
- setRegisterRegistry(this);
745
- };
746
- SystemJS.prototype = systemJSPrototype;
747
- System.constructor = SystemJS;
733
+ (function(){
734
+ var envGlobal = typeof self !== 'undefined' ? self : global;
735
+ var System = envGlobal.System;
736
+ var register = System.register;
737
+ var registerRegistry = Object.create(null)
748
738
 
749
- var firstNamedDefine, firstName;
750
-
751
- function setRegisterRegistry(systemInstance) {
752
- systemInstance.registerRegistry = Object.create(null);
753
- systemInstance.namedRegisterAliases = Object.create(null);
754
- }
755
-
756
- var register = systemJSPrototype.register;
757
- systemJSPrototype.register = function (name, deps, declare) {
758
- if (typeof name !== 'string')
759
- return register.apply(this, arguments);
739
+ System.register = function (name, deps, declare) {
740
+ if (typeof name !== 'string') return register.apply(this, arguments);
760
741
  var define = [deps, declare];
761
- this.registerRegistry[name] = define;
762
- if (!firstNamedDefine) {
763
- firstNamedDefine = define;
764
- firstName = name;
765
- }
766
- Promise.resolve().then(function () {
767
- firstNamedDefine = null;
768
- firstName = null;
769
- });
770
- return register.apply(this, [deps, declare]);
742
+ var url = System.resolve(`./${name}`);
743
+ registerRegistry[url] = define;
744
+ return register.call(this, deps, declare, url);
771
745
  };
772
746
 
773
- var resolve = systemJSPrototype.resolve;
774
- systemJSPrototype.resolve = function (id, parentURL) {
775
- try {
776
- // Prefer import map (or other existing) resolution over the registerRegistry
777
- return resolve.call(this, id, parentURL);
778
- } catch (err) {
779
- if (id in this.registerRegistry) {
780
- return this.namedRegisterAliases[id] || id;
781
- }
782
- throw err;
783
- }
784
- };
747
+ var instantiate = System.instantiate;
748
+ System.instantiate = function (url, firstParentUrl) {
749
+ var result = registerRegistry[url];
785
750
 
786
- var instantiate = systemJSPrototype.instantiate;
787
- systemJSPrototype.instantiate = function (url, firstParentUrl) {
788
- var result = this.registerRegistry[url];
789
751
  if (result) {
790
- this.registerRegistry[url] = null;
752
+ registerRegistry[url] = null;
791
753
  return result;
792
754
  } else {
793
755
  return instantiate.call(this, url, firstParentUrl);
794
756
  }
795
757
  };
796
758
 
797
- var getRegister = systemJSPrototype.getRegister;
798
- systemJSPrototype.getRegister = function (url) {
759
+ var getRegister = System.getRegister;
760
+ System.getRegister = function (url) {
799
761
  // Calling getRegister() because other extras need to know it was called so they can perform side effects
800
762
  var register = getRegister.call(this, url);
801
-
802
- if (firstName && url) {
803
- this.namedRegisterAliases[firstName] = url;
804
- }
805
- var result = firstNamedDefine || register;
806
- firstNamedDefine = null;
807
- firstName = null;
763
+ var result = registerRegistry[url] || register;
808
764
  return result;
809
765
  };
810
- })(typeof self !== 'undefined' ? self : global);}());
766
+ }());