@avocadostudio-ai/cli 0.11.6 → 0.11.7

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.
package/dist/index.js CHANGED
@@ -15371,6 +15371,7 @@ function parseArgs(args) {
15371
15371
  let orchestrator = env.AVOCADO_ORCHESTRATOR_URL ?? "http://localhost:4200";
15372
15372
  let siteOrigin = env.AVOCADO_SITE_ORIGIN ?? "http://localhost:3000";
15373
15373
  let publishToken = env.AVOCADO_PUBLISH_TOKEN;
15374
+ let siteDraftSecret = env.AVOCADO_SITE_DRAFT_SECRET ?? env.DRAFT_MODE_SECRET;
15374
15375
  let port = Number(env.PORT ?? 4100);
15375
15376
  let host = env.HOST ?? "127.0.0.1";
15376
15377
  for (let i = 0; i < args.length; i++) {
@@ -15392,6 +15393,11 @@ function parseArgs(args) {
15392
15393
  publishToken = next;
15393
15394
  i++;
15394
15395
  break;
15396
+ case "--draft-secret":
15397
+ if (!next) throw new Error("--draft-secret requires a value");
15398
+ siteDraftSecret = next;
15399
+ i++;
15400
+ break;
15395
15401
  case "--port":
15396
15402
  if (!next) throw new Error("--port requires a number");
15397
15403
  port = Number(next);
@@ -15407,7 +15413,7 @@ function parseArgs(args) {
15407
15413
  }
15408
15414
  }
15409
15415
  if (!Number.isFinite(port) || port <= 0) throw new Error(`Invalid port: ${port}`);
15410
- return { orchestrator, siteOrigin, publishToken, port, host };
15416
+ return { orchestrator, siteOrigin, publishToken, siteDraftSecret, port, host };
15411
15417
  }
15412
15418
  function resolveEditorDist() {
15413
15419
  const here = fileURLToPath(new URL(".", import.meta.url));
@@ -15432,7 +15438,8 @@ function configScript(opts) {
15432
15438
  const cfg = {
15433
15439
  orchestratorUrl: opts.orchestrator,
15434
15440
  siteOrigin: opts.siteOrigin,
15435
- publishToken: opts.publishToken
15441
+ publishToken: opts.publishToken,
15442
+ siteDraftSecret: opts.siteDraftSecret
15436
15443
  };
15437
15444
  const json2 = JSON.stringify(cfg).replace(/</g, "\\u003c");
15438
15445
  return `<script>window.__AVOCADO_CONFIG__=${json2};</script>`;
@@ -15516,6 +15523,13 @@ async function startCommand(args) {
15516
15523
  ` orchestrator: ${opts.orchestrator}`,
15517
15524
  ` preview site: ${opts.siteOrigin}`,
15518
15525
  opts.publishToken ? ` publish token: (set)` : ` publish token: (unset)`,
15526
+ /*
15527
+ * Say this out loud, because its absence is silent and catastrophic.
15528
+ * Without it a production editor loads, renders the site, and cannot
15529
+ * select anything — and the product has already taught the user that "a
15530
+ * click does nothing" means the element picker is off.
15531
+ */
15532
+ opts.siteDraftSecret ? ` draft secret: (set)` : ` draft secret: (unset) \u2014 editing works in dev; in production the preview will not be selectable`,
15519
15533
  ""
15520
15534
  ].join("\n")
15521
15535
  );
@@ -15548,6 +15562,7 @@ function printHelp() {
15548
15562
  " --orchestrator <url> Orchestrator base URL (env AVOCADO_ORCHESTRATOR_URL, default http://localhost:4200)",
15549
15563
  " --preview <url> Default preview site origin (env AVOCADO_SITE_ORIGIN, default http://localhost:3000)",
15550
15564
  " --publish-token <tok> Forward x-publish-token header (env AVOCADO_PUBLISH_TOKEN)",
15565
+ " --draft-secret <s> Site DRAFT_MODE_SECRET; required for editing in production (env DRAFT_MODE_SECRET)",
15551
15566
  " --port <n> Port to serve the editor on (env PORT, default 4100)",
15552
15567
  " --host <addr> Bind address (default 127.0.0.1)",
15553
15568
  ""
@@ -1 +1 @@
1
- import{P as b}from"./chunk-2CNEFIQP-C5ugG0kw.js";import{u as y,a as j,E as L,_ as m,L as M,b as p,o as P,i as A}from"./PuckPrototypeRoute-CnasXb0R.js";import{r as s,j as g}from"./index-ByDa6BbZ.js";import{E as N,u as U}from"./index-BF3lByJ7.js";import"./index-BmUfMOyw.js";A();A();function C({content:a,onChange:x,extensions:v,editable:d=!0,onFocusChange:o,name:c}){const[i,E]=P(null,50,{leading:!0,maxWait:200}),l=s.useRef(!1),S=s.useRef(""),f=s.useRef(null),R=!!f.current,_=j(t=>t.state.ui.field.focus===c),T=t=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{S.current===t&&(f.current=null)},200)},u=y(),e=U({extensions:v,content:a,editable:d,immediatelyRender:!1,parseOptions:{preserveWhitespace:"full"},onUpdate:({editor:t})=>{if(l.current||!_){u.getState().setUi({field:{focus:c}});return}const r=t.getHTML(),{from:n,to:h}=t.state.selection;E({from:n,to:h,html:r}),T(r),S.current=r}});return s.useEffect(()=>{if(!e)return;const t=()=>{o==null||o(e)};return e.on("focus",t),()=>{e.off("focus",t)}},[e,o]),s.useEffect(()=>{if(i){const{ui:t}=u.getState().state;x(i.html,{field:m(p({},t.field),{metadata:{from:i.from,to:i.to}})})}},[e,i,x,u,c]),s.useEffect(()=>{e==null||e.setEditable(d)},[e,d]),s.useEffect(()=>{var t;if(!e||R||e.getHTML()===a)return;l.current=!0,e.commands.setContent(a,{emitUpdate:!1});const{ui:n}=u.getState().state;typeof((t=n.field.metadata)==null?void 0:t.from)<"u"&&e.commands.setTextSelection({from:n.field.metadata.from,to:n.field.metadata.to}),l.current=!1},[a,e,u]),e}var F=s.memo(a=>{const{onChange:x,content:v,readOnly:d=!1,field:o,inline:c=!1,onFocus:i,id:E,name:l}=a,{tiptap:S={},options:f}=o,{extensions:R=[]}=S,_=s.useMemo(()=>[b.configure(f),...R],[o,R]),T=y(),u=`${l}${c?"::inline":""}`,e=C({content:v,onChange:x,extensions:_,editable:!d,name:u,onFocusChange:r=>{if(r){const n=T.getState();T.setState({currentRichText:{field:o,editor:r,id:E,inline:c},state:m(p({},n.state),{ui:m(p({},n.state.ui),{field:m(p({},n.state.ui.field),{focus:u})})})}),i==null||i(r)}}}),t=j(r=>{var n,h;return!c&&((n=r.currentRichText)==null?void 0:n.id)===E&&((h=r.currentRichText)!=null&&h.inlineComponentId)?r.currentRichText.editor:e});return e?g.jsx(L,m(p({},a),{editor:e,menu:g.jsx(M,{field:o,editor:t,readOnly:d}),children:g.jsx(N,{editor:e,className:"rich-text"})})):null});F.displayName="Editor";export{F as Editor};
1
+ import{P as b}from"./chunk-2CNEFIQP-Do4keyhs.js";import{u as y,a as j,E as L,_ as m,L as M,b as p,o as P,i as A}from"./PuckPrototypeRoute-CJ65s4GP.js";import{r as s,j as g}from"./index-BeG_Wqzx.js";import{E as N,u as U}from"./index-ZcTZVUY1.js";import"./index-lxXlgJ8M.js";A();A();function C({content:a,onChange:x,extensions:v,editable:d=!0,onFocusChange:o,name:c}){const[i,E]=P(null,50,{leading:!0,maxWait:200}),l=s.useRef(!1),S=s.useRef(""),f=s.useRef(null),R=!!f.current,_=j(t=>t.state.ui.field.focus===c),T=t=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{S.current===t&&(f.current=null)},200)},u=y(),e=U({extensions:v,content:a,editable:d,immediatelyRender:!1,parseOptions:{preserveWhitespace:"full"},onUpdate:({editor:t})=>{if(l.current||!_){u.getState().setUi({field:{focus:c}});return}const r=t.getHTML(),{from:n,to:h}=t.state.selection;E({from:n,to:h,html:r}),T(r),S.current=r}});return s.useEffect(()=>{if(!e)return;const t=()=>{o==null||o(e)};return e.on("focus",t),()=>{e.off("focus",t)}},[e,o]),s.useEffect(()=>{if(i){const{ui:t}=u.getState().state;x(i.html,{field:m(p({},t.field),{metadata:{from:i.from,to:i.to}})})}},[e,i,x,u,c]),s.useEffect(()=>{e==null||e.setEditable(d)},[e,d]),s.useEffect(()=>{var t;if(!e||R||e.getHTML()===a)return;l.current=!0,e.commands.setContent(a,{emitUpdate:!1});const{ui:n}=u.getState().state;typeof((t=n.field.metadata)==null?void 0:t.from)<"u"&&e.commands.setTextSelection({from:n.field.metadata.from,to:n.field.metadata.to}),l.current=!1},[a,e,u]),e}var F=s.memo(a=>{const{onChange:x,content:v,readOnly:d=!1,field:o,inline:c=!1,onFocus:i,id:E,name:l}=a,{tiptap:S={},options:f}=o,{extensions:R=[]}=S,_=s.useMemo(()=>[b.configure(f),...R],[o,R]),T=y(),u=`${l}${c?"::inline":""}`,e=C({content:v,onChange:x,extensions:_,editable:!d,name:u,onFocusChange:r=>{if(r){const n=T.getState();T.setState({currentRichText:{field:o,editor:r,id:E,inline:c},state:m(p({},n.state),{ui:m(p({},n.state.ui),{field:m(p({},n.state.ui.field),{focus:u})})})}),i==null||i(r)}}}),t=j(r=>{var n,h;return!c&&((n=r.currentRichText)==null?void 0:n.id)===E&&((h=r.currentRichText)!=null&&h.inlineComponentId)?r.currentRichText.editor:e});return e?g.jsx(L,m(p({},a),{editor:e,menu:g.jsx(M,{field:o,editor:t,readOnly:d}),children:g.jsx(N,{editor:e,className:"rich-text"})})):null});F.displayName="Editor";export{F as Editor};