@allyhub/sdk 0.9.0 → 0.10.0
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/CHANGELOG.md +8 -0
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.d.ts +3 -0
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +2 -2
- package/dist/node_modules/@allyhub/chart/dist/chart.d.ts +22 -0
- package/dist/node_modules/@allyhub/chart/dist/chart.js +1 -1
- package/dist/node_modules/@allyhub/chart/package.json +1 -1
- package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/faces.d.ts +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +87 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +89 -0
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +50 -0
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
- package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/measure/package.json +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
- package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +16 -0
- package/dist/node_modules/@allyhub/piece/dist/page/locate.js +1 -1
- package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +6 -0
- package/dist/node_modules/@allyhub/piece/package.json +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +132 -0
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +19 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.d.ts +337 -0
- package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +153 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +4 -2
- package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +43 -188
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +1 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +1 -0
- package/dist/node_modules/@allyhub/protocol/dist/mail.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +51 -91
- package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +3 -3
- package/dist/node_modules/@allyhub/protocol/package.json +5 -1
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/index.d.ts +2 -2
- package/dist/node_modules/@allyhub/scenery/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/moire.d.ts +45 -5
- package/dist/node_modules/@allyhub/scenery/dist/moire.js +2 -2
- package/dist/node_modules/@allyhub/scenery/dist/phone.d.ts +4 -3
- package/dist/node_modules/@allyhub/scenery/dist/phone.js +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.d.ts +70 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/kernels.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/maths.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.d.ts +9 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/types.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/types.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/chart.d.ts +9 -0
- package/dist/node_modules/@allyhub/sheet/dist/chart.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/ast.d.ts +12 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/move.d.ts +5 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/move.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/print.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +2 -1
- package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/inspect.d.ts +12 -2
- package/dist/node_modules/@allyhub/sheet/dist/inspect.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/printed.d.ts +19 -0
- package/dist/node_modules/@allyhub/sheet/dist/printed.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/values.d.ts +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/values.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/workbook.d.ts +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/write.js +15 -15
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.d.ts +6 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/formula.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.d.ts +0 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.d.ts +7 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.js +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.d.ts +12 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.js +3 -2
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/api.d.ts +57 -7
- package/dist/node_modules/@allyhub/slides-core/dist/api.js +2 -2
- package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/enums.d.ts +24 -0
- package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/fact.d.ts +15 -0
- package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +6 -2
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +3 -1
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/piece.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/schema.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/schema.js +1 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/dist/phone.d.ts +12 -5
- package/dist/node_modules/@allyhub/video-sdk/dist/phone.js +1 -1
- package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
- package/docs/README.md +2 -0
- package/docs/canvas.md +28 -0
- package/docs/defaults.md +20 -2
- package/docs/docs.md +8 -8
- package/docs/scenery.md +3 -4
- package/docs/sheets.md +22 -5
- package/docs/slides.md +50 -4
- package/docs/speech.md +1 -1
- package/docs/x.md +73 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{colorOfFile as ee}from"@allyhub/formats";import{readMarks as _e,markRuns as be}from"@allyhub/piece";import{chartOfFile as ye}from"@allyhub/chart";import{AUTOSHAPE_STYLE as C,SHADOW_DEFAULTS as H,CONNECTOR_STYLE as ne,DRAWN_TEXTBOX_FRAME as te,TEXT_FALLBACK as ie,TEXT_INSETS as W,isConnectorGeometry as $e,placeholderFrame as xe,styleKindOf as we}from"./office.js";import{resolveAnimation as ke,resolveTransition as oe}from"./animation.js";import{glued as ve}from"./connect.js";import{pathSteps as Se}from"./path.js";import{masterPlaceholder as Ae}from"./placeholders.js";import{DECK_FONTS as Oe,OFFICE_THEME as Te,themeOver as je}from"./theme.js";import{Pt as O}from"./units.js";export function joinPath(i,t){if(t.startsWith("/"))return t.slice(1);const u=i===""?[]:i.split("/");for(const r of t.split("/"))r===""||r==="."||(r===".."?u.pop():u.push(r));return u.join("/")}const re={left:0,top:0,width:0,height:0},U=()=>Array.from({length:9},()=>({...ie,font:{...ie.font},margin_left:0}));export function levelsOver(i,...t){return i.map((u,r)=>{let o={...u,font:{...u.font}};for(const $ of t){const l=$?.[r];l&&(o={...o,...l.alignment===void 0?{}:{alignment:l.alignment},...l.line_spacing===void 0?{}:{line_spacing:l.line_spacing},...l.space_before===void 0?{}:{space_before:l.space_before},...l.space_after===void 0?{}:{space_after:l.space_after},...l.margin_left===void 0?{}:{margin_left:l.margin_left},...l.indent===void 0?{}:{indent:l.indent},font:{...o.font,...l.font}},l.numbered!==void 0&&(o.numbered=l.numbered,delete o.bullet),l.bullet===null?(delete o.bullet,delete o.numbered):l.bullet!==void 0?(delete o.numbered,o.bullet={char:l.bullet,...l.bullet_font===void 0?{}:{font:l.bullet_font}}):l.bullet_font!==void 0&&o.bullet&&(o.bullet={...o.bullet,font:l.bullet_font}))}return o})}function I(i,...t){const u=t.filter(o=>o!==void 0),r=o=>{for(let $=u.length-1;$>=0;$--){const l=u[$]?.[o];if(l!==void 0)return l}};return{vertical_anchor:r("vertical_anchor")??i.vertical_anchor,auto_size:r("auto_size")??i.auto_size,word_wrap:r("word_wrap")??i.word_wrap,margins:{left:r("margin_left")??W.left,top:r("margin_top")??W.top,right:r("margin_right")??W.right,bottom:r("margin_bottom")??W.bottom}}}const ae={vertical_anchor:"t",auto_size:"none",word_wrap:!0};export const plainLevels=i=>levelsOver(U(),i.text_styles.other);function V(i,t){return{...I(ae,t),levels:levelsOver(U(),i.text_styles.other,t.levels)}}function Ee(i,t,...u){return{...I(xe(t),...u),levels:levelsOver(U(),i.text_styles[we(t)],...u.map(r=>r?.levels))}}const Fe=Array.from({length:9},()=>({font:{color:C.font_color}})),de={vertical_anchor:C.vertical_anchor};function le(i,t){return{...I(ae,t),levels:levelsOver(U(),i.text_styles.other,Fe,t.levels)}}const X=i=>{const t={...i};return delete t.paragraphs,t},G=i=>({paragraphs:[],levels:[],...i}),z=i=>i==="none"?null:colorOfFile(i),Ne=/<span((?:\s+(?:color|font|size|bold|italic|underline|link|highlight|baseline|strike)="[^"\n]*")+)\s*>(.*?)<\/span>/gu,ze=/(color|font|size|bold|italic|underline|link|highlight|baseline|strike)="([^"\n]*)"/gu,K=57344,Me=256,se="",Ce=/[\ue000-\ue100]|[^\ue000-\ue100]+/gu;export const colorOfFile=i=>ee(i)??"dk1";function Z(i){const{shadow:t,gradient:u}=i;return{...i.fill_transparency===void 0?{}:{fill_transparency:i.fill_transparency},...u?{gradient:{angle:u.angle??0,stops:u.stops.map(r=>({at:r.at,color:colorOfFile(r.color),...r.transparency===void 0?{}:{transparency:r.transparency}}))}}:{},...t?{shadow:{color:t.color===void 0?H.color:colorOfFile(t.color),blur:t.blur===void 0?H.blur:O(t.blur),distance:t.distance===void 0?H.distance:O(t.distance),angle:t.angle??H.angle,transparency:t.transparency??H.transparency}}:{}}}function fe(i,t,u=[]){return{...i,rows:i.rows.map((r,o)=>({height:r.height,cells:r.cells.map($=>{const l=u[o];return{...$,text:{paragraphs:$.text.paragraphs,style:B({...V(t,$.text),auto_size:"shape"},l),own:X($.text),empty:!1},...l?{fileText:l}:{}}})}))}}function B(i,t){return t?{...i,...t.anchor===void 0?{}:{vertical_anchor:t.anchor},levels:i.levels.map(u=>{const r={...u.font,...t.size===void 0?{}:{size:O(t.size)},...t.bold===void 0?{}:{bold:t.bold},...t.italic===void 0?{}:{italic:t.italic},...t.underline===void 0?{}:{underline:t.underline},...t.strike===void 0?{}:{strike:t.strike},...t.font===void 0?{}:{name:t.font}};t.color!==void 0&&(r.color=colorOfFile(t.color));const o={...u,font:r,...t.align===void 0?{}:{alignment:t.align},...t.line_spacing===void 0?{}:{line_spacing:{lines:t.line_spacing}},...t.space_before===void 0?{}:{space_before:O(t.space_before)},...t.space_after===void 0?{}:{space_after:O(t.space_after)}};return t.numbered!==void 0?(o.numbered=t.numbered,delete o.bullet):t.bullet===!1?(delete o.bullet,delete o.numbered):t.bullet!==void 0&&(o.bullet={char:t.bullet},delete o.numbered),(t.numbered!==void 0||t.bullet!==void 0&&t.bullet!==!1)&&u.margin_left===0?{...o,margin_left:ue,indent:-ue}:o})}:i}function Pe(i,t){if(!t)return[...i];const u=t.numbered!==void 0||t.bullet!==void 0;return i.map(r=>{const o={...r};return t.align!==void 0&&delete o.alignment,t.line_spacing!==void 0&&delete o.line_spacing,t.space_before!==void 0&&delete o.space_before,t.space_after!==void 0&&delete o.space_after,u&&(delete o.bullet,delete o.bullet_font,delete o.numbered),o})}function Le(i){const t={};for(const[,u,r=""]of i.matchAll(ze))if(u==="font")t.name=r.trim();else if(u==="link")t.link=r.trim();else if(u==="highlight")t.highlight=r.trim().toUpperCase();else if(u==="bold")t.bold=r.trim()!=="false";else if(u==="italic")t.italic=r.trim()!=="false";else if(u==="strike")t.strike=r.trim()!=="false";else if(u==="underline")t.underline=r.trim()!=="false";else if(u==="size"){const o=Number(r);Number.isFinite(o)&&o>0&&(t.size=O(o))}else if(u==="baseline"){const o=Number(r);Number.isFinite(o)&&(t.baseline=o)}else{const o=ee(r.trim());o!==void 0&&(t.color=o)}return t}const ue=342900;export function paragraphsOfWords(i,t=0,u=Oe.code){return i===void 0?[]:typeof i=="string"?i.split(/\r?\n/u).map(r=>{const o=[],$=r.replace(Ne,(E,N,P)=>(o.push(Le(N)),`${String.fromCharCode(K+o.length-1)}${P}${se}`)),l=_e($);let F;const M=be(l.text,l.marks).flatMap(E=>{const N=E.kinds.includes("code"),P={...E.kinds.includes("strong")?{bold:!0}:{},...E.kinds.includes("em")?{italic:!0}:{},...N?{name:u}:{}};return[...E.text.matchAll(Ce)].flatMap(Y=>{const L=Y[0],R=L.charCodeAt(0);if(L===se)return F=void 0,[];if(R>=K&&R<K+Me)return F=o[R-K],[];const D={...F,...P};return[{text:L,...Object.keys(D).length>0?{font:D}:{},...N?{code:!0}:{}}]})});return{runs:M.length>0?M:[{text:""}],level:t}}):i.flatMap(r=>paragraphsOfWords(r,Array.isArray(r)?Math.min(t+1,8):t,u))}const ce=i=>({left:O(i.x),top:O(i.y),width:O(i.w),height:O(i.h)}),Re=new Set(["dt","ftr","sldNum"]),pe=i=>({...i.locked?{locked:!0}:{},...i.rotation===void 0||i.rotation===0?{}:{rotation:i.rotation},...i.flip_h||i.flip_v?{flip:{...i.flip_h?{h:!0}:{},...i.flip_v?{v:!0}:{}}}:{}});function he(i,t,u){if(!t)return;t.fill!==void 0&&(i.background=colorOfFile(t.fill));const r=t.gradient&&Z({gradient:t.gradient}).gradient;r&&(i.background_gradient=r),t.picture!==void 0&&(i.background_picture=joinPath(u,t.picture))}const me=i=>i===void 0?void 0:{left:i.left??0,top:i.top??0,right:i.right??0,bottom:i.bottom??0};export function resolveDeck(i){const{code:t,file:u,words:r,prefix:o,base:$}=i,l=[],F=je(i.theme??Te,t.theme),M=new Map;for(const e of t.masters)for(const n of e.layouts)M.set(n.name,{layout:n,master:e});const E=[],N=(e,n,a)=>({name:e.name,kind:e.kind,frame:{...e.frame??re},...e.flip?{flip:{...e.flip}}:{},...e.connect?{connect:{...e.connect.begin?{begin:{...e.connect.begin}}:{},...e.connect.end?{end:{...e.connect.end}}:{}}}:{},...e.rotation===void 0?{}:{rotation:e.rotation},level:n,...e.text?{text:{paragraphs:e.text.paragraphs,style:e.kind==="autoshape"?le(a,e.text):V(a,e.text),own:X(e.text),empty:!1}}:{},...e.fill===void 0?{}:{fill:e.fill},...e.fill_transparency===void 0?{}:{fill_transparency:e.fill_transparency},...e.gradient?{gradient:e.gradient}:{},...e.shadow?{shadow:e.shadow}:{},...e.line===void 0?{}:{line:e.line},...e.line_width===void 0?{}:{line_width:e.line_width},...e.line_dash===void 0?{}:{line_dash:e.line_dash},...e.line_begin===void 0?{}:{line_begin:e.line_begin},...e.line_end===void 0?{}:{line_end:e.line_end},...e.path?{path:e.path}:{},...e.table?{table:fe(e.table,a)}:{},...e.chart?{chart:e.chart}:{},...e.group===void 0?{}:{group:e.group},...e.geometry?{geometry:e.geometry}:{},...e.adjustments?{adjustments:[...e.adjustments]}:{},...e.media?{media:{path:joinPath(e.media.base,e.media.path),...e.media.poster===void 0?{}:{poster:e.media.poster}}}:{},...e.component?{component:{...e.component}}:{},sources:{frame:{from:n}}}),P=(e,n)=>{const a=e.placeholder?.type??"body",m=Ae(n,a),_=e.frame??m?.frame??re;return{name:e.name,kind:"placeholder",frame:{..._},level:"slide",...e.placeholder?{placeholder:{...e.placeholder}}:{},text:{paragraphs:[],style:Ee(n,a,m?.text,e.text),empty:!0},...e.fill===void 0?{}:{fill:e.fill},...e.line===void 0?{}:{line:e.line},sources:{frame:{from:e.frame||!m?"layout":"master"},text:{from:"layout"}}}},Y=(e,n,a,m)=>{const _=t.components[e];if(!_){l.push({...a,message:/\.[cm]?[jt]sx?(?:#|$)/u.test(e)?`${e} names no component: its module has no such export, or the export is not made with defineComponent.`:`There is no component ${e} in the deck's module (it has ${Object.keys(t.components).join(", ")||"none"}).`});return}for(const b of Object.keys(n??{}))Object.hasOwn(_.props,b)||l.push({...a,message:`Component ${e} has no prop ${b} a person sets (it has ${Object.keys(_.props).join(", ")||"none"}).`});return{name:e,props:{...n??{}},...m===void 0?{}:{dur:m}}},L=(e,n,a,m,_)=>{const b={slide:m,shape:e,path:a};if(!n.frame){l.push({...b,message:`Shape ${e} is the slide's own: it needs a frame { x, y, w, h } in points.`});return}const w=ce(n.frame),s={frame:{from:"slide",path:`${a}.frame`}},y={name:e,frame:w,level:"slide",...n.fill===void 0?{}:{fill:z(n.fill)},...Z(n),...n.line===void 0?{}:{line:z(n.line)},...n.line_dash===void 0?{}:{line_dash:n.line_dash},...n.line_begin===void 0?{}:{line_begin:n.line_begin},...n.line_end===void 0?{}:{line_end:n.line_end},...n.group===void 0?{}:{group:n.group},...pe(n)};if(n.textbox)return{...y,kind:"textbox",text:{paragraphs:paragraphsOfWords(r(`${o}.${m}.${e}`),0,F.fonts.code),style:B(V(_,G(te)),n.text),own:X(G(te)),empty:!1},...n.text?{fileText:{...n.text}}:{},sources:{...s,text:{from:"slide",path:`${a}.text`}}};if(n.picture!==void 0){const f=me(n.crop);return{...y,kind:"picture",media:{path:joinPath($,n.picture),...f?{crop:f}:{}},sources:{...s,media:{from:"slide",path:`${a}.picture`}}}}if(n.movie!==void 0)return{...y,kind:"movie",media:{path:joinPath($,n.movie),...n.poster===void 0?{}:{poster:n.poster}},sources:{...s,media:{from:"slide",path:`${a}.movie`}}};if(n.chart){const f=r(`${o}.${m}.${e}`),S=ye(n.chart,{title:typeof f=="string"?f:void 0,base:$,rows:g=>i.data?.(g),problem:g=>{l.push({...b,message:`Chart ${e}: ${g}`})}});return S?{...y,kind:"chart",chart:S,sources:s}:void 0}if(n.table){const f=n.table,S=w.width/f.columns.reduce((d,c)=>d+c,0),g=w.height/f.rows.reduce((d,c)=>d+c.height,0),v=r(`${o}.${m}.${e}`),T=Array.isArray(v)?v:[];return T.length>f.rows.length&&l.push({...b,message:`Table ${e} has ${String(f.rows.length)} rows and its words ${String(T.length)}.`}),{...y,kind:"table",table:fe({columns:f.columns.map(d=>Math.round(d*S)),rows:f.rows.map((d,c)=>{const p=T[c],x=Array.isArray(p)?p:p===void 0?[]:[p];return{height:Math.round(d.height*g),cells:f.columns.map((k,A)=>({text:{levels:[],paragraphs:paragraphsOfWords(x[A],0,F.fonts.code)},...d.fill===void 0?{}:{fill:colorOfFile(d.fill)},...d.line===void 0?{}:{borders:{bottom:{color:colorOfFile(d.line),width:O(1)}}}}))}})},_,f.rows.map(d=>d.text)),sources:s}}const h=n.path&&Se(n.path.d);if(n.path&&!h){l.push({...b,message:`Shape ${e}'s path starts with M and says only M, L, C and Z, absolute.`});return}if(n.geometry!==void 0||n.path&&h){const f=!n.path&&$e(n.geometry);return{...y,kind:"autoshape",...n.path&&h?{path:{w:n.path.w,h:n.path.h,steps:h}}:n.geometry===void 0?{}:{geometry:n.geometry,...n.adjustments?{adjustments:[...n.adjustments]}:{}},...f?{line:n.line===void 0?ne.line:z(n.line),line_width:n.line_width===void 0?ne.line_width:O(n.line_width)}:{fill:n.fill===void 0?C.fill:z(n.fill),line:n.line===void 0?C.line:z(n.line),line_width:n.line_width===void 0?C.line_width:O(n.line_width)},...n.text&&!f?{fileText:{...n.text}}:{},...f?{}:{text:{paragraphs:paragraphsOfWords(r(`${o}.${m}.${e}`)).map(S=>n.text?.align===void 0?{alignment:C.alignment,...S}:S),style:B(le(_,G(de)),n.text),own:X(G(de)),empty:!1}},sources:{...s,fill:{from:"slide",path:`${a}.fill`}}}}if(n.component!==void 0){const f=Y(n.component,n.props,b,n.dur);return f?{...y,kind:"component",component:f,sources:s}:void 0}},R=(e,n,a)=>{if(n.frame&&(e.frame=ce(n.frame),e.sources.frame={from:"slide",path:`${a}.frame`}),Object.assign(e,pe(n)),n.dur!==void 0&&e.component&&(e.component={...e.component,dur:n.dur}),n.text&&e.text&&(e.text.style=B(e.text.style,n.text),e.text.paragraphs=Pe(e.text.paragraphs,n.text),e.fileText={...n.text},e.sources.text={from:"slide",path:`${a}.text`}),n.line!==void 0&&(e.line=z(n.line),e.sources.line={from:"slide",path:`${a}.line`}),n.line_width!==void 0&&(e.line_width=O(n.line_width)),n.line_dash!==void 0&&(e.line_dash=n.line_dash),n.line_begin!==void 0&&(e.line_begin=n.line_begin),n.line_end!==void 0&&(e.line_end=n.line_end),n.fill!==void 0&&(e.fill=z(n.fill),e.sources.fill={from:"slide",path:`${a}.fill`}),Object.assign(e,Z(n)),(n.picture!==void 0||n.movie!==void 0)&&(e.placeholder?.type==="pic"||e.placeholder?.type==="media"||e.placeholder?.type==="obj")){const m=me(n.crop);e.kind=n.picture!==void 0?"picture":"movie",e.media={path:joinPath($,n.picture??n.movie??""),...m?{crop:m}:{},...n.poster===void 0?{}:{poster:n.poster}},e.sources.media={from:"slide",path:`${a}.${n.picture!==void 0?"picture":"movie"}`},delete e.text}},D=(e,n,a,m,_)=>{const b=M.get(n);if(!b){l.push({slide:e,path:`slides.${String(a)}.layout`,message:`Slide ${e} is on the layout "${n}", which the deck's module does not have (it has ${[...M.keys()].join(", ")||"none"}).`});return}const{layout:w,master:s}=b,y=[...(w.display_master_shapes===!1?[]:s.shapes).filter(f=>f.kind!=="placeholder").map(f=>N(f,"master",s)),...w.shapes.filter(f=>f.kind!=="placeholder").map(f=>N(f,"layout",s))],h=w.shapes.filter(f=>f.kind==="placeholder").map((f,S)=>({shape:P(f,s),order:S}));return{slide:{id:e,layout:w.name,master:s.name,hidden:m,background:w.background??s.background,shapes:y,animations:[],file:{index:a,..._===void 0?{}:{generate:_}}},placed:h,master:s}},q=(e,n,a)=>{if(!n)return;const m=w=>{const s=n[w];if(s===void 0)return e.connect?.[w];const y=s==="none"?void 0:a(s.shape);return s==="none"||y===void 0?void 0:{shape:y,site:s.site}},_=m("begin"),b=m("end");_||b?e.connect={..._?{begin:_}:{},...b?{end:b}:{}}:delete e.connect},J=(e,n,a,m,_,b,w,s,y,h=()=>{})=>{const f=new Set(a.map(d=>d.shape.name));let S=a.length;for(const[d,c]of Object.entries(m??{})){const p=b(d);if(p===void 0)continue;const x=`${_}.shapes.${d}`,k=c.textbox!==void 0||c.geometry!==void 0||c.path!==void 0||c.table!==void 0||c.chart!==void 0||c.component!==void 0||(c.picture!==void 0||c.movie!==void 0)&&!f.has(p),A=a.find(ge=>ge.shape.name===p);if(A&&!k){R(A.shape,c,x),q(A.shape,c.connect,b),A.shown=!0,c.z!==void 0&&(A.z=c.z);continue}if(A){l.push({slide:e.id,shape:p,path:x,message:`Slide ${e.id} has a ${A.shape.kind} ${p} already: a shape of its own needs another name.`});continue}if(!k){l.push({slide:e.id,shape:p,path:x,message:`Slide ${e.id} has no shape ${p} to change (its layout's placeholders and its own shapes are ${[...f].join(", ")||"none"}).`});continue}const j=L(p,c,x,e.id,n);j&&q(j,c.connect,b),j&&(a.push({shape:j,order:S++,...c.z===void 0?{}:{z:c.z}}),f.add(p))}const g=a.filter(d=>d.shown===!0||!Re.has(d.shape.placeholder?.type??"")||w(d.shape)!==void 0);a.splice(0,a.length,...g),a.sort((d,c)=>(d.z??0)-(c.z??0)||d.order-c.order);const v=new Map(a.flatMap((d,c)=>d.shape.group===void 0?[]:[[d.shape.group,c]])),T=a.flatMap((d,c)=>{const p=d.shape.group;return p===void 0?[d]:v.get(p)===c?a.filter(x=>x.shape.group===p):[]});a.splice(0,a.length,...T);for(const d of a){const c=h(d.shape);c!==void 0&&(d.shape.alt=c);const p=d.shape.text;if(d.shape.kind==="placeholder"&&p){const x=w(d.shape);p.paragraphs=paragraphsOfWords(x,0,F.fonts.code),p.empty=p.paragraphs.length===0||p.paragraphs.every(k=>k.runs.every(A=>A.text===""))}}e.shapes.push(...a.map(d=>d.shape));for(const d of e.shapes){const c=d.connect;if(!c)continue;const p=ve(d,x=>e.shapes.find(k=>k.name===x&&k.level===d.level&&k!==d));d.frame=p.frame,p.flip?d.flip=p.flip:delete d.flip;for(const x of p.lost){const k=c[x];k&&d.level==="slide"&&l.push({slide:e.id,shape:d.name,message:`Connector ${d.name}'s ${x} is glued to site ${String(k.site)} of ${k.shape}, which slide ${e.id} has not: it stays where it is.`})}}s!==void 0&&s.trim()!==""&&(e.notes=s);for(const[d,c]of(y??[]).entries()){const p=b(c.shape);if(p===void 0)continue;const x={slide:e.id,shape:p,path:`${_}.animations.${String(d)}`},k=e.shapes.find(j=>j.name===p&&j.level==="slide");if(!k){l.push({...x,message:`Slide ${e.id} has no shape ${p} to animate (it has ${e.shapes.filter(j=>j.level==="slide").map(j=>j.name).join(", ")}).`});continue}if(c.paragraph!==void 0&&c.paragraph>=(k.text?.paragraphs.length??0)){l.push({...x,message:`Shape ${p} has no paragraph ${String(c.paragraph)} to animate (it has ${String(k.text?.paragraphs.length??0)}).`});continue}const A=ke({...c,shape:p});A?e.animations.push(A):l.push({...x,message:`The animation of ${p} needs a path that starts with M and says only M, L and C, absolute.`})}},Q=new Set;return u.slides.forEach((e,n)=>{const a=`slides.${String(n)}`;if(e.layout!==void 0){const s=D(e.id,e.layout,n,e.hidden===!0);if(!s)return;const y=r(`${o}.${e.id}.notes`);e.transition&&(s.slide.transition=oe(e.transition)),e.advance_after!==void 0&&(s.slide.advance=e.advance_after),he(s.slide,e.background,$),J(s.slide,s.master,s.placed,e.shapes,a,h=>h,h=>r(`${o}.${e.id}.${h.name}`),typeof y=="string"?y:void 0,e.animations,h=>{const f=r(`${o}.${e.id}.alt.${h.name}`);return typeof f=="string"?f:void 0}),E.push(s.slide),Q.add(e.id);return}const m=e.generate??"",_=t.generators[m];if(_===void 0){l.push({slide:e.id,path:`${a}.generate`,message:`There is no generator ${m} in the deck's module (it has ${Object.keys(t.generators).join(", ")||"none"}).`});return}if(!Array.isArray(_)){l.push({slide:e.id,path:`${a}.generate`,message:`Generator ${m} threw: ${_.error}`,..._.stack===void 0?{}:{stack:_.stack}});return}const b=_,w=new Set(Array.isArray(e.hidden)?e.hidden:[]);for(const s of b){const y=`${e.id}/${s.id}`,h=D(y,s.layout,n,w.has(s.id),m);if(!h)continue;for(const g of s.shapes){const v=g.placeholder?h.placed.find(T=>T.shape.placeholder?.idx===g.placeholder?.idx):void 0;if(v)g.frame&&(v.shape.frame={...g.frame}),v.shape.sources.frame={from:"code"},v.shown=!0;else{const T=N(g,"layout",h.master);h.placed.push({shape:{...T,level:"slide",sources:{frame:{from:"code"}}},order:h.placed.length})}}const f=`${s.id}/`,S=s.transition??(s===b[0]?e.transition:void 0);he(h.slide,e.background,$),S&&(h.slide.transition=oe(S)),J(h.slide,h.master,h.placed,e.shapes,a,g=>g.startsWith(f)?g.slice(f.length):void 0,g=>{const v=g.placeholder===void 0?void 0:s.text[g.placeholder.idx];return v===void 0?void 0:v.map(T=>T.runs.map(d=>d.text).join(""))},s.notes,[...(s.animations??[]).map(g=>({...g,shape:`${f}${g.shape}`})),...e.animations??[]]);for(const g of h.slide.shapes){const v=g.placeholder===void 0?void 0:s.text[g.placeholder.idx];v&&g.text&&(g.text.paragraphs=v,g.text.empty=!1)}E.push(h.slide),Q.add(y)}for(const s of Object.keys(e.shapes??{})){const[y]=s.split("/");y!==void 0&&!b.some(h=>h.id===y)&&l.push({slide:e.id,path:`${a}.shapes.${s}`,message:`Generator ${m} makes no slide ${y}: ${s} changes nothing.`})}}),E.forEach((e,n)=>{for(const a of e.shapes)a.placeholder?.type==="sldNum"&&a.text&&(a.text.paragraphs=[{level:0,runs:[{text:String(n+1),field:"slidenum"}]}],a.text.empty=!1)}),{deck:{width:t.slide_width,height:t.slide_height,theme:F,slides:E},problems:l}}
|
|
2
|
+
import{colorOfFile as ee}from"@allyhub/formats";import{readMarks as _e,markRuns as be}from"@allyhub/piece";import{chartOfFile as ye}from"@allyhub/chart";import{AUTOSHAPE_STYLE as C,SHADOW_DEFAULTS as H,CONNECTOR_STYLE as ne,DRAWN_TEXTBOX_FRAME as te,TEXT_FALLBACK as ie,TEXT_INSETS as W,isConnectorGeometry as $e,placeholderFrame as xe,styleKindOf as we}from"./office.js";import{resolveAnimation as ke,resolveTransition as oe}from"./animation.js";import{glued as ve}from"./connect.js";import{pathSteps as Se}from"./path.js";import{masterPlaceholder as Ae}from"./placeholders.js";import{DECK_FONTS as Oe,OFFICE_THEME as ze,themeOver as Te}from"./theme.js";import{Pt as O}from"./units.js";export function joinPath(i,t){if(t.startsWith("/"))return t.slice(1);const u=[];for(const r of[...i.split("/"),...t.split("/")])r===""||r==="."||(r===".."?u.pop():u.push(r));return u.join("/")}const re={left:0,top:0,width:0,height:0},U=()=>Array.from({length:9},()=>({...ie,font:{...ie.font},margin_left:0}));export function levelsOver(i,...t){return i.map((u,r)=>{let o={...u,font:{...u.font}};for(const $ of t){const l=$?.[r];l&&(o={...o,...l.alignment===void 0?{}:{alignment:l.alignment},...l.line_spacing===void 0?{}:{line_spacing:l.line_spacing},...l.space_before===void 0?{}:{space_before:l.space_before},...l.space_after===void 0?{}:{space_after:l.space_after},...l.margin_left===void 0?{}:{margin_left:l.margin_left},...l.indent===void 0?{}:{indent:l.indent},font:{...o.font,...l.font}},l.numbered!==void 0&&(o.numbered=l.numbered,delete o.bullet),l.bullet===null?(delete o.bullet,delete o.numbered):l.bullet!==void 0?(delete o.numbered,o.bullet={char:l.bullet,...l.bullet_font===void 0?{}:{font:l.bullet_font}}):l.bullet_font!==void 0&&o.bullet&&(o.bullet={...o.bullet,font:l.bullet_font}))}return o})}function I(i,...t){const u=t.filter(o=>o!==void 0),r=o=>{for(let $=u.length-1;$>=0;$--){const l=u[$]?.[o];if(l!==void 0)return l}};return{vertical_anchor:r("vertical_anchor")??i.vertical_anchor,auto_size:r("auto_size")??i.auto_size,word_wrap:r("word_wrap")??i.word_wrap,margins:{left:r("margin_left")??W.left,top:r("margin_top")??W.top,right:r("margin_right")??W.right,bottom:r("margin_bottom")??W.bottom}}}const ae={vertical_anchor:"t",auto_size:"none",word_wrap:!0};export const plainLevels=i=>levelsOver(U(),i.text_styles.other);function V(i,t){return{...I(ae,t),levels:levelsOver(U(),i.text_styles.other,t.levels)}}function je(i,t,...u){return{...I(xe(t),...u),levels:levelsOver(U(),i.text_styles[we(t)],...u.map(r=>r?.levels))}}const Ee=Array.from({length:9},()=>({font:{color:C.font_color}})),de={vertical_anchor:C.vertical_anchor};function le(i,t){return{...I(ae,t),levels:levelsOver(U(),i.text_styles.other,Ee,t.levels)}}const X=i=>{const t={...i};return delete t.paragraphs,t},G=i=>({paragraphs:[],levels:[],...i}),N=i=>i==="none"?null:colorOfFile(i),Fe=/<span((?:\s+(?:color|font|size|bold|italic|underline|link|highlight|baseline|strike)="[^"\n]*")+)\s*>(.*?)<\/span>/gu,Ne=/(color|font|size|bold|italic|underline|link|highlight|baseline|strike)="([^"\n]*)"/gu,K=57344,Me=256,se="",Ce=/[\ue000-\ue100]|[^\ue000-\ue100]+/gu;export const colorOfFile=i=>ee(i)??"dk1";function Z(i){const{shadow:t,gradient:u}=i;return{...i.fill_transparency===void 0?{}:{fill_transparency:i.fill_transparency},...u?{gradient:{angle:u.angle??0,stops:u.stops.map(r=>({at:r.at,color:colorOfFile(r.color),...r.transparency===void 0?{}:{transparency:r.transparency}}))}}:{},...t?{shadow:{color:t.color===void 0?H.color:colorOfFile(t.color),blur:t.blur===void 0?H.blur:O(t.blur),distance:t.distance===void 0?H.distance:O(t.distance),angle:t.angle??H.angle,transparency:t.transparency??H.transparency}}:{}}}function fe(i,t,u=[]){return{...i,rows:i.rows.map((r,o)=>({height:r.height,cells:r.cells.map($=>{const l=u[o];return{...$,text:{paragraphs:$.text.paragraphs,style:B({...V(t,$.text),auto_size:"shape"},l),own:X($.text),empty:!1},...l?{fileText:l}:{}}})}))}}function B(i,t){return t?{...i,...t.anchor===void 0?{}:{vertical_anchor:t.anchor},levels:i.levels.map(u=>{const r={...u.font,...t.size===void 0?{}:{size:O(t.size)},...t.bold===void 0?{}:{bold:t.bold},...t.italic===void 0?{}:{italic:t.italic},...t.underline===void 0?{}:{underline:t.underline},...t.strike===void 0?{}:{strike:t.strike},...t.font===void 0?{}:{name:t.font}};t.color!==void 0&&(r.color=colorOfFile(t.color));const o={...u,font:r,...t.align===void 0?{}:{alignment:t.align},...t.line_spacing===void 0?{}:{line_spacing:{lines:t.line_spacing}},...t.space_before===void 0?{}:{space_before:O(t.space_before)},...t.space_after===void 0?{}:{space_after:O(t.space_after)}};return t.numbered!==void 0?(o.numbered=t.numbered,delete o.bullet):t.bullet===!1?(delete o.bullet,delete o.numbered):t.bullet!==void 0&&(o.bullet={char:t.bullet},delete o.numbered),(t.numbered!==void 0||t.bullet!==void 0&&t.bullet!==!1)&&u.margin_left===0?{...o,margin_left:ue,indent:-ue}:o})}:i}function Pe(i,t){if(!t)return[...i];const u=t.numbered!==void 0||t.bullet!==void 0;return i.map(r=>{const o={...r};return t.align!==void 0&&delete o.alignment,t.line_spacing!==void 0&&delete o.line_spacing,t.space_before!==void 0&&delete o.space_before,t.space_after!==void 0&&delete o.space_after,u&&(delete o.bullet,delete o.bullet_font,delete o.numbered),o})}function Le(i){const t={};for(const[,u,r=""]of i.matchAll(Ne))if(u==="font")t.name=r.trim();else if(u==="link")t.link=r.trim();else if(u==="highlight")t.highlight=r.trim().toUpperCase();else if(u==="bold")t.bold=r.trim()!=="false";else if(u==="italic")t.italic=r.trim()!=="false";else if(u==="strike")t.strike=r.trim()!=="false";else if(u==="underline")t.underline=r.trim()!=="false";else if(u==="size"){const o=Number(r);Number.isFinite(o)&&o>0&&(t.size=O(o))}else if(u==="baseline"){const o=Number(r);Number.isFinite(o)&&(t.baseline=o)}else{const o=ee(r.trim());o!==void 0&&(t.color=o)}return t}const ue=342900;export function paragraphsOfWords(i,t=0,u=Oe.code){return i===void 0?[]:typeof i=="string"?i.split(/\r?\n/u).map(r=>{const o=[],$=r.replace(Fe,(j,F,P)=>(o.push(Le(F)),`${String.fromCharCode(K+o.length-1)}${P}${se}`)),l=_e($);let E;const M=be(l.text,l.marks).flatMap(j=>{const F=j.kinds.includes("code"),P={...j.kinds.includes("strong")?{bold:!0}:{},...j.kinds.includes("em")?{italic:!0}:{},...F?{name:u}:{}};return[...j.text.matchAll(Ce)].flatMap(Y=>{const L=Y[0],R=L.charCodeAt(0);if(L===se)return E=void 0,[];if(R>=K&&R<K+Me)return E=o[R-K],[];const D={...E,...P};return[{text:L,...Object.keys(D).length>0?{font:D}:{},...F?{code:!0}:{}}]})});return{runs:M.length>0?M:[{text:""}],level:t}}):i.flatMap(r=>paragraphsOfWords(r,Array.isArray(r)?Math.min(t+1,8):t,u))}const ce=i=>({left:O(i.x),top:O(i.y),width:O(i.w),height:O(i.h)}),Re=new Set(["dt","ftr","sldNum"]),pe=i=>({...i.locked?{locked:!0}:{},...i.rotation===void 0||i.rotation===0?{}:{rotation:i.rotation},...i.flip_h||i.flip_v?{flip:{...i.flip_h?{h:!0}:{},...i.flip_v?{v:!0}:{}}}:{}});function he(i,t,u){if(!t)return;t.fill!==void 0&&(i.background=colorOfFile(t.fill));const r=t.gradient&&Z({gradient:t.gradient}).gradient;r&&(i.background_gradient=r),t.picture!==void 0&&(i.background_picture=joinPath(u,t.picture))}const me=i=>i===void 0?void 0:{left:i.left??0,top:i.top??0,right:i.right??0,bottom:i.bottom??0};export function resolveDeck(i){const{code:t,file:u,words:r,prefix:o,base:$}=i,l=[],E=Te(i.theme??ze,t.theme),M=new Map;for(const e of t.masters)for(const n of e.layouts)M.set(n.name,{layout:n,master:e});const j=[],F=(e,n,a)=>({name:e.name,kind:e.kind,frame:{...e.frame??re},...e.flip?{flip:{...e.flip}}:{},...e.connect?{connect:{...e.connect.begin?{begin:{...e.connect.begin}}:{},...e.connect.end?{end:{...e.connect.end}}:{}}}:{},...e.rotation===void 0?{}:{rotation:e.rotation},level:n,...e.text?{text:{paragraphs:e.text.paragraphs,style:e.kind==="autoshape"?le(a,e.text):V(a,e.text),own:X(e.text),empty:!1}}:{},...e.fill===void 0?{}:{fill:e.fill},...e.fill_transparency===void 0?{}:{fill_transparency:e.fill_transparency},...e.gradient?{gradient:e.gradient}:{},...e.shadow===void 0?{}:{shadow:e.shadow},...e.line===void 0?{}:{line:e.line},...e.line_width===void 0?{}:{line_width:e.line_width},...e.line_dash===void 0?{}:{line_dash:e.line_dash},...e.line_begin===void 0?{}:{line_begin:e.line_begin},...e.line_end===void 0?{}:{line_end:e.line_end},...e.line_begin_size===void 0?{}:{line_begin_size:e.line_begin_size},...e.line_end_size===void 0?{}:{line_end_size:e.line_end_size},...e.path?{path:e.path}:{},...e.table?{table:fe(e.table,a)}:{},...e.chart?{chart:e.chart}:{},...e.group===void 0?{}:{group:e.group},...e.geometry?{geometry:e.geometry}:{},...e.adjustments?{adjustments:[...e.adjustments]}:{},...e.media?{media:{path:joinPath(e.media.base,e.media.path),...e.media.poster===void 0?{}:{poster:e.media.poster}}}:{},...e.component?{component:{...e.component}}:{},sources:{frame:{from:n}}}),P=(e,n)=>{const a=e.placeholder?.type??"body",m=Ae(n,a),_=e.frame??m?.frame??re;return{name:e.name,kind:"placeholder",frame:{..._},level:"slide",...e.placeholder?{placeholder:{...e.placeholder}}:{},text:{paragraphs:[],style:je(n,a,m?.text,e.text),empty:!0},...e.fill===void 0?{}:{fill:e.fill},...e.line===void 0?{}:{line:e.line},sources:{frame:{from:e.frame||!m?"layout":"master"},text:{from:"layout"}}}},Y=(e,n,a,m)=>{const _=t.components[e];if(!_){l.push({...a,message:/\.[cm]?[jt]sx?(?:#|$)/u.test(e)?`${e} names no component: its module has no such export, or the export is not made with defineComponent.`:`There is no component ${e} in the deck's module (it has ${Object.keys(t.components).join(", ")||"none"}).`});return}for(const b of Object.keys(n??{}))Object.hasOwn(_.props,b)||l.push({...a,message:`Component ${e} has no prop ${b} a person sets (it has ${Object.keys(_.props).join(", ")||"none"}).`});return{name:e,props:{...n??{}},...m===void 0?{}:{dur:m}}},L=(e,n,a,m,_)=>{const b={slide:m,shape:e,path:a};if(!n.frame){l.push({...b,message:`Shape ${e} is the slide's own: it needs a frame { x, y, w, h } in points.`});return}const w=ce(n.frame),s={frame:{from:"slide",path:`${a}.frame`}},y={name:e,frame:w,level:"slide",...n.fill===void 0?{}:{fill:N(n.fill)},...Z(n),...n.line===void 0?{}:{line:N(n.line)},...n.line_dash===void 0?{}:{line_dash:n.line_dash},...n.line_begin===void 0?{}:{line_begin:n.line_begin},...n.line_end===void 0?{}:{line_end:n.line_end},...n.line_begin_size===void 0?{}:{line_begin_size:n.line_begin_size},...n.line_end_size===void 0?{}:{line_end_size:n.line_end_size},...n.group===void 0?{}:{group:n.group},...pe(n)};if(n.textbox)return{...y,kind:"textbox",text:{paragraphs:paragraphsOfWords(r(`${o}.${m}.${e}`),0,E.fonts.code),style:B(V(_,G(te)),n.text),own:X(G(te)),empty:!1},...n.text?{fileText:{...n.text}}:{},sources:{...s,text:{from:"slide",path:`${a}.text`}}};if(n.picture!==void 0){const f=me(n.crop);return{...y,kind:"picture",media:{path:joinPath($,n.picture),...f?{crop:f}:{}},sources:{...s,media:{from:"slide",path:`${a}.picture`}}}}if(n.movie!==void 0)return{...y,kind:"movie",media:{path:joinPath($,n.movie),...n.poster===void 0?{}:{poster:n.poster}},sources:{...s,media:{from:"slide",path:`${a}.movie`}}};if(n.chart){const f=r(`${o}.${m}.${e}`),S=ye(n.chart,{title:typeof f=="string"?f:void 0,base:$,rows:g=>i.data?.(g),problem:g=>{l.push({...b,message:`Chart ${e}: ${g}`})}});return S?{...y,kind:"chart",chart:S,sources:s}:void 0}if(n.table){const f=n.table,S=w.width/f.columns.reduce((d,c)=>d+c,0),g=w.height/f.rows.reduce((d,c)=>d+c.height,0),v=r(`${o}.${m}.${e}`),z=Array.isArray(v)?v:[];return z.length>f.rows.length&&l.push({...b,message:`Table ${e} has ${String(f.rows.length)} rows and its words ${String(z.length)}.`}),{...y,kind:"table",table:fe({columns:f.columns.map(d=>Math.round(d*S)),rows:f.rows.map((d,c)=>{const p=z[c],x=Array.isArray(p)?p:p===void 0?[]:[p];return{height:Math.round(d.height*g),cells:f.columns.map((k,A)=>({text:{levels:[],paragraphs:paragraphsOfWords(x[A],0,E.fonts.code)},...d.fill===void 0?{}:{fill:colorOfFile(d.fill)},...d.line===void 0?{}:{borders:{bottom:{color:colorOfFile(d.line),width:O(1)}}}}))}})},_,f.rows.map(d=>d.text)),sources:s}}const h=n.path&&Se(n.path.d);if(n.path&&!h){l.push({...b,message:`Shape ${e}'s path starts with M and says only M, L, C and Z, absolute.`});return}if(n.geometry!==void 0||n.path&&h){const f=!n.path&&$e(n.geometry);return{...y,kind:"autoshape",...n.path&&h?{path:{w:n.path.w,h:n.path.h,steps:h}}:n.geometry===void 0?{}:{geometry:n.geometry,...n.adjustments?{adjustments:[...n.adjustments]}:{}},...f?{line:n.line===void 0?ne.line:N(n.line),line_width:n.line_width===void 0?ne.line_width:O(n.line_width)}:{fill:n.fill===void 0?C.fill:N(n.fill),line:n.line===void 0?C.line:N(n.line),line_width:n.line_width===void 0?C.line_width:O(n.line_width)},...n.text&&!f?{fileText:{...n.text}}:{},...f?{}:{text:{paragraphs:paragraphsOfWords(r(`${o}.${m}.${e}`)).map(S=>n.text?.align===void 0?{alignment:C.alignment,...S}:S),style:B(le(_,G(de)),n.text),own:X(G(de)),empty:!1}},sources:{...s,fill:{from:"slide",path:`${a}.fill`}}}}if(n.component!==void 0){const f=Y(n.component,n.props,b,n.dur);return f?{...y,kind:"component",component:f,sources:s}:void 0}},R=(e,n,a)=>{if(n.frame&&(e.frame=ce(n.frame),e.sources.frame={from:"slide",path:`${a}.frame`}),Object.assign(e,pe(n)),n.dur!==void 0&&e.component&&(e.component={...e.component,dur:n.dur}),n.text&&e.text&&(e.text.style=B(e.text.style,n.text),e.text.paragraphs=Pe(e.text.paragraphs,n.text),e.fileText={...n.text},e.sources.text={from:"slide",path:`${a}.text`}),n.line!==void 0&&(e.line=N(n.line),e.sources.line={from:"slide",path:`${a}.line`}),n.line_width!==void 0&&(e.line_width=O(n.line_width)),n.line_dash!==void 0&&(e.line_dash=n.line_dash),n.line_begin!==void 0&&(e.line_begin=n.line_begin),n.line_end!==void 0&&(e.line_end=n.line_end),n.line_begin_size!==void 0&&(e.line_begin_size=n.line_begin_size),n.line_end_size!==void 0&&(e.line_end_size=n.line_end_size),n.fill!==void 0&&(e.fill=N(n.fill),e.sources.fill={from:"slide",path:`${a}.fill`}),Object.assign(e,Z(n)),(n.picture!==void 0||n.movie!==void 0)&&(e.placeholder?.type==="pic"||e.placeholder?.type==="media"||e.placeholder?.type==="obj")){const m=me(n.crop);e.kind=n.picture!==void 0?"picture":"movie",e.media={path:joinPath($,n.picture??n.movie??""),...m?{crop:m}:{},...n.poster===void 0?{}:{poster:n.poster}},e.sources.media={from:"slide",path:`${a}.${n.picture!==void 0?"picture":"movie"}`},delete e.text}},D=(e,n,a,m,_)=>{const b=M.get(n);if(!b){l.push({slide:e,path:`slides.${String(a)}.layout`,message:`Slide ${e} is on the layout "${n}", which the deck's module does not have (it has ${[...M.keys()].join(", ")||"none"}).`});return}const{layout:w,master:s}=b,y=[...(w.display_master_shapes===!1?[]:s.shapes).filter(f=>f.kind!=="placeholder").map(f=>F(f,"master",s)),...w.shapes.filter(f=>f.kind!=="placeholder").map(f=>F(f,"layout",s))],h=w.shapes.filter(f=>f.kind==="placeholder").map((f,S)=>({shape:P(f,s),order:S}));return{slide:{id:e,layout:w.name,master:s.name,hidden:m,background:w.background??s.background,shapes:y,animations:[],file:{index:a,..._===void 0?{}:{generate:_}}},placed:h,master:s}},q=(e,n,a)=>{if(!n)return;const m=w=>{const s=n[w];if(s===void 0)return e.connect?.[w];const y=s==="none"?void 0:a(s.shape);return s==="none"||y===void 0?void 0:{shape:y,site:s.site}},_=m("begin"),b=m("end");_||b?e.connect={..._?{begin:_}:{},...b?{end:b}:{}}:delete e.connect},J=(e,n,a,m,_,b,w,s,y,h=()=>{})=>{const f=new Set(a.map(d=>d.shape.name));let S=a.length;for(const[d,c]of Object.entries(m??{})){const p=b(d);if(p===void 0)continue;const x=`${_}.shapes.${d}`,k=c.textbox!==void 0||c.geometry!==void 0||c.path!==void 0||c.table!==void 0||c.chart!==void 0||c.component!==void 0||(c.picture!==void 0||c.movie!==void 0)&&!f.has(p),A=a.find(ge=>ge.shape.name===p);if(A&&!k){R(A.shape,c,x),q(A.shape,c.connect,b),A.shown=!0,c.z!==void 0&&(A.z=c.z);continue}if(A){l.push({slide:e.id,shape:p,path:x,message:`Slide ${e.id} has a ${A.shape.kind} ${p} already: a shape of its own needs another name.`});continue}if(!k){l.push({slide:e.id,shape:p,path:x,message:`Slide ${e.id} has no shape ${p} to change (its layout's placeholders and its own shapes are ${[...f].join(", ")||"none"}).`});continue}const T=L(p,c,x,e.id,n);T&&q(T,c.connect,b),T&&(a.push({shape:T,order:S++,...c.z===void 0?{}:{z:c.z}}),f.add(p))}const g=a.filter(d=>d.shown===!0||!Re.has(d.shape.placeholder?.type??"")||w(d.shape)!==void 0);a.splice(0,a.length,...g),a.sort((d,c)=>(d.z??0)-(c.z??0)||d.order-c.order);const v=new Map(a.flatMap((d,c)=>d.shape.group===void 0?[]:[[d.shape.group,c]])),z=a.flatMap((d,c)=>{const p=d.shape.group;return p===void 0?[d]:v.get(p)===c?a.filter(x=>x.shape.group===p):[]});a.splice(0,a.length,...z);for(const d of a){const c=h(d.shape);c!==void 0&&(d.shape.alt=c);const p=d.shape.text;if(d.shape.kind==="placeholder"&&p){const x=w(d.shape);p.paragraphs=paragraphsOfWords(x,0,E.fonts.code),p.empty=p.paragraphs.length===0||p.paragraphs.every(k=>k.runs.every(A=>A.text===""))}}e.shapes.push(...a.map(d=>d.shape));for(const d of e.shapes){const c=d.connect;if(!c)continue;const p=ve(d,x=>e.shapes.find(k=>k.name===x&&k.level===d.level&&k!==d));d.frame=p.frame,p.flip?d.flip=p.flip:delete d.flip;for(const x of p.lost){const k=c[x];k&&d.level==="slide"&&l.push({slide:e.id,shape:d.name,message:`Connector ${d.name}'s ${x} is glued to site ${String(k.site)} of ${k.shape}, which slide ${e.id} has not: it stays where it is.`})}}s!==void 0&&s.trim()!==""&&(e.notes=s);for(const[d,c]of(y??[]).entries()){const p=b(c.shape);if(p===void 0)continue;const x={slide:e.id,shape:p,path:`${_}.animations.${String(d)}`},k=e.shapes.find(T=>T.name===p&&T.level==="slide");if(!k){l.push({...x,message:`Slide ${e.id} has no shape ${p} to animate (it has ${e.shapes.filter(T=>T.level==="slide").map(T=>T.name).join(", ")}).`});continue}if(c.paragraph!==void 0&&c.paragraph>=(k.text?.paragraphs.length??0)){l.push({...x,message:`Shape ${p} has no paragraph ${String(c.paragraph)} to animate (it has ${String(k.text?.paragraphs.length??0)}).`});continue}const A=ke({...c,shape:p});A?e.animations.push(A):l.push({...x,message:`The animation of ${p} needs a path that starts with M and says only M, L and C, absolute.`})}},Q=new Set;return u.slides.forEach((e,n)=>{const a=`slides.${String(n)}`;if(e.layout!==void 0){const s=D(e.id,e.layout,n,e.hidden===!0);if(!s)return;const y=r(`${o}.${e.id}.notes`);e.transition&&(s.slide.transition=oe(e.transition)),e.advance_after!==void 0&&(s.slide.advance=e.advance_after),he(s.slide,e.background,$),J(s.slide,s.master,s.placed,e.shapes,a,h=>h,h=>r(`${o}.${e.id}.${h.name}`),typeof y=="string"?y:void 0,e.animations,h=>{const f=r(`${o}.${e.id}.alt.${h.name}`);return typeof f=="string"?f:void 0}),j.push(s.slide),Q.add(e.id);return}const m=e.generate??"",_=t.generators[m];if(_===void 0){l.push({slide:e.id,path:`${a}.generate`,message:`There is no generator ${m} in the deck's module (it has ${Object.keys(t.generators).join(", ")||"none"}).`});return}if(!Array.isArray(_)){l.push({slide:e.id,path:`${a}.generate`,message:`Generator ${m} threw: ${_.error}`,..._.stack===void 0?{}:{stack:_.stack}});return}const b=_,w=new Set(Array.isArray(e.hidden)?e.hidden:[]);for(const s of b){const y=`${e.id}/${s.id}`,h=D(y,s.layout,n,w.has(s.id),m);if(!h)continue;for(const g of s.shapes){const v=g.placeholder?h.placed.find(z=>z.shape.placeholder?.idx===g.placeholder?.idx):void 0;if(v)g.frame&&(v.shape.frame={...g.frame}),v.shape.sources.frame={from:"code"},v.shown=!0;else{const z=F(g,"layout",h.master);h.placed.push({shape:{...z,level:"slide",sources:{frame:{from:"code"}}},order:h.placed.length})}}const f=`${s.id}/`,S=s.transition??(s===b[0]?e.transition:void 0);he(h.slide,e.background,$),S&&(h.slide.transition=oe(S)),J(h.slide,h.master,h.placed,e.shapes,a,g=>g.startsWith(f)?g.slice(f.length):void 0,g=>{const v=g.placeholder===void 0?void 0:s.text[g.placeholder.idx];return v===void 0?void 0:v.map(z=>z.runs.map(d=>d.text).join(""))},s.notes,[...(s.animations??[]).map(g=>({...g,shape:`${f}${g.shape}`})),...e.animations??[]]);for(const g of h.slide.shapes){const v=g.placeholder===void 0?void 0:s.text[g.placeholder.idx];v&&g.text&&(g.text.paragraphs=v,g.text.empty=!1)}j.push(h.slide),Q.add(y)}for(const s of Object.keys(e.shapes??{})){const[y]=s.split("/");y!==void 0&&!b.some(h=>h.id===y)&&l.push({slide:e.id,path:`${a}.shapes.${s}`,message:`Generator ${m} makes no slide ${y}: ${s} changes nothing.`})}}),j.forEach((e,n)=>{for(const a of e.shapes)a.placeholder?.type==="sldNum"&&a.text&&(a.text.paragraphs=[{level:0,runs:[{text:String(n+1),field:"slidenum"}]}],a.text.empty=!1)}),{deck:{width:t.slide_width,height:t.slide_height,theme:E,slides:j},problems:l}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { presentationFor } from "./index.js";
|
|
2
2
|
/** python-pptx's length functions: each gives a Length, a number of EMU that says itself in other units (`Pt(12).pt`, `.inches`, `.cm`, `.mm`, `.emu`). */
|
|
3
3
|
export declare const Emu: (n: number) => import("./units.js").LengthValue, Inches: (n: number) => import("./units.js").LengthValue, Pt: (n: number) => import("./units.js").LengthValue, Cm: (n: number) => import("./units.js").LengthValue, Mm: (n: number) => import("./units.js").LengthValue, Centipoints: (n: number) => import("./units.js").LengthValue;
|
|
4
|
-
export { RGBColor, MSO_ANCHOR, CategoryChartData, MSO_ARROWHEAD, XL_CHART_TYPE, XL_LABEL_POSITION, XL_LEGEND_POSITION, MSO_AUTO_SIZE, MSO_CONNECTOR, MSO_FILL, MSO_LINE, MSO_SHAPE, MSO_SHAPE_TYPE, MSO_THEME_COLOR, PP_ALIGN, PP_PLACEHOLDER, THEME_FONT, SLIDE_SIZES, presentationFor, isDeck, type Anchor, type AutoSize, type Background, type ColorFormat, type ComponentContext, type ComponentInput, type Deck, type FillFormat, type Font, type GeneratedSlide, type Generator, type Length, type LengthValue, type LineFormat, type ListLevel, type ListStyle, type Paragraph, type Placeholders, type PlaceholderType, type Presentation, type PresentationOptions, type PropSpec, type Run, type Shape, type ShapeCollection, type ShapeType, type SlideLayout, type SlideLayouts, type SlideMaster, type SlideMasters, type SlideSizeName, type TextFrame, type TextStyles, type ThemeInput, } from "./index.js";
|
|
4
|
+
export { RGBColor, MSO_ANCHOR, CategoryChartData, MSO_ARROWHEAD, MSO_ARROWHEAD_SIZE, XL_CHART_TYPE, XL_LABEL_POSITION, XL_LEGEND_POSITION, MSO_AUTO_SIZE, MSO_CONNECTOR, MSO_FILL, MSO_LINE, MSO_LINE_DASH_STYLE, MSO_SHAPE, MSO_SHAPE_TYPE, MSO_THEME_COLOR, PP_ALIGN, PP_PARAGRAPH_ALIGNMENT, PP_PLACEHOLDER, THEME_FONT, SLIDE_SIZES, presentationFor, isDeck, type Anchor, type AutoSize, type Background, type Cell, type ColorFormat, type ComponentContext, type ComponentInput, type Deck, type FillFormat, type FreeformBuilder, type GradientStop, type GroupShape, type Font, type GeneratedSlide, type Generator, type Length, type LengthValue, type LineFormat, type ListLevel, type ListStyle, type Paragraph, type Placeholders, type PlaceholderType, type Presentation, type PresentationOptions, type PropSpec, type Run, type Shape, type ShapeCollection, type ShapeType, type SlideLayout, type SlideLayouts, type SlideMaster, type SlideMasters, type SlideSizeName, type Table, type TextFrame, type TextStyles, type ThemeInput, } from "./index.js";
|
|
5
5
|
/**
|
|
6
6
|
* A deck: the default export of a deck's module. Its function makes
|
|
7
7
|
* the presentation's slide masters, layouts, components and generators;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{LENGTH_UNITS as O,presentationFor as _}from"./index.js";export const{Emu,Inches,Pt,Cm,Mm,Centipoints}=O;export{RGBColor,MSO_ANCHOR,CategoryChartData,MSO_ARROWHEAD,XL_CHART_TYPE,XL_LABEL_POSITION,XL_LEGEND_POSITION,MSO_AUTO_SIZE,MSO_CONNECTOR,MSO_FILL,MSO_LINE,MSO_SHAPE,MSO_SHAPE_TYPE,MSO_THEME_COLOR,PP_ALIGN,PP_PLACEHOLDER,THEME_FONT,SLIDE_SIZES,presentationFor,isDeck}from"./index.js";export const presentation=_(""),slidesFor=
|
|
2
|
+
import{LENGTH_UNITS as O,presentationFor as _}from"./index.js";export const{Emu,Inches,Pt,Cm,Mm,Centipoints}=O;export{RGBColor,MSO_ANCHOR,CategoryChartData,MSO_ARROWHEAD,MSO_ARROWHEAD_SIZE,XL_CHART_TYPE,XL_LABEL_POSITION,XL_LEGEND_POSITION,MSO_AUTO_SIZE,MSO_CONNECTOR,MSO_FILL,MSO_LINE,MSO_LINE_DASH_STYLE,MSO_SHAPE,MSO_SHAPE_TYPE,MSO_THEME_COLOR,PP_ALIGN,PP_PARAGRAPH_ALIGNMENT,PP_PLACEHOLDER,THEME_FONT,SLIDE_SIZES,presentationFor,isDeck}from"./index.js";export const presentation=_(""),slidesFor=E=>({presentation:_(E.file)});
|
|
@@ -618,8 +618,8 @@ export interface VideoOptions {
|
|
|
618
618
|
* LOAD_WAITS (4) times as long.
|
|
619
619
|
*/
|
|
620
620
|
seekLimit?: number;
|
|
621
|
-
/** Motion blur: each frame blends moments across part of the frame's time. */
|
|
622
|
-
motionBlur?: MotionBlur;
|
|
621
|
+
/** Motion blur: each frame blends moments across part of the frame's time; null (or absent) for none. */
|
|
622
|
+
motionBlur?: MotionBlur | null;
|
|
623
623
|
/**
|
|
624
624
|
* What a camera filming the picture does to it, before post: bloom,
|
|
625
625
|
* chromatic aberration, vignetting, exposure breathing, grain and
|
|
@@ -164,10 +164,10 @@ export declare const VideoOptionsMeta: z.ZodObject<{
|
|
|
164
164
|
lufs: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
|
|
165
165
|
truePeak: z.ZodOptional<z.ZodNumber>;
|
|
166
166
|
}, z.core.$strict>]>>;
|
|
167
|
-
motionBlur: z.ZodOptional<z.ZodObject<{
|
|
167
|
+
motionBlur: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
168
168
|
samples: z.ZodNumber;
|
|
169
169
|
shutter: z.ZodOptional<z.ZodNumber>;
|
|
170
|
-
}, z.core.$strict
|
|
170
|
+
}, z.core.$strict>>>;
|
|
171
171
|
capture: z.ZodOptional<z.ZodObject<{
|
|
172
172
|
bloom: z.ZodOptional<z.ZodObject<{
|
|
173
173
|
threshold: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{z as t}from"zod";import{LOCALE as m,FPS_HELP as u,VIDEO_FORMAT_HELP as b,formatSpecProblem as d,isVideoFormat as g,parseFps as f,RESERVED_DIMS as l}from"@allyhub/piece";import{OUTPUT_KINDS as h}from"./piece.js";import{musicTimeProblem as x}from"./music.js";export const VideoFormatSchema=t.string().refine(g,{message:`unknown format (${b})`}),ComboSchema=t.record(t.string(),t.string()),ProblemSchema=t.strictObject({code:t.string().regex(/^AK-[A-Z]\d{3}$/),level:t.enum(["error","warn"]),message:t.string(),piece:t.string().optional(),output:t.string().optional(),combo:ComboSchema.optional(),format:t.string().optional(),part:t.string().optional(),t:t.number().optional(),page:t.number().int().nonnegative().optional(),where:t.strictObject({file:t.string().optional(),line:t.number().int().optional(),selector:t.string().optional(),bbox:t.tuple([t.number(),t.number(),t.number(),t.number()]).optional()}).optional()}),Locale=t.string().regex(m,"must be a lower-case locale such as en or zh-cn"),PieceId=t.string().regex(/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*$/,"id: lowercase letters, digits, . _ -, with / between levels"),DimName=t.string().regex(/^[a-z][a-zA-Z0-9_-]*$/,"dimension name: starts with a letter; letters, digits, _ and -"),DimValue=t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/,"dimension value: letters, digits, . _ -"),OutputName=t.string().regex(/^[A-Za-z][A-Za-z0-9_-]*$/,"output name: starts with a letter; letters, digits, _ and -"),DimsSchema=t.record(DimName,t.array(DimValue).min(1)).superRefine((o,e)=>{for(const[n,a]of Object.entries(o)){if(l.includes(n)){e.addIssue({code:"custom",path:[n],message:n==="size"||n==="format"?`${n} is not a dimension: a piece has one format, format: "9x16", and another format is a piece of its own`:`${n} cannot name a dimension: the preview's address uses it. Choose another name`});continue}if(new Set(a).size!==a.length&&e.addIssue({code:"custom",path:[n],message:"the same value is listed twice"}),n==="lang")for(const s of a)m.test(s)||e.addIssue({code:"custom",path:[n],message:`lang value ${s} must be a lowercase language tag, such as en or zh-cn`})}});const O=o=>l.includes(o)?`${o} cannot name a slot: the framework uses it. Choose another name`:void 0;export const CandidateSchema=t.union([DimValue,t.strictObject({name:DimValue,tags:t.array(t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/)).optional()})]),SlotSchema=t.union([t.array(CandidateSchema).min(1),t.strictObject({pool:t.string().min(1),tags:t.array(t.string().min(1)).optional()})]);const j=t.union([t.string().min(1),t.array(t.string().min(1)).min(1)]),r=t.record(t.string(),j);export const MatrixSchema=t.strictObject({dims:DimsSchema.optional(),slots:t.record(DimName,SlotSchema).optional(),structures:t.record(DimValue,t.array(DimName).min(1)).optional(),combos:t.array(t.record(DimName,DimValue)).min(1).max(1e4).optional(),pick:t.number().int().min(1).max(1e4).optional(),seed:t.union([t.number(),t.string()]).optional(),differ:t.strictObject({slots:t.number().int().min(1).optional(),first:t.union([t.number().int().min(1),t.array(DimName).min(1)]).optional()}).optional(),rules:t.array(t.strictObject({if:r.optional(),require:r.optional(),exclude:r.optional()})).optional()}).superRefine((o,e)=>{for(const n of Object.keys(o.slots??{})){const a=O(n);a&&e.addIssue({code:"custom",path:["slots",n],message:a})}if(o.structures&&!o.slots&&e.addIssue({code:"custom",path:["structures"],message:"structures order slots: declare matrix.slots too"}),o.combos&&!o.slots&&e.addIssue({code:"custom",path:["combos"],message:"combos choose candidates of slots: declare matrix.slots too"}),o.combos)for(const n of["pick","seed"])o[n]!==void 0&&e.addIssue({code:"custom",path:[n],message:`combos names the combos to make, so nothing is sampled: remove ${n}, which only steers sampling`})}),FormatSpecSchema=t.strictObject({format:t.string().min(1),safe:t.strictObject({top:t.number().optional(),bottom:t.number().optional(),left:t.number().optional(),right:t.number().optional()}).optional()}).superRefine((o,e)=>{const n=d(o);n&&e.addIssue({code:"custom",message:n})}),FormatEntrySchema=t.union([t.string().min(1),FormatSpecSchema]);const i=t.number().min(-70).max(0),c=t.unknown().superRefine((o,e)=>{const n=x(o);n&&e.addIssue({code:"custom",message:n})}),p=t.strictObject({from:c,to:c.optional()}),S=t.union([t.number().min(0),t.string().min(1),t.strictObject({part:t.string().min(1),at:t.union([t.number(),t.string().min(1)])})]);export const PartDefaultsSchema=t.strictObject({dur:t.number().positive().max(3600).optional(),lead:t.number().min(0).max(60).optional(),tail:t.number().min(0).max(60).optional()}),VideoOptionsMeta=t.strictObject({music:t.strictObject({file:t.union([t.string().min(1),t.record(Locale,t.string().min(1))]).optional(),from:t.number().min(0).optional(),loop:t.union([t.boolean(),p]).optional(),play:t.array(p).min(1).optional(),seam:t.number().min(0).max(5).optional(),meter:t.number().int().min(1).max(32).optional(),downbeat:t.number().min(0).optional(),end:t.enum(["film","bar","beat"]).optional(),snap:t.boolean().optional(),bpm:t.number().min(20).max(400).optional(),gain:t.array(t.strictObject({at:S,db:t.number().min(-60).max(24)})).min(1).optional(),filter:t.string().min(1).optional(),eq:t.array(t.unknown()).optional(),compress:t.unknown().optional()}).optional(),mix:t.strictObject({speech:i.optional(),music:i.optional(),musicAlone:i.optional(),sfx:i.optional(),footage:i.optional(),footageUnderSpeech:i.optional(),duck:t.strictObject({db:t.number().min(-60).max(0).optional(),attack:t.number().min(0).max(10).optional(),release:t.number().min(0).max(10).optional(),hold:t.number().min(0).max(60).optional()}).optional(),musicFade:t.strictObject({in:t.number().min(0).max(60).optional(),out:t.number().min(0).max(60).optional()}).optional()}).optional(),mic:t.union([t.string().min(1),t.record(t.string(),t.unknown()),t.literal(!1)]).optional(),look:t.string().min(1).optional(),defaults:t.strictObject({part:PartDefaultsSchema.optional()}).optional(),covers:t.literal(!0).optional(),fps:t.union([t.number(),t.string()]).refine(o=>f(o)!==void 0,{error:`A frame rate is ${u}`}).optional(),transparent:t.boolean().optional(),maxDuration:t.number().positive().optional(),loadLimit:t.number().positive().optional(),seekLimit:t.number().positive().optional(),deliverable:t.boolean().optional(),master:t.union([i,t.literal(!1),t.strictObject({lufs:t.union([i,t.literal(!1)]).optional(),truePeak:t.number().min(-9).max(0).optional()})]).optional(),motionBlur:t.strictObject({samples:t.number().int().min(2).max(16),shutter:t.number().gt(0).max(1).optional()}).optional(),capture:t.strictObject({bloom:t.strictObject({threshold:t.number().optional(),radius:t.number().optional(),strength:t.number().optional()}).optional(),aberration:t.number().optional(),soften:t.number().optional(),vignette:t.number().optional(),exposure:t.strictObject({drift:t.number().optional(),period:t.number().optional()}).optional(),grain:t.strictObject({amount:t.number().optional(),size:t.number().optional(),shadows:t.number().optional(),highlights:t.number().optional(),chroma:t.number().optional(),chromaSize:t.number().optional(),static:t.boolean().optional()}).optional(),sharpen:t.number().optional()}).optional(),post:t.strictObject({filter:t.string().min(1).optional(),lut:t.string().regex(/\.cube$/i,"A LUT is a .cube file").optional()}).optional()}),OutputMeta=t.strictObject({kind:t.enum(h),options:t.record(t.string(),t.unknown())}),PieceMeta=t.strictObject({id:PieceId.optional(),script:t.string().min(1).optional(),title:t.union([t.string().min(1),t.record(Locale,t.string().min(1))]).optional(),format:FormatEntrySchema.optional(),matrix:MatrixSchema.optional(),meta:t.record(t.string(),t.unknown()).optional(),outputs:t.record(OutputName,OutputMeta).refine(o=>Object.keys(o).length>0,"outputs needs at least one output")}),LookConfigSchema=t.strictObject({color:t.strictObject({bg:t.string().min(1).optional(),fg:t.string().min(1).optional(),accent:t.string().min(1).optional(),muted:t.string().min(1).optional(),surface:t.string().min(1).optional()}).optional(),font:t.strictObject({display:t.string().min(1).optional(),body:t.string().min(1).optional(),mono:t.string().min(1).optional(),emoji:t.string().min(1).optional()}).optional(),motion:t.strictObject({beat:t.number().positive().optional()}).optional(),sfx:t.record(t.string().regex(/^[a-z][a-z0-9-]*$/,"a sound's name: lowercase letters, digits and -"),t.string().min(1).refine(o=>!o.startsWith("/")&&!o.split(/[\\/]/).includes(".."),"a sound is an audio file relative to the workspace's root")).optional()}),PropSchemaEntry=t.looseObject({type:t.enum(["text","time","asset","color","number","boolean","list","object"])}),ComponentEntry=t.strictObject({name:t.string(),label:t.union([t.string(),t.record(t.string(),t.string())]),file:t.string(),props:t.record(t.string(),PropSchemaEntry),examples:t.array(t.string()),hidden:t.boolean()}),VideoConfigSchema=t.object({look:LookConfigSchema.optional(),defaults:t.strictObject({format:VideoFormatSchema.optional(),part:PartDefaultsSchema.optional()}).optional()});
|
|
2
|
+
import{z as t}from"zod";import{LOCALE as m,FPS_HELP as u,VIDEO_FORMAT_HELP as b,formatSpecProblem as d,isVideoFormat as g,parseFps as f,RESERVED_DIMS as l}from"@allyhub/piece";import{OUTPUT_KINDS as h}from"./piece.js";import{musicTimeProblem as x}from"./music.js";export const VideoFormatSchema=t.string().refine(g,{message:`unknown format (${b})`}),ComboSchema=t.record(t.string(),t.string()),ProblemSchema=t.strictObject({code:t.string().regex(/^AK-[A-Z]\d{3}$/),level:t.enum(["error","warn"]),message:t.string(),piece:t.string().optional(),output:t.string().optional(),combo:ComboSchema.optional(),format:t.string().optional(),part:t.string().optional(),t:t.number().optional(),page:t.number().int().nonnegative().optional(),where:t.strictObject({file:t.string().optional(),line:t.number().int().optional(),selector:t.string().optional(),bbox:t.tuple([t.number(),t.number(),t.number(),t.number()]).optional()}).optional()}),Locale=t.string().regex(m,"must be a lower-case locale such as en or zh-cn"),PieceId=t.string().regex(/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*$/,"id: lowercase letters, digits, . _ -, with / between levels"),DimName=t.string().regex(/^[a-z][a-zA-Z0-9_-]*$/,"dimension name: starts with a letter; letters, digits, _ and -"),DimValue=t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/,"dimension value: letters, digits, . _ -"),OutputName=t.string().regex(/^[A-Za-z][A-Za-z0-9_-]*$/,"output name: starts with a letter; letters, digits, _ and -"),DimsSchema=t.record(DimName,t.array(DimValue).min(1)).superRefine((o,e)=>{for(const[n,a]of Object.entries(o)){if(l.includes(n)){e.addIssue({code:"custom",path:[n],message:n==="size"||n==="format"?`${n} is not a dimension: a piece has one format, format: "9x16", and another format is a piece of its own`:`${n} cannot name a dimension: the preview's address uses it. Choose another name`});continue}if(new Set(a).size!==a.length&&e.addIssue({code:"custom",path:[n],message:"the same value is listed twice"}),n==="lang")for(const s of a)m.test(s)||e.addIssue({code:"custom",path:[n],message:`lang value ${s} must be a lowercase language tag, such as en or zh-cn`})}});const O=o=>l.includes(o)?`${o} cannot name a slot: the framework uses it. Choose another name`:void 0;export const CandidateSchema=t.union([DimValue,t.strictObject({name:DimValue,tags:t.array(t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/)).optional()})]),SlotSchema=t.union([t.array(CandidateSchema).min(1),t.strictObject({pool:t.string().min(1),tags:t.array(t.string().min(1)).optional()})]);const j=t.union([t.string().min(1),t.array(t.string().min(1)).min(1)]),r=t.record(t.string(),j);export const MatrixSchema=t.strictObject({dims:DimsSchema.optional(),slots:t.record(DimName,SlotSchema).optional(),structures:t.record(DimValue,t.array(DimName).min(1)).optional(),combos:t.array(t.record(DimName,DimValue)).min(1).max(1e4).optional(),pick:t.number().int().min(1).max(1e4).optional(),seed:t.union([t.number(),t.string()]).optional(),differ:t.strictObject({slots:t.number().int().min(1).optional(),first:t.union([t.number().int().min(1),t.array(DimName).min(1)]).optional()}).optional(),rules:t.array(t.strictObject({if:r.optional(),require:r.optional(),exclude:r.optional()})).optional()}).superRefine((o,e)=>{for(const n of Object.keys(o.slots??{})){const a=O(n);a&&e.addIssue({code:"custom",path:["slots",n],message:a})}if(o.structures&&!o.slots&&e.addIssue({code:"custom",path:["structures"],message:"structures order slots: declare matrix.slots too"}),o.combos&&!o.slots&&e.addIssue({code:"custom",path:["combos"],message:"combos choose candidates of slots: declare matrix.slots too"}),o.combos)for(const n of["pick","seed"])o[n]!==void 0&&e.addIssue({code:"custom",path:[n],message:`combos names the combos to make, so nothing is sampled: remove ${n}, which only steers sampling`})}),FormatSpecSchema=t.strictObject({format:t.string().min(1),safe:t.strictObject({top:t.number().optional(),bottom:t.number().optional(),left:t.number().optional(),right:t.number().optional()}).optional()}).superRefine((o,e)=>{const n=d(o);n&&e.addIssue({code:"custom",message:n})}),FormatEntrySchema=t.union([t.string().min(1),FormatSpecSchema]);const i=t.number().min(-70).max(0),c=t.unknown().superRefine((o,e)=>{const n=x(o);n&&e.addIssue({code:"custom",message:n})}),p=t.strictObject({from:c,to:c.optional()}),S=t.union([t.number().min(0),t.string().min(1),t.strictObject({part:t.string().min(1),at:t.union([t.number(),t.string().min(1)])})]);export const PartDefaultsSchema=t.strictObject({dur:t.number().positive().max(3600).optional(),lead:t.number().min(0).max(60).optional(),tail:t.number().min(0).max(60).optional()}),VideoOptionsMeta=t.strictObject({music:t.strictObject({file:t.union([t.string().min(1),t.record(Locale,t.string().min(1))]).optional(),from:t.number().min(0).optional(),loop:t.union([t.boolean(),p]).optional(),play:t.array(p).min(1).optional(),seam:t.number().min(0).max(5).optional(),meter:t.number().int().min(1).max(32).optional(),downbeat:t.number().min(0).optional(),end:t.enum(["film","bar","beat"]).optional(),snap:t.boolean().optional(),bpm:t.number().min(20).max(400).optional(),gain:t.array(t.strictObject({at:S,db:t.number().min(-60).max(24)})).min(1).optional(),filter:t.string().min(1).optional(),eq:t.array(t.unknown()).optional(),compress:t.unknown().optional()}).optional(),mix:t.strictObject({speech:i.optional(),music:i.optional(),musicAlone:i.optional(),sfx:i.optional(),footage:i.optional(),footageUnderSpeech:i.optional(),duck:t.strictObject({db:t.number().min(-60).max(0).optional(),attack:t.number().min(0).max(10).optional(),release:t.number().min(0).max(10).optional(),hold:t.number().min(0).max(60).optional()}).optional(),musicFade:t.strictObject({in:t.number().min(0).max(60).optional(),out:t.number().min(0).max(60).optional()}).optional()}).optional(),mic:t.union([t.string().min(1),t.record(t.string(),t.unknown()),t.literal(!1)]).optional(),look:t.string().min(1).optional(),defaults:t.strictObject({part:PartDefaultsSchema.optional()}).optional(),covers:t.literal(!0).optional(),fps:t.union([t.number(),t.string()]).refine(o=>f(o)!==void 0,{error:`A frame rate is ${u}`}).optional(),transparent:t.boolean().optional(),maxDuration:t.number().positive().optional(),loadLimit:t.number().positive().optional(),seekLimit:t.number().positive().optional(),deliverable:t.boolean().optional(),master:t.union([i,t.literal(!1),t.strictObject({lufs:t.union([i,t.literal(!1)]).optional(),truePeak:t.number().min(-9).max(0).optional()})]).optional(),motionBlur:t.strictObject({samples:t.number().int().min(2).max(16),shutter:t.number().gt(0).max(1).optional()}).nullable().optional(),capture:t.strictObject({bloom:t.strictObject({threshold:t.number().optional(),radius:t.number().optional(),strength:t.number().optional()}).optional(),aberration:t.number().optional(),soften:t.number().optional(),vignette:t.number().optional(),exposure:t.strictObject({drift:t.number().optional(),period:t.number().optional()}).optional(),grain:t.strictObject({amount:t.number().optional(),size:t.number().optional(),shadows:t.number().optional(),highlights:t.number().optional(),chroma:t.number().optional(),chromaSize:t.number().optional(),static:t.boolean().optional()}).optional(),sharpen:t.number().optional()}).optional(),post:t.strictObject({filter:t.string().min(1).optional(),lut:t.string().regex(/\.cube$/i,"A LUT is a .cube file").optional()}).optional()}),OutputMeta=t.strictObject({kind:t.enum(h),options:t.record(t.string(),t.unknown())}),PieceMeta=t.strictObject({id:PieceId.optional(),script:t.string().min(1).optional(),title:t.union([t.string().min(1),t.record(Locale,t.string().min(1))]).optional(),format:FormatEntrySchema.optional(),matrix:MatrixSchema.optional(),meta:t.record(t.string(),t.unknown()).optional(),outputs:t.record(OutputName,OutputMeta).refine(o=>Object.keys(o).length>0,"outputs needs at least one output")}),LookConfigSchema=t.strictObject({color:t.strictObject({bg:t.string().min(1).optional(),fg:t.string().min(1).optional(),accent:t.string().min(1).optional(),muted:t.string().min(1).optional(),surface:t.string().min(1).optional()}).optional(),font:t.strictObject({display:t.string().min(1).optional(),body:t.string().min(1).optional(),mono:t.string().min(1).optional(),emoji:t.string().min(1).optional()}).optional(),motion:t.strictObject({beat:t.number().positive().optional()}).optional(),sfx:t.record(t.string().regex(/^[a-z][a-z0-9-]*$/,"a sound's name: lowercase letters, digits and -"),t.string().min(1).refine(o=>!o.startsWith("/")&&!o.split(/[\\/]/).includes(".."),"a sound is an audio file relative to the workspace's root")).optional()}),PropSchemaEntry=t.looseObject({type:t.enum(["text","time","asset","color","number","boolean","list","object"])}),ComponentEntry=t.strictObject({name:t.string(),label:t.union([t.string(),t.record(t.string(),t.string())]),file:t.string(),props:t.record(t.string(),PropSchemaEntry),examples:t.array(t.string()),hidden:t.boolean()}),VideoConfigSchema=t.object({look:LookConfigSchema.optional(),defaults:t.strictObject({format:VideoFormatSchema.optional(),part:PartDefaultsSchema.optional()}).optional()});
|
|
@@ -5,17 +5,24 @@ export type { Deeper } from "@allyhub/scenery";
|
|
|
5
5
|
export interface PhoneCamera extends SceneryPhone {
|
|
6
6
|
/** video({ capture }): the marks on the picture it records. */
|
|
7
7
|
capture: CaptureOptions;
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* video({ motionBlur }): the shutter's blur of what moves (a scenery's
|
|
10
|
+
* camera too). null by default: each sample draws the frame again (8 cost
|
|
11
|
+
* a phone-filmed short about three times its render), and a hand-held
|
|
12
|
+
* phone's moves barely show it.
|
|
13
|
+
*/
|
|
14
|
+
motionBlur: MotionBlur | null;
|
|
10
15
|
}
|
|
11
16
|
/**
|
|
12
17
|
* A phone's main camera filming a screen or a room indoors, held in a
|
|
13
18
|
* hand: a 26 mm lens on its 4:3 frame at f/8 equivalent (f/1.8 on its
|
|
14
19
|
* small sensor), a 12 MP sensor, a hand whose tremor its stabiliser mostly
|
|
15
20
|
* takes out, focus that hunts after a cut, a reframe or a jolt, exposure
|
|
16
|
-
* that follows a new framing late; grain
|
|
17
|
-
*
|
|
18
|
-
*
|
|
21
|
+
* that follows a new framing late; fine grain, a little coloured, as strong
|
|
22
|
+
* on a screen's white as in its middle tones (faded in the whites, a
|
|
23
|
+
* screen reads as paper), a lens a little soft and the phone's sharpening
|
|
24
|
+
* on it, so text is crisp as a phone's photo of a screen shows it; no motion
|
|
25
|
+
* blur. Measured against phone photos of a laptop's screen (2026-11).
|
|
19
26
|
*/
|
|
20
27
|
export declare const PHONE_CAMERA: PhoneCamera;
|
|
21
28
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{PHONE_CAMERA as
|
|
2
|
+
import{PHONE_CAMERA as s}from"@allyhub/scenery";export const PHONE_CAMERA={...s,capture:{soften:.3,grain:{amount:.013,size:.75,shadows:2,highlights:1,chroma:.4,chromaSize:3},sharpen:.9,vignette:.2,bloom:{threshold:.92,radius:14,strength:.15}},motionBlur:null};const i=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function u(t,n){if(!i(t)||!i(n))return n===void 0?t:n;const o={...t};for(const[r,e]of Object.entries(n))o[r]=e===void 0?t[r]:u(t[r],e);return o}export function phoneCamera(t={}){return u(PHONE_CAMERA,t)}
|
package/docs/README.md
CHANGED
|
@@ -17,5 +17,7 @@ What a piece is written with, for the version of the SDK installed beside them.
|
|
|
17
17
|
- [modeling.md](modeling.md): a prop modelled in code with `@allyhub/model` and put in a scenery.
|
|
18
18
|
- [docs.md](docs.md): a doc, one MDX file: its title, the Markdown and tags it reads, pictures and links, check and render.
|
|
19
19
|
- [sheets.md](sheets.md): a sheet, a workbook as YAML and CSV: tables, formulas, names, checks, the openpyxl API (`@allyhub/sdk/sheets`), calc, trace and render.
|
|
20
|
+
- [canvas.md](canvas.md): a canvas, a JSON Canvas file laying a project's work out with notes, groups and edges.
|
|
21
|
+
- [x.md](x.md): an X post, thread or long post in POST /2/tweets's fields, and an X article in X's blocks: what X counts and refuses, and what they render to.
|
|
20
22
|
- [websites.md](websites.md): a website, any web project with its JSON file: how Studio serves it while it is made (`PORT`, `HOST`, the preview hosts), a project's videos in its pages, its build.
|
|
21
23
|
- [defaults.md](defaults.md): every default of the piece API, generated from the code's constants, with the option that changes it.
|
package/docs/canvas.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Canvases
|
|
2
|
+
|
|
3
|
+
A canvas lays a project's work out to be seen together: items side by side, with notes, groups and edges. It draws nothing of its own and exports nothing. It is a `.canvas` file anywhere in the project, in [JSON Canvas 1.0](https://jsoncanvas.org) as Obsidian writes it, listed in `allyhub.yaml` with no `kind` (`- file: boards/launch.canvas`, [project.md](project.md#items)): its editor opens it by its name.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```json
|
|
7
|
+
{
|
|
8
|
+
"nodes":[
|
|
9
|
+
{"id":"7d1f0c3a9b2e4f60","type":"group","label":"Share pictures","x":-40,"y":-80,"width":1360,"height":520},
|
|
10
|
+
{"id":"2b9e81c04d7f3a15","type":"file","file":"launch/og/og.ts","x":0,"y":0,"width":600,"height":340},
|
|
11
|
+
{"id":"c04d7f3a152b9e81","type":"text","text":"**Why this plate**: the river reads at 400 px.","x":640,"y":0,"width":320,"height":160,"color":"4"},
|
|
12
|
+
{"id":"9a6e2f10b3c84d57","type":"link","url":"https://example.com/launch","x":640,"y":200,"width":320,"height":120}
|
|
13
|
+
],
|
|
14
|
+
"edges":[
|
|
15
|
+
{"id":"5e3a9c1d7b0f2846","fromNode":"c04d7f3a152b9e81","fromSide":"left","toNode":"2b9e81c04d7f3a15","toSide":"right","label":"chosen"}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- **Paths are from the project's folder**, wherever the canvas is.
|
|
21
|
+
- **A file node points at an item by its file**, as `allyhub.yaml` lists it (`launch/og/og.ts`); it shows the item's own preview, live: an image's boards, a deck's slide, a video's still, a doc's first words. Any other file (a picture, a clip, a sound) shows itself.
|
|
22
|
+
- **Nodes**: `text` (Markdown), `file`, `link` (`url`) and `group` (`label`), each with whole-pixel `x`, `y`, `width` and `height`; y grows down. The first node is drawn at the back, so a group comes before what it holds. A group holds the nodes whose boxes are inside its box.
|
|
23
|
+
- **Edges** join two nodes by id, from a side (`top`, `right`, `bottom`, `left`) to a side, with a `label`; `toEnd` is an arrow unless `"none"`.
|
|
24
|
+
- **Colours** are `"1"` red, `"2"` orange, `"3"` yellow, `"4"` green, `"5"` cyan, `"6"` purple, or a hex colour.
|
|
25
|
+
- **Ids** are unique across nodes and edges: 16 hex digits, as Obsidian makes them.
|
|
26
|
+
- **A person's changes** (moves, notes, edges) are written to the same file, which keeps the ids and the fields it does not know.
|
|
27
|
+
|
|
28
|
+
`allyhub check` reports a duplicate id, a file node at a missing file and an edge at a missing node (AK-C001 to AK-C004). `allyhub inspect canvas <file>` lists the nodes with their boxes and what they point at, what each group holds and each edge's ends.
|
package/docs/defaults.md
CHANGED
|
@@ -268,6 +268,17 @@ A bar or column chart's bars: the gap between groups, % of a bar (Office's `gap_
|
|
|
268
268
|
| `gap` | `80` |
|
|
269
269
|
| `overlap` | `-8` |
|
|
270
270
|
|
|
271
|
+
## Sheets
|
|
272
|
+
|
|
273
|
+
### `ITERATION_DEFAULTS`
|
|
274
|
+
|
|
275
|
+
A sheet's iterative calculation, Excel's own limits: how many rounds at most, and the change under which it stops. The workbook file's `iteration: { max_iterations, max_change }`.
|
|
276
|
+
|
|
277
|
+
| Key | Value |
|
|
278
|
+
| --- | --- |
|
|
279
|
+
| `max_iterations` | `100` |
|
|
280
|
+
| `max_change` | `0.001` |
|
|
281
|
+
|
|
271
282
|
## Importing
|
|
272
283
|
|
|
273
284
|
### `ZIP_LIMITS`
|
|
@@ -896,7 +907,7 @@ A `scenery()` layer's drawing scale, its name and its depth of field's levels. `
|
|
|
896
907
|
|
|
897
908
|
| Key | Value |
|
|
898
909
|
| --- | --- |
|
|
899
|
-
| `scale` | `
|
|
910
|
+
| `scale` | `1` |
|
|
900
911
|
| `name` | `"scenery"` |
|
|
901
912
|
| `focusLevels` | `8` |
|
|
902
913
|
|
|
@@ -947,7 +958,13 @@ A phone's main camera held in a hand: its lens, sensor and hand. `phoneCamera(ch
|
|
|
947
958
|
| `sensor.moire` | `1` |
|
|
948
959
|
| `sensor.chroma` | `0.3` |
|
|
949
960
|
| `sensor.distortion` | `-0.03` |
|
|
950
|
-
| `sensor.grade.
|
|
961
|
+
| `sensor.grade.room.curve` | `[[0,0],[0.25,0.21],[0.5,0.47],[0.75,0.78],[1,1]]` |
|
|
962
|
+
| `sensor.grade.room.saturation` | `1.08` |
|
|
963
|
+
| `sensor.grade.screen.curve` | `[[0,0],[0.36,0.1],[0.51,0.16],[0.67,0.46],[0.8,0.84],[1,1]]` |
|
|
964
|
+
| `sensor.grade.screen.saturation` | `1.25` |
|
|
965
|
+
| `sensor.grade.screen.hue` | `5` |
|
|
966
|
+
| `sensor.grade.screen.balance` | `[1,0.97,1]` |
|
|
967
|
+
| `sensor.grade.share` | `[0.5,0.8]` |
|
|
951
968
|
| `hand.angle` | `0.25` |
|
|
952
969
|
| `hand.roll` | `0.6` |
|
|
953
970
|
| `hand.shift` | `0.001` |
|
|
@@ -1080,6 +1097,7 @@ A screen's physical pixels, which the sensor films. `screen(…, { pixels })`.
|
|
|
1080
1097
|
| --- | --- |
|
|
1081
1098
|
| `density` | `2` |
|
|
1082
1099
|
| `rows` | `0.15` |
|
|
1100
|
+
| `mesh` | `0.09` |
|
|
1083
1101
|
|
|
1084
1102
|
### `SCREEN_LIGHT_DEFAULTS`
|
|
1085
1103
|
|
package/docs/docs.md
CHANGED
|
@@ -28,7 +28,7 @@ It is the PDF's title, and the doc's name where people see it unless `allyhub.ya
|
|
|
28
28
|
|
|
29
29
|
## What a doc reads
|
|
30
30
|
|
|
31
|
-
The file is MDX: Markdown with GFM tables, strike-through and task lists, plus tags and `import` lines. Bare addresses are not links (no autolinks): write `[text](https://…)`.
|
|
31
|
+
The file is MDX: Markdown with GFM tables, strike-through and task lists, plus tags and `import` lines. Bare addresses are not links (no autolinks): write `[text](https://…)`. `*`, `_`, `[` and `<` are Markdown's marks as CommonMark reads them: a blank to fill in written `[__]` twice in a paragraph makes the words between the two bold; write `\_\_` (or `[ ]`) for one.
|
|
32
32
|
|
|
33
33
|
| Written | Block |
|
|
34
34
|
| --- | --- |
|
|
@@ -39,7 +39,7 @@ The file is MDX: Markdown with GFM tables, strike-through and task lists, plus t
|
|
|
39
39
|
| `- [ ] item`, `- [x] item` | task, unchecked or checked |
|
|
40
40
|
| `> line` | quote |
|
|
41
41
|
| A fenced code block | code, with its language; ```` ```math ```` and ```` ```mermaid ```` are drawn ([below](#equations-and-diagrams)) |
|
|
42
|
-
| A GFM table | table, its first row the head,
|
|
42
|
+
| A GFM table | table, its first row the head, bold on its ground, the table between a strong rule over and under it and its rows apart by lines (a report's three rules); a head row whose cells are all empty is not drawn, the table then without a head; a column whose cells are all numbers (`12%`, `$1,200`, `7.9×`, `29.8k`; a dash or `n/a` may stand for one) is set to the right, its head too (`numberColumns`); its columns share its width as CSS 2.1's automatic table layout and Word's AutoFit to contents do (`columnShares`): each at least as wide as its longest word and its cell's margins, what is left by how much more each needs to hold its longest cell (6 to 36 characters) on a line, alike on paper and in Word |
|
|
43
43
|
| `` alone on a line | picture |
|
|
44
44
|
| `---` | divider |
|
|
45
45
|
|
|
@@ -58,7 +58,7 @@ Tags with plain string attributes (`name="value"`, or the bare name for `toggle`
|
|
|
58
58
|
| `<strong>` `<b>`, `<em>` `<i>`, `<del>` `<s>`, `<code>` | The marks `**`, `*`, `~~` and a backtick make, where Markdown's own would not read back. A doc reads `**` beside Chinese punctuation as a Chinese writer means it (`**“引号”**` is bold, as markdown-cjk-friendly reads it); other Markdown readers may not, and the editor writes a tag there |
|
|
59
59
|
| `<br />` | Inside a line, a line break; on a line of its own, an empty paragraph |
|
|
60
60
|
| `<Block align color bg toggle>` | One block's look. Inside it: the block, then the blocks under it. `align` is `center`, `right` or `justify`; `toggle` makes a heading or a line fold the blocks after it |
|
|
61
|
-
| `<Callout icon color bg>` | A line set apart in a box with
|
|
61
|
+
| `<Callout icon color bg>` | A line set apart in a box, with `icon` before it when given (none when absent). Inside it: the line, then the blocks under it |
|
|
62
62
|
| `<img src alt title width align id />` | A picture with a width in px or a place (`align`: `center` or `right`); `title` is its caption, `id` what a reference names it by. Without those, write `` |
|
|
63
63
|
| `<Table widths head caption id>` around one GFM table | Column widths in px, comma-separated, an empty entry for a column that shares what is left by its content (`widths="120,,200"`); `head` is `row` (the default), `column`, `both` or `none`; `caption` is set over it, `id` is what a reference names it by |
|
|
64
64
|
| `<Chart type …>` around one GFM table, or `<Chart type data … />` | A chart drawn from numbers ([below](#charts)) |
|
|
@@ -91,7 +91,7 @@ Folded under the heading.
|
|
|
91
91
|
|
|
92
92
|
</Block>
|
|
93
93
|
|
|
94
|
-
<Callout
|
|
94
|
+
<Callout bg="yellow">
|
|
95
95
|
|
|
96
96
|
Check the dates.
|
|
97
97
|
|
|
@@ -195,7 +195,7 @@ Where a page breaks is Chrome's and Word's, by the rules Word sets by default: a
|
|
|
195
195
|
|
|
196
196
|
`<TableOfContents />` lists the doc's headings (its title left out) to the level its `levels` says, default 3, each a link to it, under its `title` (Word's TOC Heading, set as a heading 1 and listed nowhere): default "Contents", 目录 in a doc written in Chinese, `title=""` for none; on paper each with the page it is on after a line of dots, in Word as Word's own contents (its entries with the PDF's pages until Word's Update Table sets its own). The editor lists them, each a link.
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
Unless the front matter says `captions: plain`, a picture, a component or a chart with a caption (a chart's is its `title`, set under it as its caption on paper and in Word) is numbered Figure 1, 2, 3, and a table with a `caption` Table 1, 2, 3; in a doc written in Chinese 图 1 and 表 1. A link with no words of its own to an `id` says the figure's or table's number, and to a heading's anchor (its words in lower case, spaces as hyphens, as GitHub writes them) its words:
|
|
199
199
|
|
|
200
200
|
```mdx
|
|
201
201
|
As [](#sales) shows, revenue doubled; [](#costs) lists the costs.
|
|
@@ -273,7 +273,7 @@ captions: numbered
|
|
|
273
273
|
|
|
274
274
|
| Key | Means |
|
|
275
275
|
| --- | --- |
|
|
276
|
-
| `preset` | A convention that sets the keys below as it does; any key the doc writes wins over it. `report`: a report read on screen and on paper (the text 10.5 pt at 1.2 lines, 0.7 em after each paragraph, the title 24 pt, levels 1 and 2 at 18 and 14 pt with a hairline under them, level 3 at 11.5 pt), for figures (`<Stats>`), cards and tags. `apa`: APA 7's student paper (Letter at 1 in, Times 12 double-spaced, paragraphs set in 0.5 in with no space between them, the page number at the top right, the title and headings the text's size and bold, level 1 centred, levels 3 and 5 italic, APA citations). `mla`: MLA 9's paper (the same page; write the surname before the number: `header: { right: "Smith {page}" }`; the title centred and plain, MLA citations and Works Cited) |
|
|
276
|
+
| `preset` | A convention that sets the keys below as it does; any key the doc writes wins over it. `report`: a report read on screen and on paper (the text 10.5 pt at 1.2 lines, 0.7 em after each paragraph, the title 24 pt, levels 1 and 2 at 18 and 14 pt with a hairline under them, level 3 at 11.5 pt), for figures (`<Stats>`), cards and tags. `apa`: APA 7's student paper (Letter at 1 in, Times 12 double-spaced, paragraphs set in 0.5 in with no space between them, the page number at the top right, the title and headings the text's size and bold, level 1 centred, levels 3 and 5 italic, APA citations). `mla`: MLA 9's paper (the same page; write the surname before the number: `header: { right: "Smith {page}" }`; the title centred and plain, MLA citations and Works Cited). `memo`: Purdue OWL's memo (Letter at 1 in, Times 12 single-spaced, paragraphs flush left with a blank line between them, the title and headings the text's size and bold, the page number at the foot's centre; write the heading block, TO, FROM, DATE and SUBJECT, yourself). `business-letter`: Purdue OWL's block-format letter (the same page, no running head or foot and no page numbers; the date, inside address, salutation and closing are your paragraphs) |
|
|
277
277
|
| `paper` | `Letter` (the default), `Legal`, `A4`, `A3`, `A5`, `B5`, or `[width, height]` in mm |
|
|
278
278
|
| `orientation` | `portrait` (the default) or `landscape` |
|
|
279
279
|
| `margins` | mm: one for all four, `[top and bottom, sides]`, or `[top, right, bottom, left]`; default 18 at the top and bottom, 20 at the sides |
|
|
@@ -286,7 +286,7 @@ captions: numbered
|
|
|
286
286
|
| `grid` | Word's document grid: `{ chars: 28, lines: 22 }`, the line height and the spacing of characters made to fit the text area; headings are lines of it, and where a mark that may not start a line (,。、) would take the character before it down, the line's marks are set half wide at its end, as Word squeezes them, so a full line holds its characters |
|
|
287
287
|
| `title`, `headings` | How the title and each heading level are set: `{ font, size, weight, align, italic, rule }` (`weight` is `normal` or `bold`, `align` `left`, `center` or `right`, `italic` `true` or `false`, `rule` `true` for a hairline under it, 3 pt below its text, as Word's paragraph border); `headings` by level, `2: { font: hei }` |
|
|
288
288
|
| `header`, `footer` | What runs at the head and foot of every page: words (centred), `false`, or `{ left, center, right, outside, inside, font, size }` (`outside` is at the right of odd pages and the left of even ones). `{title}`, `{section}` (the top-level heading the page is in, as Word's STYLEREF finds it), `{page}` and `{pages}` stand for theirs. Default: no header, the title at the left of the foot and `{page} / {pages}` at its right. A page that opens with a cover has no header |
|
|
289
|
-
| `captions` | `numbered
|
|
289
|
+
| `captions` | `numbered` (the default): figures and tables with a caption are numbered ([above](#contents-captions-and-references)); `plain`: their captions stand without a number |
|
|
290
290
|
| `bibliography`, `citation-style` | The sources the doc cites and how they are set ([above](#citations)) |
|
|
291
291
|
| `accent` | A colour (the names above, or `#RRGGBB`): links, a quote's rule and a chart's first colour |
|
|
292
292
|
| `cover` | A picture across the top of the page, as Notion's: its path from the doc's folder (it must be in the project, AK-M008), or an address. AllyHub's own covers, the editor's gallery: `allyhub doc cover list` names them, `allyhub doc cover set <doc> <name>` writes one beside the doc (`cover-<name>.svg`) and names it here. Edge to edge across the top, as Notion's: in the editor the page's width, about a third of the window high; on paper the first page's top, 64 mm high (`COVER_HEIGHT_MM`), with no margin around it; in Word the same band, floated at the page's corner; first in Markdown |
|
|
@@ -306,4 +306,4 @@ Without front matter the page is Letter, sans, with the default accent and no co
|
|
|
306
306
|
- `allyhub check` reports AK-M008 for a doc whose file is not MDX, that holds what a doc does not draw (`{…}`, a tag inside a line other than the marks above, a wrong attribute or value), that shows a picture which is not in the project, that names a component which is not one or a prop it does not have, whose chart cannot be drawn from its numbers or whose equation is not TeX KaTeX reads, that cites a source its bibliography does not hold (or names a bibliography that is not CSL-JSON in the project); each problem has its file and line.
|
|
307
307
|
- `allyhub inspect pages <doc>` measures its pages as `allyhub render` prints them, from the PDF itself, and says the facts with their raw numbers (mm on the paper, each block by its line in the doc's file): the space left at each page's foot, each block broken over pages with its lines (a table's rows) on each and whether its head repeats, a heading near a page's foot with the lines after it on its page, a paragraph's short last line, content past the column and what is cut at the paper's edge, a line that starts or ends with a mark Chinese type keeps off it, each numbered figure's page and the pages that name it, the text as a grid, and whether the contents' page numbers held. It draws the pages too, each block outlined and labelled by its line, the space at each foot shaded (`.allyhub/work/inspect/<place>/pages.webp`). They are facts, never problems: where a page breaks well is yours to judge. `--heading-lines` and `--short-line` say what is listed, `--all` lists every heading and last line.
|
|
308
308
|
- `allyhub frames <doc>` draws its pages as `allyhub render` prints them, its components drawn first (the PDF printed and thrown away, each page drawn), tiled on one picture under `.allyhub/work/frames/<place>/`, and says how many pages there are and on what paper; `--page 2-3` draws those pages large. It is how to look at a doc and fit it to a length, and nothing is written to `.allyhub/out/`.
|
|
309
|
-
- `allyhub render` prints each doc under `.allyhub/out/`, by its id, as `plan.pdf`; `--type png` writes a picture of the whole page (`plan.png`), `--type docx` a Word document (`plan.docx`: its text and its charts editable, a picture Word cannot show as a JPEG, an equation and a diagram as pictures), `--type md` plain Markdown (`plan.md`: what the doc says without what only a doc can say, a chart as its table of numbers), and `--type pdf,docx,png,md` all of them. A doc with a problem is not rendered: the command fails and says why. `allyhub help render` has every option.
|
|
309
|
+
- `allyhub render` prints each doc under `.allyhub/out/`, by its id, as `plan.pdf`; `--type png` writes a picture of the whole page (`plan.png`), `--type docx` a Word document (`plan.docx`: its text and its charts editable, a picture Word cannot show as a JPEG, an equation and a diagram as pictures), `--type md` plain Markdown (`plan.md`: what the doc says without what only a doc can say, a chart as its table of numbers), and `--type pdf,docx,png,md` all of them. With a PDF or a Word document it says how the pages printed: how many, the share of each page's text area left empty at its foot, the blocks broken over pages (a Word document alone is printed once to measure it); `allyhub inspect pages` has every fact. A doc with a problem is not rendered: the command fails and says why. `allyhub help render` has every option.
|
package/docs/scenery.md
CHANGED
|
@@ -154,7 +154,7 @@ camera: shots([
|
|
|
154
154
|
|
|
155
155
|
### A phone
|
|
156
156
|
|
|
157
|
-
`PHONE_CAMERA` (`@allyhub/sdk/scenery`) names a phone's main camera as the options of each mechanism; `phoneCamera(over)` changes any value and keeps the rest. `lens` goes into a camera state, `sensor` into `scenery({ sensor })`, `hand` into `handheld()`, and the marks it leaves on its picture (grain, softness, sharpening
|
|
157
|
+
`PHONE_CAMERA` (`@allyhub/sdk/scenery`) names a phone's main camera as the options of each mechanism; `phoneCamera(over)` changes any value and keeps the rest. `lens` goes into a camera state, `sensor` into `scenery({ sensor })`, `hand` into `handheld()`, and the marks it leaves on its picture (grain, softness, sharpening) into `video()`'s `capture` ([video.md](video.md)). Its `motionBlur` is null: each sample draws a frame again (8 made a phone-filmed short take three times as long to render), and a hand's moves barely show it. The sensor's `grade` follows what fills the frame, as a phone's exposure does: on a room or a person its `room` grade (a gentle contrast, a little more colour); as a screen comes to fill the frame, its `screen` grade (the phone exposes for the lit screen: its white a neutral light grey, its middle tones and colours deep), eased in between `share[0]` and `share[1]` of the frame filled (default 50% and 80%), frame by frame. Each grade is a brightness curve (`curve`, hues kept), then `saturation` and `hue`; it grades the scenery layer alone, not captions laid over it; `grade: null` for none. The screen's grade and the capture's marks are measured against phone photos of a laptop's screen (fine grain kept in the whites, crisp sharpened text). Each is a starting point, not a look.
|
|
158
158
|
|
|
159
159
|
```ts file=phone/phone.ts
|
|
160
160
|
import { part, video } from "@allyhub/sdk";
|
|
@@ -182,7 +182,6 @@ const camera = handheld(
|
|
|
182
182
|
export default video({
|
|
183
183
|
format: "9x16",
|
|
184
184
|
capture: phone.capture,
|
|
185
|
-
motionBlur: phone.motionBlur,
|
|
186
185
|
parts: () => [
|
|
187
186
|
part({
|
|
188
187
|
key: "look",
|
|
@@ -238,7 +237,7 @@ export default video({
|
|
|
238
237
|
| `box` | the frame | `[x, y, w, h]` as fractions of the frame; the camera's aspect is the box's |
|
|
239
238
|
| `background` | the scenery's own | A colour, or `"transparent"`; without it what `build` set as the scene's background, else transparent |
|
|
240
239
|
| `time` | `{ from: 0 }` | The scenery's time from the film's: `{ from }` at the film's start, or `(filmT) => number`. It runs on across parts and cuts |
|
|
241
|
-
| `quality` | `{ scale:
|
|
240
|
+
| `quality` | `{ scale: 1, focusLevels: 8 }` | `scale`: the share of the layer's size each way it is drawn at (above 1 supersamples; 0.5 for a quicker draft, softer). `focusLevels`: Gaussian levels a screen's depth of field is mixed from. `SCENERY_LAYER_DEFAULTS` |
|
|
242
241
|
| `sensor` | none | A phone's sensor filming it: the moiré its Bayer grid makes of the screens' pixels. `{ photosites, lens, moire, chroma, distortion }`, `SENSOR_DEFAULTS` |
|
|
243
242
|
| `screens` | none | `{ <object name>: screen(…) }` (below) |
|
|
244
243
|
| `props` | none | `SceneryProp`s this layer brings in (below) |
|
|
@@ -264,7 +263,7 @@ export default video({
|
|
|
264
263
|
| `size` | `[1920, 1080]` | Layers only: the content's pixels (a video uses its format's) |
|
|
265
264
|
| `dur` | to the layer's end | Layers only |
|
|
266
265
|
| `background` | `"#000000"` | Behind the content, or `"transparent"` |
|
|
267
|
-
| `pixels` | `{ density: 2, rows: 0.15 }` | Its physical pixels, for a sensor's
|
|
266
|
+
| `pixels` | `{ density: 2, rows: 0.15, mesh: 0.09 }` | Its physical pixels, for a sensor's moiré, and `mesh` (0–1, 0 none): the fine grid of faint lines a phone close to a screen shows, every three of its pixels (`PANEL_DEFAULTS`) |
|
|
268
267
|
| `glass` | none | `{ reflectance?, roughness?, scale? }`: what its glass reflects of the scenery over its picture, by Fresnel; `{}` the defaults (`GLASS_DEFAULTS`) |
|
|
269
268
|
| `inScenery` | `true` | Drawn in the scenery: `{ brightness?, light? }` (below); `false`: laid over the scenery |
|
|
270
269
|
|
package/docs/sheets.md
CHANGED
|
@@ -71,8 +71,9 @@ Its JSON Schema is `https://allyhub.com/schemas/sheet.schema.json`.
|
|
|
71
71
|
| `sheets[].validations` | Data validation: `{ range, type, operator, formula, values, blank, dropdown, prompt, error }`. See below |
|
|
72
72
|
| `checks` | `{ name, formula }`: a formula that must hold. One that is false, 0 or an error is a problem (AK-M009) |
|
|
73
73
|
| `scenarios` | Named sets of inputs, each what names hold instead: see [Scenarios](#scenarios) |
|
|
74
|
+
| `iteration` | Excel's iterative calculation: `true`, or `{ max_iterations, max_change }` (Excel's 100 and 0.001 unless it says). A circular reference is then computed again until it settles |
|
|
74
75
|
|
|
75
|
-
A **cell** is YAML's value: a number, `true`, text; text that starts with `=` is a formula. In a `{ … }` a formula with a comma or a bracket is quoted. Its long form is `{ value | formula, format, name, …look }`: `name` is a defined name for that cell.
|
|
76
|
+
A **cell** is YAML's value: a number, `true`, text; text that starts with `=` is a formula. In a `{ … }` a formula with a comma or a bracket is quoted. Its long form is `{ value | formula, format, name, start, …look }`: `name` is a defined name for that cell; `start` is what a formula's cell holds before it is computed, where [iterative calculation](#formulas) starts, as an Excel cell keeps its last value.
|
|
76
77
|
|
|
77
78
|
A **range key** (`B3:M3`) gives one value or formula to every cell in it. A formula is written for its first cell and moved as a fill moves it: relative references shift, `$` ones stay. A single cell's key wins over a range's, and a later range over an earlier one; `B5: null` keeps a cell of a range empty.
|
|
78
79
|
|
|
@@ -127,6 +128,8 @@ sheets:
|
|
|
127
128
|
protect: true # Protect Sheet, with no password
|
|
128
129
|
```
|
|
129
130
|
|
|
131
|
+
`allyhub render` says, with each Excel file, how each sheet prints (its pages across and down and its scale), the cells whose text its column and the empty cells after it cannot hold (Excel cuts it where the next cell starts), the numbers wider than their column (Excel shows ####), counted in characters of Calibri 11's digit as Excel counts a column's width, and the numbers of 1,000 or more with no number format.
|
|
132
|
+
|
|
130
133
|
In a script: `ws.page_setup.orientation`, `.paperSize`, `.fitToWidth`, `.fitToHeight`, `ws.page_margins.left`, `ws.print_area`, `ws.print_title_rows`, `ws.print_title_cols`, `ws.oddFooter.right.text`, `cell.hyperlink`, `cell.comment = new Comment("Check", "Finance")`, `ws.add_image(new Image("files/logo.png"), "B1")`, `ws.row_dimensions[12].outlineLevel`, `ws.protection.sheet`.
|
|
131
134
|
|
|
132
135
|
### Files in a cell
|
|
@@ -186,8 +189,9 @@ A **calculated column** has its `formula` in `columns` and no column in the CSV,
|
|
|
186
189
|
The language is Excel's: `A1` and `$` references, ranges, `Sheet!A1`, `'My Sheet'!A1`, `Jan:Dec!A1`, whole columns and rows, defined names, structured references (`orders[total]`, `[@price]`, `orders[@total]`, `orders[[#Headers],[a]:[c]]`, `orders` for its rows), operators with Excel's precedence (`-2^2` is 4), array constants, `LET`, `LAMBDA` (a name may hold one, and is then called: `=double(4)`), error values. `allyhub sheet capabilities` lists the functions under `formulas`.
|
|
187
190
|
|
|
188
191
|
- Results are computed in order, each once. `NOW`, `TODAY`, `RAND`, `RANDBETWEEN`, `OFFSET` and `INDIRECT` are volatile. `NOW` and `TODAY` read the clock when the sheet is built or exported; `RAND` in a build and an export is seeded by the sheet's files, so the same files give the same rows.
|
|
189
|
-
- A formula that reads itself is a problem, and its cells and what reads them show `#CYCLE!`: Excel says so in a dialog. A cycle through a branch `IF` does not take is none, as in Excel.
|
|
192
|
+
- A formula that reads itself is a problem, and its cells and what reads them show `#CYCLE!`: Excel says so in a dialog. A cycle through a branch `IF` does not take is none, as in Excel. With `iteration` on it is no problem: as Excel's iterative calculation does, its cells and what reads them are computed again, each reading the latest value of the others (a cell not computed yet reads its `start`, or 0), until no value moves by `max_change` or `max_iterations` rounds have run. `allyhub inspect sheet` says how many rounds ran and how far a value moved in the last.
|
|
190
193
|
- An array result spills, as in Excel: the formula's cell shows the first value and the cells beside it the rest. They hold nothing in any file, read like any others, and `A1#` is the range the spill covers now. `#SPILL!` says something stands in the way (a cell that holds anything, a merge, a table, the edge of the sheet), and what stands there going lets it spill. A calculated column cannot spill. `=@A1:A9` is the value in the formula's own row. `FILTER`, `SORT`, `SORTBY`, `UNIQUE`, `SEQUENCE`, `RANDARRAY` (seeded as `RAND` is), `TEXTSPLIT`, `TAKE`, `DROP`, `VSTACK`, `HSTACK`, `TOCOL`, `TOROW`, `CHOOSEROWS`, `CHOOSECOLS`, `EXPAND`, `WRAPROWS` and `WRAPCOLS` give arrays; `MAP`, `REDUCE`, `SCAN`, `BYROW`, `BYCOL` and `MAKEARRAY` take a `LAMBDA`.
|
|
194
|
+
- A **data table** is Excel's What-If Analysis table, `=TABLE(row input, column input)` over its cells as a range key (`B5:F9: =TABLE($B$1,$B$2)`), its references absolute: each cell is the table's formula with the inputs set to the value atop its column and the value left of its row. A two-way table's formula is the cell above its left column, `A4` here; with a column input alone (`=TABLE(,$B$2)`) the formulas are the row above it, one a column, and with a row input alone (`=TABLE($B$1,)`) the column left of it, one a row. It is worked out after what it reads, iterating where the model does, and again with every change; an `.xlsx` holds it as Excel's own.
|
|
191
195
|
- A formula cannot reach into another workbook.
|
|
192
196
|
|
|
193
197
|
## In a script
|
|
@@ -290,7 +294,20 @@ charts:
|
|
|
290
294
|
size: 9 # its text, points; title_size 14 and color #595959 unless it says
|
|
291
295
|
```
|
|
292
296
|
|
|
293
|
-
In a flow map (`{ … }`), quote a reference with `[`. A scatter's `x` names its places across, each series its own, the chart's `categories` unless it says.
|
|
297
|
+
In a flow map (`{ … }`), quote a reference with `[`. A scatter's `x` names its places across, each series its own, the chart's `categories` unless it says.
|
|
298
|
+
|
|
299
|
+
A **combination chart** is Excel's: a column, line or area chart whose series each may be drawn as another of those kinds, `type` (`column-clustered`, `column-stacked`, `column-stacked-100`, `line`, `line-markers`, `area`, `area-stacked`, `area-stacked-100`), and on a second value axis at the right, `secondary: true`, which `secondary_axis` sets as `value_axis` sets the first (`{ title, min, max, major, format, gridlines, visible }`). Areas are drawn first, then columns, then lines, the second axis's over the first's:
|
|
300
|
+
|
|
301
|
+
```yaml
|
|
302
|
+
- type: column-clustered
|
|
303
|
+
at: F3
|
|
304
|
+
categories: orders[month]
|
|
305
|
+
series:
|
|
306
|
+
- { values: "orders[total]" }
|
|
307
|
+
- { values: "orders[margin]", type: line-markers, secondary: true }
|
|
308
|
+
secondary_axis: { min: 0, max: 1, format: "0%" }
|
|
309
|
+
```
|
|
310
|
+
Rows and columns a person or a filter hides are left out, as Excel plots what shows; an empty cell or `#N/A` is a gap, text is 0. An inserted row, a renamed table or column and a cut reach a chart's references as they reach a formula, and `allyhub check` reports one that names nothing.
|
|
294
311
|
|
|
295
312
|
In a script they are openpyxl's classes. A `Reference` is a range; a table's column or a spill, which it cannot name, is a formula's text:
|
|
296
313
|
|
|
@@ -381,7 +398,7 @@ A name of openpyxl's that is not held throws where it is used, naming what the c
|
|
|
381
398
|
- `allyhub sheet calc <sheet> [what]` prints what a workbook computes, as an aligned table: a sheet (`Summary`, its used range), a range (`Summary!B3:M3`), a table, a name, or every sheet. `--scenario high` computes it with a scenario's inputs; `--scenarios` compares them.
|
|
382
399
|
- `allyhub sheet trace <sheet> <cell>` prints a cell's formula, where it is written, what it reads and what reads it.
|
|
383
400
|
- `allyhub sheet <sheet>` measures each table's columns: counts, empty cells, distinct values, errors, smallest and largest, sum and mean, lengths, the most frequent values.
|
|
384
|
-
- `allyhub inspect <sheet>`, and `allyhub inspect` for a whole project, says what a workbook's formulas and cells are like, as facts, never problems: `sheet-error`, each cell whose value is an error and whether it starts there; `sheet-number`, numbers written into a formula and what takes each, once for a formula a range holds; `sheet-unlike`, a cell between neighbours that read alike, unlike them; `sheet-exception`, a cell set apart from its calculated column's formula; `sheet-unused`, names and typed numbers nothing reads (no formula, chart, rule, check or name); `sheet-invalid`, a value under a validation that breaks it; `sheet-typed`, a number its code typed that neither its data nor its code holds; `sheet-ordinary`, a sheet its code makes and the workbook file holds too. `allyhub inspect sheet <sheet>` has their options: `--plain 0,1,-1` the numbers not said, `--around 1` how many neighbours each side must agree, `--kind`, `--all` for every finding, every number and a table's columns nothing reads.
|
|
401
|
+
- `allyhub inspect <sheet>`, and `allyhub inspect` for a whole project, says what a workbook's formulas and cells are like, as facts, never problems: `sheet-error`, each cell whose value is an error and whether it starts there; `sheet-number`, numbers written into a formula and what takes each, once for a formula a range holds; `sheet-unlike`, a cell between neighbours that read alike, unlike them; `sheet-exception`, a cell set apart from its calculated column's formula; `sheet-unused`, names and typed numbers nothing reads (no formula, chart, rule, check or name); `sheet-invalid`, a value under a validation that breaks it; `sheet-typed`, a number its code typed that neither its data nor its code holds; `sheet-ordinary`, a sheet its code makes and the workbook file holds too; `sheet-iteration`, with `iteration` on, the rounds iterative calculation ran over how many cells and how far a value moved in the last. `allyhub inspect sheet <sheet>` has their options: `--plain 0,1,-1` the numbers not said, `--around 1` how many neighbours each side must agree, `--kind`, `--all` for every finding, every number and a table's columns nothing reads.
|
|
385
402
|
- `allyhub sheet diff <was> <now>` compares two versions, two folders or a folder and an `.xlsx`: what changed value under a formula that did not, what changed formula with its value the same, both, what came and went, names, a table's rows lined up by its `key`, else by their place. `--tolerance`, `--all`, `--json`.
|
|
386
403
|
- `allyhub sheet capabilities` says what the SDK holds of openpyxl's.
|
|
387
404
|
- `allyhub sheet import <file> --to finance/forecast.yaml` makes a sheet of an Excel, CSV or TSV file, its tables' rows in `finance/data/`, never over a place that is taken (see [Excel](#excel)).
|
|
@@ -397,7 +414,7 @@ A name of openpyxl's that is not held throws where it is used, naming what the c
|
|
|
397
414
|
**In.** `allyhub sheet import <file.xlsx>` reads a file whatever wrote it and writes what it means as short text: neighbours with one formula as one range key, a table as a table, a column of one formula as a calculated column, a large rectangle of typed cells as a CSV file, looks as rectangles. It prints:
|
|
398
415
|
|
|
399
416
|
- Excel's scenarios come in by the names of the cells they set; a cell with no name is said, and a `Base case` that holds what the cells hold is left out.
|
|
400
|
-
- `Not carried over:` VBA, pivot tables, a chart of a kind a sheet has none of (radar, stock, surface, bubble, 3-D,
|
|
417
|
+
- `Not carried over:` VBA, pivot tables, a chart of a kind a sheet has none of (radar, stock, surface, bubble, 3-D, a pie or a scatter among other kinds) or whose numbers are written in it, shapes, links to other workbooks, a protection's password, page breaks, rich text (kept as text), filters by condition, kinds of rule the format has no place for, and so on, with where. Notes, links, pictures (beside the workbook file), outlines, Page Layout, protection, a sheet's own names and hidden names come in.
|
|
401
418
|
- A formula that cannot be computed here (a function the engine does not have, another workbook) keeps its value, listed with its cell and why. An array formula over several cells is its first cell's, and the others spill from it.
|
|
402
419
|
- `Computed here against the file:` every formula's result compared with the value the file holds, each difference with its cell (`--tolerance` is how close numbers must be, `--all` lists every one; a formula that reads the clock or a random number is not compared). JSON has every difference.
|
|
403
420
|
|