ifs-code-tools 1.0.1 → 1.0.2-beta.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/dist/index.js CHANGED
@@ -9705,7 +9705,13 @@ var moduleCache = /* @__PURE__ */ new Map();
9705
9705
  var loadedStyles = /* @__PURE__ */ new Set();
9706
9706
  var loadingPromises = /* @__PURE__ */ new Map();
9707
9707
  var WIDGET_CDN_BASE = "https://mos.m.taobao.com/mixo";
9708
- var IFS_CDN_BASE = "https://pre-code.iconfont.cn/ifs/api/getPublishFileUrlOpen";
9708
+ var IFS_CDN_BASE = `https://${location.hostname.startsWith("ifs.alibaba.net") || location.hostname.startsWith("local.code.iconfont.cn") ? "ifs.alibaba.net" : location.hostname.startsWith("pre-code.iconfont.cn") ? "pre-code.iconfont.cn" : "code.iconfont.cn"}/ifs/api/getPublishFileUrlOpen`;
9709
+ var isIntranet = [
9710
+ "mixo.alibaba-inc.com",
9711
+ "pre-mixo.alibaba-inc.com",
9712
+ "local.mixo.alibaba-inc.com",
9713
+ "mixo.alibaba.net"
9714
+ ].some((v) => location.hostname.includes(v));
9709
9715
  async function getOssWidget(appId) {
9710
9716
  const requestUrl = `${IFS_CDN_BASE}?appId=${appId}&env=online`;
9711
9717
  const ossConfig = await fetch(requestUrl).then((res) => res.json());
@@ -9753,14 +9759,18 @@ async function getWidgetResourceConfig(appId, version) {
9753
9759
  }
9754
9760
  async function resolveWidgetUrlsByAppId(appId) {
9755
9761
  let config;
9756
- try {
9757
- config = await getOssWidget(appId);
9758
- } catch (error) {
9759
- console.error(`Failed to get OSS widget for appId: ${appId}`, error);
9760
- }
9761
- if (!config?.js) {
9762
+ if (isIntranet) {
9762
9763
  const version = await getWidgetVersion(appId);
9763
9764
  config = await getWidgetResourceConfig(appId, version);
9765
+ } else {
9766
+ try {
9767
+ config = await getOssWidget(appId);
9768
+ } catch (error) {
9769
+ console.error(`Failed to get OSS widget for appId: ${appId}`, error);
9770
+ }
9771
+ }
9772
+ if (!config) {
9773
+ throw new Error(`Failed to get widget config for appId: ${appId}`);
9764
9774
  }
9765
9775
  const jsBlob = new Blob([config.js], { type: "application/javascript" });
9766
9776
  const moduleUrl = URL.createObjectURL(jsBlob);