@allyhub/sdk 0.12.0 → 0.13.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/dist/plan.d.ts +3 -0
- package/dist/node_modules/@allyhub/audio/dist/render.js +1 -1
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-file.d.ts +2 -0
- package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +3 -2
- package/dist/node_modules/@allyhub/chart/dist/chart.d.ts +5 -12
- package/dist/node_modules/@allyhub/chart/dist/chart.js +2 -1
- package/dist/node_modules/@allyhub/chart/dist/color.d.ts +37 -0
- package/dist/node_modules/@allyhub/chart/dist/color.js +2 -0
- package/dist/node_modules/@allyhub/chart/dist/index.d.ts +1 -0
- package/dist/node_modules/@allyhub/chart/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/chart/dist/svg.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/deck-code.d.ts +130 -0
- package/dist/node_modules/@allyhub/formats/dist/data/deck-code.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/gen.d.ts +3 -1
- package/dist/node_modules/@allyhub/formats/dist/data/gen.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +512 -166
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +2523 -136
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +931 -87
- package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
- 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/color.d.ts +11 -0
- package/dist/node_modules/@allyhub/ooxml/dist/color.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/ext.d.ts +43 -0
- package/dist/node_modules/@allyhub/ooxml/dist/ext.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/index.d.ts +2 -1
- package/dist/node_modules/@allyhub/ooxml/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/transform.d.ts +13 -0
- package/dist/node_modules/@allyhub/ooxml/dist/transform.js +2 -0
- package/dist/node_modules/@allyhub/ooxml/package.json +5 -1
- package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +4 -4
- package/dist/node_modules/@allyhub/piece/dist/media.d.ts +2 -2
- package/dist/node_modules/@allyhub/piece/package.json +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +35 -0
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +19 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +35 -20
- package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +3 -3
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +28 -2
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +73 -10
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +9 -9
- package/dist/node_modules/@allyhub/protocol/package.json +1 -1
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/annotations.d.ts +14 -0
- package/dist/node_modules/@allyhub/sheet/dist/annotations.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/index.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/rules.d.ts +24 -0
- package/dist/node_modules/@allyhub/sheet/dist/api/rules.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/styles.d.ts +12 -0
- package/dist/node_modules/@allyhub/sheet/dist/api/styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/arrange.d.ts +28 -1
- package/dist/node_modules/@allyhub/sheet/dist/arrange.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/data-tools.d.ts +42 -0
- package/dist/node_modules/@allyhub/sheet/dist/data-tools.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/edit.d.ts +43 -2
- package/dist/node_modules/@allyhub/sheet/dist/edit.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/fill.d.ts +10 -0
- package/dist/node_modules/@allyhub/sheet/dist/fill.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/filter.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/rewrite.d.ts +14 -0
- package/dist/node_modules/@allyhub/sheet/dist/formula/rewrite.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/html.js +10 -10
- package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +6 -1
- package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/outline.d.ts +30 -0
- package/dist/node_modules/@allyhub/sheet/dist/outline.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/rich.d.ts +29 -0
- package/dist/node_modules/@allyhub/sheet/dist/rich.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/rules.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/table-style.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/table-style.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/table-styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/workbook.d.ts +5 -1
- package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.d.ts +17 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/runs.d.ts +56 -0
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/runs.js +2 -0
- 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.js +1 -1
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/animation.d.ts +117 -21
- package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/api.d.ts +181 -30
- package/dist/node_modules/@allyhub/slides-core/dist/api.js +3 -3
- package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/chart-api.d.ts +28 -2
- package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/check.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/enums.d.ts +222 -4
- package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/file.d.ts +6 -0
- package/dist/node_modules/@allyhub/slides-core/dist/file.js +3 -3
- package/dist/node_modules/@allyhub/slides-core/dist/generated/table-styles.d.ts +3 -0
- package/dist/node_modules/@allyhub/slides-core/dist/generated/table-styles.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/index.d.ts +3 -0
- package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +98 -10
- package/dist/node_modules/@allyhub/slides-core/dist/numbering.d.ts +6 -0
- package/dist/node_modules/@allyhub/slides-core/dist/numbering.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/office.d.ts +53 -0
- package/dist/node_modules/@allyhub/slides-core/dist/office.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/patterns.d.ts +8 -0
- package/dist/node_modules/@allyhub/slides-core/dist/patterns.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +36 -6
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/script.d.ts +11 -0
- package/dist/node_modules/@allyhub/slides-core/dist/script.js +2 -2
- 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/dist/table-style.d.ts +48 -0
- package/dist/node_modules/@allyhub/slides-core/dist/table-style.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/timeline.d.ts +4 -0
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
- package/docs/defaults.md +78 -4
- package/docs/image.md +1 -1
- package/docs/pictures.md +1 -1
- package/docs/project.md +1 -1
- package/docs/sheets.md +19 -9
- package/docs/slides.md +30 -16
- package/docs/speech.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Feature highlights from each AllyHub release.
|
|
4
4
|
|
|
5
|
+
## 0.13.0
|
|
6
|
+
|
|
7
|
+
- **Decks and sheets work like PowerPoint and Excel.** The deck editor has PowerPoint's ribbon and every animation effect; the sheet editor has Excel's everyday commands, from filters by colour to Paste Special, and rich text in a cell. An export says what it leaves out.
|
|
8
|
+
- **A provenance record is `<file>.provenance`.** The record beside a file a tool made no longer ends in `.json`, so reading a folder's data skips it.
|
|
9
|
+
- **Choose how hard AllyHub's own agent thinks.** Studio offers each model's Effort, starting at medium.
|
|
10
|
+
- **More of each cloud tool's options**, such as the country TikTok is seen from or YouTube's counts and descriptions in search.
|
|
11
|
+
- **A new account starts with 200 credits**, and uploads and tools' results are let go 2 hours after they were used.
|
|
12
|
+
|
|
5
13
|
## 0.12.0
|
|
6
14
|
|
|
7
15
|
- **AllyHub learns what is used and what fails.** The CLI and Studio tell AllyHub which commands run, how long agents take and the errors they meet, never what you make or say. Studio's Settings or `ALLYHUB_TELEMETRY=off` turns it off; the list of what is told is public.
|
|
@@ -94,6 +94,9 @@ export interface SfxPlay {
|
|
|
94
94
|
file?: string;
|
|
95
95
|
/** When it starts (a built-in one is placed so its transient is at the cue). */
|
|
96
96
|
at: number;
|
|
97
|
+
/** A file's seconds it plays from, and how many of them; its whole file unless said. */
|
|
98
|
+
from?: number;
|
|
99
|
+
length?: number;
|
|
97
100
|
gainDb: number;
|
|
98
101
|
/** Seeds a built-in sound. */
|
|
99
102
|
seed: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{clipSource as
|
|
2
|
+
import{clipSource as k}from"./decode.js";import{equalPower as z,gainAt as A}from"./envelope.js";import{playMusic as B}from"./music.js";import{shapes as C,shapeSound as H,soundLevel as q}from"./shape.js";import{synthSfx as J}from"./sfx.js";import{playVoice as K,voiceGroups as N}from"./voice.js";function Q(n,r,o){if(r.length===0)return;const s=n[0].length;for(let f=0;f<s;f++){const e=10**(A(r,f/o)/20);e!==1&&(n[0][f]=(n[0][f]??0)*e,n[1][f]=(n[1][f]??0)*e)}}function x(n,r,o,s,f,e){const m=Math.round(o.dur*s),y=Math.round(o.at*s),b=10**(o.gainDb/20),p=Math.min(Math.round(.01*s),Math.floor(m/4)),t=l=>l===void 0||l<=0?0:Math.min(Math.round(l*s),Math.floor(m/2)),i=t(o.fadeIn),h=t(o.fadeOut),c=(l,g)=>g>0?z(l/g):p>0&&l<p?l/p:1,a=[...o.envelope??[]],v=n[0].length,u=r[0].length,d=f===void 0?o.speed??1:1,S=f===void 0?o.from*s:o.from/f*s;for(let l=0;l<m;l++){const g=y+l;if(g<0||g>=v)continue;const F=d===1?Math.round(S)+l:S+l*d,M=Math.floor(F);if(M<0||M>=u)continue;const E=F-M,I=Math.min(M+1,u-1),w=g/s,O=a.length>0||e.length>0?10**((A(a,w)+A(e,w))/20):1,V=b*O*c(l,i)*c(m-1-l,h);for(let D=0;D<2;D++){const G=r[D]??r[0],L=G[M]??0,j=G[I]??0,P=n[D]??n[0];P[g]=(P[g]??0)+(L+(j-L)*E)*V}}}export function playSfx(n,r,o){if(!n.shape||!(C(n.shape)||n.shape.filter!==void 0))return{src:r,gainDb:n.gainDb};const s=q(r,o)?.lufs,f=[Float32Array.from(r[0]),Float32Array.from(r[1])];H(f,n.shape,o,0);const e=q(f,o)?.lufs;return e===void 0?{src:f,gainDb:n.gainDb}:n.level?{src:f,gainDb:n.level.target-e+n.level.gainDb}:{src:f,gainDb:n.gainDb+(s===void 0?0:s-e)}}function R(n,r,o){const s=J(n,r,o);return[s,s]}export function renderMix(n,r,o,s={}){const f=Math.round(n.duration*o),e=[new Float32Array(f),new Float32Array(f)],m=n.speechGain??[],y=k(r),{groups:b,dry:p}=N(n);for(const t of b){const[i,h]=K(t,n.duration,o,y);Q([i,h],m,o);for(let c=0;c<f;c++)e[0][c]=(e[0][c]??0)+(i[c]??0),e[1][c]=(e[1][c]??0)+(h[c]??0)}for(const t of p){const i=y(t);i&&x(e,i.src,t,o,i.stretched,m)}if(s.only==="voice")return e;for(const t of n.footage){const i=r(t.file,{});i&&x(e,i.src,t,o,void 0,[])}if(n.music){const t=n.music,i=r(t.file,t.shape?.filter?{filter:t.shape.filter}:{});if(i){const[h,c]=B(t,i.src,n.duration,o);for(let a=0;a<f;a++)e[0][a]=(e[0][a]??0)+(h[a]??0),e[1][a]=(e[1][a]??0)+(c[a]??0)}}for(const t of n.sfx){let i;if(t.file!==void 0?i=r(t.file,t.shape?.filter?{filter:t.shape.filter}:{})?.src:i=R(t.sound,o,t.seed),!i)continue;if(t.from!==void 0||t.length!==void 0){const u=Math.max(0,Math.round((t.from??0)*o)),d=t.length===void 0?i[0].length:Math.min(i[0].length,u+Math.round(t.length*o));i=[i[0].subarray(u,d),i[1].subarray(u,d)]}const h=playSfx(t,i,o),c=10**(h.gainDb/20),a=Math.round(t.at*o),v=h.src[0].length;for(let u=0;u<v;u++){const d=a+u;d<0||d>=f||(e[0][d]=(e[0][d]??0)+(h.src[0][u]??0)*c,e[1][d]=(e[1][d]??0)+(h.src[1][u]??0)*c)}}return e}
|
|
@@ -2,6 +2,8 @@ import { type ChartFile } from "@allyhub/formats";
|
|
|
2
2
|
import { type ChartDef } from "./chart.js";
|
|
3
3
|
export declare function chartOfFile(f: ChartFile, o: {
|
|
4
4
|
title: string | undefined;
|
|
5
|
+
/** Its axes' titles, words beside the file (a deck's script). */
|
|
6
|
+
axisTitles?: Partial<Record<"category_axis" | "value_axis" | "secondary_axis", string>>;
|
|
5
7
|
/** The folder of the file that writes it (a deck's, a doc's). */
|
|
6
8
|
base: string;
|
|
7
9
|
/** A data file's content, by its path from that folder. */
|
|
@@ -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
|
|
2
|
+
import{colorOfFile as O}from"@allyhub/formats";import{isCombinable as S,isScatter as k,labelPositionsOf as w}from"./chart.js";const u=e=>O(e)??"dk1";function F(e,n){if(n.startsWith("/"))return n.slice(1);const i=e===""?[]:e.split("/");for(const s of n.split("/"))s===""||s==="."||(s===".."?i.pop():i.push(s));return i.join("/")}function p(e,n){if(e===void 0&&n===void 0)return;const i=e??{};return{...n===void 0?{}:{title:n},...i.min===void 0?{}:{minimum_scale:i.min},...i.max===void 0?{}:{maximum_scale:i.max},...i.major===void 0?{}:{major_unit:i.major},...i.gridlines===void 0?{}:{has_major_gridlines:i.gridlines},...i.visible===void 0?{}:{visible:i.visible},...i.format===void 0?{}:{number_format:i.format},...i.reverse===void 0?{}:{reverse_order:i.reverse},...i.gridline_color===void 0?{}:{gridline_color:u(i.gridline_color)},...i.line_color===void 0?{}:{line_color:u(i.line_color)}}}const A=e=>{if(!(e===void 0||e===!1))return e===!0?{show_value:!0}:{...e.value===void 0?{}:{show_value:e.value},...e.percentage===void 0?{}:{show_percentage:e.percentage},...e.category===void 0?{}:{show_category_name:e.category},...e.series===void 0?{}:{show_series_name:e.series},...e.format===void 0?{}:{number_format:e.format},...e.position===void 0?{}:{position:e.position},...e.size===void 0?{}:{size:e.size},...e.color===void 0?{}:{color:u(e.color)}}};function $(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(e==null)return null;if(typeof e!="string")return;const n=e.trim();if(n==="")return null;const i=Number(n);return Number.isFinite(i)?i:void 0}export function chartOfFile(e,n){const i=A(e.labels),s=k(e.type);let l,m;const g=r=>({...r.color===void 0?{}:{color:u(r.color)},...r.format===void 0?{}:{number_format:r.format},...r.smooth===void 0?{}:{smooth:r.smooth},...r.line_width===void 0?{}:{line_width:r.line_width},...r.marker_size===void 0?{}:{marker_size:r.marker_size},...r.type===void 0?{}:{type:r.type},...r.secondary===void 0?{}:{secondary:r.secondary}});if(e.data!==void 0){let r;try{r=n.rows(e.data)}catch(o){n.problem(`${e.data} cannot be read: ${o instanceof Error?o.message:String(o)}`);return}if(!Array.isArray(r)||r.length===0){n.problem(`${e.data} holds no rows.`);return}const t=r,d=e.categories;if(typeof d!="string"){n.problem("with data, categories names its column.");return}const b=Object.keys(t[0]??{}),v=[d,...e.series.map(o=>typeof o=="string"?o:o.name)].filter(o=>!b.includes(o));if(v.length>0){n.problem(`${e.data} has no column ${v.join(", ")} (it has ${b.join(", ")}).`);return}l=t.map(o=>{const a=o[d];return typeof a=="string"||typeof a=="number"?String(a):""}),m=e.series.map(o=>{const a=typeof o=="string"?o:o.name,z=t.map((c,j)=>{const x=$(c[a]);return x===void 0?(n.problem(`${String(e.data)} row ${String(j+1)}: ${JSON.stringify(c[a])} in ${a} is not a number.`),null):x});return{name:a,values:z,...s?{x:t.map(c=>$(c[d])??null)}:{},...typeof o=="string"?{}:g(o)}})}else{if(typeof e.categories=="string"){n.problem("categories names a column, and there is no data to read.");return}if(e.categories===void 0&&!s){n.problem(`a ${e.type} chart has categories.`);return}l=e.categories??[];const r=[];for(const t of e.series){if(typeof t=="string"||!t.values){const d=typeof t=="string"?t:t.name;n.problem(`series ${d} has no values, and there is no data to read.`);return}if(s){if(t.x?.length!==t.values.length){n.problem(`series ${t.name} has an x for each of its values.`);return}}else t.values.length!==l.length&&n.problem(`series ${t.name} has ${String(t.values.length)} values for ${String(l.length)} categories.`);r.push({name:t.name,values:t.values,...s&&t.x?{x:t.x}:{},...g(t)})}m=r}!S(e.type)&&e.series.some(r=>typeof r!="string"&&(r.type!==void 0||r.secondary===!0))&&n.problem(`a ${e.type} chart combines with no other kind and has no second axis: only columns, lines and areas do.`);const f=i?.position;f!==void 0&&!w(e.type).includes(f)&&n.problem(`a ${e.type} chart has no label position ${f}, which PowerPoint would repair (it has ${w(e.type).join(", ")||"none"}).`);const _=p(e.value_axis,n.axisTitles?.value_axis),y=p(e.category_axis,n.axisTitles?.category_axis),h=p(e.secondary_axis,n.axisTitles?.secondary_axis);return{type:e.type,categories:l,series:m,...n.title===void 0?{}:{title:n.title},...e.legend===void 0?{}:{legend:e.legend},...i?{labels:i}:{},...e.gap_width===void 0?{}:{gap_width:e.gap_width},...e.overlap===void 0?{}:{overlap:e.overlap},...e.vary_by_categories===void 0?{}:{vary_by_categories:e.vary_by_categories},...e.category_colors===void 0?{}:{category_colors:e.category_colors.map(u)},...e.hole_size===void 0?{}:{hole_size:e.hole_size},..._?{value_axis:_}:{},...y?{category_axis:y}:{},...h?{secondary_axis:h}:{},...e.size===void 0?{}:{font_size:e.size},...e.title_size===void 0?{}:{title_size:e.title_size},...e.color===void 0?{}:{font_color:u(e.color)},...e.data===void 0?{}:{source:F(n.base,e.data)}}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{
|
|
3
|
-
`,b="2118791784",y="2140495176",
|
|
2
|
+
import{colorXml as V}from"./color.js";import{accentOf as I,CHART_DEFAULTS as m,chartDrawing as B,groupingOf as A,groupsOf as R,hasLines as W,hasMarkers as Z,isArea as X,isBar as L,isHorizontal as G,isLine as S,isRound as h,isScatter as w,labelPositionOf as H,variesOf as j}from"./chart.js";const Y="http://schemas.openxmlformats.org/drawingml/2006/chart",q="http://schemas.openxmlformats.org/drawingml/2006/main",K="http://schemas.openxmlformats.org/officeDocument/2006/relationships",J=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3
|
+
`,b="2118791784",y="2140495176",M="2118791785",T="2140495177",Q={"&":"&","<":"<",">":">",'"':"""},ee=e=>{const n=e.charCodeAt(0);return n<32&&n!==9&&n!==10&&n!==13||n===65534||n===65535},d=e=>Array.from(e,n=>ee(n)?"":Q[n]??n).join("");function o(e,n={},...a){const r=Object.entries(n).filter(([,s])=>s!==void 0).map(([s,i])=>` ${s}="${d(typeof i=="boolean"?i?"1":"0":String(i))}"`).join(""),c=a.join("");return c===""?`<${e}${r}/>`:`<${e}${r}>${c}</${e}>`}const te=e=>V(e),x=e=>e===null?o("a:noFill"):o("a:solidFill",{},te(e)),t=(e,n)=>o(e,{val:typeof n=="boolean"?n?1:0:n}),f=(e,n)=>o("a:ln",n===void 0?{}:{w:Math.round(n*12700)},x(e)),O=(e,n)=>o("c:txPr",{},o("a:bodyPr"),o("a:lstStyle"),o("a:p",{},o("a:pPr",{},o("a:defRPr",e===void 0?{}:{sz:Math.round(e*100)},n===void 0?"":x(n))),o("a:endParaRPr",{lang:"en-US"}))),$=e=>o("c:strCache",{},t("c:ptCount",e.length),...e.map((n,a)=>o("c:pt",{idx:a},`<c:v>${d(n)}</c:v>`))),F=(e,n)=>o("c:numCache",{},`<c:formatCode>${d(e??"General")}</c:formatCode>`,t("c:ptCount",n.length),...n.flatMap((a,r)=>a===null?[]:[o("c:pt",{idx:r},`<c:v>${String(a)}</c:v>`)])),ne=(e,n)=>o("c:tx",{},n===void 0?`<c:v>${d(e.name)}</c:v>`:o("c:strRef",{},`<c:f>${d(n)}</c:f>`,$([e.name]))),oe=(e,n)=>n===void 0?"":o("c:xVal",{},o("c:numRef",{},`<c:f>${d(n)}</c:f>`,F("General",e.x??[])));function re(e,n,a,r){const c=n.color??I(a),s=h(e.type),i=w(e.type),l=S(e.type)||i,u=Z(e.type),z=l?o("c:spPr",{},W(e.type)?f(c,n.line_width??m.lineWidth):o("a:ln",{w:19050},x(null))):o("c:spPr",{},x(c),s?f("lt1",1):""),v=r.categories;return o("c:ser",{},t("c:idx",a),t("c:order",a),ne(n,r.name(a)),z,L(e.type)?t("c:invertIfNegative",!1):"",l?o("c:marker",{},t("c:symbol",u?"circle":"none"),u?t("c:size",n.marker_size??m.marker):"",u?o("c:spPr",{},x(c),f(c)):""):"",...j(e)&&!l&&!X(e.type)?e.categories.map((C,p)=>o("c:dPt",{},t("c:idx",p),L(e.type)?t("c:invertIfNegative",!1):"",t("c:bubble3D",!1),o("c:spPr",{},x(e.category_colors?.[p]??I(p)),s?f("lt1",1):""))):[],i?oe(n,r.x?.(a)):v===void 0?"":o("c:cat",{},r.numeric===!0?o("c:numRef",{},`<c:f>${d(v)}</c:f>`,F(r.categoryFormat??"General",r.categoryNumbers??e.categories.map(C=>{const p=Number(C);return C===""||!Number.isFinite(p)?null:p}))):o("c:strRef",{},`<c:f>${d(v)}</c:f>`,$(e.categories))),o(i?"c:yVal":"c:val",{},o("c:numRef",{},`<c:f>${d(r.values(a))}</c:f>`,F(n.number_format,n.values))),l?t("c:smooth",n.smooth===!0||e.type==="scatter-smooth"):"")}function _(e){const n=e.labels;if(!n)return"";const a=n.show_percentage===!0,r=H(e);return o("c:dLbls",{},n.number_format===void 0?"":o("c:numFmt",{formatCode:n.number_format,sourceLinked:0}),n.size===void 0&&n.color===void 0&&!h(e.type)?"":O(n.size,n.color??(h(e.type)?"lt1":void 0)),r===void 0?"":t("c:dLblPos",r),t("c:showLegendKey",!1),t("c:showVal",n.show_value??!a),t("c:showCatName",n.show_category_name===!0),t("c:showSerName",n.show_series_name===!0),t("c:showPercent",a),t("c:showBubbleSize",!1))}function ce(e,n){const a=R(e);return a.length<=1?E(e,e.series.map((r,c)=>c),n,!1):a.map(r=>E({...e,type:r.kind},r.series,n,r.secondary)).join("")}function E(e,n,a,r){const c=n.map(l=>{const u=e.series[l];return u?re(e,u,l,a):""}).join(""),s=A(e.type),i=r?t("c:axId",M)+t("c:axId",T):t("c:axId",b)+t("c:axId",y);if(h(e.type)){const l=e.type==="pie";return o(l?"c:pieChart":"c:doughnutChart",{},t("c:varyColors",j(e)),c,_(e),t("c:firstSliceAng",0),l?"":t("c:holeSize",e.hole_size??50))}if(w(e.type))return o("c:scatterChart",{},t("c:scatterStyle","lineMarker"),t("c:varyColors",!1),c,_(e),i);if(L(e.type)){const l=s!=="clustered";return o("c:barChart",{},t("c:barDir",G(e.type)?"bar":"col"),t("c:grouping",s),t("c:varyColors",j(e)),c,_(e),t("c:gapWidth",e.gap_width??150),e.overlap!==void 0||l?t("c:overlap",e.overlap??100):"",i)}return o(S(e.type)?"c:lineChart":"c:areaChart",{},t("c:grouping",s),t("c:varyColors",!1),c,_(e),S(e.type)?t("c:marker",!0):"",i)}const g=e=>o("c:scaling",{},t("c:orientation",e.reverse_order===!0?"maxMin":"minMax"),e.maximum_scale===void 0?"":t("c:max",e.maximum_scale),e.minimum_scale===void 0?"":t("c:min",e.minimum_scale)),N=e=>o("c:spPr",{},f(e.line_color??{rgb:m.axisLine},m.gridWidth)),k=e=>e.has_major_gridlines===!0?o("c:majorGridlines",{},o("c:spPr",{},f(e.gridline_color??{rgb:m.gridline},m.gridWidth))):"",U=(e,n)=>o("c:rich",{},o("a:bodyPr"),o("a:lstStyle"),...e.split(`
|
|
4
|
+
`).map(a=>o("a:p",{},o("a:pPr",{},o("a:defRPr",{sz:n,b:0})),o("a:r",{},o("a:rPr",{lang:"en-US",sz:n,b:0}),`<a:t>${d(a)}</a:t>`)))),P=(e,n)=>e===void 0||e===""?"":o("c:title",{},o("c:tx",{},U(e,n)),t("c:overlay",!1));function ae(e,n){if(h(e.type))return"";const a=w(e.type),r=G(e.type),c=e.category_axis??{},s={has_major_gridlines:!0,...e.value_axis},i=A(e.type)==="percentStacked",l=s.number_format??(i?"0%":e.series[0]?.number_format??"General"),u=Math.round((e.font_size??m.fontSize)*100);return(a?o("c:valAx",{},t("c:axId",b),g(c),t("c:delete",c.visible===!1),t("c:axPos","b"),k(c),P(c.title,u),o("c:numFmt",{formatCode:c.number_format??"General",sourceLinked:c.number_format===void 0?1:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),N(c),t("c:crossAx",y),t("c:crosses","autoZero"),t("c:crossBetween","midCat"),c.major_unit===void 0?"":t("c:majorUnit",c.major_unit)):o("c:catAx",{},t("c:axId",b),g(c),t("c:delete",c.visible===!1),t("c:axPos",r?"l":"b"),k(c),P(c.title,u),n?.numeric===!0?o("c:numFmt",{formatCode:c.number_format??n.categoryFormat??"General",sourceLinked:c.number_format===void 0?1:0}):o("c:numFmt",{formatCode:"General",sourceLinked:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),N(c),t("c:crossAx",y),t("c:crosses","autoZero"),t("c:auto",!0),t("c:lblAlgn","ctr"),t("c:lblOffset",100),t("c:noMultiLvlLbl",!1)))+o("c:valAx",{},t("c:axId",y),g(s),t("c:delete",s.visible===!1),t("c:axPos",r?"b":"l"),k(s),P(s.title,u),o("c:numFmt",{formatCode:l,sourceLinked:s.number_format===void 0&&!i?1:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),o("c:spPr",{},f(null)),t("c:crossAx",b),t("c:crosses","autoZero"),t("c:crossBetween",X(e.type)||a?"midCat":"between"),s.major_unit===void 0?"":t("c:majorUnit",s.major_unit))+se(e,u)}function se(e,n){const a=R(e).find(i=>i.secondary);if(!a)return"";const r=e.secondary_axis??{},c=A(a.kind)==="percentStacked",s=r.number_format??(c?"0%":e.series[a.series[0]??0]?.number_format??"General");return o("c:catAx",{},t("c:axId",M),g({}),t("c:delete",!0),t("c:axPos","b"),o("c:numFmt",{formatCode:"General",sourceLinked:1}),t("c:majorTickMark","out"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),t("c:crossAx",T),t("c:crosses","autoZero"),t("c:auto",!0),t("c:lblAlgn","ctr"),t("c:lblOffset",100),t("c:noMultiLvlLbl",!1))+o("c:valAx",{},t("c:axId",T),g(r),t("c:delete",r.visible===!1),t("c:axPos","r"),k(r),P(r.title,n),o("c:numFmt",{formatCode:s,sourceLinked:r.number_format===void 0&&!c?1:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),o("c:spPr",{},f(null)),t("c:crossAx",M),t("c:crosses","max"),t("c:crossBetween","between"),r.major_unit===void 0?"":t("c:majorUnit",r.major_unit))}const ie={bottom:"b",top:"t",left:"l",right:"r"};function le(e,n){const a=n.width,r=n.height,{plot:c}=B(e,a,r),s=i=>Number(i.toFixed(5));return o("c:layout",{},o("c:manualLayout",{},t("c:layoutTarget","inner"),t("c:xMode","edge"),t("c:yMode","edge"),t("c:x",s(c.x/a)),t("c:y",s(c.y/r)),t("c:w",s(c.width/a)),t("c:h",s(c.height/r))))}const D=o("c:spPr",{},o("a:noFill"),o("a:ln",{},o("a:noFill")));export function chartSpaceXml(e,n){const a=e.title!==void 0&&e.title!==""?e.title:void 0,r=e.font_size??m.fontSize,c=Math.round((e.title_size??r*m.titleScale)*100);return J+o("c:chartSpace",{"xmlns:c":Y,"xmlns:a":q,"xmlns:r":K},t("c:date1904",!1),t("c:roundedCorners",!1),o("c:chart",{},a===void 0?"":o("c:title",{},o("c:tx",{},n.titleRef===void 0?U(a,c):o("c:strRef",{},`<c:f>${d(n.titleRef)}</c:f>`,$([a]))),t("c:overlay",!1)),t("c:autoTitleDeleted",a===void 0),o("c:plotArea",{},n.frame?le(e,n.frame):o("c:layout"),ce(e,n.refs),ae(e,n.refs),n.frameless===!0?D:""),e.legend===void 0?"":o("c:legend",{},t("c:legendPos",ie[e.legend]),t("c:overlay",e.legend_overlay===!0)),t("c:plotVisOnly",n.plotVisible??!0),t("c:dispBlanksAs","gap")),n.frameless===!0?D:"",O(r,e.font_color??"dk1"),n.tail??"")}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import type { ChartLegendPosition, Color, SheetChartType
|
|
1
|
+
import type { ChartLegendPosition, Color, SheetChartType } from "@allyhub/formats";
|
|
2
2
|
export type { Color };
|
|
3
|
-
/** A theme colour at a brightness: its name alone at 0. */
|
|
4
|
-
export declare const themeColor: (theme_color: ThemeColor, brightness?: number) => Color;
|
|
5
|
-
/** The theme colour a colour is, at any brightness. */
|
|
6
|
-
export declare const themeColorOf: (c: Color) => ThemeColor | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* A colour as it is drawn, against the theme in force: a theme colour's
|
|
9
|
-
* value, lighter or darker by its brightness as PowerPoint makes it, or its
|
|
10
|
-
* own. Every colour drawn or measured comes through here.
|
|
11
|
-
*/
|
|
12
|
-
export declare function colorRgb(c: Color, colors: Readonly<Record<ThemeColor, string>>): string;
|
|
13
3
|
/** The kinds a chart is drawn as: a slide's and a sheet's (which adds scatter). */
|
|
14
4
|
export type ChartKind = SheetChartType;
|
|
15
5
|
/** Where a data label sits (`c:dLblPos`). */
|
|
@@ -68,6 +58,7 @@ export interface ChartDef {
|
|
|
68
58
|
type: ChartKind;
|
|
69
59
|
categories: string[];
|
|
70
60
|
series: ChartSeriesDef[];
|
|
61
|
+
/** Its title, a line of it for each line break (`c:title`, a paragraph each). */
|
|
71
62
|
title?: string;
|
|
72
63
|
/** Where its legend is; absent: it has none. */
|
|
73
64
|
legend?: ChartLegendPosition;
|
|
@@ -109,7 +100,7 @@ export declare const CHART_DEFAULTS: {
|
|
|
109
100
|
readonly margin: 6;
|
|
110
101
|
readonly gridline: "#D9D9D9";
|
|
111
102
|
readonly axisLine: "#BFBFBF";
|
|
112
|
-
/** A share of a letter's size: how wide a letter is taken to be. */
|
|
103
|
+
/** A share of a letter's size: how wide a letter outside ASCII and CJK is taken to be. */
|
|
113
104
|
readonly letter: 0.55;
|
|
114
105
|
/** Line widths, points. */
|
|
115
106
|
readonly lineWidth: 2.25;
|
|
@@ -150,6 +141,8 @@ export interface ChartGroup {
|
|
|
150
141
|
* chart's: areas, then columns, then lines, those on the second axis after
|
|
151
142
|
* the first's. A chart of one kind on one axis is one group; a series' own
|
|
152
143
|
* kind counts only where both it and the chart's are columns, lines or areas.
|
|
144
|
+
* Where every series says it is on the second axis, all are on the first, as
|
|
145
|
+
* PowerPoint draws them.
|
|
153
146
|
*/
|
|
154
147
|
export declare function groupsOf(c: Pick<ChartDef, "type" | "series">): ChartGroup[];
|
|
155
148
|
/** Whether each category has its own colour. */
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{format as Vt,isValidFormat as Rt}from"numfmt";import{brightened as Zt}from"@allyhub/ooxml/brightness";export const themeColor=(t,s=0)=>s===0?t:{theme_color:t,brightness:s},themeColorOf=t=>typeof t=="string"?t:"theme_color"in t?t.theme_color:void 0;export function colorRgb(t,s){return typeof t=="string"?s[t]:"rgb"in t?t.rgb:Zt(s[t.theme_color],t.brightness)}export const CHART_DEFAULTS={fontSize:12,titleScale:1.2,gapWidth:150,holeSize:50,margin:6,gridline:"#D9D9D9",axisLine:"#BFBFBF",letter:.55,lineWidth:2.25,gridWidth:.75,marker:5};const Ft=["accent1","accent2","accent3","accent4","accent5","accent6"];export const accentOf=t=>Ft[t%Ft.length]??"accent1",isBar=t=>t.startsWith("column")||t.startsWith("bar"),isHorizontal=t=>t.startsWith("bar"),isLine=t=>t.startsWith("line"),isArea=t=>t.startsWith("area"),isRound=t=>t==="pie"||t==="doughnut",isScatter=t=>t.startsWith("scatter"),hasLines=t=>!isScatter(t)||t!=="scatter",hasMarkers=t=>t==="line-markers"||t==="scatter"||t==="scatter-lines",groupingOf=t=>t.endsWith("-100")?"percentStacked":t.endsWith("-stacked")?"stacked":isBar(t)?"clustered":"standard";export function labelPositionsOf(t){return isArea(t)||t==="doughnut"?[]:t==="pie"?["bestFit","outEnd","inEnd","ctr"]:isLine(t)||isScatter(t)?["t","b","l","r","ctr"]:groupingOf(t)==="clustered"?["outEnd","inEnd","ctr","inBase"]:["inEnd","ctr","inBase"]}export function labelPositionOf(t){const s=labelPositionsOf(t.type),h=t.labels?.position;if(h!==void 0&&s.includes(h))return h;if(s.length!==0)return t.type==="pie"?"ctr":isLine(t.type)||isScatter(t.type)?"t":groupingOf(t.type)==="clustered"?"outEnd":"ctr"}export const isCombinable=t=>t.startsWith("column")||isLine(t)||isArea(t);export function groupsOf(t){const s=isCombinable(t.type),h=[];t.series.forEach((o,c)=>{const n=o.type!==void 0&&s&&isCombinable(o.type)?o.type??t.type:t.type,S=s&&o.secondary===!0,_=h.find(O=>O.kind===n&&O.secondary===S);_?_.series.push(c):h.push({kind:n,secondary:S,series:[c]})});const r=o=>(o.secondary?3:0)+(isArea(o.kind)?0:isBar(o.kind)?1:2);return h.sort((o,c)=>r(o)-r(c))}export const variesOf=t=>t.vary_by_categories??isRound(t.type);export function formatValue(t,s="General"){return s==="General"||!Rt(s)?String(Number(t.toPrecision(10))):Vt(s,t)}const Ut=[1,2,5,10];export function chartScale(t,s,h,r,o={}){const c=t>0&&(s-t)/s<.16666666666666666?t:Math.min(t,0),a=s<=0&&t<0?0:s,n=o.minimum_scale??c,S=o.maximum_scale??a,_=S>n?S-n:1,O=Math.max(1,Math.floor(h/r)),k=_/O,P=10**Math.floor(Math.log10(k)),N=o.major_unit??(Ut.find(v=>v*P>=k)??10)*P,z=(v,j)=>Number((j(Number((v/N).toFixed(9)))*N).toPrecision(12)),q=a>0?a+_*.05:a===c?_:a,x=o.maximum_scale??z(q,Math.ceil),Z=c<0?c-_*.05:c,V=o.minimum_scale??z(Z,Math.floor),D=[],y=Math.round((x-V)/N);for(let v=0;v<=y;v++)D.push(Number((V+v*N).toPrecision(12)));return{min:V,max:x,major:N,ticks:D}}const it=(t,s)=>{let h=0;for(const r of t)h+=(r.codePointAt(0)??0)>11903?1:CHART_DEFAULTS.letter;return h*s},m=t=>String(Number(t.toFixed(3)));function jt(t){const s=h=>t[Math.max(0,Math.min(t.length-1,h))]??[0,0];return t.map(([h,r],o)=>{if(o===0)return`M${m(h)} ${m(r)}`;const[c,a]=s(o-2),[n,S]=s(o-1),[_,O]=s(o+1),k=`${m(n+(h-c)/6)} ${m(S+(r-a)/6)}`,P=`${m(h-(_-n)/6)} ${m(r-(O-S)/6)}`;return`C${k} ${P} ${m(h)} ${m(r)}`}).join(" ")}const gt=t=>t.map(([s,h],r)=>`${r===0?"M":"L"}${m(s)} ${m(h)}`).join(" ");function qt(t,s,h,r,o,c){const a=(O,k)=>`${m(t+O*Math.sin(k))} ${m(s-O*Math.cos(k))}`,n=c-o>=Math.PI*2?o+Math.PI*2-1e-4:c,S=n-o>Math.PI?1:0,_=`M${a(h,o)} A${m(h)} ${m(h)} 0 ${String(S)} 1 ${a(h,n)}`;return r<=0?`${_} L${m(t)} ${m(s)} Z`:`${_} L${a(r,n)} A${m(r)} ${m(r)} 0 ${String(S)} 0 ${a(r,o)} Z`}function Nt(t,s,h,r){const o=r*1.5;return s!==void 0&&s!==""&&(t.bottom-=o),h!==void 0&&h!==""&&(t.left+=o),{x:t.left-o/2,y:t.bottom+o/2}}function Bt(t,s,h,r,o,c,a){r!==void 0&&r!==""&&t.words.push({x:s.x+s.width/2,y:h.y,text:r,size:c,anchor:"middle",color:a}),o!==void 0&&o!==""&&t.words.push({x:h.x,y:s.y+s.height/2,text:o,size:c,anchor:"middle",color:a,rotate:-90})}const xt=(t,s,h,r,o)=>{const c=t.labels;if(!c)return"";const a=isRound(t.type),n=[];return c.show_series_name&&n.push(r.name),c.show_category_name&&n.push(o),(c.show_value??!(c.show_percentage??!1))&&n.push(formatValue(s,c.number_format??r.number_format)),c.show_percentage&&a&&n.push(formatValue(h,c.number_format??"0%")),n.join(", ")};function Jt(t,s,h,r,o){const c=CHART_DEFAULTS,a=t.category_axis??{},n=t.value_axis??{},S=Nt(h,a.title,n.title,r),_=t.series.map(f=>f.values.flatMap((W,B)=>{const I=f.x?.[B]??(f.x?null:B+1);return I===null||W===null?[]:[[I,W]]})),O=_.flat().map(f=>f[0]),k=_.flat().map(f=>f[1]),P=f=>f.length>0?Math.min(...f):0,N=f=>f.length>0?Math.max(...f):1,z=n.number_format??t.series[0]?.number_format??"General",q=a.number_format??"General",x=r*.5,Z=chartScale(P(k),N(k),h.bottom-h.top,r*2.4,n),V=n.visible===!1?0:Math.max(0,...Z.ticks.map(f=>it(formatValue(f,z),r)))+x,D=a.visible===!1?0:r*1.2+x,y={x:h.left+V,y:h.top,width:h.right-h.left-V,height:h.bottom-h.top-D};s.plot=y,Bt(s,y,S,a.title,n.title,r,o);const v=chartScale(P(O),N(O),y.width,r*5,a),j=chartScale(P(k),N(k),y.height,r*2.4,n),U=f=>y.x+(Math.min(v.max,Math.max(v.min,f))-v.min)/(v.max-v.min)*y.width,G=f=>y.y+y.height-(Math.min(j.max,Math.max(j.min,f))-j.min)/(j.max-j.min)*y.height;for(const f of j.ticks){const W=G(f);(n.has_major_gridlines??!0)&&s.grid.push({d:`M${m(y.x)} ${m(W)} H${m(y.x+y.width)}`,color:n.gridline_color??{rgb:c.gridline},width:c.gridWidth}),n.visible!==!1&&s.words.push({x:y.x-x,y:W,text:formatValue(f,z),size:r,anchor:"end",color:o})}for(const f of v.ticks){const W=U(f);a.has_major_gridlines===!0&&s.grid.push({d:`M${m(W)} ${m(y.y)} V${m(y.y+y.height)}`,color:a.gridline_color??{rgb:c.gridline},width:c.gridWidth}),a.visible!==!1&&s.words.push({x:W,y:y.y+y.height+x+r*.6,text:formatValue(f,q),size:r,anchor:"middle",color:o})}s.axes.push({d:`M${m(y.x)} ${m(G(Math.max(j.min,Math.min(j.max,0))))} H${m(y.x+y.width)}`,color:a.line_color??{rgb:c.axisLine},width:c.gridWidth}),t.series.forEach((f,W)=>{const B=f.color??accentOf(W),I=(_[W]??[]).map(([J,R])=>[U(J),G(R)]);if(I.length!==0&&(hasLines(t.type)&&s.lines.push({d:t.type==="scatter-smooth"||f.smooth===!0?jt(I):gt(I),color:B,width:f.line_width??c.lineWidth,series:W}),hasMarkers(t.type)))for(const[J,R]of I)s.dots.push({x:J,y:R,r:(f.marker_size??c.marker)/2,color:B})})}export function chartDrawing(t,s,h){const r=CHART_DEFAULTS,o=t.font_size??r.fontSize,c=t.font_color??"dk1",a={grid:[],shapes:[],boxes:[],lines:[],axes:[],dots:[],keys:[],words:[],plot:{x:0,y:0,width:0,height:0}},n={left:r.margin,top:r.margin,right:s-r.margin,bottom:h-r.margin};if(t.title!==void 0&&t.title!==""){const e=t.title_size??o*r.titleScale;a.words.push({x:s/2,y:n.top+e*.7,text:t.title,size:e,anchor:"middle",color:c}),n.top+=e*1.6}const S=isRound(t.type),_=variesOf(t),O=(e,i)=>_?t.category_colors?.[i]??accentOf(i):t.series[e]?.color??accentOf(e);if(t.legend!==void 0){const e=_?t.categories:t.series.map(d=>d.name),i=o*.6,g=o*.4,l=o*1.5,b=e.map(d=>i+g+it(d,o)),F=(d,w,u)=>{a.keys.push({x:w,y:u-i/2,width:i,height:i,color:_?t.category_colors?.[d]??accentOf(d):t.series[d]?.color??accentOf(d),series:_?0:d,category:_?d:0}),a.words.push({x:w+i+g,y:u,text:e[d]??"",size:o,anchor:"start",color:c})};if(t.legend==="top"||t.legend==="bottom"){const d=b.reduce((E,M)=>E+M,0)+o*(e.length-1),w=t.legend==="top"?n.top+l/2:n.bottom-l/2;let u=(s-d)/2;e.forEach((E,M)=>{F(M,u,w),u+=(b[M]??0)+o}),t.legend_overlay!==!0&&(t.legend==="top"?n.top+=l:n.bottom-=l)}else{const d=Math.max(0,...b),w=t.legend==="left"?n.left:n.right-d,u=(n.top+n.bottom-l*e.length)/2+l/2;e.forEach((E,M)=>{F(M,w,u+M*l)}),t.legend_overlay!==!0&&(t.legend==="left"?n.left+=d+o:n.right-=d+o)}}const k=t.labels,P=k?.size??o,N=k?.color??c,z=(e,i,g,l,b=N)=>{g!==""&&a.words.push({x:e,y:i,text:g,size:P,anchor:l,color:b})};if(S){const e=t.series[0],i=(e?.values??[]).map(u=>Math.max(0,u??0)),g=i.reduce((u,E)=>u+E,0),l=Math.max(0,Math.min(n.right-n.left,n.bottom-n.top)/2),b=(n.left+n.right)/2,F=(n.top+n.bottom)/2,d=t.type==="doughnut"?l*((t.hole_size??r.holeSize)/100):0;a.plot={x:b-l,y:F-l,width:l*2,height:l*2};let w=0;return i.forEach((u,E)=>{const M=g>0?u/g:0,$=w+M*Math.PI*2;if(M>0){a.shapes.push({d:qt(b,F,l,d,w,$),color:"lt1",width:1,fill:O(0,E),series:0,category:E});const A=(w+$)/2,T=d>0?(l+d)/2:labelPositionOf(t)==="inEnd"?l*.85:l*.6;e&&z(b+T*Math.sin(A),F-T*Math.cos(A),xt(t,u,M,e,t.categories[E]??""),"middle",k?.color??"lt1")}w=$}),a}if(isScatter(t.type))return Jt(t,a,n,o,c),a;const q=Math.max(1,t.categories.length),x=isHorizontal(t.type),Z=groupsOf(t),V=Z.every(e=>e.secondary)?Z.map(e=>({...e,secondary:!1})):Z,D=t.series.map(e=>t.categories.map((i,g)=>e.values[g]??null)),y=V.map(e=>{const i=groupingOf(e.kind),g=i!=="clustered"&&i!=="standard",l=i==="percentStacked",b=t.categories.map((F,d)=>e.series.reduce((w,u)=>w+Math.abs(D[u]?.[d]??0),0));return{...e,stacked:g,percent:l,totals:b}}),v=(e,i,g)=>{const l=D[i]?.[g];if(l==null)return null;const b=e.totals[g]??0;return e.percent?b>0?l/b:0:l},j=e=>{let i=0,g=0,l=1/0,b=!1;for(const u of y)if(u.secondary===e&&(b||=u.percent,t.categories.forEach((E,M)=>{let $=0,A=0;for(const T of u.series){const C=v(u,T,M)??0;u.stacked?C>=0?$+=C:A+=C:($=Math.max($,C),A=Math.min(A,C))}g=Math.max(g,$),i=Math.min(i,A)}),!u.stacked))for(const E of u.series)for(const M of D[E]??[])M!==null&&(l=Math.min(l,M));y.every(u=>u.secondary!==e||!u.stacked)&&Number.isFinite(l)&&l>0&&(i=l),b&&(g=1,i=Math.min(i,0));const d=y.find(u=>u.secondary===e),w=d===void 0?void 0:d.series[0];return{low:i,high:g,percent:b,format:w===void 0?void 0:t.series[w]?.number_format}},U=j(!1),G=y.some(e=>e.secondary)?j(!0):void 0,f=t.value_axis??{},W=t.secondary_axis??{},B=t.category_axis??{},I=f.number_format??(U.percent?"0%":U.format??"General"),J=W.number_format??(G?.percent===!0?"0%":G?.format??"General"),R=(e,i,g,l)=>chartScale(e.low,e.high,g,l,{...i,...e.percent?{maximum_scale:i.maximum_scale??1}:{}}),yt=x?n.right-n.left:n.bottom-n.top,at=x?o*5:o*2.4,It=R(U,f,yt,at),bt=f.visible===!1?[]:It.ticks.map(e=>formatValue(e,I)),Mt=Math.max(0,...bt.map(e=>it(e,o))),wt=G===void 0||W.visible===!1?0:Math.max(0,...R(G,W,yt,at).ticks.map(e=>it(formatValue(e,J),o))),ct=B.visible!==!1,_t=ct?Math.max(0,...t.categories.map(e=>it(e,o))):0,H=o*.5,$t=x?f.title:B.title,kt=x?B.title:f.title,zt=Nt(n,$t,kt,o),p=x?{x:n.left+(ct?_t+H:0),y:n.top,width:0,height:n.bottom-n.top-(f.visible===!1?0:o*1.2+H)}:{x:n.left+(f.visible===!1?0:Mt+H),y:n.top,width:0,height:n.bottom-n.top-(ct?o*1.2+H:0)};p.width=n.right-p.x-(x&&bt.length>0?Mt/2:0)-(wt>0?wt+H:0),a.plot=p,Bt(a,p,zt,$t,kt,o,c);const ft=x?p.width:p.height,et=R(U,f,ft,at),ot=G===void 0?void 0:R(G,W,ft,at),vt=(e,i)=>(Math.min(e.max,Math.max(e.min,i))-e.min)/(e.max-e.min)*ft,ut=(e,i)=>x?p.x+vt(e,i):p.y+p.height-vt(e,i),Wt=e=>ut(et,e),Et=y.every(e=>isArea(e.kind)),St=B.reverse_order===!0,Ot=x?!St:St,mt=(x?p.height:p.width)/q,Pt=Et?(x?p.height:p.width)/Math.max(1,q-1):mt,pt=e=>{const i=Et?e*Pt:(e+.5)*mt,g=x?p.height:p.width,l=Ot?g-i:i;return(x?p.y:p.x)+l},At=Wt(Math.max(et.min,Math.min(et.max,0)));for(const e of et.ticks){const i=Wt(e);(f.has_major_gridlines??!0)&&a.grid.push({d:x?`M${m(i)} ${m(p.y)} V${m(p.y+p.height)}`:`M${m(p.x)} ${m(i)} H${m(p.x+p.width)}`,color:f.gridline_color??{rgb:r.gridline},width:r.gridWidth}),f.visible!==!1&&a.words.push(x?{x:i,y:p.y+p.height+H+o*.6,text:formatValue(e,I),size:o,anchor:"middle",color:c}:{x:p.x-H,y:i,text:formatValue(e,I),size:o,anchor:"end",color:c})}if(ot&&W.visible!==!1)for(const e of ot.ticks)a.words.push({x:p.x+p.width+H,y:ut(ot,e),text:formatValue(e,J),size:o,anchor:"start",color:c});if(a.axes.push({d:x?`M${m(At)} ${m(p.y)} V${m(p.y+p.height)}`:`M${m(p.x)} ${m(At)} H${m(p.x+p.width)}`,color:B.line_color??{rgb:r.axisLine},width:r.gridWidth}),ct){const e=x?o*1.3:_t+o,i=Math.max(1,Math.ceil(e/Math.max(1,Pt)));t.categories.forEach((g,l)=>{if(l%i!==0)return;const b=pt(l);a.words.push(x?{x:p.x-H,y:b,text:g,size:o,anchor:"end",color:c}:{x:b,y:p.y+p.height+H+o*.6,text:g,size:o,anchor:"middle",color:c})})}for(const e of y){const i=e.secondary&&ot?ot:et,g=b=>ut(i,b),l={type:e.kind,...t.labels===void 0?{}:{labels:t.labels}};isBar(e.kind)?Dt(e,g,l):Gt(e,g,l)}return a;function Dt(e,i,g){const l=(t.gap_width??r.gapWidth)/100,b=e.stacked?1:e.series.length,F=e.stacked?1:(t.overlap??0)/100,d=mt/(Math.max(1,b-(b-1)*F)+l),w=d*(1-F),u=d+w*(b-1);t.categories.forEach((E,M)=>{const $=pt(M);let A=0,T=0;e.series.forEach((C,nt)=>{const K=t.series[C],L=v(e,C,M);if(L===null||!K)return;const lt=e.stacked?L>=0?A:T:0,st=lt+L;e.stacked&&(L>=0?A=st:T=st);const Q=i(lt),X=i(st),ht=(e.stacked?$-d/2:$-u/2+nt*w)+(x&&Ot&&!e.stacked?u-d-2*nt*w:0),Ht=x?{x:Math.min(Q,X),y:ht,width:Math.abs(X-Q),height:d}:{x:ht,y:Math.min(Q,X),width:d,height:Math.abs(X-Q)};if(a.boxes.push({...Ht,color:O(C,M),series:C,category:M}),!k)return;const Ct=xt(t,D[C]?.[M]??0,0,K,t.categories[M]??""),dt=labelPositionOf(g),Y=P*.8,Tt=L>=0?1:-1,Lt=(rt,tt)=>dt==="ctr"?(rt+tt)/2:dt==="inBase"?rt+(tt>rt?Y:-Y):dt==="inEnd"?tt-(tt>rt?Y:-Y):tt+(tt>=rt?Y:-Y);x?z(Lt(Q,X),ht+d/2,Ct,dt==="outEnd"?Tt>0?"start":"end":"middle"):z(ht+d/2,Lt(Q,X),Ct,"middle")})})}function Gt(e,i,g){const l=t.categories.map(()=>0),b=e.series.map(d=>{const w=t.series[d],u=[],E=[];return t.categories.forEach((M,$)=>{const A=v(e,d,$);if(A===null||!w)return;const T=e.stacked?l[$]??0:0,C=T+A;e.stacked&&(l[$]=C);const nt=pt($),K=L=>x?[i(L),nt]:[nt,i(L)];if(u.push(K(C)),E.push(K(T)),isLine(e.kind)&&k){const L=labelPositionOf(g),[lt,st]=K(C);z(lt+(L==="r"?P:L==="l"?-P:0),st+(L==="t"?-P:L==="b"?P:0),xt(t,D[d]?.[$]??0,0,w,t.categories[$]??""),L==="r"?"start":L==="l"?"end":"middle")}}),{series:w,s:d,points:u,base:E}}),F=[];for(const{series:d,s:w,points:u,base:E}of b){if(!d)continue;const M=d.color??accentOf(w);if(isArea(e.kind)&&u.length>0)F.push({d:`${gt([...u,...[...E].reverse()])} Z`,color:M,width:0,fill:M,series:w});else if(u.length>0&&(a.lines.push({d:d.smooth===!0?jt(u):gt(u),color:M,width:d.line_width??r.lineWidth,series:w}),hasMarkers(e.kind)))for(const[$,A]of u)a.dots.push({x:$,y:A,r:(d.marker_size??r.marker)/2,color:M})}a.shapes.push(...F.reverse())}}
|
|
2
|
+
import{format as Zt,isValidFormat as Ut}from"numfmt";export const CHART_DEFAULTS={fontSize:12,titleScale:1.2,gapWidth:150,holeSize:50,margin:6,gridline:"#D9D9D9",axisLine:"#BFBFBF",letter:.55,lineWidth:2.25,gridWidth:.75,marker:5};const jt=["accent1","accent2","accent3","accent4","accent5","accent6"];export const accentOf=t=>jt[t%jt.length]??"accent1",isBar=t=>t.startsWith("column")||t.startsWith("bar"),isHorizontal=t=>t.startsWith("bar"),isLine=t=>t.startsWith("line"),isArea=t=>t.startsWith("area"),isRound=t=>t==="pie"||t==="doughnut",isScatter=t=>t.startsWith("scatter"),hasLines=t=>!isScatter(t)||t!=="scatter",hasMarkers=t=>t==="line-markers"||t==="scatter"||t==="scatter-lines",groupingOf=t=>t.endsWith("-100")?"percentStacked":t.endsWith("-stacked")?"stacked":isBar(t)?"clustered":"standard";export function labelPositionsOf(t){return isArea(t)||t==="doughnut"?[]:t==="pie"?["bestFit","outEnd","inEnd","ctr"]:isLine(t)||isScatter(t)?["t","b","l","r","ctr"]:groupingOf(t)==="clustered"?["outEnd","inEnd","ctr","inBase"]:["inEnd","ctr","inBase"]}export function labelPositionOf(t){const c=labelPositionsOf(t.type),h=t.labels?.position;if(h!==void 0&&c.includes(h))return h;if(c.length!==0)return t.type==="pie"?"ctr":isLine(t.type)||isScatter(t.type)?"t":groupingOf(t.type)==="clustered"?"outEnd":"ctr"}export const isCombinable=t=>t.startsWith("column")||isLine(t)||isArea(t);export function groupsOf(t){const c=isCombinable(t.type),h=[];if(t.series.forEach((n,i)=>{const o=n.type!==void 0&&c&&isCombinable(n.type)?n.type??t.type:t.type,S=c&&n.secondary===!0,_=h.find(A=>A.kind===o&&A.secondary===S);_?_.series.push(i):h.push({kind:o,secondary:S,series:[i]})}),h.every(n=>n.secondary))for(const n of h)n.secondary=!1;const r=n=>(n.secondary?3:0)+(isArea(n.kind)?0:isBar(n.kind)?1:2);return h.sort((n,i)=>r(n)-r(i))}export const variesOf=t=>t.vary_by_categories??isRound(t.type);export function formatValue(t,c="General"){return c==="General"||!Ut(c)?String(Number(t.toPrecision(10))):Zt(c,t)}const qt=[1,2,5,10];export function chartScale(t,c,h,r,n={}){const i=t>0&&(c-t)/c<.16666666666666666?t:Math.min(t,0),a=c<=0&&t<0?0:c,o=n.minimum_scale??i,S=n.maximum_scale??a,_=S>o?S-o:1,A=Math.max(1,Math.floor(h/r)),k=_/A,O=10**Math.floor(Math.log10(k)),T=n.major_unit??(qt.find(E=>E*O>=k)??10)*O,D=(E,P)=>Number((P(Number((E/T).toFixed(9)))*T).toPrecision(12)),U=a>0?a+_*.05:a===i?_:a,x=n.maximum_scale??D(U,Math.ceil),tt=i<0?i-_*.05:i,N=n.minimum_scale??D(tt,Math.floor),B=[],M=Math.round((x-N)/T);for(let E=0;E<=M;E++)B.push(Number((N+E*T).toPrecision(12)));return{min:N,max:x,major:T,ticks:B}}const Jt=[278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584],it=(t,c)=>{let h=0;for(const r of t){const n=r.codePointAt(0)??0,i=Jt[n-32];h+=i!==void 0?i/1e3:n>11903?1:CHART_DEFAULTS.letter}return h*c},m=t=>String(Number(t.toFixed(3)));function Nt(t){const c=h=>t[Math.max(0,Math.min(t.length-1,h))]??[0,0];return t.map(([h,r],n)=>{if(n===0)return`M${m(h)} ${m(r)}`;const[i,a]=c(n-2),[o,S]=c(n-1),[_,A]=c(n+1),k=`${m(o+(h-i)/6)} ${m(S+(r-a)/6)}`,O=`${m(h-(_-o)/6)} ${m(r-(A-S)/6)}`;return`C${k} ${O} ${m(h)} ${m(r)}`}).join(" ")}const xt=t=>t.map(([c,h],r)=>`${r===0?"M":"L"}${m(c)} ${m(h)}`).join(" ");function Kt(t,c,h,r,n,i){const a=(A,k)=>`${m(t+A*Math.sin(k))} ${m(c-A*Math.cos(k))}`,o=i-n>=Math.PI*2?n+Math.PI*2-1e-4:i,S=o-n>Math.PI?1:0,_=`M${a(h,n)} A${m(h)} ${m(h)} 0 ${String(S)} 1 ${a(h,o)}`;return r<=0?`${_} L${m(t)} ${m(c)} Z`:`${_} L${a(r,o)} A${m(r)} ${m(r)} 0 ${String(S)} 0 ${a(r,n)} Z`}function Tt(t,c,h,r){const n=r*1.5;return c!==void 0&&c!==""&&(t.bottom-=n),h!==void 0&&h!==""&&(t.left+=n),{x:t.left-n/2,y:t.bottom+n/2}}function Bt(t,c,h,r,n,i,a){r!==void 0&&r!==""&&t.words.push({x:c.x+c.width/2,y:h.y,text:r,size:i,anchor:"middle",color:a}),n!==void 0&&n!==""&&t.words.push({x:h.x,y:c.y+c.height/2,text:n,size:i,anchor:"middle",color:a,rotate:-90})}const yt=(t,c,h,r,n)=>{const i=t.labels;if(!i)return"";const a=isRound(t.type),o=[];return i.show_series_name&&o.push(r.name),i.show_category_name&&o.push(n),(i.show_value??!(i.show_percentage??!1))&&o.push(formatValue(c,i.number_format??r.number_format)),i.show_percentage&&a&&o.push(formatValue(h,i.number_format??"0%")),o.join(", ")};function Qt(t,c,h,r,n){const i=CHART_DEFAULTS,a=t.category_axis??{},o=t.value_axis??{},S=Tt(h,a.title,o.title,r),_=t.series.map(p=>p.values.flatMap((v,R)=>{const z=p.x?.[R]??(p.x?null:R+1);return z===null||v===null?[]:[[z,v]]})),A=_.flat().map(p=>p[0]),k=_.flat().map(p=>p[1]),O=p=>p.length>0?Math.min(...p):0,T=p=>p.length>0?Math.max(...p):1,D=o.number_format??t.series[0]?.number_format??"General",U=a.number_format??"General",x=r*.5,tt=chartScale(O(k),T(k),h.bottom-h.top,r*2.4,o),N=o.visible===!1?0:Math.max(0,...tt.ticks.map(p=>it(formatValue(p,D),r)))+x,B=a.visible===!1?0:r*1.2+x,M={x:h.left+N,y:h.top,width:h.right-h.left-N,height:h.bottom-h.top-B};c.plot=M,Bt(c,M,S,a.title,o.title,r,n);const E=chartScale(O(A),T(A),M.width,r*5,a),P=chartScale(O(k),T(k),M.height,r*2.4,o),H=p=>M.x+(Math.min(E.max,Math.max(E.min,p))-E.min)/(E.max-E.min)*M.width,C=p=>M.y+M.height-(Math.min(P.max,Math.max(P.min,p))-P.min)/(P.max-P.min)*M.height;for(const p of P.ticks){const v=C(p);(o.has_major_gridlines??!0)&&c.grid.push({d:`M${m(M.x)} ${m(v)} H${m(M.x+M.width)}`,color:o.gridline_color??{rgb:i.gridline},width:i.gridWidth}),o.visible!==!1&&c.words.push({x:M.x-x,y:v,text:formatValue(p,D),size:r,anchor:"end",color:n})}for(const p of E.ticks){const v=H(p);a.has_major_gridlines===!0&&c.grid.push({d:`M${m(v)} ${m(M.y)} V${m(M.y+M.height)}`,color:a.gridline_color??{rgb:i.gridline},width:i.gridWidth}),a.visible!==!1&&c.words.push({x:v,y:M.y+M.height+x+r*.6,text:formatValue(p,U),size:r,anchor:"middle",color:n})}c.axes.push({d:`M${m(M.x)} ${m(C(Math.max(P.min,Math.min(P.max,0))))} H${m(M.x+M.width)}`,color:a.line_color??{rgb:i.axisLine},width:i.gridWidth}),t.series.forEach((p,v)=>{const R=p.color??accentOf(v),z=(_[v]??[]).map(([Z,q])=>[H(Z),C(q)]);if(z.length!==0&&(hasLines(t.type)&&c.lines.push({d:t.type==="scatter-smooth"||p.smooth===!0?Nt(z):xt(z),color:R,width:p.line_width??i.lineWidth,series:v}),hasMarkers(t.type)))for(const[Z,q]of z)c.dots.push({x:Z,y:q,r:(p.marker_size??i.marker)/2,color:R})})}export function chartDrawing(t,c,h){const r=CHART_DEFAULTS,n=t.font_size??r.fontSize,i=t.font_color??"dk1",a={grid:[],shapes:[],boxes:[],lines:[],axes:[],dots:[],keys:[],words:[],plot:{x:0,y:0,width:0,height:0}},o={left:r.margin,top:r.margin,right:c-r.margin,bottom:h-r.margin};if(t.title!==void 0&&t.title!==""){const e=t.title_size??n*r.titleScale,s=t.title.split(`
|
|
3
|
+
`);s.forEach((g,l)=>{a.words.push({x:c/2,y:o.top+e*(.7+l*1.2),text:g,size:e,anchor:"middle",color:i})}),o.top+=e*(1.6+(s.length-1)*1.2)}const S=isRound(t.type),_=variesOf(t),A=(e,s)=>_?t.category_colors?.[s]??accentOf(s):t.series[e]?.color??accentOf(e);if(t.legend!==void 0){const e=_?t.categories:t.series.map(d=>d.name),s=n*.6,g=n*.4,l=n*1.5,y=e.map(d=>s+g+it(d,n)),j=(d,w,f)=>{a.keys.push({x:w,y:f-s/2,width:s,height:s,color:_?t.category_colors?.[d]??accentOf(d):t.series[d]?.color??accentOf(d),series:_?0:d,category:_?d:0}),a.words.push({x:w+s+g,y:f,text:e[d]??"",size:n,anchor:"start",color:i})};if(t.legend==="top"||t.legend==="bottom"){const d=y.reduce((W,b)=>W+b,0)+n*(e.length-1),w=t.legend==="top"?o.top+l/2:o.bottom-l/2;let f=(c-d)/2;e.forEach((W,b)=>{j(b,f,w),f+=(y[b]??0)+n}),t.legend_overlay!==!0&&(t.legend==="top"?o.top+=l:o.bottom-=l)}else{const d=Math.max(0,...y),w=t.legend==="left"?o.left:o.right-d,f=(o.top+o.bottom-l*e.length)/2+l/2;e.forEach((W,b)=>{j(b,w,f+b*l)}),t.legend_overlay!==!0&&(t.legend==="left"?o.left+=d+n:o.right-=d+n)}}const k=t.labels,O=k?.size??n,T=k?.color??i,D=(e,s,g,l,y=T)=>{g!==""&&a.words.push({x:e,y:s,text:g,size:O,anchor:l,color:y})};if(S){const e=t.series[0],s=(e?.values??[]).map(f=>Math.max(0,f??0)),g=s.reduce((f,W)=>f+W,0),l=Math.max(0,Math.min(o.right-o.left,o.bottom-o.top)/2),y=(o.left+o.right)/2,j=(o.top+o.bottom)/2,d=t.type==="doughnut"?l*((t.hole_size??r.holeSize)/100):0;a.plot={x:y-l,y:j-l,width:l*2,height:l*2};let w=0;return s.forEach((f,W)=>{const b=g>0?f/g:0,$=w+b*Math.PI*2;if(b>0){a.shapes.push({d:Kt(y,j,l,d,w,$),color:"lt1",width:1,fill:A(0,W),series:0,category:W});const I=(w+$)/2,V=d>0?(l+d)/2:labelPositionOf(t)==="inEnd"?l*.85:l*.6;e&&D(y+V*Math.sin(I),j-V*Math.cos(I),yt(t,f,b,e,t.categories[W]??""),"middle",k?.color??"lt1")}w=$}),a}if(isScatter(t.type))return Qt(t,a,o,n,i),a;const U=Math.max(1,t.categories.length),x=isHorizontal(t.type),tt=groupsOf(t),N=t.series.map(e=>t.categories.map((s,g)=>e.values[g]??null)),B=tt.map(e=>{const s=groupingOf(e.kind),g=s!=="clustered"&&s!=="standard",l=s==="percentStacked",y=t.categories.map((j,d)=>e.series.reduce((w,f)=>w+Math.abs(N[f]?.[d]??0),0));return{...e,stacked:g,percent:l,totals:y}}),M=(e,s,g)=>{const l=N[s]?.[g];if(l==null)return null;const y=e.totals[g]??0;return e.percent?y>0?l/y:0:l},E=e=>{let s=0,g=0,l=1/0,y=!1;for(const f of B)if(f.secondary===e&&(y||=f.percent,t.categories.forEach((W,b)=>{let $=0,I=0;for(const V of f.series){const L=M(f,V,b)??0;f.stacked?L>=0?$+=L:I+=L:($=Math.max($,L),I=Math.min(I,L))}g=Math.max(g,$),s=Math.min(s,I)}),!f.stacked))for(const W of f.series)for(const b of N[W]??[])b!==null&&(l=Math.min(l,b));B.every(f=>f.secondary!==e||!f.stacked)&&Number.isFinite(l)&&l>0&&(s=l),y&&(g=1,s=Math.min(s,0));const d=B.find(f=>f.secondary===e),w=d===void 0?void 0:d.series[0];return{low:s,high:g,percent:y,format:w===void 0?void 0:t.series[w]?.number_format}},P=E(!1),H=B.some(e=>e.secondary)?E(!0):void 0,C=t.value_axis??{},p=t.secondary_axis??{},v=t.category_axis??{},R=C.number_format??(P.percent?"0%":P.format??"General"),z=p.number_format??(H?.percent===!0?"0%":H?.format??"General"),Z=(e,s,g,l)=>chartScale(e.low,e.high,g,l,{...s,...e.percent?{maximum_scale:s.maximum_scale??1}:{}}),q=x?o.right-o.left:o.bottom-o.top,at=x?n*5:n*2.4,Dt=Z(P,C,q,at),bt=C.visible===!1?[]:Dt.ticks.map(e=>formatValue(e,R)),wt=Math.max(0,...bt.map(e=>it(e,n))),Mt=H===void 0||p.visible===!1?0:Math.max(0,...Z(H,p,q,at).ticks.map(e=>it(formatValue(e,z),n))),ct=v.visible!==!1,_t=ct?Math.max(0,...t.categories.map(e=>it(e,n))):0,G=n*.5,$t=x?C.title:v.title,kt=x?v.title:C.title,Ht=Tt(o,$t,kt,n),lt=H===void 0?void 0:p.title,vt=n*1.5,Wt=lt!==void 0&<!==""?(o.right-=vt)+vt/2:void 0,u=x?{x:o.left+(ct?_t+G:0),y:o.top,width:0,height:o.bottom-o.top-(C.visible===!1?0:n*1.2+G)}:{x:o.left+(C.visible===!1?0:wt+G),y:o.top,width:0,height:o.bottom-o.top-(ct?n*1.2+G:0)};u.width=o.right-u.x-(x&&bt.length>0?wt/2:0)-(Mt>0?Mt+G:0),a.plot=u,Bt(a,u,Ht,$t,kt,n,i),Wt!==void 0&<!==void 0&&a.words.push({x:Wt,y:u.y+u.height/2,text:lt,size:n,anchor:"middle",color:i,rotate:-90});const ut=x?u.width:u.height,et=Z(P,C,ut,at),nt=H===void 0?void 0:Z(H,p,ut,at),Et=(e,s)=>(Math.min(e.max,Math.max(e.min,s))-e.min)/(e.max-e.min)*ut,mt=(e,s)=>x?u.x+Et(e,s):u.y+u.height-Et(e,s),St=e=>mt(et,e),At=B.every(e=>isArea(e.kind)),Ot=v.reverse_order===!0,Pt=x?!Ot:Ot,pt=(x?u.height:u.width)/U,Ct=At?(x?u.height:u.width)/Math.max(1,U-1):pt,gt=e=>{const s=At?e*Ct:(e+.5)*pt,g=x?u.height:u.width,l=Pt?g-s:s;return(x?u.y:u.x)+l},It=St(Math.max(et.min,Math.min(et.max,0)));for(const e of et.ticks){const s=St(e);(C.has_major_gridlines??!0)&&a.grid.push({d:x?`M${m(s)} ${m(u.y)} V${m(u.y+u.height)}`:`M${m(u.x)} ${m(s)} H${m(u.x+u.width)}`,color:C.gridline_color??{rgb:r.gridline},width:r.gridWidth}),C.visible!==!1&&a.words.push(x?{x:s,y:u.y+u.height+G+n*.6,text:formatValue(e,R),size:n,anchor:"middle",color:i}:{x:u.x-G,y:s,text:formatValue(e,R),size:n,anchor:"end",color:i})}if(nt&&p.visible!==!1)for(const e of nt.ticks)a.words.push({x:u.x+u.width+G,y:mt(nt,e),text:formatValue(e,z),size:n,anchor:"start",color:i});if(a.axes.push({d:x?`M${m(It)} ${m(u.y)} V${m(u.y+u.height)}`:`M${m(u.x)} ${m(It)} H${m(u.x+u.width)}`,color:v.line_color??{rgb:r.axisLine},width:r.gridWidth}),ct){const e=x?n*1.3:_t+n,s=Math.max(1,Math.ceil(e/Math.max(1,Ct)));t.categories.forEach((g,l)=>{if(l%s!==0)return;const y=gt(l);a.words.push(x?{x:u.x-G,y,text:g,size:n,anchor:"end",color:i}:{x:y,y:u.y+u.height+G+n*.6,text:g,size:n,anchor:"middle",color:i})})}for(const e of B){const s=e.secondary&&nt?nt:et,g=y=>mt(s,y),l={type:e.kind,...t.labels===void 0?{}:{labels:t.labels}};isBar(e.kind)?zt(e,g,l):Gt(e,g,l)}return a;function zt(e,s,g){const l=(t.gap_width??r.gapWidth)/100,y=e.stacked?1:e.series.length,j=e.stacked?1:(t.overlap??0)/100,d=pt/(Math.max(1,y-(y-1)*j)+l),w=d*(1-j),f=d+w*(y-1);t.categories.forEach((W,b)=>{const $=gt(b);let I=0,V=0;e.series.forEach((L,ot)=>{const J=t.series[L],F=M(e,L,b);if(F===null||!J)return;const ht=e.stacked?F>=0?I:V:0,st=ht+F;e.stacked&&(F>=0?I=st:V=st);const K=s(ht),Q=s(st),dt=(e.stacked?$-d/2:$-f/2+ot*w)+(x&&Pt&&!e.stacked?f-d-2*ot*w:0),Vt=x?{x:Math.min(K,Q),y:dt,width:Math.abs(Q-K),height:d}:{x:dt,y:Math.min(K,Q),width:d,height:Math.abs(Q-K)};if(a.boxes.push({...Vt,color:A(L,b),series:L,category:b}),!k)return;const Lt=yt(t,N[L]?.[b]??0,0,J,t.categories[b]??""),ft=labelPositionOf(g),X=O*.8,Rt=F>=0?1:-1,Ft=(rt,Y)=>ft==="ctr"?(rt+Y)/2:ft==="inBase"?rt+(Y>rt?X:-X):ft==="inEnd"?Y-(Y>rt?X:-X):Y+(Y>=rt?X:-X);x?D(Ft(K,Q),dt+d/2,Lt,ft==="outEnd"?Rt>0?"start":"end":"middle"):D(dt+d/2,Ft(K,Q),Lt,"middle")})})}function Gt(e,s,g){const l=t.categories.map(()=>0),y=e.series.map(d=>{const w=t.series[d],f=[],W=[];return t.categories.forEach((b,$)=>{const I=M(e,d,$);if(I===null||!w)return;const V=e.stacked?l[$]??0:0,L=V+I;e.stacked&&(l[$]=L);const ot=gt($),J=F=>x?[s(F),ot]:[ot,s(F)];if(f.push(J(L)),W.push(J(V)),isLine(e.kind)&&k){const F=labelPositionOf(g),[ht,st]=J(L);D(ht+(F==="r"?O:F==="l"?-O:0),st+(F==="t"?-O:F==="b"?O:0),yt(t,N[d]?.[$]??0,0,w,t.categories[$]??""),F==="r"?"start":F==="l"?"end":"middle")}}),{series:w,s:d,points:f,base:W}}),j=[];for(const{series:d,s:w,points:f,base:W}of y){if(!d)continue;const b=d.color??accentOf(w);if(isArea(e.kind)&&f.length>0)j.push({d:`${xt([...f,...[...W].reverse()])} Z`,color:b,width:0,fill:b,series:w});else if(f.length>0&&(a.lines.push({d:d.smooth===!0?Nt(f):xt(f),color:b,width:d.line_width??r.lineWidth,series:w}),hasMarkers(e.kind)))for(const[$,I]of f)a.dots.push({x:$,y:I,r:(d.marker_size??r.marker)/2,color:b})}a.shapes.push(...j.reverse())}}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Rgba } from "@allyhub/ooxml/transform";
|
|
2
|
+
import type { Color, ColorName, ColorTransform, MappedColor, ThemeColor } from "@allyhub/formats";
|
|
3
|
+
/** Office's colour map: text and background 1 and 2 are dark and light 1 and 2. */
|
|
4
|
+
export declare const DEFAULT_MAPPED: Readonly<Record<MappedColor, ThemeColor>>;
|
|
5
|
+
/**
|
|
6
|
+
* The colours a colour is drawn against: the theme's twelve and, where a
|
|
7
|
+
* master's colour map says, what text and background 1 and 2 (or a
|
|
8
|
+
* remapped accent) are; Office's map where it says nothing.
|
|
9
|
+
*/
|
|
10
|
+
export type ThemeColors = Readonly<Record<ThemeColor, string>> & Readonly<Partial<Record<MappedColor, string>>>;
|
|
11
|
+
/** A colour map: what each name the map holds is of the theme's colours. */
|
|
12
|
+
export type ColorMapDef = Readonly<Partial<Record<ColorName, ThemeColor>>>;
|
|
13
|
+
/** The theme's colours through a colour map: each of its names (`tx1`, a remapped `accent1`) the theme colour it maps to. */
|
|
14
|
+
export declare function mappedColors(colors: ThemeColors, map: ColorMapDef | undefined): ThemeColors;
|
|
15
|
+
/** A theme colour at a brightness: its name alone at 0. */
|
|
16
|
+
export declare const themeColor: (theme_color: ColorName, brightness?: number) => Color;
|
|
17
|
+
/** The theme colour a colour is, at any brightness or with any transforms. */
|
|
18
|
+
export declare const themeColorOf: (c: Color) => ColorName | undefined;
|
|
19
|
+
/** A transform's value as DrawingML writes it: a share in 100 000ths, an angle in 60 000ths of a degree. */
|
|
20
|
+
export declare const transformVal: (t: ColorTransform) => number;
|
|
21
|
+
/** A colour drawn: red, green and blue, and its alpha. */
|
|
22
|
+
export declare function colorRgba(c: Color, colors: ThemeColors): Rgba;
|
|
23
|
+
/**
|
|
24
|
+
* A colour as it is drawn, against the theme in force: a theme colour's
|
|
25
|
+
* value, lighter or darker by its brightness as PowerPoint makes it, with
|
|
26
|
+
* its transforms, or its own; `#RRGGBB`, or `#RRGGBBAA` where its alpha
|
|
27
|
+
* lets some through. Every colour drawn or measured comes through here.
|
|
28
|
+
*/
|
|
29
|
+
export declare function colorRgb(c: Color, colors: ThemeColors): string;
|
|
30
|
+
/**
|
|
31
|
+
* A colour as DrawingML writes it: the theme's (`a:schemeClr`, `tx1` as
|
|
32
|
+
* it is, for the master's map to make), lighter or darker as PowerPoint's
|
|
33
|
+
* picker writes it (`a:lumMod`, `a:lumOff`), or RGB (`a:srgbClr`), its
|
|
34
|
+
* transforms in order, then `after` (an alpha a field of its own gives).
|
|
35
|
+
*/
|
|
36
|
+
export declare function colorXml(c: Color, after?: string): string;
|
|
37
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
+
import{brightened as u,hexOfRgb as h,lumOf as p,rgbOfHex as b}from"@allyhub/ooxml/brightness";import{transformed as d}from"@allyhub/ooxml/transform";export const DEFAULT_MAPPED={tx1:"dk1",bg1:"lt1",tx2:"dk2",bg2:"lt2"};export function mappedColors(t,r){if(!r||Object.keys(r).length===0)return t;const e={...t};for(const[o,n]of Object.entries(r))e[o]=t[n];return e}export const themeColor=(t,r=0)=>r===0?t:{theme_color:t,brightness:r},themeColorOf=t=>typeof t=="string"?t:"theme_color"in t?t.theme_color:void 0;const f=(t,r)=>r[t]??(t in DEFAULT_MAPPED?r[DEFAULT_MAPPED[t]]:"#000000"),x=new Set(["hue","hueOff"]);export const transformVal=t=>Math.round(t.value*(x.has(t.name)?6e4:1e5));export function colorRgba(t,r){const e=typeof t=="string"?f(t,r):"rgb"in t?t.rgb:"brightness"in t?u(f(t.theme_color,r),t.brightness):f(t.theme_color,r),o=typeof t=="string"||"brightness"in t?[]:t.transforms;let n={rgb:b(e),alpha:1};for(const a of o??[])n=d(n,a.name,transformVal(a));return n}export function colorRgb(t,r){if(typeof t=="string")return f(t,r);if("rgb"in t&&!t.transforms?.length)return t.rgb;if("brightness"in t)return u(f(t.theme_color,r),t.brightness);const{rgb:e,alpha:o}=colorRgba(t,r),n=h(e);return o>=1?n:`${n}${Math.round(o*255).toString(16).padStart(2,"0").toUpperCase()}`}const g=t=>Object.entries(t).map(([r,e])=>` ${r}="${String(e)}"`).join("");export function colorXml(t,r=""){const e=(s,i,m)=>m===""?`<${s}${g(i)}/>`:`<${s}${g(i)}>${m}</${s}>`,o=(s,i)=>`<a:${s} val="${String(i)}"/>`;if(typeof t=="string")return e("a:schemeClr",{val:t},r);const n=s=>(s??[]).map(i=>o(i.name,transformVal(i))).join("");if("rgb"in t)return e("a:srgbClr",{val:t.rgb.replace("#","").toUpperCase()},n(t.transforms)+r);if("transforms"in t)return e("a:schemeClr",{val:t.theme_color},n(t.transforms)+r);const{lumMod:a,lumOff:l}=p(t.brightness);return e("a:schemeClr",{val:t.theme_color},o("lumMod",a)+(l===void 0?"":o("lumOff",l))+r)}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
export*from"./chart.js";export*from"./chart-file.js";export*from"./chart-xml.js";export*from"./embedded.js";export*from"./svg.js";
|
|
2
|
+
export*from"./color.js";export*from"./chart.js";export*from"./chart-file.js";export*from"./chart-xml.js";export*from"./embedded.js";export*from"./svg.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{
|
|
2
|
+
import{colorRgb as u}from"./color.js";import{chartDrawing as F}from"./chart.js";export const OFFICE_COLORS={dk1:"#000000",lt1:"#FFFFFF",dk2:"#44546A",lt2:"#E7E6E6",accent1:"#4472C4",accent2:"#ED7D31",accent3:"#A5A5A5",accent4:"#FFC000",accent5:"#5B9BD5",accent6:"#70AD47",hlink:"#0563C1",folHlink:"#954F72"};const w={"&":"&","<":"<",">":">",'"':"""},i=n=>n.replace(/[&<>"]/gu,r=>w[r]??r),o=n=>String(Number(n.toFixed(3)));function k(n,r){const l=t=>{const c=t.fill===void 0?"none":r(t.fill),s=t.width>0?r(t.color):"none";return`<path d="${i(t.d)}" fill="${c}" stroke="${s}" stroke-width="${o(t.width)}" stroke-linejoin="round"/>`},e=[];for(const t of[...n.grid,...n.shapes])e.push(l(t));for(const t of[...n.boxes,...n.keys])e.push(`<rect x="${o(t.x)}" y="${o(t.y)}" width="${o(t.width)}" height="${o(t.height)}" fill="${r(t.color)}"/>`);for(const t of[...n.axes,...n.lines])e.push(l(t));for(const t of n.dots)e.push(`<circle cx="${o(t.x)}" cy="${o(t.y)}" r="${o(t.r)}" fill="${r(t.color)}"/>`);for(const t of n.words){const c=t.rotate===void 0?"":` transform="rotate(${o(t.rotate)} ${o(t.x)} ${o(t.y)})"`;e.push(`<text x="${o(t.x)}" y="${o(t.y)}" font-size="${o(t.size)}" text-anchor="${t.anchor}" dominant-baseline="central" fill="${r(t.color)}"${c}>${i(t.text)}</text>`)}return e.join("")}export function chartSvg(n,r,l,e={}){const t=e.pointsPerPixel??.75,c=r*t,s=l*t,f=e.colors??OFFICE_COLORS,h=g=>u(g,f),d=e.font??"Carlito, Calibri, Arial, sans-serif",$=e.paper??"#FFFFFF",a=e.edge??"#D9D9D9",p=e.label===void 0?"":` role="img" aria-label="${i(e.label)}"`,x=$==="none"&&a==="none"?"":`<rect x="0.375" y="0.375" width="${o(c-.75)}" height="${o(s-.75)}" fill="${i($)}" stroke="${i(a)}" stroke-width="${a==="none"?"0":"0.75"}"/>`;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${o(c)} ${o(s)}" width="${o(r)}" height="${o(l)}" font-family="${i(d)}"${p}>${x}${k(F(n,c,s),h)}</svg>`}
|
|
@@ -35,6 +35,10 @@ export declare const DeckCodeSchema: z.ZodObject<{
|
|
|
35
35
|
accent6: "accent6";
|
|
36
36
|
hlink: "hlink";
|
|
37
37
|
folHlink: "folHlink";
|
|
38
|
+
tx1: "tx1";
|
|
39
|
+
bg1: "bg1";
|
|
40
|
+
tx2: "tx2";
|
|
41
|
+
bg2: "bg2";
|
|
38
42
|
}>, z.ZodObject<{
|
|
39
43
|
theme_color: z.ZodEnum<{
|
|
40
44
|
dk1: "dk1";
|
|
@@ -49,11 +53,103 @@ export declare const DeckCodeSchema: z.ZodObject<{
|
|
|
49
53
|
accent6: "accent6";
|
|
50
54
|
hlink: "hlink";
|
|
51
55
|
folHlink: "folHlink";
|
|
56
|
+
tx1: "tx1";
|
|
57
|
+
bg1: "bg1";
|
|
58
|
+
tx2: "tx2";
|
|
59
|
+
bg2: "bg2";
|
|
52
60
|
}>;
|
|
53
61
|
brightness: z.ZodNumber;
|
|
62
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
63
|
+
theme_color: z.ZodEnum<{
|
|
64
|
+
dk1: "dk1";
|
|
65
|
+
lt1: "lt1";
|
|
66
|
+
dk2: "dk2";
|
|
67
|
+
lt2: "lt2";
|
|
68
|
+
accent1: "accent1";
|
|
69
|
+
accent2: "accent2";
|
|
70
|
+
accent3: "accent3";
|
|
71
|
+
accent4: "accent4";
|
|
72
|
+
accent5: "accent5";
|
|
73
|
+
accent6: "accent6";
|
|
74
|
+
hlink: "hlink";
|
|
75
|
+
folHlink: "folHlink";
|
|
76
|
+
tx1: "tx1";
|
|
77
|
+
bg1: "bg1";
|
|
78
|
+
tx2: "tx2";
|
|
79
|
+
bg2: "bg2";
|
|
80
|
+
}>;
|
|
81
|
+
transforms: z.ZodArray<z.ZodObject<{
|
|
82
|
+
name: z.ZodEnum<{
|
|
83
|
+
tint: "tint";
|
|
84
|
+
shade: "shade";
|
|
85
|
+
lumMod: "lumMod";
|
|
86
|
+
lumOff: "lumOff";
|
|
87
|
+
lum: "lum";
|
|
88
|
+
satMod: "satMod";
|
|
89
|
+
satOff: "satOff";
|
|
90
|
+
sat: "sat";
|
|
91
|
+
hueMod: "hueMod";
|
|
92
|
+
hueOff: "hueOff";
|
|
93
|
+
hue: "hue";
|
|
94
|
+
alpha: "alpha";
|
|
95
|
+
alphaMod: "alphaMod";
|
|
96
|
+
alphaOff: "alphaOff";
|
|
97
|
+
}>;
|
|
98
|
+
value: z.ZodNumber;
|
|
99
|
+
}, z.core.$strict>>;
|
|
54
100
|
}, z.core.$strict>, z.ZodObject<{
|
|
55
101
|
rgb: z.ZodString;
|
|
102
|
+
transforms: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
103
|
+
name: z.ZodEnum<{
|
|
104
|
+
tint: "tint";
|
|
105
|
+
shade: "shade";
|
|
106
|
+
lumMod: "lumMod";
|
|
107
|
+
lumOff: "lumOff";
|
|
108
|
+
lum: "lum";
|
|
109
|
+
satMod: "satMod";
|
|
110
|
+
satOff: "satOff";
|
|
111
|
+
sat: "sat";
|
|
112
|
+
hueMod: "hueMod";
|
|
113
|
+
hueOff: "hueOff";
|
|
114
|
+
hue: "hue";
|
|
115
|
+
alpha: "alpha";
|
|
116
|
+
alphaMod: "alphaMod";
|
|
117
|
+
alphaOff: "alphaOff";
|
|
118
|
+
}>;
|
|
119
|
+
value: z.ZodNumber;
|
|
120
|
+
}, z.core.$strict>>>;
|
|
56
121
|
}, z.core.$strict>]>;
|
|
122
|
+
color_map: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
123
|
+
dk1: "dk1";
|
|
124
|
+
lt1: "lt1";
|
|
125
|
+
dk2: "dk2";
|
|
126
|
+
lt2: "lt2";
|
|
127
|
+
accent1: "accent1";
|
|
128
|
+
accent2: "accent2";
|
|
129
|
+
accent3: "accent3";
|
|
130
|
+
accent4: "accent4";
|
|
131
|
+
accent5: "accent5";
|
|
132
|
+
accent6: "accent6";
|
|
133
|
+
hlink: "hlink";
|
|
134
|
+
folHlink: "folHlink";
|
|
135
|
+
tx1: "tx1";
|
|
136
|
+
bg1: "bg1";
|
|
137
|
+
tx2: "tx2";
|
|
138
|
+
bg2: "bg2";
|
|
139
|
+
}> & z.core.$partial, z.ZodEnum<{
|
|
140
|
+
dk1: "dk1";
|
|
141
|
+
lt1: "lt1";
|
|
142
|
+
dk2: "dk2";
|
|
143
|
+
lt2: "lt2";
|
|
144
|
+
accent1: "accent1";
|
|
145
|
+
accent2: "accent2";
|
|
146
|
+
accent3: "accent3";
|
|
147
|
+
accent4: "accent4";
|
|
148
|
+
accent5: "accent5";
|
|
149
|
+
accent6: "accent6";
|
|
150
|
+
hlink: "hlink";
|
|
151
|
+
folHlink: "folHlink";
|
|
152
|
+
}>>>;
|
|
57
153
|
text_styles: z.ZodObject<{
|
|
58
154
|
title: z.ZodArray<z.ZodObject<{}, z.core.$loose>>;
|
|
59
155
|
body: z.ZodArray<z.ZodObject<{}, z.core.$loose>>;
|
|
@@ -80,6 +176,7 @@ export declare const DeckCodeSchema: z.ZodObject<{
|
|
|
80
176
|
placeholder: z.ZodOptional<z.ZodObject<{
|
|
81
177
|
type: z.ZodString;
|
|
82
178
|
idx: z.ZodNumber;
|
|
179
|
+
orient: z.ZodOptional<z.ZodLiteral<"vert">>;
|
|
83
180
|
}, z.core.$strict>>;
|
|
84
181
|
text: z.ZodOptional<z.ZodObject<{
|
|
85
182
|
paragraphs: z.ZodArray<z.ZodObject<{
|
|
@@ -102,6 +199,37 @@ export declare const DeckCodeSchema: z.ZodObject<{
|
|
|
102
199
|
layouts: z.ZodArray<z.ZodObject<{
|
|
103
200
|
name: z.ZodString;
|
|
104
201
|
master: z.ZodString;
|
|
202
|
+
color_map: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
203
|
+
dk1: "dk1";
|
|
204
|
+
lt1: "lt1";
|
|
205
|
+
dk2: "dk2";
|
|
206
|
+
lt2: "lt2";
|
|
207
|
+
accent1: "accent1";
|
|
208
|
+
accent2: "accent2";
|
|
209
|
+
accent3: "accent3";
|
|
210
|
+
accent4: "accent4";
|
|
211
|
+
accent5: "accent5";
|
|
212
|
+
accent6: "accent6";
|
|
213
|
+
hlink: "hlink";
|
|
214
|
+
folHlink: "folHlink";
|
|
215
|
+
tx1: "tx1";
|
|
216
|
+
bg1: "bg1";
|
|
217
|
+
tx2: "tx2";
|
|
218
|
+
bg2: "bg2";
|
|
219
|
+
}> & z.core.$partial, z.ZodEnum<{
|
|
220
|
+
dk1: "dk1";
|
|
221
|
+
lt1: "lt1";
|
|
222
|
+
dk2: "dk2";
|
|
223
|
+
lt2: "lt2";
|
|
224
|
+
accent1: "accent1";
|
|
225
|
+
accent2: "accent2";
|
|
226
|
+
accent3: "accent3";
|
|
227
|
+
accent4: "accent4";
|
|
228
|
+
accent5: "accent5";
|
|
229
|
+
accent6: "accent6";
|
|
230
|
+
hlink: "hlink";
|
|
231
|
+
folHlink: "folHlink";
|
|
232
|
+
}>>>;
|
|
105
233
|
shapes: z.ZodArray<z.ZodObject<{
|
|
106
234
|
name: z.ZodString;
|
|
107
235
|
kind: z.ZodEnum<{
|
|
@@ -123,6 +251,7 @@ export declare const DeckCodeSchema: z.ZodObject<{
|
|
|
123
251
|
placeholder: z.ZodOptional<z.ZodObject<{
|
|
124
252
|
type: z.ZodString;
|
|
125
253
|
idx: z.ZodNumber;
|
|
254
|
+
orient: z.ZodOptional<z.ZodLiteral<"vert">>;
|
|
126
255
|
}, z.core.$strict>>;
|
|
127
256
|
text: z.ZodOptional<z.ZodObject<{
|
|
128
257
|
paragraphs: z.ZodArray<z.ZodObject<{
|
|
@@ -171,6 +300,7 @@ export declare const DeckCodeSchema: z.ZodObject<{
|
|
|
171
300
|
placeholder: z.ZodOptional<z.ZodObject<{
|
|
172
301
|
type: z.ZodString;
|
|
173
302
|
idx: z.ZodNumber;
|
|
303
|
+
orient: z.ZodOptional<z.ZodLiteral<"vert">>;
|
|
174
304
|
}, z.core.$strict>>;
|
|
175
305
|
text: z.ZodOptional<z.ZodObject<{
|
|
176
306
|
paragraphs: z.ZodArray<z.ZodObject<{
|
|
@@ -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{THEME_COLORS as
|
|
2
|
+
import{z as t}from"zod";import{COLOR_NAMES as o,COLOR_TRANSFORMS as l,THEME_COLORS as n}from"./slides.js";const e=t.number(),s=t.array(t.strictObject({name:t.enum(l),value:t.number()})),m=t.union([t.enum(o),t.strictObject({theme_color:t.enum(o),brightness:t.number().min(-1).max(1)}),t.strictObject({theme_color:t.enum(o),transforms:s}),t.strictObject({rgb:t.string().regex(/^#?[0-9A-Fa-f]{6}$/u),transforms:s.optional()})]),i=t.partialRecord(t.enum(o),t.enum(n)),p=t.strictObject({left:e,top:e,width:e,height:e}),b=t.looseObject({text:t.string()}),c=t.looseObject({level:t.number().int().min(0).max(8),runs:t.array(b)}),g=t.looseObject({paragraphs:t.array(c),levels:t.array(t.looseObject({}))}),r=t.looseObject({name:t.string(),kind:t.enum(["placeholder","textbox","picture","movie","autoshape","table","chart","component"]),frame:p.optional(),placeholder:t.strictObject({type:t.string(),idx:t.number().int(),orient:t.literal("vert").optional()}).optional(),text:g.optional(),media:t.looseObject({path:t.string(),base:t.string()}).optional(),component:t.strictObject({name:t.string(),props:t.record(t.string(),t.unknown())}).optional()}),h=t.looseObject({name:t.string(),master:t.string(),color_map:i.optional(),shapes:t.array(r)}),O=t.looseObject({name:t.string(),background:m,color_map:i.optional(),text_styles:t.strictObject({title:t.array(t.looseObject({})),body:t.array(t.looseObject({})),other:t.array(t.looseObject({}))}),shapes:t.array(r),layouts:t.array(h)}),a=t.lazy(()=>t.looseObject({type:t.string(),optional:t.boolean().optional(),of:a.optional(),fields:t.record(t.string(),a).optional(),kind:t.string().optional()})),d=t.looseObject({id:t.string(),layout:t.string(),shapes:t.array(r),text:t.record(t.string(),t.array(c)),notes:t.string().optional()});export const DeckCodeSchema=t.strictObject({slide_width:e.positive(),slide_height:e.positive(),theme:t.strictObject({name:t.string().optional(),colors:t.partialRecord(t.enum(n),t.string()).optional(),fonts:t.record(t.string(),t.string()).optional()}).optional(),masters:t.array(O),components:t.record(t.string(),t.strictObject({props:t.record(t.string(),a)})),generators:t.record(t.string(),t.union([t.array(d),t.strictObject({error:t.string(),stack:t.string().optional()})]))});
|
|
@@ -26,6 +26,8 @@ export declare const GenFileSchema: z.ZodObject<{
|
|
|
26
26
|
}, z.core.$strict>;
|
|
27
27
|
export type GenFile = z.infer<typeof GenFileSchema>;
|
|
28
28
|
export { Omitted as OmittedValueSchema };
|
|
29
|
-
/**
|
|
29
|
+
/** A record's extension, added to its file's name. */
|
|
30
|
+
export declare const PROVENANCE_SUFFIX = ".provenance";
|
|
31
|
+
/** The record of a file: beside it, `.provenance` added. */
|
|
30
32
|
export declare const genFileFor: (file: string) => string;
|
|
31
33
|
//# sourceMappingURL=gen.d.ts.map
|
|
@@ -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{INSTANT as e,SHA256 as n,dataFile as i}from"./file.js";const r=t.strictObject({omitted:t.literal(!0),sha256:n,bytes:t.int().nonnegative()});export const GenFileSchema=i({version:t.literal(1),ai:t.boolean(),tool:t.string().optional(),model:t.string().optional(),input:t.record(t.string(),t.unknown()).optional(),inputHash:n.optional(),output:t.record(t.string(),t.unknown()).optional(),credits:t.number().nonnegative().optional(),at:e,sha256:n,bytes:t.int().nonnegative(),source:t.strictObject({library:t.string(),page:t.url(),authors:t.array(t.string()).default([]),license:t.string()}).optional()});export{r as OmittedValueSchema};export const genFileFor=o=>`${o}
|
|
2
|
+
import{z as t}from"zod";import{INSTANT as e,SHA256 as n,dataFile as i}from"./file.js";const r=t.strictObject({omitted:t.literal(!0),sha256:n,bytes:t.int().nonnegative()});export const GenFileSchema=i({version:t.literal(1),ai:t.boolean(),tool:t.string().optional(),model:t.string().optional(),input:t.record(t.string(),t.unknown()).optional(),inputHash:n.optional(),output:t.record(t.string(),t.unknown()).optional(),credits:t.number().nonnegative().optional(),at:e,sha256:n,bytes:t.int().nonnegative(),source:t.strictObject({library:t.string(),page:t.url(),authors:t.array(t.string()).default([]),license:t.string()}).optional()});export{r as OmittedValueSchema};export const PROVENANCE_SUFFIX=".provenance",genFileFor=o=>`${o}${PROVENANCE_SUFFIX}`;
|