@khanacademy/perseus-core 0.0.0-PR3152-20251218202743 → 0.0.0-PR3154-20251219001324

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.
@@ -246,6 +246,15 @@ export type Hint = PerseusRenderer & {
246
246
  * is displayed. This allows for hints that build upon each other.
247
247
  */
248
248
  replace?: boolean;
249
+ /**
250
+ * The UI needs to know how many hints there are before we have
251
+ * answerful PerseusItems. In a crunch, we decided to replace existing hints
252
+ * with empty hints and add a placeholder flag to signal that they're
253
+ * not real hints.
254
+ *
255
+ * TODO(LEMS-3806): there's probably a better way to do this
256
+ */
257
+ placeholder?: boolean;
249
258
  };
250
259
  export type PerseusImageDetail = {
251
260
  width: number;
@@ -150,7 +150,7 @@ const parsePerseusRenderer=defaulted(object({content:defaulted(string,()=>""),wi
150
150
 
151
151
  union(parsePerseusRenderer).or(array(parsePerseusRenderer)).parser;
152
152
 
153
- const parseHint=object({replace:defaulted(optional(boolean),()=>undefined),content:string,widgets:defaulted(parseWidgetsMap,()=>({})),images:parseImages,metadata:any});
153
+ const parseHint=object({replace:defaulted(optional(boolean),()=>undefined),placeholder:defaulted(optional(boolean),()=>undefined),content:string,widgets:defaulted(parseWidgetsMap,()=>({})),images:parseImages,metadata:any});
154
154
 
155
155
  const parsePerseusAnswerArea=pipeParsers(defaulted(object({}),()=>({}))).then(convert(toAnswerArea)).parser;function toAnswerArea(raw){return {calculator:!!raw.calculator,financialCalculatorMonthlyPayment:!!raw.financialCalculatorMonthlyPayment,financialCalculatorTotalAmount:!!raw.financialCalculatorTotalAmount,financialCalculatorTimeToPayOff:!!raw.financialCalculatorTimeToPayOff,periodicTable:!!raw.periodicTable,periodicTableWithKey:!!raw.periodicTableWithKey}}
156
156
 
@@ -186,7 +186,7 @@ const DEFAULT_STATIC=false;const applyDefaultsToWidget=oldWidgetInfo=>{const typ
186
186
 
187
187
  function splitPerseusRenderer(original){const clone=deepClone(original);const originalWidgets=clone.widgets??{};const upgradedWidgets=applyDefaultsToWidgets(originalWidgets);const splitWidgets={};for(const[id,widget]of Object.entries(upgradedWidgets)){if(widget.static){splitWidgets[id]=widget;}else {const publicWidgetOptionsFun=getPublicWidgetOptionsFunction(widget.type);splitWidgets[id]={...widget,options:publicWidgetOptionsFun(widget.options)};}}return {...original,widgets:splitWidgets}}
188
188
 
189
- function splitPerseusItem(original){const item=deepClone(original);return {...item,question:splitPerseusRenderer(item.question),hints:[]}}function splitPerseusItemJSON(data){const parseResult=parseAndMigratePerseusItem(data);if(isFailure(parseResult)){throw new SyntaxError(parseResult.detail.message)}const item=parseResult.value;return JSON.stringify(splitPerseusItem(item))}
189
+ function splitPerseusItem(original){const item=deepClone(original);return {...item,question:splitPerseusRenderer(item.question),hints:original.hints.map(()=>({content:"",widgets:{},images:{},placeholder:true}))}}function splitPerseusItemJSON(data){const parseResult=parseAndMigratePerseusItem(data);if(isFailure(parseResult)){throw new SyntaxError(parseResult.detail.message)}const item=parseResult.value;return JSON.stringify(splitPerseusItem(item))}
190
190
 
191
191
  export { splitPerseusItem, splitPerseusItemJSON };
192
192
  //# sourceMappingURL=index.item-splitting.js.map