@aigne/aigne-hub 1.74.0-beta.4 → 1.74.0-beta.6

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.
@@ -2,11 +2,29 @@ let ufo = require("ufo");
2
2
  let _aigne_model_base_utils_fetch = require("@aigne/model-base/utils/fetch");
3
3
 
4
4
  //#region src/utils/blocklet.ts
5
+ const cache = /* @__PURE__ */ new Map();
6
+ const inflight = /* @__PURE__ */ new Map();
5
7
  async function getAIGNEHubMountPoint(url, component) {
6
8
  const { origin } = new URL(url);
9
+ const cacheKey = `${origin}#${component}`;
10
+ const cached = cache.get(cacheKey);
11
+ if (cached) return cached;
12
+ const pending = inflight.get(cacheKey);
13
+ if (pending) return pending;
14
+ const promise = _fetchMountPoint(origin, url, component, cacheKey);
15
+ inflight.set(cacheKey, promise);
16
+ try {
17
+ return await promise;
18
+ } finally {
19
+ inflight.delete(cacheKey);
20
+ }
21
+ }
22
+ async function _fetchMountPoint(origin, url, component, cacheKey) {
7
23
  const comp = ((await (await (0, _aigne_model_base_utils_fetch.fetch)((0, ufo.joinURL)(origin, "__blocklet__.js?type=json"))).json())?.componentMountPoints || []).find((m) => m.did === component);
8
24
  if (!comp) throw new Error(`Component ${component} not found in blocklet ${url}`);
9
- return (0, ufo.joinURL)(origin, comp.mountPoint);
25
+ const result = (0, ufo.joinURL)(origin, comp.mountPoint);
26
+ cache.set(cacheKey, result);
27
+ return result;
10
28
  }
11
29
 
12
30
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"blocklet.d.cts","names":[],"sources":["../../src/utils/blocklet.ts"],"mappings":";iBAGsB,qBAAA,CAAsB,GAAA,UAAa,SAAA,WAAiB,OAAA"}
1
+ {"version":3,"file":"blocklet.d.cts","names":[],"sources":["../../src/utils/blocklet.ts"],"mappings":";iBAMsB,qBAAA,CAAsB,GAAA,UAAa,SAAA,WAAiB,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"blocklet.d.mts","names":[],"sources":["../../src/utils/blocklet.ts"],"mappings":";iBAGsB,qBAAA,CAAsB,GAAA,UAAa,SAAA,WAAiB,OAAA"}
1
+ {"version":3,"file":"blocklet.d.mts","names":[],"sources":["../../src/utils/blocklet.ts"],"mappings":";iBAMsB,qBAAA,CAAsB,GAAA,UAAa,SAAA,WAAiB,OAAA"}
@@ -2,11 +2,29 @@ import { joinURL } from "ufo";
2
2
  import { fetch } from "@aigne/model-base/utils/fetch";
3
3
 
4
4
  //#region src/utils/blocklet.ts
5
+ const cache = /* @__PURE__ */ new Map();
6
+ const inflight = /* @__PURE__ */ new Map();
5
7
  async function getAIGNEHubMountPoint(url, component) {
6
8
  const { origin } = new URL(url);
9
+ const cacheKey = `${origin}#${component}`;
10
+ const cached = cache.get(cacheKey);
11
+ if (cached) return cached;
12
+ const pending = inflight.get(cacheKey);
13
+ if (pending) return pending;
14
+ const promise = _fetchMountPoint(origin, url, component, cacheKey);
15
+ inflight.set(cacheKey, promise);
16
+ try {
17
+ return await promise;
18
+ } finally {
19
+ inflight.delete(cacheKey);
20
+ }
21
+ }
22
+ async function _fetchMountPoint(origin, url, component, cacheKey) {
7
23
  const comp = ((await (await fetch(joinURL(origin, "__blocklet__.js?type=json"))).json())?.componentMountPoints || []).find((m) => m.did === component);
8
24
  if (!comp) throw new Error(`Component ${component} not found in blocklet ${url}`);
9
- return joinURL(origin, comp.mountPoint);
25
+ const result = joinURL(origin, comp.mountPoint);
26
+ cache.set(cacheKey, result);
27
+ return result;
10
28
  }
11
29
 
12
30
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"blocklet.mjs","names":[],"sources":["../../src/utils/blocklet.ts"],"sourcesContent":["import { fetch } from \"@aigne/model-base/utils/fetch\";\nimport { joinURL } from \"ufo\";\n\nexport async function getAIGNEHubMountPoint(url: string, component: string) {\n const { origin } = new URL(url);\n const BLOCKLET_JSON_PATH = \"__blocklet__.js?type=json\";\n const blockletInfo = await fetch(joinURL(origin, BLOCKLET_JSON_PATH));\n const blocklet = await blockletInfo.json();\n const comp = (blocklet?.componentMountPoints || []).find(\n (m: { did: string }) => m.did === component,\n );\n if (!comp) throw new Error(`Component ${component} not found in blocklet ${url}`);\n\n return joinURL(origin, comp.mountPoint);\n}\n"],"mappings":";;;;AAGA,eAAsB,sBAAsB,KAAa,WAAmB;CAC1E,MAAM,EAAE,WAAW,IAAI,IAAI,IAAI;CAI/B,MAAM,SADW,OADI,MAAM,MAAM,QAAQ,QADd,4BACyC,CAAC,EACjC,MAAM,GAClB,wBAAwB,EAAE,EAAE,MACjD,MAAuB,EAAE,QAAQ,UACnC;AACD,KAAI,CAAC,KAAM,OAAM,IAAI,MAAM,aAAa,UAAU,yBAAyB,MAAM;AAEjF,QAAO,QAAQ,QAAQ,KAAK,WAAW"}
1
+ {"version":3,"file":"blocklet.mjs","names":[],"sources":["../../src/utils/blocklet.ts"],"sourcesContent":["import { fetch } from \"@aigne/model-base/utils/fetch\";\nimport { joinURL } from \"ufo\";\n\nconst cache = new Map<string, string>();\nconst inflight = new Map<string, Promise<string>>();\n\nexport async function getAIGNEHubMountPoint(url: string, component: string) {\n const { origin } = new URL(url);\n const cacheKey = `${origin}#${component}`;\n const cached = cache.get(cacheKey);\n if (cached) return cached;\n\n const pending = inflight.get(cacheKey);\n if (pending) return pending;\n\n const promise = _fetchMountPoint(origin, url, component, cacheKey);\n inflight.set(cacheKey, promise);\n try {\n return await promise;\n } finally {\n inflight.delete(cacheKey);\n }\n}\n\nasync function _fetchMountPoint(origin: string, url: string, component: string, cacheKey: string) {\n const BLOCKLET_JSON_PATH = \"__blocklet__.js?type=json\";\n const blockletInfo = await fetch(joinURL(origin, BLOCKLET_JSON_PATH));\n const blocklet = await blockletInfo.json();\n const comp = (blocklet?.componentMountPoints || []).find(\n (m: { did: string }) => m.did === component,\n );\n if (!comp) throw new Error(`Component ${component} not found in blocklet ${url}`);\n\n const result = joinURL(origin, comp.mountPoint);\n cache.set(cacheKey, result);\n return result;\n}\n"],"mappings":";;;;AAGA,MAAM,wBAAQ,IAAI,KAAqB;AACvC,MAAM,2BAAW,IAAI,KAA8B;AAEnD,eAAsB,sBAAsB,KAAa,WAAmB;CAC1E,MAAM,EAAE,WAAW,IAAI,IAAI,IAAI;CAC/B,MAAM,WAAW,GAAG,OAAO,GAAG;CAC9B,MAAM,SAAS,MAAM,IAAI,SAAS;AAClC,KAAI,OAAQ,QAAO;CAEnB,MAAM,UAAU,SAAS,IAAI,SAAS;AACtC,KAAI,QAAS,QAAO;CAEpB,MAAM,UAAU,iBAAiB,QAAQ,KAAK,WAAW,SAAS;AAClE,UAAS,IAAI,UAAU,QAAQ;AAC/B,KAAI;AACF,SAAO,MAAM;WACL;AACR,WAAS,OAAO,SAAS;;;AAI7B,eAAe,iBAAiB,QAAgB,KAAa,WAAmB,UAAkB;CAIhG,MAAM,SADW,OADI,MAAM,MAAM,QAAQ,QADd,4BACyC,CAAC,EACjC,MAAM,GAClB,wBAAwB,EAAE,EAAE,MACjD,MAAuB,EAAE,QAAQ,UACnC;AACD,KAAI,CAAC,KAAM,OAAM,IAAI,MAAM,aAAa,UAAU,yBAAyB,MAAM;CAEjF,MAAM,SAAS,QAAQ,QAAQ,KAAK,WAAW;AAC/C,OAAM,IAAI,UAAU,OAAO;AAC3B,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/aigne-hub",
3
- "version": "1.74.0-beta.4",
3
+ "version": "1.74.0-beta.6",
4
4
  "description": "AIGNE Hub SDK for integrating with Hub AI models",
5
5
  "license": "Elastic-2.0",
6
6
  "publishConfig": {
@@ -49,18 +49,18 @@
49
49
  "https-proxy-agent": "^7.0.6",
50
50
  "ufo": "^1.6.1",
51
51
  "zod": "^3.25.67",
52
- "@aigne/anthropic": "^1.74.0-beta.4",
53
- "@aigne/bedrock": "^1.74.0-beta.4",
54
- "@aigne/deepseek": "^1.74.0-beta.4",
55
- "@aigne/model-base": "^1.74.0-beta.4",
56
- "@aigne/gemini": "^1.74.0-beta.4",
57
- "@aigne/doubao": "^1.74.0-beta.4",
58
- "@aigne/open-router": "^1.74.0-beta.4",
59
- "@aigne/openai": "^1.74.0-beta.4",
60
- "@aigne/ideogram": "^1.74.0-beta.4",
61
- "@aigne/ollama": "^1.74.0-beta.4",
62
- "@aigne/poe": "^1.74.0-beta.4",
63
- "@aigne/xai": "^1.74.0-beta.4"
52
+ "@aigne/anthropic": "^1.74.0-beta.6",
53
+ "@aigne/model-base": "^1.74.0-beta.6",
54
+ "@aigne/bedrock": "^1.74.0-beta.6",
55
+ "@aigne/deepseek": "^1.74.0-beta.6",
56
+ "@aigne/doubao": "^1.74.0-beta.6",
57
+ "@aigne/gemini": "^1.74.0-beta.6",
58
+ "@aigne/ideogram": "^1.74.0-beta.6",
59
+ "@aigne/open-router": "^1.74.0-beta.6",
60
+ "@aigne/ollama": "^1.74.0-beta.6",
61
+ "@aigne/poe": "^1.74.0-beta.6",
62
+ "@aigne/xai": "^1.74.0-beta.6",
63
+ "@aigne/openai": "^1.74.0-beta.6"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/bun": "^1.3.6",