ifs-code-tools 1.0.2-beta.1 → 1.0.2-beta.2

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.cjs CHANGED
@@ -9706,16 +9706,18 @@ window.__mixoToolsWidgetSchema = {};
9706
9706
  var moduleCache = /* @__PURE__ */ new Map();
9707
9707
  var loadedStyles = /* @__PURE__ */ new Set();
9708
9708
  var loadingPromises = /* @__PURE__ */ new Map();
9709
- var WIDGET_CDN_BASE = "https://mos.m.taobao.com/mixo";
9710
- 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`;
9711
- var isIntranet = [
9712
- "mixo.alibaba-inc.com",
9713
- "pre-mixo.alibaba-inc.com",
9714
- "local.mixo.alibaba-inc.com",
9715
- "mixo.alibaba.net"
9716
- ].some((v) => location.hostname.includes(v));
9709
+ var WIDGET_CDN_BASE = (() => {
9710
+ if (location.hostname.endsWith("alibaba-inc.com") || location.hostname.endsWith("alibaba.net") || location.hostname.endsWith("iconfont.cn") || location.hostname.endsWith("ifscode.cn")) {
9711
+ if (location.hostname.includes("mixo")) {
9712
+ return `${location.origin}/mixo/open/getPublishFileUrlOpen`;
9713
+ } else {
9714
+ return `${location.origin}/ifs/open/getPublishFileUrlOpen`;
9715
+ }
9716
+ }
9717
+ return "https://code.iconfont.cn/ifs/open/getPublishFileUrlOpen";
9718
+ })();
9717
9719
  async function getOssWidget(appId) {
9718
- const requestUrl = `${IFS_CDN_BASE}?appId=${appId}&env=online`;
9720
+ const requestUrl = `${WIDGET_CDN_BASE}?appId=${appId}&env=online`;
9719
9721
  const ossConfig = await fetch(requestUrl).then((res) => res.json());
9720
9722
  if (!ossConfig.success) {
9721
9723
  throw new Error(`Failed to get oss config: ${ossConfig.message}`);
@@ -9735,42 +9737,8 @@ async function getOssWidget(appId) {
9735
9737
  schema: schema || ""
9736
9738
  };
9737
9739
  }
9738
- async function getWidgetVersion(appId) {
9739
- const url = `${WIDGET_CDN_BASE}/widget-version-${appId}`;
9740
- const response = await fetch(url);
9741
- if (!response.ok) {
9742
- throw new Error(`Failed to get widget version: ${response.status}`);
9743
- }
9744
- const data = await response.json();
9745
- if (!data.version) {
9746
- throw new Error("Invalid widget version response: version not found");
9747
- }
9748
- return data.version;
9749
- }
9750
- async function getWidgetResourceConfig(appId, version) {
9751
- const url = `${WIDGET_CDN_BASE}/widget-${appId}-${version}`;
9752
- const response = await fetch(url);
9753
- if (!response.ok) {
9754
- throw new Error(`Failed to get widget resource config: ${response.status}`);
9755
- }
9756
- const data = await response.json();
9757
- if (!data.js) {
9758
- throw new Error("Invalid widget resource config: js not found");
9759
- }
9760
- return data;
9761
- }
9762
9740
  async function resolveWidgetUrlsByAppId(appId) {
9763
- let config;
9764
- if (isIntranet) {
9765
- const version = await getWidgetVersion(appId);
9766
- config = await getWidgetResourceConfig(appId, version);
9767
- } else {
9768
- try {
9769
- config = await getOssWidget(appId);
9770
- } catch (error) {
9771
- console.error(`Failed to get OSS widget for appId: ${appId}`, error);
9772
- }
9773
- }
9741
+ const config = await getOssWidget(appId);
9774
9742
  if (!config) {
9775
9743
  throw new Error(`Failed to get widget config for appId: ${appId}`);
9776
9744
  }