Files
oops-plugin-framework/dist/bridge/api/StateAPI.js

2 lines
1.6 KiB
JavaScript

"use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var r in t)p(e,r,{get:t[r],enumerable:!0})},l=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of d(t))!c.call(e,o)&&o!==r&&p(e,o,{get:()=>t[o],enumerable:!(s=u(t,o))||s.enumerable});return e};var m=e=>l(p({},"__esModule",{value:!0}),e);var f={};g(f,{StateAPI:()=>a,getStateAPI:()=>S,resetStateAPI:()=>P});module.exports=m(f);function h(e,t,r){e.statusCode=t,e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(JSON.stringify(r))}var n=class{constructor(){this.projectId="";this.projectPath=""}setProjectPath(t){this.projectPath=t}getProjectPath(){return this.projectPath}setProjectId(t){this.projectId=t}getProjectId(){return this.projectId}validateProjectId(t){return t===this.projectId}getRequestMethod(t){return t.method||"GET"}checkRequest(t,r){let s=this.getMethodName(t),o=this.getApiPath();return s==="GET"&&o===t.url?(this.handleRequest(t,r),!0):!1}getMethodName(t){return(t.method||"GET").toUpperCase()}};var a=class extends n{constructor(){super(...arguments);this.port=56688;this.running=!1}setPort(r){this.port=r}getPort(){return this.port}setRunning(r){this.running=r}isRunning(){return this.running}getState(){return{projectId:this.projectId,projectPath:this.projectPath,port:this.port,running:this.running}}async handleRequest(r,s){let o={ok:!0,state:this.getState()};h(s,200,o)}getApiPath(){return"/api/State"}getMethod(){return"GET"}},i=null;function S(){return i||(i=new a),i}function P(){i=null}0&&(module.exports={StateAPI,getStateAPI,resetStateAPI});