{"version":3,"file":"platform.mjs","sources":["../../src/platform.ts"],"sourcesContent":["import { ScreenshotItem } from '@midscene/core';\nimport type { Agent } from '@midscene/core/agent';\nimport {\n  type AgentFactory,\n  type LaunchPlaygroundOptions,\n  type PlaygroundPreviewDescriptor,\n  createMjpegPreviewDescriptor,\n  definePlaygroundPlatform,\n} from '@midscene/playground';\nimport { StaticPage, StaticPageAgent } from './static';\n\nexport interface WebPlatformOptions {\n  agent?: Agent;\n  agentFactory?: AgentFactory;\n  title?: string;\n  preview?: PlaygroundPreviewDescriptor;\n  launchOptions?: LaunchPlaygroundOptions;\n}\n\nfunction createDefaultWebAgent(): StaticPageAgent {\n  const page = new StaticPage({\n    shotSize: { width: 800, height: 600 },\n    screenshot: ScreenshotItem.create('', Date.now()),\n    shrunkShotToLogicalRatio: 1,\n  });\n\n  return new StaticPageAgent(page);\n}\n\nexport const webPlaygroundPlatform = definePlaygroundPlatform<\n  WebPlatformOptions | undefined\n>({\n  id: 'web',\n  title: 'Midscene Web Playground',\n  description: 'Web playground platform descriptor',\n  async prepare(options) {\n    const agent = options?.agent;\n    const agentFactory =\n      options?.agentFactory ||\n      (!options?.agent && !options?.agentFactory\n        ? () => createDefaultWebAgent()\n        : undefined);\n\n    return {\n      platformId: 'web',\n      title: options?.title || 'Midscene Web Playground',\n      agent: agent || (!agentFactory ? createDefaultWebAgent() : undefined),\n      agentFactory,\n      launchOptions: options?.launchOptions,\n      preview:\n        options?.preview ||\n        createMjpegPreviewDescriptor({\n          title: 'Web page preview',\n        }),\n      metadata: {\n        interfaceType: agent?.interface?.interfaceType || 'web',\n      },\n    };\n  },\n});\n"],"names":["createDefaultWebAgent","page","StaticPage","ScreenshotItem","Date","StaticPageAgent","webPlaygroundPlatform","definePlaygroundPlatform","options","agent","agentFactory","undefined","createMjpegPreviewDescriptor"],"mappings":";;;AAmBA,SAASA;IACP,MAAMC,OAAO,IAAIC,WAAW;QAC1B,UAAU;YAAE,OAAO;YAAK,QAAQ;QAAI;QACpC,YAAYC,eAAe,MAAM,CAAC,IAAIC,KAAK,GAAG;QAC9C,0BAA0B;IAC5B;IAEA,OAAO,IAAIC,gBAAgBJ;AAC7B;AAEO,MAAMK,wBAAwBC,yBAEnC;IACA,IAAI;IACJ,OAAO;IACP,aAAa;IACb,MAAM,SAAQC,OAAO;QACnB,MAAMC,QAAQD,SAAS;QACvB,MAAME,eACJF,SAAS,gBACR,CAACA,SAAS,SAAUA,SAAS,eAE1BG,SADA,IAAMX,uBACE;QAEd,OAAO;YACL,YAAY;YACZ,OAAOQ,SAAS,SAAS;YACzB,OAAOC,SAAU,CAACC,eAAyCC,SAA1BX,uBAAkC;YACnEU;YACA,eAAeF,SAAS;YACxB,SACEA,SAAS,WACTI,6BAA6B;gBAC3B,OAAO;YACT;YACF,UAAU;gBACR,eAAeH,OAAO,WAAW,iBAAiB;YACpD;QACF;IACF;AACF"}