@aglyn/plugins-ai 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/components/ai-job-requests.d.ts +5 -0
- package/src/lib/components/ai-job-requests.js +4 -0
- package/src/lib/components/ai-job-requests.js.map +1 -1
- package/src/lib/components/ai-site-build-page.component.js +10 -3
- package/src/lib/components/ai-site-build-page.component.js.map +1 -1
- package/src/lib/components/ai-site-import-finish.component.d.ts +40 -0
- package/src/lib/components/ai-site-import-finish.component.js +174 -0
- package/src/lib/components/ai-site-import-finish.component.js.map +1 -0
- package/src/lib/components/ai-site-import-job.component.d.ts +11 -3
- package/src/lib/components/ai-site-import-job.component.js +220 -135
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/components/ai-site-import-start.component.d.ts +11 -2
- package/src/lib/components/ai-site-import-start.component.js +27 -5
- package/src/lib/components/ai-site-import-start.component.js.map +1 -1
- package/src/lib/components/ai-site-start-card.component.js +1 -1
- package/src/lib/components/ai-site-start-card.component.js.map +1 -1
- package/src/lib/jobs/ai-build-capabilities.js +2 -2
- package/src/lib/jobs/ai-build-capabilities.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +2 -0
- package/src/lib/jobs/ai-job-import-step.js +31 -8
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.d.ts +40 -2
- package/src/lib/jobs/ai-job-page-language.js +188 -9
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.js +2 -0
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-privacy-step.d.ts +5 -0
- package/src/lib/jobs/ai-job-privacy-step.js +9 -4
- package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
- package/src/lib/jobs/ai-job-text-step.d.ts +7 -1
- package/src/lib/jobs/ai-job-text-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.d.ts +13 -2
- package/src/lib/jobs/ai-site-import-compile.js +115 -21
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +5 -1
- package/src/lib/jobs/ai-site-import-document.js +5 -1
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +16 -4
- package/src/lib/jobs/ai-site-import-look.js +54 -13
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/jobs/ai-site-import-wording.d.ts +187 -0
- package/src/lib/jobs/ai-site-import-wording.js +747 -0
- package/src/lib/jobs/ai-site-import-wording.js.map +1 -0
- package/src/lib/layout-language/ai-layout-compiler.d.ts +12 -1
- package/src/lib/layout-language/ai-layout-compiler.js +29 -30
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +211 -2
- package/src/lib/model/ai-site-import-fidelity.js +1011 -14
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-report.d.ts +52 -1
- package/src/lib/model/ai-site-import-report.js +102 -5
- package/src/lib/model/ai-site-import-report.js.map +1 -1
- package/src/lib/model/ai-site-import-view.d.ts +62 -2
- package/src/lib/model/ai-site-import-view.js +83 -4
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +122 -6
- package/src/lib/model/ai-site-import.js +202 -9
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +51 -0
- package/src/lib/model/ai-site-look.js +205 -29
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +19 -0
- package/src/lib/runtime/ai-doctrine-validators.js +25 -0
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-doctrine.js +4 -1
- package/src/lib/runtime/ai-doctrine.js.map +1 -1
- package/src/lib/server/ai-allotments.js +4 -2
- package/src/lib/server/ai-allotments.js.map +1 -1
- package/src/lib/server/ai-jobs-resume.js +32 -5
- package/src/lib/server/ai-jobs-resume.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +36 -10
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +48 -4
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-look-slate.d.ts +27 -0
- package/src/lib/site-import/fixtures/site-look-slate.js +29 -0
- package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -0
- package/src/lib/site-import/site-import-layout.d.ts +19 -5
- package/src/lib/site-import/site-import-layout.js +137 -16
- package/src/lib/site-import/site-import-layout.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-wording.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, ITS WORDING IMPROVED (AGL-4152).\n *\n * Under Improve it with Also improve my wording on, a main page Aglyn AI\n * arranges is asked one more answer after its design: `submit_wording`, the\n * lines it rewords, each by its index in the page's blocks with its new\n * words. Nothing else rides the tool — no link, no picture, no structure —\n * so the page's sections, groups, buttons and destinations are the source's\n * whatever it says.\n *\n * - **What may be reworded** (`aiSiteImportWordingPage`): headings,\n * paragraphs, list items and a link the source draws as a button, the\n * words of FAQ, card, step and list items among them. Everything else is\n * kept as written: quotes and testimonials, pricing, stats and logos,\n * card titles, figures, badges, tables, tabs, eyebrows and fine print, a\n * paragraph with a link inside it, a postal address, an email or phone\n * link, and every line with no words.\n * - **What every rewrite holds** (`aiSiteImportWordingHolds`, pure): its\n * facts — prices, numbers, dates, times, percentages, emails, web\n * addresses, phones and names, the site's own name among them — exactly as\n * often as its line says them and none of its own; no contact the page\n * does not give; no gap; its line's script; 0.5 to 1.6 times its words,\n * within the characters its place holds; most of its meaning\n * (`SITE_IMPORT_MEANING_FLOOR`); and no filler, placeholder or judgment\n * word. A line refused is asked again once; refused again, it is kept as\n * written.\n * - **The page** (`aiSiteImportRewordedDocument`): the source's document\n * with the rewritten lines' words swapped in, every block at its index and\n * the source's own layout pinned, which the page step compiles and checks\n * whole as any page brought in, rule 14's copy checks on for the reworded\n * lines (`AiDoctrineTreeContext.rewritten`).\n *\n * Never asked of a page copied as it is, of a policy page, of the header and\n * footer, of the page's listing or of its title in the Pages list.\n *=========================================*/\n\nimport { fenceUntrustedText, UNTRUSTED_TEXT_RULE } from '@aglyn/shared-util-tools/untrusted-text'\nimport { aiLayoutGuardContacts } from '../layout-language/ai-layout-copy'\nimport type { SiteImportLayoutNode, SiteImportLineRef } from '../model/ai-site-import'\nimport {\n SITE_IMPORT_MEANING_FLOOR,\n siteImportContentKept,\n siteImportFactScope,\n siteImportFactTokens,\n type SiteImportFactScope,\n} from '../model/ai-site-import-fidelity'\nimport type { AiSystemBlock, AiTool } from '../providers/contract'\nimport type { AiGenerationCheck } from '../runtime/ai-doctrine'\nimport { detectOffVoiceCopy, type AiCopyFraming, type AiDoctrineViolation } from '../runtime/ai-doctrine-validators'\nimport { AI_GENERATION_MAX_ATTEMPTS } from '../runtime/ai-generation-bounds'\nimport { aiPlaceholderTokens } from '../runtime/ai-placeholder-tokens'\nimport { AI_TEXT_LIMITS } from '../runtime/ai-palette'\nimport type { SiteImportBlock } from '../site-import/site-import-html'\nimport { aiSiteImportLayoutOf } from './ai-site-import-compile'\nimport {\n AI_SITE_IMPORT_HEADLINE_MAX_CHARS,\n AI_SITE_IMPORT_LABEL_CHARS,\n AI_SITE_IMPORT_TEXT_MAX_CHARS,\n aiSiteImportWordsIn,\n type AiSiteImportDocument,\n} from './ai-site-import-document'\n\n/*------------------------------------------\n * The tool and its cached instructions\n *-----------------------------------------*/\n\n/** The wording answer's kind of generation: the name its re-ask and its doctrine scope go by. */\nexport const AI_SITE_IMPORT_WORDING_KIND = 'page-wording'\n\n/** The wording tool: the lines reworded, each by its number, with its new words, and nothing else. */\nexport const AI_SITE_IMPORT_WORDING_TOOL: AiTool = {\n name: 'submit_wording',\n description: \"Submit the page's reworded lines: one entry for each line reworded, by its number, with its new words. A line left out keeps its words.\",\n strict: true,\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n required: ['lines'],\n properties: {\n lines: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['line', 'text'],\n properties: { line: { type: 'integer' }, text: { type: 'string' } },\n },\n },\n },\n },\n}\n\n/** The most a rewrite may run to, against its line's words. */\nexport const AI_SITE_IMPORT_WORDING_LENGTH = { least: 0.5, most: 1.6 } as const\n\n/**\n * What a wording answer is told, cached: one static block every page shares,\n * and the rule that fenced text is data. The page itself rides the user turn.\n */\nexport const AI_SITE_IMPORT_WORDING_TEXT = [\n \"You rewrite the wording of a page brought in from its owner's own website so it reads as a strong professional copywriter would write it, in the owner's voice: each heading a clear, specific promise of what the visitor gets, each paragraph leading with the benefit, in active words, with nothing that does not earn its place. Rebuild a sentence freely where that makes it clearer or stronger. The page's design, its sections and what each section shows are fixed, and so is every fact on it.\",\n '',\n 'Answer with submit_wording: one entry in lines for each line you reword, by its number, with its new words. A line you leave out is kept exactly as written. Rewrite every heading, lede, paragraph and button that could be clearer or stronger, and leave out only a line that is already as strong as it can be. Reword only a line shown as a heading, a paragraph, a list item or a button; a line shown \"as written\" is the owner\\'s exactly and is never answered.',\n '',\n 'Each rewrite:',\n \"- says what its line means, in the line's own language and script, and makes no claim, promise, offer or detail the page does not make;\",\n '- keeps every name, price, number, date, time, percentage, address, phone number, email and web address exactly as the line writes it, as often as the line has it, and adds none;',\n `- runs between ${AI_SITE_IMPORT_WORDING_LENGTH.least} and ${AI_SITE_IMPORT_WORDING_LENGTH.most} times its line's words, and never past the characters shown;`,\n '- stays what its line is: a heading for a heading, a sentence or more for a paragraph, a short label for a button;',\n '- writes no placeholder, no gap in brackets, no filler and no word that calls the work simple or cheap.',\n].join('\\n')\n\n/** The wording answer's cached instructions, and the rule that fenced text is data. */\nexport const AI_SITE_IMPORT_WORDING_INSTRUCTIONS: readonly AiSystemBlock[] = [\n { text: AI_SITE_IMPORT_WORDING_TEXT, cacheBreakpoint: true },\n { text: UNTRUSTED_TEXT_RULE },\n]\n\n/*------------------------------------------\n * The page's lines: those it may reword, and those kept as written\n *-----------------------------------------*/\n\n/** What a line is, as the prompt names it and its place holds it. */\nexport type AiSiteImportWordingKind = 'heading' | 'paragraph' | 'list item' | 'button'\n\n/** A line a rewrite may reword. */\nexport interface AiSiteImportWordingLine {\n /** Its index in the page's blocks: the number the tool answers by. */\n line: SiteImportLineRef\n kind: AiSiteImportWordingKind\n /** Its words as written. */\n text: string\n /** The most characters a rewrite of it holds. */\n limit: number\n /** Its section, by index. */\n section: number\n}\n\n/** One entry of the page as the prompt shows it: a line to reword, one kept as written, or a part with no lines of the tool. */\nexport interface AiSiteImportWordingEntry {\n section: number\n /** The line's number, absent for a part shown whole (a table). */\n line?: SiteImportLineRef\n /** What it is: \"heading\", \"quote\", \"a table of 4 rows\". */\n what: string\n text: string\n /** Set where a rewrite may reword it. */\n reword?: AiSiteImportWordingLine\n}\n\n/** A page as the wording answer is shown it. */\nexport interface AiSiteImportWordingPage {\n /** The page's sections' names, in order. */\n sections: string[]\n /** Every entry, in order, as far as the prompt's room goes. */\n entries: AiSiteImportWordingEntry[]\n /** The lines a rewrite may reword: those shown. */\n lines: AiSiteImportWordingLine[]\n /** Whether the page runs past what the prompt shows: the rest keeps its words. */\n cut: boolean\n}\n\n/** The most characters of a page the wording prompt shows, inside the fence's cap with room for its section heads. */\nexport const AI_SITE_IMPORT_WORDING_MAX_CHARS = 12_000\nconst SHOWN_MAX_CHARS = AI_SITE_IMPORT_WORDING_MAX_CHARS - 1_000\n\n/** The most characters of a line kept as written the prompt shows: it is there to be read around, never answered. */\nconst KEPT_SHOWN_CHARS = 160\n\n/** Groups whose every line is the owner's exactly: quotes, prices, figures, names. */\nconst FIXED_GROUPS = new Set(['quotes', 'pricing', 'stats', 'logos'])\n\n/** Groups whose items' titles are names: a card's title is a product's or a service's. */\nconst NAMED_GROUPS = new Set(['cards', 'pricing'])\n\n/** A postal address as a page writes one: a house number, a few words and a street word; a PO box; a region and postal code. */\nconst POSTAL = [\n /\\b\\d{1,6}\\s+(?:[\\p{L}\\d'.-]+\\s+){0,4}(?:street|st|avenue|ave|road|rd|boulevard|blvd|lane|ln|drive|dr|way|court|ct|place|pl|parkway|pkwy|highway|hwy|trail|trl|circle|cir|square|sq|suite|ste)\\b/iu,\n /\\bp\\.?\\s?o\\.?\\s+box\\s+\\d/iu,\n /\\b[A-Z]{2}\\s+\\d{5}(?:-\\d{4})?\\b/u,\n] as const\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\n/** Whether a block is a line of the page: a link inside a sentence is in its sentence. */\nfunction isLine(block: SiteImportBlock | undefined): boolean {\n if (!block) return false\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/** The most characters a rewrite of a line holds: its place's, or the line's own where it already runs past it. */\nfunction limitOf(kind: AiSiteImportWordingKind, text: string, title: boolean): number {\n const place =\n kind === 'heading'\n ? AI_SITE_IMPORT_HEADLINE_MAX_CHARS\n : kind === 'button'\n ? AI_SITE_IMPORT_LABEL_CHARS\n : title\n ? AI_TEXT_LIMITS.label\n : AI_SITE_IMPORT_TEXT_MAX_CHARS\n return text.length > place ? text.length : place\n}\n\n/** Tokens a line's words come to, as the ceiling plans them: four characters a token, and the entry around it. */\nconst tokensOf = (line: AiSiteImportWordingLine) => Math.ceil(line.text.length / 4) + 12\n\n/** Room for the thinking a wording answer does before it writes, inside its ceiling. */\nexport const AI_SITE_IMPORT_WORDING_THINKING_TOKENS = 1_000\n\n/** How much of a page the wording answer is shown. */\nexport interface AiSiteImportWordingRoom {\n /** The most characters of the page the prompt shows. */\n maxChars?: number\n /** The ceiling the answer is asked at: the lines offered are those a rewrite of every one fits in (`aiSiteImportWordingTokens`). */\n maxTokens?: number\n}\n\n/**\n * The page as the wording answer is shown it (G1, G2): its sections and,\n * in each, its lines in order, each marked as a line a rewrite may reword\n * or one kept as written. A line is reworded only where every place the\n * layout puts it allows it. The lines shown stop where the prompt's room,\n * or the answer's ceiling, does; those past it keep their words.\n */\nexport function aiSiteImportWordingPage(doc: Pick<AiSiteImportDocument, 'blocks' | 'title' | 'layout'>, room: AiSiteImportWordingRoom = {}): AiSiteImportWordingPage {\n const maxChars = room.maxChars ?? SHOWN_MAX_CHARS\n const maxTokens = room.maxTokens ?? Number.POSITIVE_INFINITY\n const layout = aiSiteImportLayoutOf(doc)\n const fixed = new Set<SiteImportLineRef>()\n const order: Array<{ section: number; ref?: SiteImportLineRef; what?: string; reword?: { kind: AiSiteImportWordingKind; title: boolean } }> = []\n const seen = new Set<SiteImportLineRef>()\n\n const kept = (section: number, ref: SiteImportLineRef | undefined) => {\n if (ref === undefined || !isLine(doc.blocks[ref]) || doc.blocks[ref]?.kind === 'image') return\n fixed.add(ref)\n if (!seen.has(ref)) {\n seen.add(ref)\n order.push({ section, ref })\n }\n }\n // A line placed where a rewrite may reach it, unless what it says keeps it as written.\n const offer = (section: number, ref: SiteImportLineRef | undefined, place: { button?: boolean; role?: string; title?: boolean } = {}) => {\n if (ref === undefined) return\n const block = doc.blocks[ref]\n if (!block || !isLine(block) || block.kind === 'image') return\n const kind = rewordable(ref, block, place)\n if (!kind) return kept(section, ref)\n if (!seen.has(ref)) {\n seen.add(ref)\n order.push({ section, ref, reword: { kind, title: !!place.title } })\n }\n }\n const rewordable = (ref: SiteImportLineRef, block: SiteImportBlock, place: { button?: boolean; role?: string }): AiSiteImportWordingKind | null => {\n if (block.kind === 'image' || block.kind === 'quote') return null\n const text = clean(block.text)\n if (!aiSiteImportWordsIn(text) || !/\\p{L}/u.test(text)) return null\n if (POSTAL.some((pattern) => pattern.test(text))) return null\n // A label the source sets apart, or its fine print, is the owner's as written.\n if (place.role === 'eyebrow' || place.role === 'note') return null\n if (block.kind === 'link') {\n if (!place.button || /^(?:mailto|tel|sms):/i.test(block.href)) return null\n return 'button'\n }\n // A sentence with a link inside it keeps its words, so the link's words are still in it.\n const next = doc.blocks[ref + 1]\n if (next?.kind === 'link' && next.inline) return null\n if (block.kind === 'heading') return 'heading'\n if (block.kind === 'list-item') return 'list item'\n return 'paragraph'\n }\n\n const walk = (nodes: readonly SiteImportLayoutNode[], section: number, whole: boolean): void => {\n for (const node of nodes) {\n switch (node.kind) {\n case 'line':\n if (whole) kept(section, node.line)\n else offer(section, node.line, { button: !!node.button, ...(node.role ? { role: node.role } : {}) })\n break\n case 'row':\n for (const cell of node.cells) walk(cell.nodes, section, whole)\n break\n case 'group': {\n const all = whole || FIXED_GROUPS.has(node.group)\n for (const item of node.items) {\n const ctas = new Set((item.ctas ?? []).map((cta) => cta.line))\n const named = new Set<SiteImportLineRef>()\n const place = (ref: SiteImportLineRef | undefined, how: { button?: boolean; title?: boolean } = {}) => {\n if (ref === undefined) return\n named.add(ref)\n if (all) kept(section, ref)\n else offer(section, ref, how)\n }\n // A card's title names its product or service; a figure, a badge and a period are facts.\n if (NAMED_GROUPS.has(node.group)) {\n if (item.title !== undefined) named.add(item.title)\n kept(section, item.title)\n } else place(item.title, { title: true })\n for (const ref of [item.figure, item.badge, item.period]) {\n if (ref === undefined) continue\n named.add(ref)\n kept(section, ref)\n }\n for (const ref of item.text ?? []) place(ref)\n for (const ref of item.list ?? []) place(ref)\n for (const ref of item.link ?? []) {\n if (ctas.has(ref)) place(ref, { button: true })\n else {\n named.add(ref)\n kept(section, ref)\n }\n }\n for (const ref of item.lines) if (!named.has(ref) && ref !== item.image) kept(section, ref)\n }\n break\n }\n case 'table': {\n for (const row of node.rows) {\n for (const cell of row.cells) {\n for (const ref of cell.lines) {\n fixed.add(ref)\n seen.add(ref)\n }\n }\n }\n order.push({ section, what: `a table of ${node.rows.length} ${node.rows.length === 1 ? 'row' : 'rows'}` })\n break\n }\n case 'tabs':\n for (const tab of node.tabs) {\n kept(section, tab.label ?? undefined)\n walk(tab.panel, section, true)\n }\n break\n default:\n break\n }\n }\n }\n layout.sections.forEach((section, index) => {\n walk(section.nodes, index, false)\n // A line of the section no part of its layout places keeps its words.\n for (const ref of section.lines) if (!seen.has(ref)) kept(index, ref)\n })\n\n const all: AiSiteImportWordingEntry[] = order.map((entry) => {\n if (entry.ref === undefined) return { section: entry.section, what: `${entry.what ?? 'a part'}, as written`, text: '' }\n const block = doc.blocks[entry.ref] as SiteImportBlock\n const text = block.kind === 'image' ? '' : clean(block.text)\n const reword = entry.reword && !fixed.has(entry.ref) ? entry.reword : null\n if (!reword) {\n return { section: entry.section, line: entry.ref, what: block.kind === 'quote' ? 'quote, as written' : 'as written', text: text.length > KEPT_SHOWN_CHARS ? `${text.slice(0, KEPT_SHOWN_CHARS).trimEnd()} …` : text }\n }\n const line: AiSiteImportWordingLine = { line: entry.ref, kind: reword.kind, text, limit: limitOf(reword.kind, text, reword.title), section: entry.section }\n // A paragraph's own ceiling is far past what 1.6 times its words reach: only a tighter place's is shown.\n const bound = line.limit < AI_SITE_IMPORT_TEXT_MAX_CHARS\n return { section: entry.section, line: entry.ref, what: bound ? `${line.kind}, up to ${line.limit} characters` : line.kind, text, reword: line }\n })\n const entries: AiSiteImportWordingEntry[] = []\n const lines: AiSiteImportWordingLine[] = []\n let chars = 0\n let tokens = 0\n let cut = false\n for (const entry of shortened(all)) {\n chars += entry.what.length + entry.text.length + 12\n if (entry.reword) tokens += tokensOf(entry.reword)\n if (chars > maxChars || 2 * tokens + AI_SITE_IMPORT_WORDING_THINKING_TOKENS > maxTokens) {\n cut = true\n break\n }\n entries.push(entry)\n if (entry.reword) lines.push(entry.reword)\n }\n return { sections: layout.sections.map((section) => section.name), entries, lines, cut }\n}\n\n/** The most lines kept as written the prompt shows in a row: a run longer than this shows its first two, and how many follow. */\nconst KEPT_RUN = 3\n\n/**\n * The page's entries with each long run of lines kept as written told in a\n * few: a plan's prices or a table's cells are there to be read around, and\n * a run of them would crowd out the lines that are the answer's to reword.\n */\nfunction shortened(entries: readonly AiSiteImportWordingEntry[]): AiSiteImportWordingEntry[] {\n const out: AiSiteImportWordingEntry[] = []\n for (let at = 0; at < entries.length; ) {\n const first = entries[at] as AiSiteImportWordingEntry\n if (first.reword) {\n out.push(first)\n at += 1\n continue\n }\n let end = at\n while (end < entries.length && !entries[end]?.reword && entries[end]?.section === first.section) end += 1\n const run = entries.slice(at, end)\n if (run.length > KEPT_RUN) {\n out.push(...run.slice(0, 2), { section: first.section, what: `${run.length - 2} more lines, as written`, text: '' })\n } else out.push(...run)\n at = end\n }\n return out\n}\n\n/*------------------------------------------\n * The prompt\n *-----------------------------------------*/\n\n/** The page's lines as the fence holds them: each section's name, then its lines, numbered. */\nexport function aiSiteImportWordingText(page: AiSiteImportWordingPage): string {\n const out: string[] = []\n let section = -1\n for (const entry of page.entries) {\n if (entry.section !== section) {\n section = entry.section\n out.push(`Section ${section + 1} \"${page.sections[section] ?? ''}\":`)\n }\n out.push(entry.line === undefined ? `- ${entry.what}` : `[${entry.line}] ${entry.what}: ${entry.text}`)\n }\n if (page.cut) out.push('(The page goes on past here; the rest keeps its words.)')\n return out.join('\\n')\n}\n\n/** A wording answer's user turn: the page, the site's own name, and its lines, fenced as the owner's data. */\nexport function aiSiteImportWordingPrompt(input: {\n screen: { title: string; slug: string }\n doc: Pick<AiSiteImportDocument, 'url'>\n page: AiSiteImportWordingPage\n siteName?: string | null\n}): string {\n const name = clean(input.siteName)\n const count = input.page.lines.length\n return [\n `Page: \"${input.screen.title}\" at ${input.screen.slug}`,\n ...(name ? [\"The site's own name, which every rewrite writes exactly as it is wherever its line says it:\", fenceUntrustedText(\"The site's name\", name, { maxChars: 200 })] : []),\n `Its lines, in order, ${count === 1 ? 'one of them' : `${count} of them`} yours to reword, each with its number and what it is, and the most characters a rewrite may hold where its place holds fewer than a paragraph:`,\n fenceUntrustedText(`The words of the owner's page ${input.doc.url}`, aiSiteImportWordingText(input.page), { maxChars: AI_SITE_IMPORT_WORDING_MAX_CHARS }),\n ].join('\\n')\n}\n\n/**\n * The ceiling a page's wording answer wants (G1): twice its lines' own\n * tokens, so a rewrite of every line fits with room, and its thinking.\n * The page step holds it to the time the design answer leaves.\n */\nexport function aiSiteImportWordingTokens(page: AiSiteImportWordingPage): number {\n return 2 * page.lines.reduce((sum, line) => sum + tokensOf(line), 0) + AI_SITE_IMPORT_WORDING_THINKING_TOKENS\n}\n\n/*------------------------------------------\n * The answer, and what every rewrite holds\n *-----------------------------------------*/\n\n/** One line as an answer rewords it. */\nexport interface AiSiteImportRewrite {\n line: number\n text: string\n}\n\n/** An answer's lines, read defensively: each with a whole number and words; `null` where it has no list of lines. */\nexport function aiReadWordingAnswer(answer: Record<string, unknown> | null | undefined): AiSiteImportRewrite[] | null {\n const lines = answer?.['lines']\n if (!Array.isArray(lines)) return null\n return lines.flatMap((entry): AiSiteImportRewrite[] => {\n if (!entry || typeof entry !== 'object') return []\n const { line, text } = entry as Record<string, unknown>\n return typeof line === 'number' && Number.isInteger(line) && typeof text === 'string' ? [{ line, text }] : []\n })\n}\n\n/** Why a rewrite was refused (G3). */\nexport type AiSiteImportWordingCode =\n | 'wording-no-line'\n | 'wording-fixed-line'\n | 'wording-repeated-line'\n | 'wording-empty'\n | 'wording-script'\n | 'wording-length'\n | 'wording-dropped-fact'\n | 'wording-dropped-name'\n | 'wording-invented-fact'\n | 'wording-gap'\n | 'wording-meaning'\n | 'wording-copy'\n\n/** A rewrite refused, and why. */\nexport interface AiSiteImportWordingRefusal {\n line: number\n code: AiSiteImportWordingCode\n /** What the model is told: what the line broke and what to do. */\n message: string\n /** What it broke, beyond the message: the facts it dropped or added. */\n detail?: string\n}\n\n/** What a page's rewrites are held to beyond their own lines. */\nexport interface AiSiteImportWordingScope {\n doc: Pick<AiSiteImportDocument, 'blocks'>\n page: Pick<AiSiteImportWordingPage, 'lines'>\n /** The site's own name, which every rewrite says as often as its line does. */\n siteName?: string | null\n /** Who the copy is framed for: agency and enterprise copy holds to the judgment-word rule. */\n framing?: AiCopyFraming\n}\n\n/** The rewrites that hold, by line, and those refused. */\nexport interface AiSiteImportWordingHeld {\n held: Map<number, string>\n refused: AiSiteImportWordingRefusal[]\n}\n\n/** The scripts a line is told apart by; Chinese and Japanese writing count as one. */\nconst SCRIPTS: ReadonlyArray<readonly [string, RegExp]> = [\n ['latin', /\\p{Script=Latin}/u],\n ['cyrillic', /\\p{Script=Cyrillic}/u],\n ['greek', /\\p{Script=Greek}/u],\n ['arabic', /\\p{Script=Arabic}/u],\n ['hebrew', /\\p{Script=Hebrew}/u],\n ['cjk', /[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}]/u],\n ['hangul', /\\p{Script=Hangul}/u],\n ['thai', /\\p{Script=Thai}/u],\n ['devanagari', /\\p{Script=Devanagari}/u],\n]\n\n/** The script most of a line's letters are written in; `null` for a line with none. */\nexport function aiSiteImportScriptOf(text: string): string | null {\n const counts = new Map<string, number>()\n for (const char of text) {\n if (!/\\p{L}/u.test(char)) continue\n const script = SCRIPTS.find(([, pattern]) => pattern.test(char))?.[0] ?? 'other'\n counts.set(script, (counts.get(script) ?? 0) + 1)\n }\n let best: string | null = null\n let most = 0\n for (const [script, count] of counts) {\n if (count > most) {\n best = script\n most = count\n }\n }\n return best\n}\n\n/** How often a run of words says a name, whole, in any case. */\nfunction timesSaid(text: string, name: string): number {\n if (!name) return 0\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\s+/g, '\\\\s+')\n return [...text.matchAll(new RegExp(`(?<![\\\\p{L}\\\\p{N}])${escaped}(?![\\\\p{L}\\\\p{N}])`, 'giu'))].length\n}\n\n/** Each token of `a` not matched by one of `b`, as often as it is short. */\nfunction short(a: readonly string[], b: readonly string[]): string[] {\n const left = new Map<string, number>()\n for (const token of b) left.set(token, (left.get(token) ?? 0) + 1)\n const out: string[] = []\n for (const token of a) {\n const count = left.get(token) ?? 0\n if (count > 0) left.set(token, count - 1)\n else out.push(token)\n }\n return out\n}\n\n/** A fact token as the model reads it: its words, not its kind. */\nconst shownFact = (token: string) => `\"${token.replace(/^[a-z]+:/, '')}\"`\n\n/** The words of every line of the page as written: the facts a rewrite's contact details are held to. */\nfunction pageText(doc: Pick<AiSiteImportDocument, 'blocks'>): string {\n return doc.blocks.map((block) => (block.kind === 'image' ? clean(block.alt) : clean(block.text))).filter(Boolean).join('\\n')\n}\n\n/**\n * Every rule a rewrite is held to (G2, G3), pure, one line at a time: a\n * rewrite that breaks one is refused, and its line keeps its words. A\n * rewrite the same as its line is no rewrite, and is neither.\n */\nexport function aiSiteImportWordingHolds(scope: AiSiteImportWordingScope, rewrites: readonly AiSiteImportRewrite[]): AiSiteImportWordingHeld {\n const allowed = new Map(scope.page.lines.map((line) => [line.line, line]))\n const sources = scope.doc.blocks.flatMap((block) => (isLine(block) && block.kind !== 'image' ? [clean(block.text)] : []))\n const facts: SiteImportFactScope = siteImportFactScope(sources)\n const contacts = pageText(scope.doc)\n const name = clean(scope.siteName)\n const held = new Map<number, string>()\n const refused: AiSiteImportWordingRefusal[] = []\n const answered = new Set<number>()\n for (const rewrite of rewrites) {\n const at = rewrite.line\n const refuse = (code: AiSiteImportWordingCode, message: string, detail?: string) => refused.push({ line: at, code, message: `Line ${at}: ${message}`, ...(detail ? { detail } : {}) })\n if (answered.has(at)) {\n refuse('wording-repeated-line', 'it was answered more than once. Give each line once.')\n continue\n }\n answered.add(at)\n const block = scope.doc.blocks[at]\n if (!block || !isLine(block)) {\n refuse('wording-no-line', 'there is no such line on this page. Answer only the lines shown, by their numbers.')\n continue\n }\n const line = allowed.get(at)\n if (!line) {\n refuse('wording-fixed-line', 'it is kept exactly as the owner wrote it. Leave it out.')\n continue\n }\n const text = clean(rewrite.text)\n if (!text) {\n refuse('wording-empty', 'it was given no words. Leave a line out to keep it as written; never empty it.')\n continue\n }\n if (text === line.text) continue\n if (aiSiteImportScriptOf(text) !== aiSiteImportScriptOf(line.text)) {\n refuse('wording-script', \"it is not written in the line's own language. Write it in the language and script the line is in.\")\n continue\n }\n const words = aiSiteImportWordsIn(text)\n const source = aiSiteImportWordsIn(line.text)\n if (words < AI_SITE_IMPORT_WORDING_LENGTH.least * source || words > AI_SITE_IMPORT_WORDING_LENGTH.most * source || text.length > line.limit) {\n const least = Math.ceil(AI_SITE_IMPORT_WORDING_LENGTH.least * source)\n const most = Math.floor(AI_SITE_IMPORT_WORDING_LENGTH.most * source)\n refuse(\n 'wording-length',\n `it runs to ${words} ${words === 1 ? 'word' : 'words'} and ${text.length} characters. Keep it between ${least} and ${most} words, and within ${line.limit} characters.`,\n `The line has ${source} ${source === 1 ? 'word' : 'words'}.`,\n )\n continue\n }\n const before = siteImportFactTokens(line.text, facts, false)\n const after = siteImportFactTokens(text, facts, true)\n const nameBefore = timesSaid(line.text, name)\n const nameAfter = timesSaid(text, name)\n const dropped = short(before, after)\n const added = short(after, before)\n const names = [...dropped.filter((token) => token.startsWith('name:')), ...(nameAfter < nameBefore ? [`name:${name}`] : [])]\n if (names.length) {\n refuse('wording-dropped-name', 'it leaves out a name the line says. Keep every name exactly as the line writes it, as often.', `Left out: ${[...new Set(names)].map(shownFact).join(', ')}.`)\n continue\n }\n if (dropped.length) {\n refuse(\n 'wording-dropped-fact',\n 'it leaves out a fact the line says. Keep every price, number, date, time, percentage, address, phone number, email and web address exactly as the line writes it, as often.',\n `Left out: ${[...new Set(dropped)].map(shownFact).join(', ')}.`,\n )\n continue\n }\n const guarded = aiLayoutGuardContacts(text, contacts)\n if (added.length || nameAfter > nameBefore || guarded !== text) {\n const shown = [...new Set([...added, ...(nameAfter > nameBefore ? [`name:${name}`] : [])])]\n refuse('wording-invented-fact', 'it adds a fact or a name the line does not say. Add none of your own.', shown.length ? `Added: ${shown.map(shownFact).join(', ')}.` : undefined)\n continue\n }\n if (/\\[[^\\]]*\\]/.test(text) && !/\\[[^\\]]*\\]/.test(line.text)) {\n refuse('wording-gap', 'it leaves a gap in square brackets. Write the line whole, from its own words.')\n continue\n }\n if (siteImportContentKept(line.text, text) < SITE_IMPORT_MEANING_FLOOR) {\n refuse('wording-meaning', \"it no longer says what the line says. Keep its meaning and most of its words' substance.\")\n continue\n }\n if (detectOffVoiceCopy([{ at: 'line', text }], scope.framing ?? null).length || aiPlaceholderTokens(text).length) {\n refuse('wording-copy', \"it holds filler, a placeholder or a word that calls the work simple or cheap. Write real words from the line's own.\")\n continue\n }\n held.set(at, text)\n }\n return { held, refused }\n}\n\n/** A refusal as the re-ask names it. */\nexport function aiSiteImportWordingViolation(refusal: AiSiteImportWordingRefusal): AiDoctrineViolation {\n const shape = refusal.code === 'wording-no-line' || refusal.code === 'wording-fixed-line' || refusal.code === 'wording-repeated-line'\n return { rule: shape ? null : 14, code: refusal.code, message: refusal.message, ...(refusal.detail ? { detail: refusal.detail } : {}) }\n}\n\n/*------------------------------------------\n * The page reworded\n *-----------------------------------------*/\n\n/**\n * The page with its rewrites (G3): the source's document, each rewritten\n * line's words in place of its own and every block at its index, its layout\n * pinned to the source's so no section moves or is renamed. An image, or a\n * line no rewrite names, is the source's.\n */\nexport function aiSiteImportRewordedDocument(doc: AiSiteImportDocument, rewrites: ReadonlyMap<number, string>): AiSiteImportDocument {\n return {\n ...doc,\n layout: aiSiteImportLayoutOf(doc),\n blocks: doc.blocks.map((block, index) => {\n const text = rewrites.get(index)\n return text === undefined || block.kind === 'image' ? block : { ...block, text }\n }),\n }\n}\n\n/** A page's wording, settled: the page built in its rewrites, and the lines kept as written after their re-ask. */\nexport interface AiSiteImportWorded<T> {\n built: T\n /** The lines reworded, by number. */\n rewrites: Map<number, string>\n /** The lines refused twice, which keep their words. */\n kept: AiSiteImportWordingRefusal[]\n}\n\n/**\n * The wording answer's check (G3): every rewrite held line by line, a\n * refused one asked again once — the lines that held are kept between the\n * answers — and the page built whole in what held (`build`, the page step's\n * check of a page brought in, with rule 14 on for the rewritten lines). On\n * the last answer a line refused again keeps its words; a page that cannot\n * be built in its rewrites is refused whole, and the page step keeps the\n * page's words.\n *\n * Stateful across one generation's answers: make one for each.\n */\nexport function aiSiteImportWordingCheck<T>(input: AiSiteImportWordingScope & {\n doc: AiSiteImportDocument\n build: (reworded: AiSiteImportDocument, rewritten: readonly string[]) => { value: T | null; violations: AiDoctrineViolation[] }\n /** The answers one generation makes; the last keeps a line refused again as written. */\n attempts?: number\n}): AiGenerationCheck<AiSiteImportWorded<T>> {\n const attempts = input.attempts ?? AI_GENERATION_MAX_ATTEMPTS\n const held = new Map<number, string>()\n let answers = 0\n return (answer) => {\n answers += 1\n const rewrites = aiReadWordingAnswer(answer)\n if (!rewrites) return { value: null, violations: [{ rule: null, code: 'wording-unreadable', message: 'The answer gave no list of lines. Answer with submit_wording.' }] }\n const checked = aiSiteImportWordingHolds(input, rewrites)\n for (const [line, text] of checked.held) held.set(line, text)\n // A line refused now that held in an earlier answer keeps that rewrite.\n const refused = checked.refused.filter((refusal) => !held.has(refusal.line))\n if (refused.length && answers < attempts) {\n return {\n value: null,\n violations: [\n ...refused.map(aiSiteImportWordingViolation),\n {\n rule: null,\n code: 'wording-kept-lines',\n message: `Every other line you reworded holds and is kept. Answer again with ${refused.length === 1 ? 'that line' : 'those lines'} alone, or leave ${refused.length === 1 ? 'it' : 'them'} out to keep the owner's words.`,\n },\n ],\n offending: { lines: rewrites.filter((rewrite) => refused.some((refusal) => refusal.line === rewrite.line)) },\n }\n }\n const reworded = aiSiteImportRewordedDocument(input.doc, held)\n const built = input.build(reworded, [...held.values()])\n if (!built.value) return { value: null, violations: built.violations }\n return { value: { built: built.value, rewrites: new Map(held), kept: refused }, violations: [] }\n }\n}\n"],"names":["fenceUntrustedText","UNTRUSTED_TEXT_RULE","aiLayoutGuardContacts","SITE_IMPORT_MEANING_FLOOR","siteImportContentKept","siteImportFactScope","siteImportFactTokens","detectOffVoiceCopy","AI_GENERATION_MAX_ATTEMPTS","aiPlaceholderTokens","AI_TEXT_LIMITS","aiSiteImportLayoutOf","AI_SITE_IMPORT_HEADLINE_MAX_CHARS","AI_SITE_IMPORT_LABEL_CHARS","AI_SITE_IMPORT_TEXT_MAX_CHARS","aiSiteImportWordsIn","AI_SITE_IMPORT_WORDING_KIND","AI_SITE_IMPORT_WORDING_TOOL","name","description","strict","inputSchema","type","additionalProperties","required","properties","lines","items","line","text","AI_SITE_IMPORT_WORDING_LENGTH","least","most","AI_SITE_IMPORT_WORDING_TEXT","join","AI_SITE_IMPORT_WORDING_INSTRUCTIONS","cacheBreakpoint","AI_SITE_IMPORT_WORDING_MAX_CHARS","SHOWN_MAX_CHARS","KEPT_SHOWN_CHARS","FIXED_GROUPS","Set","NAMED_GROUPS","POSTAL","clean","replace","trim","isLine","block","kind","url","inline","limitOf","title","place","label","length","tokensOf","Math","ceil","AI_SITE_IMPORT_WORDING_THINKING_TOKENS","aiSiteImportWordingPage","doc","room","maxChars","maxTokens","Number","POSITIVE_INFINITY","layout","fixed","order","seen","kept","section","ref","undefined","blocks","add","has","push","offer","rewordable","reword","test","some","pattern","role","button","href","next","walk","nodes","whole","node","cell","cells","all","group","item","ctas","map","cta","named","how","figure","badge","period","list","link","image","row","rows","what","tab","tabs","panel","sections","forEach","index","entry","slice","trimEnd","limit","bound","entries","chars","tokens","cut","shortened","KEPT_RUN","out","at","first","end","run","aiSiteImportWordingText","page","aiSiteImportWordingPrompt","input","siteName","count","screen","slug","aiSiteImportWordingTokens","reduce","sum","aiReadWordingAnswer","answer","Array","isArray","flatMap","isInteger","SCRIPTS","aiSiteImportScriptOf","counts","Map","char","script","find","set","get","best","timesSaid","escaped","matchAll","RegExp","short","a","b","left","token","shownFact","pageText","alt","filter","Boolean","aiSiteImportWordingHolds","scope","rewrites","allowed","sources","facts","contacts","held","refused","answered","rewrite","refuse","code","message","detail","words","source","floor","before","after","nameBefore","nameAfter","dropped","added","names","startsWith","guarded","shown","framing","aiSiteImportWordingViolation","refusal","shape","rule","aiSiteImportRewordedDocument","aiSiteImportWordingCheck","attempts","answers","value","violations","checked","offending","reworded","built","build","values"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAkC2C,GAE3C,SAASA,kBAAkB,EAAEC,mBAAmB,QAAQ,0CAAyC;AACjG,SAASC,qBAAqB,QAAQ,uCAAmC;AAEzE,SACEC,yBAAyB,EACzBC,qBAAqB,EACrBC,mBAAmB,EACnBC,oBAAoB,QAEf,sCAAkC;AAGzC,SAASC,kBAAkB,QAAsD,uCAAmC;AACpH,SAASC,0BAA0B,QAAQ,qCAAiC;AAC5E,SAASC,mBAAmB,QAAQ,sCAAkC;AACtE,SAASC,cAAc,QAAQ,2BAAuB;AAEtD,SAASC,oBAAoB,QAAQ,8BAA0B;AAC/D,SACEC,iCAAiC,EACjCC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,mBAAmB,QAEd,+BAA2B;AAElC;;2CAE2C,GAE3C,+FAA+F,GAC/F,OAAO,MAAMC,8BAA8B,eAAc;AAEzD,oGAAoG,GACpG,OAAO,MAAMC,8BAAsC;IACjDC,MAAM;IACNC,aAAa;IACbC,QAAQ;IACRC,aAAa;QACXC,MAAM;QACNC,sBAAsB;QACtBC,UAAU;YAAC;SAAQ;QACnBC,YAAY;YACVC,OAAO;gBACLJ,MAAM;gBACNK,OAAO;oBACLL,MAAM;oBACNC,sBAAsB;oBACtBC,UAAU;wBAAC;wBAAQ;qBAAO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,CAACyG;oBACf;wBACEG,MAAM;wBACNpB,MAAM;wBACNC,SAAS,CAAC,mEAAmE,EAAEL,QAAQhI,MAAM,KAAK,IAAI,cAAc,cAAc,iBAAiB,EAAEgI,QAAQhI,MAAM,KAAK,IAAI,OAAO,OAAO,+BAA+B,CAAC;oBAC5N;iBACD;gBACDgK,WAAW;oBAAE9L,OAAOwJ,SAASJ,MAAM,CAAC,CAACY,UAAYF,QAAQpG,IAAI,CAAC,CAAC0H,UAAYA,QAAQlL,IAAI,KAAK8J,QAAQ9J,IAAI;gBAAG;YAC7G;QACF;QACA,MAAM6L,WAAWR,6BAA6BvE,MAAM5E,GAAG,EAAEyH;QACzD,MAAMmC,QAAQhF,MAAMiF,KAAK,CAACF,UAAU;eAAIlC,KAAKqC,MAAM;SAAG;QACtD,IAAI,CAACF,MAAML,KAAK,EAAE,OAAO;YAAEA,OAAO;YAAMC,YAAYI,MAAMJ,UAAU;QAAC;QACrE,OAAO;YAAED,OAAO;gBAAEK,OAAOA,MAAML,KAAK;gBAAEnC,UAAU,IAAIvB,IAAI4B;gBAAO/G,MAAMgH;YAAQ;YAAG8B,YAAY,EAAE;QAAC;IACjG;AACF"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { type AiIconLibraryEntry } from '../runtime/ai-icon-library';
|
|
18
|
-
import { type AiLayoutBand, type AiLayoutBlock, type AiLayoutSection, type AiLayoutSettlement } from './ai-layout-language';
|
|
18
|
+
import { type AiLayoutBand, type AiLayoutBlock, type AiLayoutImportFinish, type AiLayoutWidth, type AiLayoutSection, type AiLayoutSettlement } from './ai-layout-language';
|
|
19
19
|
import { type AiLayoutDesign, type AiLayoutDesignChoices, type AiLayoutGroupVariant } from './ai-layout-design';
|
|
20
20
|
import { type AiLayoutDestination, type AiLayoutLinkScope, type AiLayoutTargets } from './ai-layout-links';
|
|
21
21
|
import { aiLayoutSpans, AiLayoutTreeBuilder, type AiLayoutRawTree } from './ai-layout-tree';
|
|
@@ -102,6 +102,15 @@ export interface AiLayoutCompileOptions {
|
|
|
102
102
|
* source's own picture, as its design answer chose.
|
|
103
103
|
*/
|
|
104
104
|
verbatim?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* How a `verbatim` page is finished (AGL-4152). Absent or `keep`, as above:
|
|
107
|
+
* every band the source's, its opening's words held to the source's own
|
|
108
|
+
* measure where the section gives one. `improve`, its bands are the site's
|
|
109
|
+
* design's — the rhythm, a third strong band settled soft — and its
|
|
110
|
+
* opening's words take the hero's own share. Every word, item, picture and
|
|
111
|
+
* link is still the source's.
|
|
112
|
+
*/
|
|
113
|
+
finish?: AiLayoutImportFinish;
|
|
105
114
|
}
|
|
106
115
|
/** Words exactly as given, one space between them: how a page brought in shows them (AGL-4107). */
|
|
107
116
|
export declare function aiLayoutAsWritten(value: unknown): string;
|
|
@@ -213,6 +222,8 @@ export interface SectionScope {
|
|
|
213
222
|
heading?: string;
|
|
214
223
|
/** A group style the section's arrangement settled, over the one its words would pick. */
|
|
215
224
|
groupStyle?: AiLayoutGroupVariant;
|
|
225
|
+
/** A page brought in and kept (AGL-4152): the width its opening's words are held to, over the hero's own share. */
|
|
226
|
+
measure?: AiLayoutWidth;
|
|
216
227
|
}
|
|
217
228
|
/** Compiles a page designed in the layout language into the tree it stores. */
|
|
218
229
|
export declare function aiCompileLayoutPage(designed: readonly AiLayoutSection[], plan: AiLayoutPagePlan, targets: AiLayoutTargets, options: AiLayoutCompileOptions): AiLayoutCompiledPage;
|
|
@@ -209,19 +209,24 @@ function sectionScope(page, raw, index) {
|
|
|
209
209
|
var _page_design, _raw_blocks_find, _page_plan_sections_index;
|
|
210
210
|
const at = `sections[${index}]`;
|
|
211
211
|
const asked = (_raw_band = raw.band) != null ? _raw_band : 'plain';
|
|
212
|
-
// A page brought in keeps the source's bands, every one (AGL-4107)
|
|
212
|
+
// A page brought in keeps the source's bands, every one (AGL-4107), unless
|
|
213
|
+
// its owner asked it improved (AGL-4152): then the site's design rhythms them.
|
|
213
214
|
const verbatim = page.options.verbatim === true;
|
|
214
|
-
const
|
|
215
|
+
const kept = verbatim && page.options.finish !== 'improve';
|
|
216
|
+
const ruled = kept ? asked : rhythmBand(page, index, asked);
|
|
215
217
|
if (ruled !== asked) page.settled.push({
|
|
216
218
|
at: `${at}.band`,
|
|
217
219
|
what: `drawn ${ruled}: the page's ${(_page_design = page.design) == null ? void 0 : _page_design.choices.bandRhythm} band rhythm`
|
|
218
220
|
});
|
|
219
|
-
const band =
|
|
220
|
-
return {
|
|
221
|
+
const band = kept ? asked : settleBand(page, ruled, at);
|
|
222
|
+
return _extends({
|
|
221
223
|
page,
|
|
222
224
|
index,
|
|
223
225
|
at,
|
|
224
|
-
band
|
|
226
|
+
band
|
|
227
|
+
}, kept && raw.measure ? {
|
|
228
|
+
measure: raw.measure
|
|
229
|
+
} : {}, {
|
|
225
230
|
centered: raw.align === 'center',
|
|
226
231
|
level: index === 0 ? 1 : 2,
|
|
227
232
|
headed: false,
|
|
@@ -239,7 +244,7 @@ function sectionScope(page, raw, index) {
|
|
|
239
244
|
return (_block_text = block.text) != null ? _block_text : '';
|
|
240
245
|
})
|
|
241
246
|
].join(' ')
|
|
242
|
-
};
|
|
247
|
+
});
|
|
243
248
|
}
|
|
244
249
|
function drawSection(page, raw, index, scope) {
|
|
245
250
|
var _page_targets_listings, _ref;
|
|
@@ -1986,6 +1991,18 @@ function instances(scope, placed, items, perRow) {
|
|
|
1986
1991
|
container
|
|
1987
1992
|
], bandSx(band), band === 'dark');
|
|
1988
1993
|
}
|
|
1994
|
+
/**
|
|
1995
|
+
* How wide a hero's words run on a wide screen: the hero's own share of its
|
|
1996
|
+
* Container, or, on a page brought in and kept as it is (AGL-4152), the
|
|
1997
|
+
* theme's breakpoint nearest the source's own heading measure, never a pixel
|
|
1998
|
+
* width. A phone runs them across.
|
|
1999
|
+
*/ function wordsMeasure(scope, share) {
|
|
2000
|
+
var _scope_measure;
|
|
2001
|
+
return {
|
|
2002
|
+
xs: '100%',
|
|
2003
|
+
md: (_scope_measure = scope.measure) != null ? _scope_measure : share
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
1989
2006
|
/** Words over a full-bleed photo, on a scrim that keeps them readable, in the site's dark scheme. */ function cover(scope, flow, picture, minHeight) {
|
|
1990
2007
|
const tree = scope.page.tree;
|
|
1991
2008
|
// The photo dimmed over black: the scrim that keeps the words over it readable.
|
|
@@ -2002,16 +2019,10 @@ function instances(scope, placed, items, perRow) {
|
|
|
2002
2019
|
scope.overPhoto = true;
|
|
2003
2020
|
const words = compileFlow(scope, flow, 'full');
|
|
2004
2021
|
const measure = tree.add('muiBox', null, scope.centered ? {
|
|
2005
|
-
maxWidth:
|
|
2006
|
-
xs: '100%',
|
|
2007
|
-
md: '75%'
|
|
2008
|
-
},
|
|
2022
|
+
maxWidth: wordsMeasure(scope, '75%'),
|
|
2009
2023
|
mx: 'auto'
|
|
2010
2024
|
} : {
|
|
2011
|
-
maxWidth:
|
|
2012
|
-
xs: '100%',
|
|
2013
|
-
md: '62%'
|
|
2014
|
-
}
|
|
2025
|
+
maxWidth: wordsMeasure(scope, '62%')
|
|
2015
2026
|
}, [
|
|
2016
2027
|
words
|
|
2017
2028
|
], 'measure');
|
|
@@ -2058,10 +2069,7 @@ function instances(scope, placed, items, perRow) {
|
|
|
2058
2069
|
scope.centered = false;
|
|
2059
2070
|
const words = compileFlow(scope, flow, 'half');
|
|
2060
2071
|
const measure = tree.add('muiBox', null, {
|
|
2061
|
-
maxWidth:
|
|
2062
|
-
xs: '100%',
|
|
2063
|
-
md: '88%'
|
|
2064
|
-
},
|
|
2072
|
+
maxWidth: wordsMeasure(scope, '88%'),
|
|
2065
2073
|
px: {
|
|
2066
2074
|
xs: 3,
|
|
2067
2075
|
sm: 6,
|
|
@@ -2125,10 +2133,7 @@ function instances(scope, placed, items, perRow) {
|
|
|
2125
2133
|
scope.centered = true;
|
|
2126
2134
|
const words = compileFlow(scope, flow, 'full');
|
|
2127
2135
|
const measure = tree.add('muiBox', null, {
|
|
2128
|
-
maxWidth:
|
|
2129
|
-
xs: '100%',
|
|
2130
|
-
md: '72%'
|
|
2131
|
-
},
|
|
2136
|
+
maxWidth: wordsMeasure(scope, '72%'),
|
|
2132
2137
|
mx: 'auto'
|
|
2133
2138
|
}, [
|
|
2134
2139
|
words
|
|
@@ -2146,10 +2151,7 @@ function instances(scope, placed, items, perRow) {
|
|
|
2146
2151
|
// What the source sets under its picture stays under it, centered as the words above are.
|
|
2147
2152
|
const under = ((_picture_after = picture.after) == null ? void 0 : _picture_after.length) ? [
|
|
2148
2153
|
tree.add('muiBox', null, {
|
|
2149
|
-
maxWidth:
|
|
2150
|
-
xs: '100%',
|
|
2151
|
-
md: '72%'
|
|
2152
|
-
},
|
|
2154
|
+
maxWidth: wordsMeasure(scope, '72%'),
|
|
2153
2155
|
mx: 'auto'
|
|
2154
2156
|
}, [
|
|
2155
2157
|
compileFlow(scope, picture.after, 'full')
|
|
@@ -2347,10 +2349,7 @@ function instances(scope, placed, items, perRow) {
|
|
|
2347
2349
|
});
|
|
2348
2350
|
const words = compileFlow(scope, flow, 'full');
|
|
2349
2351
|
const measure = tree.add('muiBox', null, {
|
|
2350
|
-
maxWidth:
|
|
2351
|
-
xs: '100%',
|
|
2352
|
-
md: '72%'
|
|
2353
|
-
},
|
|
2352
|
+
maxWidth: wordsMeasure(scope, '72%'),
|
|
2354
2353
|
mx: 'auto'
|
|
2355
2354
|
}, [
|
|
2356
2355
|
words
|