@aglyn/plugins-ai 1.8.0 → 1.9.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/package.json +17 -17
- package/src/lib/activity/ai-activity.js +4 -2
- package/src/lib/activity/ai-activity.js.map +1 -1
- package/src/lib/components/ai-credits-card.component.d.ts +4 -3
- package/src/lib/components/ai-credits-card.component.js +13 -12
- package/src/lib/components/ai-credits-card.component.js.map +1 -1
- package/src/lib/components/ai-site-import-job.component.js +14 -5
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.d.ts +2 -2
- package/src/lib/components/ai-upsell-dialog.component.js +3 -3
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/components/staff-org-ai-card.component.js +2 -2
- package/src/lib/components/staff-org-ai-card.component.js.map +1 -1
- package/src/lib/declarations.d.ts +2 -2
- package/src/lib/declarations.js +10 -9
- package/src/lib/declarations.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +3 -0
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.js +6 -1
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +38 -13
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +2 -0
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-site-import-view.js +4 -3
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +2 -0
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-upsell-copy.js +4 -3
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/plan-entitlements.d.ts +3 -3
- package/src/lib/plan-entitlements.js +1 -1
- package/src/lib/plan-entitlements.js.map +1 -1
- package/src/lib/providers/model-choice.d.ts +6 -3
- package/src/lib/providers/model-choice.js +8 -4
- package/src/lib/providers/model-choice.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +5 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/site-import-layout.js +5 -1
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/usage/assist-credits.d.ts +5 -4
- package/src/lib/usage/assist-credits.js +5 -4
- package/src/lib/usage/assist-credits.js.map +1 -1
- package/src/lib/usage/staff-org-ai-view.js +6 -6
- package/src/lib/usage/staff-org-ai-view.js.map +1 -1
- package/src/lib/usage/staff-org-ai.d.ts +4 -4
- package/src/lib/usage/staff-org-ai.js +8 -7
- package/src/lib/usage/staff-org-ai.js.map +1 -1
- package/src/lib/usage/staff-org-usage-ai.js +2 -2
- package/src/lib/usage/staff-org-usage-ai.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-document.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * A PAGE BROUGHT IN WORD FOR WORD (AGL-4084, AGL-4107).\n *\n * An imported page is never rewritten. Its words are the source's, as the\n * crawler read them (`AiSiteImportPageRead.blocks`), and how the source lays\n * them out is the reader's (`AiSiteImportPageRead.layout`, AGL-4106). This\n * module is the page as its job carries it: its blocks, its layout, its\n * photos and where its links go, read defensively off the job's inputs.\n *\n * - **Lines.** The page's main region, numbered: every heading, paragraph,\n * list item, quote, link and picture in source order. A link inside a\n * sentence is in its sentence already and is no line of its own.\n * - **Sections.** Where a read kept no layout (one made before the reader,\n * or one past its budget), one for the page's opening and one at each\n * second-level heading, as the source divides itself.\n *\n * The page is drawn by the site compiler (`ai-site-import-compile.ts`), with\n * every line on it exactly once and never a word that is not the source's.\n *=========================================*/\n\n\nimport {\n AI_SITE_IMPORT_LABEL_MAX_CHARS,\n AI_SITE_IMPORT_MAX_SECTIONS,\n type AiSiteImportBuild,\n type AiSiteImportPhoto,\n type SiteImportLayout,\n} from '../model/ai-site-import'\nimport type { SiteImportBlock, SiteImportVideo } from '../site-import/site-import-html'\nimport { siteImportLabel } from '../site-import/site-import-page'\nimport { AI_TEXT_LIMITS } from '../runtime/ai-palette'\n\n/** The unit input carrying a page brought in word for word: its lines, its photos and where its links go. */\nexport const AI_LAYOUT_IMPORTED_SECTIONS_INPUT = 'importedSections'\n\n/** A page brought in, as the import step hands it to the page step. Untrusted data from the owner's site. */\nexport interface AiSiteImportDocument {\n build: AiSiteImportBuild\n /** The page's name on the new site: its h1 where the source shows no heading. */\n title: string\n /** Where the page is on the owner's website. */\n url: string\n /** The page's main region, in order. */\n blocks: SiteImportBlock[]\n /** Its photos as the library holds them, each by the source address it was read from. */\n photos: AiSiteImportPhoto[]\n /** The site's own pages a link may go to: the source path each was read from, and the page it is now. */\n links: Array<{ path: string; id: string }>\n /** The origins the old site answers on: a link to one of them is to a page of its own. */\n origins: string[]\n /**\n * How the source lays the page out (AGL-4106), over `blocks` by index;\n * absent on a read made before the reader, or one past its budget.\n */\n layout?: SiteImportLayout | null\n /** Each form of the read, by its index, and the saved form that takes its place (AGL-4083); absent on a page that asked for none. */\n forms?: Array<{ index: number; formId: string | null }> | null\n /** The page's videos (AGL-4140), which its layout places by index; absent on a page that shows none. */\n videos?: SiteImportVideo[]\n}\n\n/** The most characters a text element holds (the palette's ceiling for body copy). */\nexport const AI_SITE_IMPORT_TEXT_MAX_CHARS = AI_TEXT_LIMITS.body\n\n/** The most characters a heading style holds; a longer heading is drawn in a subtitle style, still a heading. */\nexport const AI_SITE_IMPORT_HEADLINE_MAX_CHARS = AI_TEXT_LIMITS.headline\n\n/** The most characters a button's label holds; a longer link keeps its words as a line of text. */\nexport const AI_SITE_IMPORT_LABEL_CHARS = 40\n\n/**\n * What one page may weigh, inside the budget of a page of its owner's own\n * words (`AI_OWN_WORDS_PAGE_BUDGET`): a page that would run past it ends at\n * the section before, marked `cut`.\n */\nexport const AI_SITE_IMPORT_DOC_MAX_NODES = 1_400\nexport const AI_SITE_IMPORT_DOC_MAX_CHARS = 200_000\n\n/** One numbered line of a page. */\nexport interface AiSiteImportLine {\n /** 1-based, in source order. */\n n: number\n block: SiteImportBlock\n /** The section it belongs to, by plan index. */\n section: number\n}\n\nexport interface AiSiteImportDocSection {\n name: string\n /** Its lines' numbers, in order. */\n lines: number[]\n}\n\nexport interface AiSiteImportDocLines {\n lines: AiSiteImportLine[]\n sections: AiSiteImportDocSection[]\n}\n\nconst clean = (text: string) => String(text ?? '').replace(/\\s+/g, ' ').trim()\n\n/** Whether a block is a line of its own: a link inside a sentence is in its sentence already. */\nfunction isLine(block: SiteImportBlock): boolean {\n if (block.kind === 'image') return !!block.url\n if (block.kind === 'link') return !block.inline && !!clean(block.text)\n return !!clean(block.text)\n}\n\n/**\n * The page's lines and sections (AGL-4084): the opening, then one section\n * at each second-level heading, at most `AI_SITE_IMPORT_MAX_SECTIONS` (the\n * last holds whatever follows). A page that opens on a second-level heading\n * opens with it. Section names are the headings' words, neutralized and cut\n * to a label, since they travel outside a fence.\n */\nexport function aiSiteImportDocLines(blocks: readonly SiteImportBlock[], title: string): AiSiteImportDocLines {\n const lines: AiSiteImportLine[] = []\n const sections: AiSiteImportDocSection[] = []\n let current: AiSiteImportDocSection | null = null\n for (const block of blocks) {\n if (!isLine(block)) continue\n const starts = block.kind === 'heading' && block.level === 2 && sections.length < AI_SITE_IMPORT_MAX_SECTIONS\n if (!current || (starts && current.lines.length > 0)) {\n current = { name: '', lines: [] }\n sections.push(current)\n }\n const n = lines.length + 1\n lines.push({ n, block, section: sections.length - 1 })\n current.lines.push(n)\n }\n const named = new Set<string>()\n sections.forEach((section, index) => {\n const heading = section.lines.map((n) => lines[n - 1].block).find((block) => block.kind === 'heading')\n let name = siteImportLabel(heading && heading.kind === 'heading' ? heading.text : index === 0 ? title : '') || (index === 0 ? siteImportLabel(title) : '')\n if (!name) name = `Section ${index + 1}`\n // Two sections of one name are told apart, so a link to either finds it.\n let unique = name\n for (let attempt = 2; named.has(unique.toLowerCase()); attempt += 1) {\n unique = `${name.slice(0, AI_SITE_IMPORT_LABEL_MAX_CHARS - 4)} (${attempt})`\n }\n named.add(unique.toLowerCase())\n section.name = unique\n })\n if (!sections.length) sections.push({ name: siteImportLabel(title) || 'Introduction', lines: [] })\n return { lines, sections }\n}\n\n/** The words a line shows: an image's are its description. */\nexport function aiSiteImportLineText(line: Pick<AiSiteImportLine, 'block'>): string {\n return line.block.kind === 'image' ? clean(line.block.alt) : clean(line.block.text)\n}\n\n/** How many words a line says: its runs of letters and digits, as the review counts them. */\nexport const aiSiteImportWordsIn = (text: string): number => (text.match(/[\\p{L}\\p{N}]+/gu) ?? []).length\n\n/** The input a page job carries, read defensively; `null` on every other job. */\nexport function aiSiteImportDocumentOf(inputs: Readonly<Record<string, unknown>> | null | undefined): AiSiteImportDocument | null {\n const raw = inputs?.[AI_LAYOUT_IMPORTED_SECTIONS_INPUT]\n if (!raw || typeof raw !== 'object') return null\n const value = raw as Record<string, unknown>\n const build = value['build'] === 'copied' || value['build'] === 'arranged' ? value['build'] : null\n if (!build || !Array.isArray(value['blocks'])) return null\n const blocks = (value['blocks'] as unknown[]).flatMap((entry): SiteImportBlock[] => {\n if (!entry || typeof entry !== 'object') return []\n const block = entry as Record<string, unknown>\n const text = typeof block['text'] === 'string' ? block['text'] : ''\n const region = 'main' as const\n switch (block['kind']) {\n case 'heading': {\n const level = Number(block['level'])\n return [{ kind: 'heading', level: (Number.isInteger(level) && level >= 1 && level <= 6 ? level : 2) as 1 | 2 | 3 | 4 | 5 | 6, text, region }]\n }\n case 'paragraph':\n case 'list-item':\n case 'quote':\n return [{ kind: block['kind'], text, region }]\n case 'image':\n return typeof block['url'] === 'string' ? [{ kind: 'image', url: block['url'], alt: typeof block['alt'] === 'string' ? block['alt'] : '', region }] : []\n case 'link':\n return typeof block['href'] === 'string'\n ? [{ kind: 'link', text, href: block['href'], region, ...(block['inline'] === true ? { inline: true as const } : {}) }]\n : []\n default:\n return []\n }\n })\n const strings = (list: unknown) => (Array.isArray(list) ? list.filter((entry): entry is string => typeof entry === 'string') : [])\n return {\n build,\n title: typeof value['title'] === 'string' ? value['title'] : '',\n url: typeof value['url'] === 'string' ? value['url'].slice(0, 2048) : '',\n blocks,\n photos: (Array.isArray(value['photos']) ? value['photos'] : []).flatMap((entry): AiSiteImportPhoto[] => {\n const photo = entry as Record<string, unknown> | null\n return photo && typeof photo['mediaId'] === 'string' && typeof photo['src'] === 'string'\n ? [\n {\n mediaId: photo['mediaId'],\n src: photo['src'],\n ...(typeof photo['alt'] === 'string' ? { alt: photo['alt'] } : {}),\n ...(typeof photo['from'] === 'string' ? { from: photo['from'] } : {}),\n },\n ]\n : []\n }),\n links: (Array.isArray(value['links']) ? value['links'] : []).flatMap((entry) => {\n const link = entry as Record<string, unknown> | null\n return link && typeof link['path'] === 'string' && typeof link['id'] === 'string' ? [{ path: link['path'], id: link['id'] }] : []\n }),\n origins: strings(value['origins']),\n ...(isLayout(value['layout']) ? { layout: value['layout'] } : {}),\n ...(Array.isArray(value['videos']) ? { videos: (value['videos'] as unknown[]).map(videoOf) } : {}),\n }\n}\n\n/**\n * A video as the read keeps it (AGL-4140), read defensively: every address\n * held to http(s), every fact to its kind. One that is no object keeps its\n * place in the list, so the layout's indexes still name the right one.\n */\nfunction videoOf(entry: unknown): SiteImportVideo {\n const video = entry && typeof entry === 'object' ? (entry as Record<string, unknown>) : {}\n const address = (value: unknown): string | undefined => (typeof value === 'string' && /^https?:\\/\\//i.test(value.trim()) ? value.trim().slice(0, 2048) : undefined)\n const words = (value: unknown, max: number): string | undefined => (typeof value === 'string' && value.trim() ? value.replace(/\\s+/g, ' ').trim().slice(0, max) : undefined)\n const src = address(video['src'])\n const embed = address(video['embed'])\n const poster = address(video['poster'])\n const description = words(video['description'], 2_000)\n const uploadDate = typeof video['uploadDate'] === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(video['uploadDate']) ? video['uploadDate'] : undefined\n const seconds = Number(video['durationSeconds'])\n const flag = (key: 'autoplay' | 'muted' | 'loop' | 'controls') => (video[key] === true ? { [key]: true as const } : {})\n return {\n ...(src ? { src } : {}),\n ...(embed ? { embed } : {}),\n ...(poster ? { poster } : {}),\n title: words(video['title'], 200) ?? '',\n ...(description ? { description } : {}),\n ...(uploadDate ? { uploadDate } : {}),\n ...(Number.isFinite(seconds) && seconds > 0 ? { durationSeconds: Math.round(seconds) } : {}),\n ...flag('autoplay'),\n ...flag('muted'),\n ...flag('loop'),\n ...flag('controls'),\n }\n}\n\n/** Whether a value is a layout as the reader writes one: its sections, icons and look. */\nfunction isLayout(value: unknown): value is SiteImportLayout {\n if (!value || typeof value !== 'object') return false\n const layout = value as Record<string, unknown>\n return (\n layout['v'] === 1 &&\n Array.isArray(layout['sections']) &&\n (layout['sections'] as unknown[]).every((section) => !!section && typeof section === 'object' && Array.isArray((section as Record<string, unknown>)['nodes'])) &&\n Array.isArray(layout['icons'])\n )\n}\n\n/*------------------------------------------\n * Words in parts a text element holds\n *-----------------------------------------*/\n\n/** A paragraph cut between sentences into parts a text element holds, every word kept in order. */\nexport function aiSiteImportTextParts(text: string, max = AI_SITE_IMPORT_TEXT_MAX_CHARS): string[] {\n const words = clean(text)\n if (words.length <= max) return words ? [words] : []\n const sentences = words.match(/[^.!?…]+(?:[.!?…]+[\"'”’)\\]]*\\s*|$)/g) ?? [words]\n const parts: string[] = []\n let part = ''\n const push = () => {\n if (part.trim()) parts.push(part.trim())\n part = ''\n }\n for (const sentence of sentences) {\n if ((part + sentence).trim().length <= max) {\n part += sentence\n continue\n }\n push()\n // One sentence longer than an element holds is cut between words.\n let rest = sentence.trim()\n while (rest.length > max) {\n const at = rest.lastIndexOf(' ', max)\n const cut = at > 0 ? at : max\n parts.push(rest.slice(0, cut).trim())\n rest = rest.slice(cut).trim()\n }\n part = rest ? `${rest} ` : ''\n }\n push()\n return parts\n}\n"],"names":["AI_SITE_IMPORT_LABEL_MAX_CHARS","AI_SITE_IMPORT_MAX_SECTIONS","siteImportLabel","AI_TEXT_LIMITS","AI_LAYOUT_IMPORTED_SECTIONS_INPUT","AI_SITE_IMPORT_TEXT_MAX_CHARS","body","AI_SITE_IMPORT_HEADLINE_MAX_CHARS","headline","AI_SITE_IMPORT_LABEL_CHARS","AI_SITE_IMPORT_DOC_MAX_NODES","AI_SITE_IMPORT_DOC_MAX_CHARS","clean","text","String","replace","trim","isLine","block","kind","url","inline","aiSiteImportDocLines","blocks","title","lines","sections","current","starts","level","length","name","push","n","section","named","Set","forEach","index","heading","map","find","unique","attempt","has","toLowerCase","slice","add","aiSiteImportLineText","line","alt","aiSiteImportWordsIn","match","aiSiteImportDocumentOf","inputs","raw","value","build","Array","isArray","flatMap","entry","region","Number","isInteger","href","strings","list","filter","photos","photo","mediaId","src","from","links","link","path","id","origins","isLayout","layout","videos","videoOf","words","video","address","test","undefined","max","embed","poster","description","uploadDate","seconds","flag","key","isFinite","durationSeconds","Math","round","every","aiSiteImportTextParts","sentences","parts","part","sentence","rest","at","lastIndexOf","cut"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;2CAkB2C,GAG3C,SACEA,8BAA8B,EAC9BC,2BAA2B,QAItB,6BAAyB;AAEhC,SAASC,eAAe,QAAQ,qCAAiC;AACjE,SAASC,cAAc,QAAQ,2BAAuB;AAEtD,2GAA2G,GAC3G,OAAO,MAAMC,oCAAoC,mBAAkB;AA4B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D,KAAK,OAAOL,QAAQ;QAACA;KAAM,GAAG,EAAE;IACpD,MAAMmB,aAAYnB,eAAAA,MAAM/B,KAAK,CAAC,kDAAZ+B,eAAsD;QAACA;KAAM;IAC/E,MAAMoB,QAAkB,EAAE;IAC1B,IAAIC,OAAO;IACX,MAAMxE,OAAO;QACX,IAAIwE,KAAKxF,IAAI,IAAIuF,MAAMvE,IAAI,CAACwE,KAAKxF,IAAI;QACrCwF,OAAO;IACT;IACA,KAAK,MAAMC,YAAYH,UAAW;QAChC,IAAI,AAACE,CAAAA,OAAOC,QAAO,EAAGzF,IAAI,GAAGc,MAAM,IAAI0D,KAAK;YAC1CgB,QAAQC;YACR;QACF;QACAzE;QACA,kEAAkE;QAClE,IAAI0E,OAAOD,SAASzF,IAAI;QACxB,MAAO0F,KAAK5E,MAAM,GAAG0D,IAAK;YACxB,MAAMmB,KAAKD,KAAKE,WAAW,CAAC,KAAKpB;YACjC,MAAMqB,MAAMF,KAAK,IAAIA,KAAKnB;YAC1Be,MAAMvE,IAAI,CAAC0E,KAAK5D,KAAK,CAAC,GAAG+D,KAAK7F,IAAI;YAClC0F,OAAOA,KAAK5D,KAAK,CAAC+D,KAAK7F,IAAI;QAC7B;QACAwF,OAAOE,OAAO,GAAGA,KAAK,CAAC,CAAC,GAAG;IAC7B;IACA1E;IACA,OAAOuE;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-document.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * A PAGE BROUGHT IN WORD FOR WORD (AGL-4084, AGL-4107).\n *\n * An imported page is never rewritten. Its words are the source's, as the\n * crawler read them (`AiSiteImportPageRead.blocks`), and how the source lays\n * them out is the reader's (`AiSiteImportPageRead.layout`, AGL-4106). This\n * module is the page as its job carries it: its blocks, its layout, its\n * photos and where its links go, read defensively off the job's inputs.\n *\n * - **Lines.** The page's main region, numbered: every heading, paragraph,\n * list item, quote, link and picture in source order. A link inside a\n * sentence is in its sentence already and is no line of its own.\n * - **Sections.** Where a read kept no layout (one made before the reader,\n * or one past its budget), one for the page's opening and one at each\n * second-level heading, as the source divides itself.\n *\n * The page is drawn by the site compiler (`ai-site-import-compile.ts`), with\n * every line on it exactly once and never a word that is not the source's.\n *=========================================*/\n\n\nimport {\n AI_SITE_IMPORT_LABEL_MAX_CHARS,\n AI_SITE_IMPORT_MAX_SECTIONS,\n type AiSiteImportBuild,\n type AiSiteImportPhoto,\n type SiteImportLayout,\n} from '../model/ai-site-import'\nimport type { SiteImportBlock, SiteImportVideo } from '../site-import/site-import-html'\nimport { siteImportLabel } from '../site-import/site-import-page'\nimport { AI_TEXT_LIMITS } from '../runtime/ai-palette'\n\n/** The unit input carrying a page brought in word for word: its lines, its photos and where its links go. */\nexport const AI_LAYOUT_IMPORTED_SECTIONS_INPUT = 'importedSections'\n\n/** A page brought in, as the import step hands it to the page step. Untrusted data from the owner's site. */\nexport interface AiSiteImportDocument {\n build: AiSiteImportBuild\n /** The page's name on the new site: its h1 where the source shows no heading. */\n title: string\n /** Where the page is on the owner's website. */\n url: string\n /** The page's main region, in order. */\n blocks: SiteImportBlock[]\n /** Its photos as the library holds them, each by the source address it was read from. */\n photos: AiSiteImportPhoto[]\n /** The site's own pages a link may go to: the source path each was read from, and the page it is now. */\n links: Array<{ path: string; id: string }>\n /** The origins the old site answers on: a link to one of them is to a page of its own. */\n origins: string[]\n /**\n * How the source lays the page out (AGL-4106), over `blocks` by index;\n * absent on a read made before the reader, or one past its budget.\n */\n layout?: SiteImportLayout | null\n /** Each form of the read, by its index, and the saved form that takes its place (AGL-4083); absent on a page that asked for none. */\n forms?: Array<{ index: number; formId: string | null }> | null\n /** The page's videos (AGL-4140), which its layout places by index; absent on a page that shows none. */\n videos?: SiteImportVideo[]\n}\n\n/** The most characters a text element holds (the palette's ceiling for body copy). */\nexport const AI_SITE_IMPORT_TEXT_MAX_CHARS = AI_TEXT_LIMITS.body\n\n/** The most characters a heading style holds; a longer heading is drawn in a subtitle style, still a heading. */\nexport const AI_SITE_IMPORT_HEADLINE_MAX_CHARS = AI_TEXT_LIMITS.headline\n\n/** The most characters a button's label holds; a longer link keeps its words as a line of text. */\nexport const AI_SITE_IMPORT_LABEL_CHARS = 40\n\n/**\n * What one page may weigh, inside the budget of a page of its owner's own\n * words (`AI_OWN_WORDS_PAGE_BUDGET`): a page that would run past it ends at\n * the section before, marked `cut`.\n */\nexport const AI_SITE_IMPORT_DOC_MAX_NODES = 1_400\nexport const AI_SITE_IMPORT_DOC_MAX_CHARS = 200_000\n\n/** One numbered line of a page. */\nexport interface AiSiteImportLine {\n /** 1-based, in source order. */\n n: number\n block: SiteImportBlock\n /** The section it belongs to, by plan index. */\n section: number\n}\n\nexport interface AiSiteImportDocSection {\n name: string\n /** Its lines' numbers, in order. */\n lines: number[]\n}\n\nexport interface AiSiteImportDocLines {\n lines: AiSiteImportLine[]\n sections: AiSiteImportDocSection[]\n}\n\nconst clean = (text: string) => String(text ?? '').replace(/\\s+/g, ' ').trim()\n\n/** Whether a block is a line of its own: a link inside a sentence is in its sentence already. */\nfunction isLine(block: SiteImportBlock): boolean {\n if (block.kind === 'image') return !!block.url\n if (block.kind === 'link') return !block.inline && !!clean(block.text)\n return !!clean(block.text)\n}\n\n/**\n * The page's lines and sections (AGL-4084): the opening, then one section\n * at each second-level heading, at most `AI_SITE_IMPORT_MAX_SECTIONS` (the\n * last holds whatever follows). A page that opens on a second-level heading\n * opens with it. Section names are the headings' words, neutralized and cut\n * to a label, since they travel outside a fence.\n */\nexport function aiSiteImportDocLines(blocks: readonly SiteImportBlock[], title: string): AiSiteImportDocLines {\n const lines: AiSiteImportLine[] = []\n const sections: AiSiteImportDocSection[] = []\n let current: AiSiteImportDocSection | null = null\n for (const block of blocks) {\n if (!isLine(block)) continue\n const starts = block.kind === 'heading' && block.level === 2 && sections.length < AI_SITE_IMPORT_MAX_SECTIONS\n if (!current || (starts && current.lines.length > 0)) {\n current = { name: '', lines: [] }\n sections.push(current)\n }\n const n = lines.length + 1\n lines.push({ n, block, section: sections.length - 1 })\n current.lines.push(n)\n }\n const named = new Set<string>()\n sections.forEach((section, index) => {\n const heading = section.lines.map((n) => lines[n - 1].block).find((block) => block.kind === 'heading')\n let name = siteImportLabel(heading && heading.kind === 'heading' ? heading.text : index === 0 ? title : '') || (index === 0 ? siteImportLabel(title) : '')\n if (!name) name = `Section ${index + 1}`\n // Two sections of one name are told apart, so a link to either finds it.\n let unique = name\n for (let attempt = 2; named.has(unique.toLowerCase()); attempt += 1) {\n unique = `${name.slice(0, AI_SITE_IMPORT_LABEL_MAX_CHARS - 4)} (${attempt})`\n }\n named.add(unique.toLowerCase())\n section.name = unique\n })\n if (!sections.length) sections.push({ name: siteImportLabel(title) || 'Introduction', lines: [] })\n return { lines, sections }\n}\n\n/** The words a line shows: an image's are its description. */\nexport function aiSiteImportLineText(line: Pick<AiSiteImportLine, 'block'>): string {\n return line.block.kind === 'image' ? clean(line.block.alt) : clean(line.block.text)\n}\n\n/** How many words a line says: its runs of letters and digits, as the review counts them. */\nexport const aiSiteImportWordsIn = (text: string): number => (text.match(/[\\p{L}\\p{N}]+/gu) ?? []).length\n\n/** The input a page job carries, read defensively; `null` on every other job. */\nexport function aiSiteImportDocumentOf(inputs: Readonly<Record<string, unknown>> | null | undefined): AiSiteImportDocument | null {\n const raw = inputs?.[AI_LAYOUT_IMPORTED_SECTIONS_INPUT]\n if (!raw || typeof raw !== 'object') return null\n const value = raw as Record<string, unknown>\n const build = value['build'] === 'copied' || value['build'] === 'arranged' ? value['build'] : null\n if (!build || !Array.isArray(value['blocks'])) return null\n const blocks = (value['blocks'] as unknown[]).flatMap((entry): SiteImportBlock[] => {\n if (!entry || typeof entry !== 'object') return []\n const block = entry as Record<string, unknown>\n const text = typeof block['text'] === 'string' ? block['text'] : ''\n const region = 'main' as const\n switch (block['kind']) {\n case 'heading': {\n const level = Number(block['level'])\n return [{ kind: 'heading', level: (Number.isInteger(level) && level >= 1 && level <= 6 ? level : 2) as 1 | 2 | 3 | 4 | 5 | 6, text, region }]\n }\n case 'paragraph':\n case 'list-item':\n case 'quote':\n return [{ kind: block['kind'], text, region }]\n case 'image':\n return typeof block['url'] === 'string' ? [{ kind: 'image', url: block['url'], alt: typeof block['alt'] === 'string' ? block['alt'] : '', region }] : []\n case 'link':\n return typeof block['href'] === 'string'\n ? [{ kind: 'link', text, href: block['href'], region, ...(block['inline'] === true ? { inline: true as const } : {}) }]\n : []\n default:\n return []\n }\n })\n const strings = (list: unknown) => (Array.isArray(list) ? list.filter((entry): entry is string => typeof entry === 'string') : [])\n const size = (value: unknown) => (typeof value === 'number' && Number.isFinite(value) && value > 0 ? Math.round(value) : 0)\n return {\n build,\n title: typeof value['title'] === 'string' ? value['title'] : '',\n url: typeof value['url'] === 'string' ? value['url'].slice(0, 2048) : '',\n blocks,\n photos: (Array.isArray(value['photos']) ? value['photos'] : []).flatMap((entry): AiSiteImportPhoto[] => {\n const photo = entry as Record<string, unknown> | null\n return photo && typeof photo['mediaId'] === 'string' && typeof photo['src'] === 'string'\n ? [\n {\n mediaId: photo['mediaId'],\n src: photo['src'],\n // Its size, which frames it at its own shape where the source's tag gives none (AGL-4138).\n ...(size(photo['width']) ? { width: size(photo['width']) } : {}),\n ...(size(photo['height']) ? { height: size(photo['height']) } : {}),\n ...(typeof photo['alt'] === 'string' ? { alt: photo['alt'] } : {}),\n ...(typeof photo['from'] === 'string' ? { from: photo['from'] } : {}),\n },\n ]\n : []\n }),\n links: (Array.isArray(value['links']) ? value['links'] : []).flatMap((entry) => {\n const link = entry as Record<string, unknown> | null\n return link && typeof link['path'] === 'string' && typeof link['id'] === 'string' ? [{ path: link['path'], id: link['id'] }] : []\n }),\n origins: strings(value['origins']),\n ...(isLayout(value['layout']) ? { layout: value['layout'] } : {}),\n ...(Array.isArray(value['videos']) ? { videos: (value['videos'] as unknown[]).map(videoOf) } : {}),\n }\n}\n\n/**\n * A video as the read keeps it (AGL-4140), read defensively: every address\n * held to http(s), every fact to its kind. One that is no object keeps its\n * place in the list, so the layout's indexes still name the right one.\n */\nfunction videoOf(entry: unknown): SiteImportVideo {\n const video = entry && typeof entry === 'object' ? (entry as Record<string, unknown>) : {}\n const address = (value: unknown): string | undefined => (typeof value === 'string' && /^https?:\\/\\//i.test(value.trim()) ? value.trim().slice(0, 2048) : undefined)\n const words = (value: unknown, max: number): string | undefined => (typeof value === 'string' && value.trim() ? value.replace(/\\s+/g, ' ').trim().slice(0, max) : undefined)\n const src = address(video['src'])\n const embed = address(video['embed'])\n const poster = address(video['poster'])\n const description = words(video['description'], 2_000)\n const uploadDate = typeof video['uploadDate'] === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(video['uploadDate']) ? video['uploadDate'] : undefined\n const seconds = Number(video['durationSeconds'])\n const flag = (key: 'autoplay' | 'muted' | 'loop' | 'controls') => (video[key] === true ? { [key]: true as const } : {})\n return {\n ...(src ? { src } : {}),\n ...(embed ? { embed } : {}),\n ...(poster ? { poster } : {}),\n title: words(video['title'], 200) ?? '',\n ...(description ? { description } : {}),\n ...(uploadDate ? { uploadDate } : {}),\n ...(Number.isFinite(seconds) && seconds > 0 ? { durationSeconds: Math.round(seconds) } : {}),\n ...flag('autoplay'),\n ...flag('muted'),\n ...flag('loop'),\n ...flag('controls'),\n }\n}\n\n/** Whether a value is a layout as the reader writes one: its sections, icons and look. */\nfunction isLayout(value: unknown): value is SiteImportLayout {\n if (!value || typeof value !== 'object') return false\n const layout = value as Record<string, unknown>\n return (\n layout['v'] === 1 &&\n Array.isArray(layout['sections']) &&\n (layout['sections'] as unknown[]).every((section) => !!section && typeof section === 'object' && Array.isArray((section as Record<string, unknown>)['nodes'])) &&\n Array.isArray(layout['icons'])\n )\n}\n\n/*------------------------------------------\n * Words in parts a text element holds\n *-----------------------------------------*/\n\n/** A paragraph cut between sentences into parts a text element holds, every word kept in order. */\nexport function aiSiteImportTextParts(text: string, max = AI_SITE_IMPORT_TEXT_MAX_CHARS): string[] {\n const words = clean(text)\n if (words.length <= max) return words ? [words] : []\n const sentences = words.match(/[^.!?…]+(?:[.!?…]+[\"'”’)\\]]*\\s*|$)/g) ?? [words]\n const parts: string[] = []\n let part = ''\n const push = () => {\n if (part.trim()) parts.push(part.trim())\n part = ''\n }\n for (const sentence of sentences) {\n if ((part + sentence).trim().length <= max) {\n part += sentence\n continue\n }\n push()\n // One sentence longer than an element holds is cut between words.\n let rest = sentence.trim()\n while (rest.length > max) {\n const at = rest.lastIndexOf(' ', max)\n const cut = at > 0 ? at : max\n parts.push(rest.slice(0, cut).trim())\n rest = rest.slice(cut).trim()\n }\n part = rest ? `${rest} ` : ''\n }\n push()\n return parts\n}\n"],"names":["AI_SITE_IMPORT_LABEL_MAX_CHARS","AI_SITE_IMPORT_MAX_SECTIONS","siteImportLabel","AI_TEXT_LIMITS","AI_LAYOUT_IMPORTED_SECTIONS_INPUT","AI_SITE_IMPORT_TEXT_MAX_CHARS","body","AI_SITE_IMPORT_HEADLINE_MAX_CHARS","headline","AI_SITE_IMPORT_LABEL_CHARS","AI_SITE_IMPORT_DOC_MAX_NODES","AI_SITE_IMPORT_DOC_MAX_CHARS","clean","text","String","replace","trim","isLine","block","kind","url","inline","aiSiteImportDocLines","blocks","title","lines","sections","current","starts","level","length","name","push","n","section","named","Set","forEach","index","heading","map","find","unique","attempt","has","toLowerCase","slice","add","aiSiteImportLineText","line","alt","aiSiteImportWordsIn","match","aiSiteImportDocumentOf","inputs","raw","value","build","Array","isArray","flatMap","entry","region","Number","isInteger","href","strings","list","filter","size","isFinite","Math","round","photos","photo","mediaId","src","width","height","from","links","link","path","id","origins","isLayout","layout","videos","videoOf","words","video","address","test","undefined","max","embed","poster","description","uploadDate","seconds","flag","key","durationSeconds","every","aiSiteImportTextParts","sentences","parts","part","sentence","rest","at","lastIndexOf","cut"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;2CAkB2C,GAG3C,SACEA,8BAA8B,EAC9BC,2BAA2B,QAItB,6BAAyB;AAEhC,SAASC,eAAe,QAAQ,qCAAiC;AACjE,SAASC,cAAc,QAAQ,2BAAuB;AAEtD,2GAA2G,GAC3G,OAAO,MAAMC,oCAAoC,mBAAkB;AA4BnE,oFAAoF,GACpF,OAAO,MAAMC,gCAAgCF,eAAeG,IAAI,CAAA;AAEhE,+GAA+G,GAC/G,OAAO,MAAMC,oCAAoCJ,eAAeK,QAAQ,CAAA;AAExE,iGAAiG,GACjG,OAAO,MAAMC,6BAA6B,GAAE;AAE5C;;;;CAIC,GACD,OAAO,MAAMC,+BAA+B,KAAK;AACjD,OAAO,MAAMC,+BAA+B,OAAO;AAsBnD,MAAMC,QAAQ,CAACC,OAAiBC,OAAOD,eAAAA,OAAQ,IAAIE,OAAO,CAAC,QAAQ,KAAKC,IAAI;AAE5E,+FAA+F,GAC/F,SAASC,OAAOC,KAAsB;IACpC,IAAIA,MAAMC,IAAI,KAAK,SAAS,OAAO,CAAC,CAACD,MAAME,GAAG;IAC9C,IAAIF,MAAMC,IAAI,KAAK,QAAQ,OAAO,CAACD,MAAMG,MAAM,IAAI,CAAC,CAACT,MAAMM,MAAML,IAAI;IACrE,OAAO,CAAC,CAACD,MAAMM,MAAML,IAAI;AAC3B;AAEA;;;;;;CAMC,GACD,OAAO,SAASS,qBAAqBC,MAAkC,EAAEC,KAAa;IACpF,MAAMC,QAA4B,EAAE;IACpC,MAAMC,WAAqC,EAAE;IAC7C,IAAIC,UAAyC;IAC7C,KAAK,MAAMT,SAASK,OAAQ;QAC1B,IAAI,CAACN,OAA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AI;QACxB,MAAO6F,KAAK/E,MAAM,GAAGgE,IAAK;YACxB,MAAMgB,KAAKD,KAAKE,WAAW,CAAC,KAAKjB;YACjC,MAAMkB,MAAMF,KAAK,IAAIA,KAAKhB;YAC1BY,MAAM1E,IAAI,CAAC6E,KAAK/D,KAAK,CAAC,GAAGkE,KAAKhG,IAAI;YAClC6F,OAAOA,KAAK/D,KAAK,CAACkE,KAAKhG,IAAI;QAC7B;QACA2F,OAAOE,OAAO,GAAGA,KAAK,CAAC,CAAC,GAAG;IAC7B;IACA7E;IACA,OAAO0E;AACT"}
|
|
@@ -1683,6 +1683,10 @@ function instances(scope, placed, items, perRow) {
|
|
|
1683
1683
|
borderRadius: fit.rounded ? 3 : 2
|
|
1684
1684
|
}, fit.shadow ? {
|
|
1685
1685
|
boxShadow: 3
|
|
1686
|
+
} : {}, fit.measure ? {
|
|
1687
|
+
width: '100%',
|
|
1688
|
+
maxWidth: fit.measure,
|
|
1689
|
+
mx: 'auto'
|
|
1686
1690
|
} : {});
|
|
1687
1691
|
}
|
|
1688
1692
|
/**
|
|
@@ -2115,6 +2119,7 @@ function instances(scope, placed, items, perRow) {
|
|
|
2115
2119
|
* A masthead (AGL-3985): the words centered in a narrow column, as a journal
|
|
2116
2120
|
* or a quiet practice opens, and a wide photo under them.
|
|
2117
2121
|
*/ function columnHero(scope, flow, picture, home) {
|
|
2122
|
+
var _picture_after;
|
|
2118
2123
|
const tree = scope.page.tree;
|
|
2119
2124
|
const band = scope.band;
|
|
2120
2125
|
scope.centered = true;
|
|
@@ -2138,12 +2143,25 @@ function instances(scope, placed, items, perRow) {
|
|
|
2138
2143
|
},
|
|
2139
2144
|
borderRadius: 2
|
|
2140
2145
|
}));
|
|
2146
|
+
// What the source sets under its picture stays under it, centered as the words above are.
|
|
2147
|
+
const under = ((_picture_after = picture.after) == null ? void 0 : _picture_after.length) ? [
|
|
2148
|
+
tree.add('muiBox', null, {
|
|
2149
|
+
maxWidth: {
|
|
2150
|
+
xs: '100%',
|
|
2151
|
+
md: '72%'
|
|
2152
|
+
},
|
|
2153
|
+
mx: 'auto'
|
|
2154
|
+
}, [
|
|
2155
|
+
compileFlow(scope, picture.after, 'full')
|
|
2156
|
+
], 'measure')
|
|
2157
|
+
] : [];
|
|
2141
2158
|
const stack = tree.add('muiStack', {
|
|
2142
2159
|
spacing: '8',
|
|
2143
2160
|
useFlexGap: true
|
|
2144
2161
|
}, null, [
|
|
2145
2162
|
measure,
|
|
2146
|
-
photo
|
|
2163
|
+
photo,
|
|
2164
|
+
...under
|
|
2147
2165
|
], 'content');
|
|
2148
2166
|
const container = tree.add('muiContainer', {
|
|
2149
2167
|
maxWidth: 'lg'
|
|
@@ -4458,18 +4476,8 @@ function listingSection(scope, blocks, placed) {
|
|
|
4458
4476
|
// Its one picture, or its one film, poster first (AGL-4140).
|
|
4459
4477
|
const pictures = blocks.filter((block)=>block.kind === 'image' && block.picture || block.kind === 'video' && block.video);
|
|
4460
4478
|
if (pictures.length !== 1) return null;
|
|
4461
|
-
const
|
|
4462
|
-
if (!
|
|
4463
|
-
if (!flow.some((block)=>speaksHeading(scope, block))) {
|
|
4464
|
-
flow.unshift({
|
|
4465
|
-
kind: 'heading',
|
|
4466
|
-
text: page.plan.title
|
|
4467
|
-
});
|
|
4468
|
-
page.settled.push({
|
|
4469
|
-
at: scope.at,
|
|
4470
|
-
what: "no heading; the page's title written as its h1"
|
|
4471
|
-
});
|
|
4472
|
-
}
|
|
4479
|
+
const words = blocks.filter((block)=>block.kind !== 'image' && block.kind !== 'video');
|
|
4480
|
+
if (!words.length || !words.every((block)=>WORD_KINDS.has(block.kind))) return null;
|
|
4473
4481
|
const film = pictures[0].kind === 'video' ? pictures[0].video : undefined;
|
|
4474
4482
|
// A film a visitor presses plays where it sits, never behind the words, which would cover it.
|
|
4475
4483
|
let asked = raw.hero;
|
|
@@ -4480,6 +4488,21 @@ function listingSection(scope, blocks, placed) {
|
|
|
4480
4488
|
});
|
|
4481
4489
|
asked = 'column';
|
|
4482
4490
|
}
|
|
4491
|
+
// The words the source sets under its picture, as a film's "Watch the film →" (AGL-4140): a
|
|
4492
|
+
// column hero draws them there, any other with its words, and the heading is never one of them.
|
|
4493
|
+
const after = asked === 'column' ? blocks.slice(blocks.indexOf(pictures[0]) + 1).filter((block)=>block.kind !== 'image' && block.kind !== 'video') : [];
|
|
4494
|
+
const under = after.length < words.length && !after.some((block)=>speaksHeading(scope, block)) ? after : [];
|
|
4495
|
+
const flow = words.slice(0, words.length - under.length);
|
|
4496
|
+
if (!flow.some((block)=>speaksHeading(scope, block))) {
|
|
4497
|
+
flow.unshift({
|
|
4498
|
+
kind: 'heading',
|
|
4499
|
+
text: page.plan.title
|
|
4500
|
+
});
|
|
4501
|
+
page.settled.push({
|
|
4502
|
+
at: scope.at,
|
|
4503
|
+
what: "no heading; the page's title written as its h1"
|
|
4504
|
+
});
|
|
4505
|
+
}
|
|
4483
4506
|
const lead = flow.findIndex((block)=>speaksHeading(scope, block));
|
|
4484
4507
|
const _flow_lead = flow[lead], { style: _style } = _flow_lead, title = _object_without_properties_loose(_flow_lead, [
|
|
4485
4508
|
"style"
|
|
@@ -4497,6 +4520,8 @@ function listingSection(scope, blocks, placed) {
|
|
|
4497
4520
|
fit: picture.fit
|
|
4498
4521
|
} : {}, film ? {
|
|
4499
4522
|
video: film
|
|
4523
|
+
} : {}, under.length ? {
|
|
4524
|
+
after: under
|
|
4500
4525
|
} : {}), asked);
|
|
4501
4526
|
return opening && raw.width ? widened(page.tree, opening, raw.width) : opening;
|
|
4502
4527
|
}
|