@avocadostudio-ai/cli 0.5.0 → 0.5.1

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
@@ -13796,6 +13796,42 @@ function unwrapZod(schema) {
13796
13796
  }
13797
13797
  return current;
13798
13798
  }
13799
+ function listElementBranches(element) {
13800
+ const unwrapped = unwrapZod(element);
13801
+ if (!unwrapped) return void 0;
13802
+ const ownShape = unwrapped.shape;
13803
+ if (ownShape) return [{ discriminantValues: [], shape: ownShape }];
13804
+ const def = unwrapped.def ?? unwrapped._def;
13805
+ const options = def?.options;
13806
+ if (!Array.isArray(options) || options.length === 0) return void 0;
13807
+ const discriminator = def?.discriminator;
13808
+ const branches = [];
13809
+ for (const option of options) {
13810
+ const optionShape = unwrapZod(option)?.shape;
13811
+ if (!optionShape) continue;
13812
+ branches.push({
13813
+ discriminantValues: discriminator ? literalValuesOf(optionShape[discriminator]) : [],
13814
+ shape: optionShape
13815
+ });
13816
+ }
13817
+ return branches.length > 0 ? branches : void 0;
13818
+ }
13819
+ function literalValuesOf(schema) {
13820
+ const def = unwrapZod(schema)?.def ?? unwrapZod(schema)?._def;
13821
+ if (!def) return [];
13822
+ if (Array.isArray(def.values)) return def.values.map(String);
13823
+ if (def.value !== void 0) return [String(def.value)];
13824
+ if (def.entries) return Object.values(def.entries).map(String);
13825
+ return [];
13826
+ }
13827
+ function deriveRequired(fields, shapes) {
13828
+ for (const [key, field] of Object.entries(fields)) {
13829
+ if (field.required !== void 0) continue;
13830
+ const backing = shapes.filter((s) => s[key]);
13831
+ if (backing.length === 0) continue;
13832
+ field.required = backing.length === shapes.length && backing.every((s) => !s[key].isOptional());
13833
+ }
13834
+ }
13799
13835
  var warnedListFields = /* @__PURE__ */ new Set();
13800
13836
  function warnUnbackedListField(type, listKey, present) {
13801
13837
  const key = `${type}.${listKey}`;
@@ -13809,8 +13845,14 @@ function warnUnbackedListField(type, listKey, present) {
13809
13845
  } catch {
13810
13846
  }
13811
13847
  }
13848
+ var _builtinBlockTypes = G.__ase_builtinBlockTypes ?? (G.__ase_builtinBlockTypes = /* @__PURE__ */ new Set());
13849
+ function registerBuiltinBlock(type, config2) {
13850
+ registerBlock(type, config2);
13851
+ _builtinBlockTypes.add(type);
13852
+ }
13812
13853
  function registerBlock(type, config2) {
13813
13854
  _blockSchemas[type] = config2.schema;
13855
+ _builtinBlockTypes.delete(type);
13814
13856
  const shape = config2.schema.shape;
13815
13857
  if (shape) {
13816
13858
  for (const [key, field] of Object.entries(config2.meta.fields)) {
@@ -13823,17 +13865,22 @@ function registerBlock(type, config2) {
13823
13865
  if (config2.meta.listFields) {
13824
13866
  for (const [listKey, listMeta] of Object.entries(config2.meta.listFields)) {
13825
13867
  const listZod = shape[listKey];
13826
- const elementShape = unwrapZod(listZod)?.element?.shape;
13827
- if (!elementShape) {
13868
+ const branches = listElementBranches(unwrapZod(listZod)?.element);
13869
+ if (!branches) {
13828
13870
  warnUnbackedListField(type, listKey, listZod !== void 0);
13829
13871
  continue;
13830
13872
  }
13831
- for (const [itemKey, itemField] of Object.entries(listMeta.itemFields)) {
13832
- if (itemField.required !== void 0) continue;
13833
- const zodItem = elementShape[itemKey];
13834
- if (zodItem) {
13835
- itemField.required = !zodItem.isOptional();
13836
- }
13873
+ deriveRequired(
13874
+ listMeta.itemFields,
13875
+ branches.map((b) => b.shape)
13876
+ );
13877
+ for (const [value, branchFields] of Object.entries(listMeta.itemFieldsByType ?? {})) {
13878
+ const matching = branches.filter((b) => b.discriminantValues.includes(value));
13879
+ if (matching.length === 0) continue;
13880
+ deriveRequired(
13881
+ branchFields,
13882
+ matching.map((b) => b.shape)
13883
+ );
13837
13884
  }
13838
13885
  }
13839
13886
  }
@@ -13886,7 +13933,7 @@ var f = {
13886
13933
  };
13887
13934
 
13888
13935
  // ../shared/src/blocks/hero.ts
13889
- registerBlock("Hero", {
13936
+ registerBuiltinBlock("Hero", {
13890
13937
  schema: external_exports.object({
13891
13938
  heading: external_exports.string().min(1),
13892
13939
  subheading: external_exports.string().min(1),
@@ -13926,7 +13973,7 @@ registerBlock("Hero", {
13926
13973
  });
13927
13974
 
13928
13975
  // ../shared/src/blocks/feature-grid.ts
13929
- registerBlock("FeatureGrid", {
13976
+ registerBuiltinBlock("FeatureGrid", {
13930
13977
  schema: external_exports.object({
13931
13978
  title: external_exports.string().min(1),
13932
13979
  columns: external_exports.enum(["2", "3", "4"]).default("3").catch("3"),
@@ -13960,7 +14007,7 @@ registerBlock("FeatureGrid", {
13960
14007
  });
13961
14008
 
13962
14009
  // ../shared/src/blocks/testimonials.ts
13963
- registerBlock("Testimonials", {
14010
+ registerBuiltinBlock("Testimonials", {
13964
14011
  schema: external_exports.object({
13965
14012
  title: external_exports.string().min(1),
13966
14013
  items: external_exports.array(external_exports.object({
@@ -13995,7 +14042,7 @@ registerBlock("Testimonials", {
13995
14042
  });
13996
14043
 
13997
14044
  // ../shared/src/blocks/faq-accordion.ts
13998
- registerBlock("FAQAccordion", {
14045
+ registerBuiltinBlock("FAQAccordion", {
13999
14046
  schema: external_exports.object({
14000
14047
  title: external_exports.string().min(1),
14001
14048
  items: external_exports.array(external_exports.object({ id: external_exports.string().optional(), q: external_exports.string().min(1), a: external_exports.string().min(1) })).min(1)
@@ -14015,7 +14062,7 @@ registerBlock("FAQAccordion", {
14015
14062
  });
14016
14063
 
14017
14064
  // ../shared/src/blocks/cta.ts
14018
- registerBlock("CTA", {
14065
+ registerBuiltinBlock("CTA", {
14019
14066
  schema: external_exports.object({
14020
14067
  title: external_exports.string().min(1),
14021
14068
  description: external_exports.string().min(1),
@@ -14045,7 +14092,7 @@ registerBlock("CTA", {
14045
14092
  });
14046
14093
 
14047
14094
  // ../shared/src/blocks/card.ts
14048
- registerBlock("Card", {
14095
+ registerBuiltinBlock("Card", {
14049
14096
  schema: external_exports.object({
14050
14097
  title: external_exports.string().min(1),
14051
14098
  description: external_exports.string().min(1),
@@ -14075,7 +14122,7 @@ registerBlock("Card", {
14075
14122
  });
14076
14123
 
14077
14124
  // ../shared/src/blocks/card-grid.ts
14078
- registerBlock("CardGrid", {
14125
+ registerBuiltinBlock("CardGrid", {
14079
14126
  schema: external_exports.object({
14080
14127
  title: external_exports.string().min(1),
14081
14128
  subtitle: external_exports.string().optional(),
@@ -14123,7 +14170,7 @@ registerBlock("CardGrid", {
14123
14170
  });
14124
14171
 
14125
14172
  // ../shared/src/blocks/rich-text.ts
14126
- registerBlock("RichText", {
14173
+ registerBuiltinBlock("RichText", {
14127
14174
  schema: external_exports.object({
14128
14175
  title: external_exports.string(),
14129
14176
  body: external_exports.string().min(1)
@@ -14141,7 +14188,7 @@ registerBlock("RichText", {
14141
14188
  });
14142
14189
 
14143
14190
  // ../shared/src/blocks/stats.ts
14144
- registerBlock("Stats", {
14191
+ registerBuiltinBlock("Stats", {
14145
14192
  schema: external_exports.object({
14146
14193
  title: external_exports.string().optional(),
14147
14194
  stats: external_exports.array(external_exports.object({
@@ -14215,7 +14262,7 @@ var twoColumnItemFieldsByType = {
14215
14262
  poster: f.image("Video poster image", { aspectRatio: "landscape", width: 768, height: 512 })
14216
14263
  }
14217
14264
  };
14218
- registerBlock("TwoColumn", {
14265
+ registerBuiltinBlock("TwoColumn", {
14219
14266
  schema: external_exports.object({
14220
14267
  variant: external_exports.enum(["default", "accent"]).default("default").catch("default"),
14221
14268
  left: external_exports.array(twoColumnChild).min(1),
@@ -14247,7 +14294,7 @@ registerBlock("TwoColumn", {
14247
14294
  });
14248
14295
 
14249
14296
  // ../shared/src/blocks/footer.ts
14250
- registerBlock("Footer", {
14297
+ registerBuiltinBlock("Footer", {
14251
14298
  schema: external_exports.object({
14252
14299
  copyright: external_exports.string().min(1),
14253
14300
  columns: external_exports.array(external_exports.object({ id: external_exports.string().optional(), title: external_exports.string().min(1), links: external_exports.string().min(1) })).min(1)
@@ -14293,7 +14340,7 @@ var navLinkLeaf = external_exports.object({
14293
14340
  href: external_exports.string().min(1),
14294
14341
  newTab: external_exports.boolean().optional()
14295
14342
  });
14296
- registerBlock("SiteHeader", {
14343
+ registerBuiltinBlock("SiteHeader", {
14297
14344
  schema: external_exports.object({
14298
14345
  siteName: external_exports.string().min(1),
14299
14346
  logoUrl: external_exports.string().min(1),
@@ -14327,7 +14374,7 @@ registerBlock("SiteHeader", {
14327
14374
  });
14328
14375
 
14329
14376
  // ../shared/src/blocks/embed.ts
14330
- registerBlock("Embed", {
14377
+ registerBuiltinBlock("Embed", {
14331
14378
  schema: external_exports.object({
14332
14379
  embedType: external_exports.enum(["map", "social", "custom"]).default("map").catch("map"),
14333
14380
  url: external_exports.string().min(1),
@@ -14348,7 +14395,7 @@ registerBlock("Embed", {
14348
14395
  });
14349
14396
 
14350
14397
  // ../shared/src/blocks/banner.ts
14351
- registerBlock("Banner", {
14398
+ registerBuiltinBlock("Banner", {
14352
14399
  schema: external_exports.object({
14353
14400
  text: external_exports.string().min(1),
14354
14401
  variant: external_exports.enum(["info", "success", "warning"]).default("info").catch("info"),
@@ -14375,7 +14422,7 @@ registerBlock("Banner", {
14375
14422
  });
14376
14423
 
14377
14424
  // ../shared/src/blocks/carousel.ts
14378
- registerBlock("Carousel", {
14425
+ registerBuiltinBlock("Carousel", {
14379
14426
  schema: external_exports.object({
14380
14427
  items: external_exports.array(external_exports.object({
14381
14428
  id: external_exports.string().optional(),
@@ -14416,7 +14463,7 @@ registerBlock("Carousel", {
14416
14463
  });
14417
14464
 
14418
14465
  // ../shared/src/blocks/gallery.ts
14419
- registerBlock("Gallery", {
14466
+ registerBuiltinBlock("Gallery", {
14420
14467
  schema: external_exports.object({
14421
14468
  title: external_exports.string().optional(),
14422
14469
  headingLevel: external_exports.string().optional(),
@@ -14451,7 +14498,7 @@ registerBlock("Gallery", {
14451
14498
  });
14452
14499
 
14453
14500
  // ../shared/src/blocks/tabs.ts
14454
- registerBlock("Tabs", {
14501
+ registerBuiltinBlock("Tabs", {
14455
14502
  schema: external_exports.object({
14456
14503
  title: external_exports.string().optional(),
14457
14504
  tabs: external_exports.array(external_exports.object({
@@ -14478,7 +14525,7 @@ registerBlock("Tabs", {
14478
14525
  });
14479
14526
 
14480
14527
  // ../shared/src/blocks/table.ts
14481
- registerBlock("Table", {
14528
+ registerBuiltinBlock("Table", {
14482
14529
  schema: external_exports.object({
14483
14530
  title: external_exports.string().optional(),
14484
14531
  headingLevel: external_exports.string().optional(),
@@ -14504,7 +14551,7 @@ registerBlock("Table", {
14504
14551
  });
14505
14552
 
14506
14553
  // ../shared/src/blocks/quote.ts
14507
- registerBlock("Quote", {
14554
+ registerBuiltinBlock("Quote", {
14508
14555
  schema: external_exports.object({
14509
14556
  quote: external_exports.string().min(1),
14510
14557
  author: external_exports.string().optional(),
@@ -14527,7 +14574,7 @@ registerBlock("Quote", {
14527
14574
  });
14528
14575
 
14529
14576
  // ../shared/src/blocks/video.ts
14530
- registerBlock("Video", {
14577
+ registerBuiltinBlock("Video", {
14531
14578
  schema: external_exports.object({
14532
14579
  src: external_exports.string().min(1),
14533
14580
  title: external_exports.string().optional(),
@@ -14576,7 +14623,8 @@ var FIELD_KINDS = [
14576
14623
  "color",
14577
14624
  "number",
14578
14625
  "boolean",
14579
- "headingLevel"
14626
+ "headingLevel",
14627
+ "reference"
14580
14628
  ];
14581
14629
  var fieldMetaSchema = external_exports.object({
14582
14630
  kind: external_exports.enum(FIELD_KINDS),
@@ -14590,6 +14638,13 @@ var fieldMetaSchema = external_exports.object({
14590
14638
  format: external_exports.enum(["png", "webp", "jpeg"]).optional()
14591
14639
  }).optional(),
14592
14640
  multiline: external_exports.boolean().optional(),
14641
+ /*
14642
+ * Travels with the manifest because the panel is what reads it, and the panel
14643
+ * is in a different process. A key this schema omits is stripped here, not
14644
+ * rejected — so a reference would have arrived in the editor with nothing to
14645
+ * label it and no sign that anything had been declared.
14646
+ */
14647
+ referenceLabelKey: external_exports.string().optional(),
14593
14648
  inline: external_exports.boolean().optional(),
14594
14649
  decorators: external_exports.array(external_exports.object({ name: external_exports.string().min(1), title: external_exports.string().optional() })).optional(),
14595
14650
  required: external_exports.boolean().optional()
@@ -1 +1 @@
1
- import{P as b}from"./chunk-2CNEFIQP-DfR5vtvK.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-C4zGt4iA.js";import{r as s,j as g}from"./index-B8UmizZ0.js";import{E as N,u as U}from"./index-DAQiYlVE.js";import"./index-C6o8aifP.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-DIGKIfTo.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-CAovKdL5.js";import{r as s,j as g}from"./index-5krAO2Jl.js";import{E as N,u as U}from"./index-nC1RD1YE.js";import"./index-CS-vW0iR.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};