@coreframe/vite 0.1.1 → 0.1.3

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.
@@ -1,4 +1,4 @@
1
- import{managedDevTokenEnv as e,managedDevUrlEnv as t}from"@coreframe/scripts/managed-dev-protocol";const n=`/@coreframe/managed-dev`,r=`/__coreframe/managed-dev`;function i({env:i=process.env}={}){let u=i[t],d=i[e],f=!!(u&&d);async function p(e,t){if(!u||!d)throw Error(`Managed development is not configured.`);return fetch(new URL(e,u),{...t,headers:{...t?.headers,Authorization:`Bearer ${d}`,"Content-Type":`application/json`}})}return{name:`coreframe:managed-dev`,apply:`serve`,async configureServer(e){if(!f)return;let t=await p(`/handshake`,{method:`POST`});if(!t.ok){let e=await t.text();throw Error(`Coreframe managed development could not start: ${e}`)}e.middlewares.use(async(e,t,i)=>{if(!e.url){i();return}let u=new URL(e.url,`http://coreframe.local`).pathname;if(u===n){t.statusCode=200,t.setHeader(`Content-Type`,`text/javascript; charset=utf-8`),t.end(l);return}if(u===`${r}/status`&&e.method===`GET`){await a(await p(`/status`),t);return}if(u===`${r}/action`&&e.method===`POST`){if(!s(e.socket.remoteAddress)){c(t,403,{error:`Managed development actions require a loopback client.`});return}await a(await p(`/action`,{body:await o(e),method:`POST`}),t);return}i()})},transformIndexHtml(){if(f)return[{tag:`script`,attrs:{src:n,type:`module`},injectTo:`body`}]}}}async function a(e,t){let n=await e.text();t.statusCode=e.status,t.setHeader(`Content-Type`,e.headers.get(`content-type`)??`application/json`),t.end(n)}async function o(e){let t=``;for await(let n of e)if(t+=String(n),t.length>1e6)throw Error(`Managed development request is too large.`);return t}function s(e){return e===`127.0.0.1`||e===`::1`||e?.startsWith(`::ffff:127.`)}function c(e,t,n){e.statusCode=t,e.setHeader(`Content-Type`,`application/json`),e.end(JSON.stringify(n))}const l=String.raw`
1
+ import{managedDevTokenEnv as e,managedDevUrlEnv as t}from"@coreframe/scripts/managed-dev-protocol";const n=`/__coreframe/managed-dev`;function r({env:r=process.env}={}){let l=r[t],u=r[e],d=!!(l&&u);async function f(e,t){if(!l||!u)throw Error(`Managed development is not configured.`);return fetch(new URL(e,l),{...t,headers:{...t?.headers,Authorization:`Bearer ${u}`,"Content-Type":`application/json`}})}return{name:`coreframe:managed-dev`,apply:`serve`,config(){return{define:{"import.meta.env.COREFRAME_MANAGED_DEV":JSON.stringify(d)}}},async configureServer(e){if(!d)return;let t=await f(`/handshake`,{method:`POST`});if(!t.ok){let e=await t.text();throw Error(`Coreframe managed development could not start: ${e}`)}e.middlewares.use(async(e,t,r)=>{if(!e.url){r();return}let l=new URL(e.url,`http://coreframe.local`).pathname;if(l===`/@coreframe/managed-dev`){t.statusCode=200,t.setHeader(`Content-Type`,`text/javascript; charset=utf-8`),t.end(c);return}if(l===`${n}/status`&&e.method===`GET`){await i(await f(`/status`),t);return}if(l===`${n}/action`&&e.method===`POST`){if(!o(e.socket.remoteAddress)){s(t,403,{error:`Managed development actions require a loopback client.`});return}await i(await f(`/action`,{body:await a(e),method:`POST`}),t);return}r()})}}}async function i(e,t){let n=await e.text();t.statusCode=e.status,t.setHeader(`Content-Type`,e.headers.get(`content-type`)??`application/json`),t.end(n)}async function a(e){let t=``;for await(let n of e)if(t+=String(n),t.length>1e6)throw Error(`Managed development request is too large.`);return t}function o(e){return e===`127.0.0.1`||e===`::1`||e?.startsWith(`::ffff:127.`)}function s(e,t,n){e.statusCode=t,e.setHeader(`Content-Type`,`application/json`),e.end(JSON.stringify(n))}const c=String.raw`
2
2
  const endpoint = "/__coreframe/managed-dev"
3
3
  const channel = new BroadcastChannel("coreframe-managed-dev")
4
4
  let status
@@ -100,7 +100,8 @@ function render() {
100
100
  ))
101
101
  }
102
102
  } else if (target && !status.busy) {
103
- content.append(actions(button("Refresh", () => act({ type: "prepare", target: target.commit }), true)))
103
+ const label = target.source === "local" ? "Sync with main" : "Refresh"
104
+ content.append(actions(button(label, () => act({ type: "prepare", target: target.commit }), true)))
104
105
  }
105
106
  }
106
107
 
@@ -145,6 +146,7 @@ function actions(...buttons) {
145
146
  function modeMessage(value) {
146
147
  if (value.mode === "unmanaged") return "Managed synchronization is unavailable for this session."
147
148
  if (value.mode === "error") return "Managed synchronization stopped."
149
+ if (value.target?.source === "local") return "New changes are available in local main."
148
150
  return "A newer main commit is ready."
149
151
  }
150
- `;export{l as browserClientSource,i as coreframeManagedDevPlugin};
152
+ `;export{c as browserClientSource,r as coreframeManagedDevPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreframe/vite",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/airlock-labs/coreframe.git",
@@ -41,7 +41,7 @@
41
41
  "@svgr/core": "^8.1.0",
42
42
  "@svgr/plugin-jsx": "^8.1.0",
43
43
  "unplugin-icons": "^23.0.1",
44
- "@coreframe/scripts": "^0.1.14",
44
+ "@coreframe/scripts": "^0.1.18",
45
45
  "@coreframe/lib": "^0.1.4"
46
46
  },
47
47
  "devDependencies": {