@midscene/shared 0.27.5 → 0.27.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.
@@ -165,7 +165,10 @@ class GlobalConfigManager {
165
165
  extendMode
166
166
  };
167
167
  if (this.initialized) this.initModelConfigForIntent();
168
- else this.initAllEnvConfig();
168
+ else {
169
+ this.initAllEnvConfig();
170
+ this.modelConfigForChromeExtension = void 0;
171
+ }
169
172
  }
170
173
  constructor(){
171
174
  _define_property(this, "override", void 0);
@@ -148,6 +148,7 @@ const localImg2Base64 = (imgPath, withoutHeader = false)=>{
148
148
  return `data:image/${finalType};base64,${body}`;
149
149
  };
150
150
  const preProcessImageUrl = async (url, convertHttpImage2Base64)=>{
151
+ if ('string' != typeof url) throw new Error(`url must be a string, but got ${url} with type ${typeof url}`);
151
152
  if (url.startsWith('data:')) return url;
152
153
  if (!(url.startsWith('http://') || url.startsWith('https://'))) return await localImg2Base64(url);
153
154
  if (!convertHttpImage2Base64) return url;
@@ -194,7 +194,10 @@ class GlobalConfigManager {
194
194
  extendMode
195
195
  };
196
196
  if (this.initialized) this.initModelConfigForIntent();
197
- else this.initAllEnvConfig();
197
+ else {
198
+ this.initAllEnvConfig();
199
+ this.modelConfigForChromeExtension = void 0;
200
+ }
198
201
  }
199
202
  constructor(){
200
203
  _define_property(this, "override", void 0);
@@ -203,6 +203,7 @@ const localImg2Base64 = (imgPath, withoutHeader = false)=>{
203
203
  return `data:image/${finalType};base64,${body}`;
204
204
  };
205
205
  const preProcessImageUrl = async (url, convertHttpImage2Base64)=>{
206
+ if ('string' != typeof url) throw new Error(`url must be a string, but got ${url} with type ${typeof url}`);
206
207
  if (url.startsWith('data:')) return url;
207
208
  if (!(url.startsWith('http://') || url.startsWith('https://'))) return await localImg2Base64(url);
208
209
  if (!convertHttpImage2Base64) return url;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/shared",
3
- "version": "0.27.5",
3
+ "version": "0.27.6",
4
4
  "repository": "https://github.com/web-infra-dev/midscene",
5
5
  "homepage": "https://midscenejs.com/",
6
6
  "types": "./dist/types/index.d.ts",
@@ -322,6 +322,8 @@ export class GlobalConfigManager {
322
322
  this.initModelConfigForIntent();
323
323
  } else {
324
324
  this.initAllEnvConfig();
325
+ // reset modelConfigForChromeExtension to force re-init when overrideAIConfig is called
326
+ this.modelConfigForChromeExtension = undefined;
325
327
  }
326
328
  }
327
329
  }
@@ -323,6 +323,11 @@ export const preProcessImageUrl = async (
323
323
  url: string,
324
324
  convertHttpImage2Base64: boolean,
325
325
  ) => {
326
+ if (typeof url !== 'string') {
327
+ throw new Error(
328
+ `url must be a string, but got ${url} with type ${typeof url}`,
329
+ );
330
+ }
326
331
  if (url.startsWith('data:')) {
327
332
  return url;
328
333
  } else if (url.startsWith('http://') || url.startsWith('https://')) {