@aglyn/plugins-ai 1.16.0 → 1.18.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/jobs/ai-job-import-step.js +7 -4
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.js +7 -4
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-layout-stock-photos.d.ts +9 -0
- package/src/lib/jobs/ai-layout-stock-photos.js +4 -0
- package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
- package/src/lib/jobs/ai-site-import-actions.d.ts +35 -0
- package/src/lib/jobs/ai-site-import-actions.js +215 -0
- package/src/lib/jobs/ai-site-import-actions.js.map +1 -0
- package/src/lib/jobs/ai-site-import-compile.d.ts +7 -0
- package/src/lib/jobs/ai-site-import-compile.js +34 -4
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-improve.d.ts +13 -1
- package/src/lib/jobs/ai-site-import-improve.js +153 -12
- package/src/lib/jobs/ai-site-import-improve.js.map +1 -1
- package/src/lib/jobs/ai-site-import-pictures.js +4 -2
- package/src/lib/jobs/ai-site-import-pictures.js.map +1 -1
- package/src/lib/jobs/ai-site-import-plan.d.ts +67 -1
- package/src/lib/jobs/ai-site-import-plan.js +173 -4
- package/src/lib/jobs/ai-site-import-plan.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +13 -15
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +6 -0
- package/src/lib/model/ai-site-import-fidelity.js +88 -10
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-ledger.js +10 -2
- package/src/lib/model/ai-site-import-ledger.js.map +1 -1
- package/src/lib/model/ai-site-import-marks.d.ts +37 -0
- package/src/lib/model/ai-site-import-marks.js +53 -0
- package/src/lib/model/ai-site-import-marks.js.map +1 -0
- package/src/lib/model/ai-site-import.d.ts +11 -1
- package/src/lib/model/ai-site-import.js +14 -2
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +8 -0
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/site-import/site-import-images.js +9 -6
- package/src/lib/site-import/site-import-images.js.map +1 -1
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* prompt reads it, the honesty validator holds an answer to it, and the
|
|
25
25
|
* fidelity scores the built page against it. No model reads or writes this.
|
|
26
26
|
*=========================================*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
27
|
+
import { aiSiteImportIsBrandMark } from "./ai-site-import-marks.js";
|
|
27
28
|
/** The fewest like items a group of the source is a ledger item at (AGL-4152): a `keep` places it whole. */ export const SITE_IMPORT_LEDGER_GROUP_ITEMS = 3;
|
|
28
29
|
/** The most characters of lines a page's ledger shows in full: past it, the page is long and its groups fold (AGL-4152). */ export const SITE_IMPORT_LEDGER_FOLD_CHARS = 4500;
|
|
29
30
|
const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim() : '';
|
|
@@ -203,8 +204,15 @@ const GROUP_ITEMS = {
|
|
|
203
204
|
if (((_entry_backdrop = entry.backdrop) == null ? void 0 : _entry_backdrop.kind) === 'video' && entry.backdrop.poster !== undefined) line(entry.backdrop.poster);
|
|
204
205
|
for (const ref of entry.lines)line(ref);
|
|
205
206
|
});
|
|
206
|
-
// The picture the page opens on outranks a new one.
|
|
207
|
-
const opening = items.find((item)=>
|
|
207
|
+
// The picture the page opens on outranks a new one; a brand's mark there is no photo of it (AGL-4152).
|
|
208
|
+
const opening = items.find((item)=>{
|
|
209
|
+
if (item.kind !== 'picture' || item.section !== 0) return false;
|
|
210
|
+
const block = blocks[item.lines[0]];
|
|
211
|
+
return !((block == null ? void 0 : block.kind) === 'image' && aiSiteImportIsBrandMark({
|
|
212
|
+
url: block.url,
|
|
213
|
+
alt: block.alt
|
|
214
|
+
}));
|
|
215
|
+
});
|
|
208
216
|
if (opening) opening.must = true;
|
|
209
217
|
const links = [];
|
|
210
218
|
const hrefs = new Set();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-import-ledger.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 * WHAT A GENERATIVE IMPROVE IT MAY NOT LOSE (AGL-4152).\n *\n * A redesign writes its own copy and plans its own sections, so nothing it\n * answers can be scored line by line against the source. What it must carry\n * is held by code instead, as a ledger read from the source's layout: each\n * thing with a ref a `keep` block places (`form:1`, `picture:3`, `plan:1`),\n * whether it must land exactly once, and every link's destination. The page\n * prompt reads it, the honesty validator holds an answer to it, and the\n * fidelity scores the built page against it. No model reads or writes this.\n *=========================================*/\n\nimport type { SiteImportBlock } from '../site-import/site-import-html'\nimport type { SiteImportLayout, SiteImportLayoutNode, SiteImportLineRef, SiteImportPictureFit } from './ai-site-import'\n\nexport type SiteImportLedgerKind = 'picture' | 'form' | 'plan' | 'table' | 'quote' | 'video' | 'contact' | 'stats' | 'logos' | 'gallery' | 'tabs' | 'group'\n\n/** One thing of the source a `keep` block places. */\nexport interface SiteImportLedgerItem {\n /** `kind:n`, counted within its kind in source order. */\n ref: string\n kind: SiteImportLedgerKind\n /** It must land exactly once: a form, plan, table, quote, video, contact line, or the page's opening picture. */\n must: boolean\n /** The source's section it was read in. */\n section: number\n /** The lines it holds, as blocks of the page. */\n lines: SiteImportLineRef[]\n /** What a `keep` block expands to; a picture on an item of a group has only its line. */\n node?: SiteImportLayoutNode\n /** How the source frames a picture. */\n fit?: SiteImportPictureFit\n /** A group's: the refs of the things it holds (its pictures, a contact line), placed with it when it is kept whole. */\n holds?: string[]\n /** A group's on a long page: shown by its items' titles alone, and kept whole. */\n folded?: true\n}\n\n/** A link of the source, each destination once. */\nexport interface SiteImportLedgerLink {\n ref: string\n line: SiteImportLineRef\n href: string\n text: string\n}\n\n/** A line of the source a redesign rewrites freely. */\nexport interface SiteImportLedgerLine {\n line: SiteImportLineRef\n section: number\n kind: SiteImportBlock['kind']\n text: string\n /** The group of like items it is a line of, by its ref. */\n group?: string\n}\n\nexport interface SiteImportLedger {\n items: SiteImportLedgerItem[]\n links: SiteImportLedgerLink[]\n lines: SiteImportLedgerLine[]\n /**\n * A long page (AGL-4152): its lines run past `SITE_IMPORT_LEDGER_FOLD_CHARS`,\n * so each of its groups is shown by its titles and kept whole, and an\n * answer writes only what is around them. One answer then fits a page's\n * ceiling however many like items the page has.\n */\n folded: boolean\n}\n\n/** The fewest like items a group of the source is a ledger item at (AGL-4152): a `keep` places it whole. */\nexport const SITE_IMPORT_LEDGER_GROUP_ITEMS = 3\n\n/** The most characters of lines a page's ledger shows in full: past it, the page is long and its groups fold (AGL-4152). */\nexport const SITE_IMPORT_LEDGER_FOLD_CHARS = 4_500\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\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. */\nexport const SITE_IMPORT_POSTAL_PATTERNS = [\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 EMAIL = /[\\p{L}\\p{N}._%+-]+@[\\p{L}\\p{N}-]+(?:\\.[\\p{L}\\p{N}-]+)+/u\nconst PHONE = /(?:\\+\\d{1,3}[\\s.-]?)?(?:\\(\\d{2,4}\\)[\\s.-]?)?\\d{2,4}[\\s.-]\\d{3,4}(?:[\\s.-]\\d{2,4})?/\n\n/** Whether a line says how to reach the business: an email, a phone number or a street address. */\nexport function siteImportLineIsContact(text: string): boolean {\n if (EMAIL.test(text) || SITE_IMPORT_POSTAL_PATTERNS.some((pattern) => pattern.test(text))) return true\n const phone = PHONE.exec(text)?.[0]\n return !!phone && phone.replace(/\\D/g, '').length >= 7\n}\n\nconst GROUP_ITEMS: Readonly<Record<string, SiteImportLedgerKind>> = { pricing: 'plan', quotes: 'quote', stats: 'stats', logos: 'logos' }\n\n/** What must land exactly once, by its kind. */\nconst MUST: ReadonlySet<SiteImportLedgerKind> = new Set(['form', 'plan', 'table', 'quote', 'video', 'contact'])\n\n/** A source's ledger (AGL-4152), in source order. */\nexport function siteImportLedger(source: { layout: SiteImportLayout; blocks: readonly SiteImportBlock[] }): SiteImportLedger {\n const { layout, blocks } = source\n const items: SiteImportLedgerItem[] = []\n const lines: SiteImportLedgerLine[] = []\n const seen = new Set<SiteImportLineRef>()\n const counts = new Map<SiteImportLedgerKind, number>()\n let section = 0\n const add = (kind: SiteImportLedgerKind, held: readonly SiteImportLineRef[], extra: Partial<SiteImportLedgerItem> = {}) => {\n const count = (counts.get(kind) ?? 0) + 1\n counts.set(kind, count)\n for (const ref of held) seen.add(ref)\n items.push({ ref: `${kind}:${count}`, kind, must: MUST.has(kind), section, lines: [...held], ...extra })\n }\n const line = (ref: SiteImportLineRef, node?: SiteImportLayoutNode) => {\n if (seen.has(ref)) return\n const block = blocks[ref]\n if (!block) return\n if (block.kind === 'image') {\n add('picture', [ref], node ? { node } : {})\n return\n }\n const text = clean(block.text)\n if (!text || (block.kind === 'link' && block.inline)) return\n seen.add(ref)\n // A paragraph that is only the words of the link after it is that link's label, read twice: the link is its line.\n const next = blocks[ref + 1]\n if (block.kind === 'paragraph' && next?.kind === 'link' && clean(next.text) === text) return\n const contact = (block.kind === 'link' && /^(?:mailto|tel):/i.test(block.href)) || siteImportLineIsContact(text)\n if (block.kind === 'quote') add('quote', [ref], { node: node ?? { kind: 'line', line: ref } })\n else if (contact) add('contact', [ref], { node: node ?? { kind: 'line', line: ref } })\n else lines.push({ line: ref, section, kind: block.kind, text })\n }\n const visit = (nodes: readonly SiteImportLayoutNode[]) => {\n for (const node of nodes) {\n switch (node.kind) {\n case 'line':\n line(node.line, node)\n break\n case 'picture':\n add('picture', [node.line], { node, ...(node.fit ? { fit: node.fit } : {}) })\n break\n case 'video':\n add('video', node.poster === undefined ? [] : [node.poster], { node })\n break\n case 'form':\n add('form', [], { node })\n break\n case 'row':\n for (const cell of node.cells) visit(cell.nodes)\n break\n case 'table':\n add('table', node.rows.flatMap((row) => row.cells.flatMap((cell) => cell.lines)), { node })\n break\n case 'tabs':\n add('tabs', node.tabs.flatMap((tab) => [...(tab.label === null ? [] : [tab.label]), ...siteImportLedgerNodeLines(tab.panel)]), { node })\n break\n case 'group': {\n // A group of photos the reader marked a gallery is one thing, its pictures with it (AGL-4152).\n const whole = node.group === 'logos' && node.gallery ? 'gallery' : GROUP_ITEMS[node.group]\n if (whole) {\n add(whole, node.items.flatMap((item) => item.lines), { node })\n break\n }\n const before = items.length\n const from = lines.length\n for (const item of node.items) for (const ref of item.lines) line(ref)\n // Three or more like items are one thing a `keep` may place whole, with what they hold (AGL-4152).\n if (node.items.length >= SITE_IMPORT_LEDGER_GROUP_ITEMS) {\n const holds = items.slice(before).map((item) => item.ref)\n add('group', node.items.flatMap((item) => item.lines), { node, ...(holds.length ? { holds } : {}) })\n const ref = items[items.length - 1]?.ref as string\n for (const entry of lines.slice(from)) entry.group = ref\n }\n break\n }\n default:\n break\n }\n }\n }\n layout.sections.forEach((entry, index) => {\n section = index\n visit(entry.nodes)\n // A film behind the words is its poster; a line the layout placed nowhere is still a line.\n if (entry.backdrop?.kind === 'video' && entry.backdrop.poster !== undefined) line(entry.backdrop.poster)\n for (const ref of entry.lines) line(ref)\n })\n // The picture the page opens on outranks a new one.\n const opening = items.find((item) => item.kind === 'picture' && item.section === 0)\n if (opening) opening.must = true\n const links: SiteImportLedgerLink[] = []\n const hrefs = new Set<string>()\n blocks.forEach((block, ref) => {\n if (block.kind !== 'link' || /^(?:mailto|tel):/i.test(block.href)) return\n const href = block.href.replace(/#.*$/, '').replace(/\\/+$/, '')\n if (!href || hrefs.has(href)) return\n hrefs.add(href)\n links.push({ ref: `link:${links.length + 1}`, line: ref, href: block.href, text: clean(block.text) })\n })\n // A long page folds its groups: each is shown by its titles, and kept whole, as are its tabs, figures and logos:\n // one answer places what the page holds and writes what is around it (AGL-4152).\n const folded = lines.reduce((sum, entry) => sum + entry.text.length, 0) > SITE_IMPORT_LEDGER_FOLD_CHARS\n if (folded) {\n for (const item of items) {\n if (item.kind === 'group') item.folded = true\n if (item.kind !== 'picture') item.must = true\n }\n }\n return { items, links, lines, folded }\n}\n\n/** Every line a list of layout nodes holds, rows, groups, tables and tabs opened. */\nexport function siteImportLedgerNodeLines(nodes: readonly SiteImportLayoutNode[]): SiteImportLineRef[] {\n const out: SiteImportLineRef[] = []\n for (const node of nodes) {\n if (node.kind === 'line' || node.kind === 'picture') out.push(node.line)\n else if (node.kind === 'video' && node.poster !== undefined) out.push(node.poster)\n else if (node.kind === 'row') for (const cell of node.cells) out.push(...siteImportLedgerNodeLines(cell.nodes))\n else if (node.kind === 'group') for (const item of node.items) out.push(...item.lines)\n else if (node.kind === 'table') for (const row of node.rows) for (const cell of row.cells) out.push(...cell.lines)\n else if (node.kind === 'tabs') for (const tab of node.tabs) out.push(...(tab.label === null ? [] : [tab.label]), ...siteImportLedgerNodeLines(tab.panel))\n }\n return out\n}\n"],"names":["SITE_IMPORT_LEDGER_GROUP_ITEMS","SITE_IMPORT_LEDGER_FOLD_CHARS","clean","text","replace","trim","SITE_IMPORT_POSTAL_PATTERNS","EMAIL","PHONE","siteImportLineIsContact","test","some","pattern","phone","exec","length","GROUP_ITEMS","pricing","quotes","stats","logos","MUST","Set","siteImportLedger","source","layout","blocks","items","lines","seen","counts","Map","section","add","kind","held","extra","count","get","set","ref","push","must","has","line","node","block","inline","next","contact","href","visit","nodes","fit","poster","undefined","cell","cells","rows","flatMap","row","tabs","tab","label","siteImportLedgerNodeLines","panel","whole","group","gallery","item","before","from","holds","slice","map","entry","sections","forEach","index","backdrop","opening","find","links","hrefs","folded","reduce","sum","out"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;2CAU2C;AA2D3C,0GAA0G,GAC1G,OAAO,MAAMA,iCAAiC,EAAC;AAE/C,0HAA0H,GAC1H,OAAO,MAAMC,gCAAgC,KAAK;AAElD,MAAMC,QAAQ,CAACC,OAA2B,OAAOA,SAAS,WAAWA,KAAKC,OAAO,CAAC,QAAQ,KAAKC,IAAI,KAAK;AAExG,8HAA8H,GAC9H,OAAO,MAAMC,8BAA8B;IACzC;IACA;IACA;CACD,CAAS;AAEV,MAAMC,QAAQ;AACd,MAAMC,QAAQ;AAEd,iGAAiG,GACjG,OAAO,SAASC,wBAAwBN,IAAY;QAEpCK;IADd,IAAID,MAAMG,IAAI,CAACP,SAASG,4BAA4BK,IAAI,CAAC,CAACC,UAAYA,QAAQF,IAAI,CAACP,QAAQ,OAAO;IAClG,MAAMU,SAAQL,cAAAA,MAAMM,IAAI,CAACX,0BAAXK,WAAkB,CAAC,EAAE;IACnC,OAAO,CAAC,CAACK,SAASA,MAAMT,OAAO,CAAC,OAAO,IAAIW,MAAM,IAAI;AACvD;AAEA,MAAMC,cAA8D;IAAEC,SAAS;IAAQC,QAAQ;IAASC,OAAO;IAASC,OAAO;AAAQ;AAEvI,8CAA8C,GAC9C,MAAMC,OAA0C,IAAIC,IAAI;IAAC;IAAQ;IAAQ;IA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ai/src/lib/model/ai-site-import-ledger.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 * WHAT A GENERATIVE IMPROVE IT MAY NOT LOSE (AGL-4152).\n *\n * A redesign writes its own copy and plans its own sections, so nothing it\n * answers can be scored line by line against the source. What it must carry\n * is held by code instead, as a ledger read from the source's layout: each\n * thing with a ref a `keep` block places (`form:1`, `picture:3`, `plan:1`),\n * whether it must land exactly once, and every link's destination. The page\n * prompt reads it, the honesty validator holds an answer to it, and the\n * fidelity scores the built page against it. No model reads or writes this.\n *=========================================*/\n\nimport type { SiteImportBlock } from '../site-import/site-import-html'\nimport type { SiteImportLayout, SiteImportLayoutNode, SiteImportLineRef, SiteImportPictureFit } from './ai-site-import'\nimport { aiSiteImportIsBrandMark } from './ai-site-import-marks'\n\nexport type SiteImportLedgerKind = 'picture' | 'form' | 'plan' | 'table' | 'quote' | 'video' | 'contact' | 'stats' | 'logos' | 'gallery' | 'tabs' | 'group'\n\n/** One thing of the source a `keep` block places. */\nexport interface SiteImportLedgerItem {\n /** `kind:n`, counted within its kind in source order. */\n ref: string\n kind: SiteImportLedgerKind\n /** It must land exactly once: a form, plan, table, quote, video, contact line, or the page's opening picture. */\n must: boolean\n /** The source's section it was read in. */\n section: number\n /** The lines it holds, as blocks of the page. */\n lines: SiteImportLineRef[]\n /** What a `keep` block expands to; a picture on an item of a group has only its line. */\n node?: SiteImportLayoutNode\n /** How the source frames a picture. */\n fit?: SiteImportPictureFit\n /** A group's: the refs of the things it holds (its pictures, a contact line), placed with it when it is kept whole. */\n holds?: string[]\n /** A group's on a long page: shown by its items' titles alone, and kept whole. */\n folded?: true\n}\n\n/** A link of the source, each destination once. */\nexport interface SiteImportLedgerLink {\n ref: string\n line: SiteImportLineRef\n href: string\n text: string\n}\n\n/** A line of the source a redesign rewrites freely. */\nexport interface SiteImportLedgerLine {\n line: SiteImportLineRef\n section: number\n kind: SiteImportBlock['kind']\n text: string\n /** The group of like items it is a line of, by its ref. */\n group?: string\n}\n\nexport interface SiteImportLedger {\n items: SiteImportLedgerItem[]\n links: SiteImportLedgerLink[]\n lines: SiteImportLedgerLine[]\n /**\n * A long page (AGL-4152): its lines run past `SITE_IMPORT_LEDGER_FOLD_CHARS`,\n * so each of its groups is shown by its titles and kept whole, and an\n * answer writes only what is around them. One answer then fits a page's\n * ceiling however many like items the page has.\n */\n folded: boolean\n}\n\n/** The fewest like items a group of the source is a ledger item at (AGL-4152): a `keep` places it whole. */\nexport const SITE_IMPORT_LEDGER_GROUP_ITEMS = 3\n\n/** The most characters of lines a page's ledger shows in full: past it, the page is long and its groups fold (AGL-4152). */\nexport const SITE_IMPORT_LEDGER_FOLD_CHARS = 4_500\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\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. */\nexport const SITE_IMPORT_POSTAL_PATTERNS = [\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 EMAIL = /[\\p{L}\\p{N}._%+-]+@[\\p{L}\\p{N}-]+(?:\\.[\\p{L}\\p{N}-]+)+/u\nconst PHONE = /(?:\\+\\d{1,3}[\\s.-]?)?(?:\\(\\d{2,4}\\)[\\s.-]?)?\\d{2,4}[\\s.-]\\d{3,4}(?:[\\s.-]\\d{2,4})?/\n\n/** Whether a line says how to reach the business: an email, a phone number or a street address. */\nexport function siteImportLineIsContact(text: string): boolean {\n if (EMAIL.test(text) || SITE_IMPORT_POSTAL_PATTERNS.some((pattern) => pattern.test(text))) return true\n const phone = PHONE.exec(text)?.[0]\n return !!phone && phone.replace(/\\D/g, '').length >= 7\n}\n\nconst GROUP_ITEMS: Readonly<Record<string, SiteImportLedgerKind>> = { pricing: 'plan', quotes: 'quote', stats: 'stats', logos: 'logos' }\n\n/** What must land exactly once, by its kind. */\nconst MUST: ReadonlySet<SiteImportLedgerKind> = new Set(['form', 'plan', 'table', 'quote', 'video', 'contact'])\n\n/** A source's ledger (AGL-4152), in source order. */\nexport function siteImportLedger(source: { layout: SiteImportLayout; blocks: readonly SiteImportBlock[] }): SiteImportLedger {\n const { layout, blocks } = source\n const items: SiteImportLedgerItem[] = []\n const lines: SiteImportLedgerLine[] = []\n const seen = new Set<SiteImportLineRef>()\n const counts = new Map<SiteImportLedgerKind, number>()\n let section = 0\n const add = (kind: SiteImportLedgerKind, held: readonly SiteImportLineRef[], extra: Partial<SiteImportLedgerItem> = {}) => {\n const count = (counts.get(kind) ?? 0) + 1\n counts.set(kind, count)\n for (const ref of held) seen.add(ref)\n items.push({ ref: `${kind}:${count}`, kind, must: MUST.has(kind), section, lines: [...held], ...extra })\n }\n const line = (ref: SiteImportLineRef, node?: SiteImportLayoutNode) => {\n if (seen.has(ref)) return\n const block = blocks[ref]\n if (!block) return\n if (block.kind === 'image') {\n add('picture', [ref], node ? { node } : {})\n return\n }\n const text = clean(block.text)\n if (!text || (block.kind === 'link' && block.inline)) return\n seen.add(ref)\n // A paragraph that is only the words of the link after it is that link's label, read twice: the link is its line.\n const next = blocks[ref + 1]\n if (block.kind === 'paragraph' && next?.kind === 'link' && clean(next.text) === text) return\n const contact = (block.kind === 'link' && /^(?:mailto|tel):/i.test(block.href)) || siteImportLineIsContact(text)\n if (block.kind === 'quote') add('quote', [ref], { node: node ?? { kind: 'line', line: ref } })\n else if (contact) add('contact', [ref], { node: node ?? { kind: 'line', line: ref } })\n else lines.push({ line: ref, section, kind: block.kind, text })\n }\n const visit = (nodes: readonly SiteImportLayoutNode[]) => {\n for (const node of nodes) {\n switch (node.kind) {\n case 'line':\n line(node.line, node)\n break\n case 'picture':\n add('picture', [node.line], { node, ...(node.fit ? { fit: node.fit } : {}) })\n break\n case 'video':\n add('video', node.poster === undefined ? [] : [node.poster], { node })\n break\n case 'form':\n add('form', [], { node })\n break\n case 'row':\n for (const cell of node.cells) visit(cell.nodes)\n break\n case 'table':\n add('table', node.rows.flatMap((row) => row.cells.flatMap((cell) => cell.lines)), { node })\n break\n case 'tabs':\n add('tabs', node.tabs.flatMap((tab) => [...(tab.label === null ? [] : [tab.label]), ...siteImportLedgerNodeLines(tab.panel)]), { node })\n break\n case 'group': {\n // A group of photos the reader marked a gallery is one thing, its pictures with it (AGL-4152).\n const whole = node.group === 'logos' && node.gallery ? 'gallery' : GROUP_ITEMS[node.group]\n if (whole) {\n add(whole, node.items.flatMap((item) => item.lines), { node })\n break\n }\n const before = items.length\n const from = lines.length\n for (const item of node.items) for (const ref of item.lines) line(ref)\n // Three or more like items are one thing a `keep` may place whole, with what they hold (AGL-4152).\n if (node.items.length >= SITE_IMPORT_LEDGER_GROUP_ITEMS) {\n const holds = items.slice(before).map((item) => item.ref)\n add('group', node.items.flatMap((item) => item.lines), { node, ...(holds.length ? { holds } : {}) })\n const ref = items[items.length - 1]?.ref as string\n for (const entry of lines.slice(from)) entry.group = ref\n }\n break\n }\n default:\n break\n }\n }\n }\n layout.sections.forEach((entry, index) => {\n section = index\n visit(entry.nodes)\n // A film behind the words is its poster; a line the layout placed nowhere is still a line.\n if (entry.backdrop?.kind === 'video' && entry.backdrop.poster !== undefined) line(entry.backdrop.poster)\n for (const ref of entry.lines) line(ref)\n })\n // The picture the page opens on outranks a new one; a brand's mark there is no photo of it (AGL-4152).\n const opening = items.find((item) => {\n if (item.kind !== 'picture' || item.section !== 0) return false\n const block = blocks[item.lines[0] as number]\n return !(block?.kind === 'image' && aiSiteImportIsBrandMark({ url: block.url, alt: block.alt }))\n })\n if (opening) opening.must = true\n const links: SiteImportLedgerLink[] = []\n const hrefs = new Set<string>()\n blocks.forEach((block, ref) => {\n if (block.kind !== 'link' || /^(?:mailto|tel):/i.test(block.href)) return\n const href = block.href.replace(/#.*$/, '').replace(/\\/+$/, '')\n if (!href || hrefs.has(href)) return\n hrefs.add(href)\n links.push({ ref: `link:${links.length + 1}`, line: ref, href: block.href, text: clean(block.text) })\n })\n // A long page folds its groups: each is shown by its titles, and kept whole, as are its tabs, figures and logos:\n // one answer places what the page holds and writes what is around it (AGL-4152).\n const folded = lines.reduce((sum, entry) => sum + entry.text.length, 0) > SITE_IMPORT_LEDGER_FOLD_CHARS\n if (folded) {\n for (const item of items) {\n if (item.kind === 'group') item.folded = true\n if (item.kind !== 'picture') item.must = true\n }\n }\n return { items, links, lines, folded }\n}\n\n/** Every line a list of layout nodes holds, rows, groups, tables and tabs opened. */\nexport function siteImportLedgerNodeLines(nodes: readonly SiteImportLayoutNode[]): SiteImportLineRef[] {\n const out: SiteImportLineRef[] = []\n for (const node of nodes) {\n if (node.kind === 'line' || node.kind === 'picture') out.push(node.line)\n else if (node.kind === 'video' && node.poster !== undefined) out.push(node.poster)\n else if (node.kind === 'row') for (const cell of node.cells) out.push(...siteImportLedgerNodeLines(cell.nodes))\n else if (node.kind === 'group') for (const item of node.items) out.push(...item.lines)\n else if (node.kind === 'table') for (const row of node.rows) for (const cell of row.cells) out.push(...cell.lines)\n else if (node.kind === 'tabs') for (const tab of node.tabs) out.push(...(tab.label === null ? [] : [tab.label]), ...siteImportLedgerNodeLines(tab.panel))\n }\n return out\n}\n"],"names":["aiSiteImportIsBrandMark","SITE_IMPORT_LEDGER_GROUP_ITEMS","SITE_IMPORT_LEDGER_FOLD_CHARS","clean","text","replace","trim","SITE_IMPORT_POSTAL_PATTERNS","EMAIL","PHONE","siteImportLineIsContact","test","some","pattern","phone","exec","length","GROUP_ITEMS","pricing","quotes","stats","logos","MUST","Set","siteImportLedger","source","layout","blocks","items","lines","seen","counts","Map","section","add","kind","held","extra","count","get","set","ref","push","must","has","line","node","block","inline","next","contact","href","visit","nodes","fit","poster","undefined","cell","cells","rows","flatMap","row","tabs","tab","label","siteImportLedgerNodeLines","panel","whole","group","gallery","item","before","from","holds","slice","map","entry","sections","forEach","index","backdrop","opening","find","url","alt","links","hrefs","folded","reduce","sum","out"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;2CAU2C;AAI3C,SAASA,uBAAuB,QAAQ,4BAAwB;AAwDhE,0GAA0G,GAC1G,OAAO,MAAMC,iCAAiC,EAAC;AAE/C,0HAA0H,GAC1H,OAAO,MAAMC,gCAAgC,KAAK;AAElD,MAAMC,QAAQ,CAACC,OAA2B,OAAOA,SAAS,WAAWA,KAAKC,OAAO,CAAC,QAAQ,KAAKC,IAAI,KAAK;AAExG,8HAA8H,GAC9H,OAAO,MAAMC,8BAA8B;IACzC;IACA;IACA;CACD,CAAS;AAEV,MAAMC,QAAQ;AACd,MAAMC,QAAQ;AAEd,iGAAiG,GACjG,OAAO,SAASC,wBAAwBN,IAAY;QAEpCK;IADd,IAAID,MAAMG,IAAI,CAACP,SAASG,4BAA4BK,IAAI,CAAC,CAACC,UAAYA,QAAQF,IAAI,CAACP,QAAQ,OAAO;IAClG,MAAMU,SAAQL,cAAAA,MAAMM,IAAI,CAACX,0BAAXK,WAAkB,CAAC,EAAE;IACnC,OAAO,CAAC,CAACK,SAASA,MAAMT,OAAO,CAAC,OAAO,IAAIW,MAAM,IAAI;AACvD;AAEA,MAAMC,cAA8D;IAAEC,SAAS;IAAQC,QAAQ;IAASC,OAAO;IAASC,OAAO;AAAQ;AAEvI,8CAA8C,GAC9C,MAAMC,OAA0C,IA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,KAAK5B,KAAK;aAC5G,IAAIiB,KAAKX,IAAI,KAAK,QAAQ,KAAK,MAAM4B,OAAOjB,KAAKgB,IAAI,CAAE4B,IAAIhD,IAAI,IAAKqB,IAAIC,KAAK,KAAK,OAAO,EAAE,GAAG;YAACD,IAAIC,KAAK;SAAC,KAAMC,0BAA0BF,IAAIG,KAAK;IACzJ;IACA,OAAOwB;AACT"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Whether a picture of the source is a brand's mark rather than a photo
|
|
19
|
+
* (AGL-4152): its file name or its alt text calls it a logo, a badge, an
|
|
20
|
+
* emblem, a wordmark or an icon. A mark is the source's words in a picture: a
|
|
21
|
+
* cover, a photo band or any slot a redesign fills with a photo never takes
|
|
22
|
+
* one, where a client's logo laid under a page's heading read as that page's
|
|
23
|
+
* work. Its address is read by its last part, its words split where it runs
|
|
24
|
+
* them together ("ClientLogo.jpg", "client+logo.png").
|
|
25
|
+
*/
|
|
26
|
+
export declare function aiSiteImportIsBrandMark(picture: {
|
|
27
|
+
alt?: string | null;
|
|
28
|
+
from?: string | null;
|
|
29
|
+
url?: string | null;
|
|
30
|
+
}): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether a picture's alt text is only its file's name (AGL-4152): what a
|
|
33
|
+
* builder fills in where its owner described nothing — "IMG_2459.jpeg",
|
|
34
|
+
* "Screenshot 2026-09-27 at 10.37.16 AM.png", a phone's id. It says nothing
|
|
35
|
+
* of what the picture shows, so it is no description of it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function aiSiteImportAltIsFileName(alt: string | null | undefined): boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /** Words in a picture's file name or alt text that make it a mark, not a photo (AGL-4152). */ const MARK_WORDS = /(?:^|[^a-z])(?:logos?|logotype|badges?|emblems?|favicon|wordmark|icons?)(?:[^a-z]|$)/i;
|
|
17
|
+
/**
|
|
18
|
+
* Whether a picture of the source is a brand's mark rather than a photo
|
|
19
|
+
* (AGL-4152): its file name or its alt text calls it a logo, a badge, an
|
|
20
|
+
* emblem, a wordmark or an icon. A mark is the source's words in a picture: a
|
|
21
|
+
* cover, a photo band or any slot a redesign fills with a photo never takes
|
|
22
|
+
* one, where a client's logo laid under a page's heading read as that page's
|
|
23
|
+
* work. Its address is read by its last part, its words split where it runs
|
|
24
|
+
* them together ("ClientLogo.jpg", "client+logo.png").
|
|
25
|
+
*/ export function aiSiteImportIsBrandMark(picture) {
|
|
26
|
+
var _ref, _picture_from, _ref1, _picture_alt;
|
|
27
|
+
var _address_split_;
|
|
28
|
+
const address = (_ref = (_picture_from = picture.from) != null ? _picture_from : picture.url) != null ? _ref : '';
|
|
29
|
+
let file = (_ref1 = (_address_split_ = address.split(/[?#]/)[0]) == null ? void 0 : _address_split_.split('/').pop()) != null ? _ref1 : '';
|
|
30
|
+
try {
|
|
31
|
+
file = decodeURIComponent(file.replace(/\+/g, ' '));
|
|
32
|
+
} catch (unused) {
|
|
33
|
+
file = file.replace(/\+/g, ' ');
|
|
34
|
+
}
|
|
35
|
+
const split = (text)=>text.replace(/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g, ' ');
|
|
36
|
+
return MARK_WORDS.test(split(file)) || MARK_WORDS.test(split((_picture_alt = picture.alt) != null ? _picture_alt : ''));
|
|
37
|
+
}
|
|
38
|
+
/** A picture file's own ending: what an upload's name ends in, never a description's. */ const FILE_ENDING = /\.(?:jpe?g|jfif|png|gif|webp|avif|heic|heif|tiff?|bmp|svg)$/i;
|
|
39
|
+
/** The names a camera, a phone or a screenshot gives a file before anyone describes it: "IMG_2459", "DSC01234", "PXL_20260927_101500". */ const CAMERA_NAME = /^(?:img|dsc|dscn|dscf|pxl|mvimg|gopr|dji|sam|wp|vid)[\s_-]?\d[\d_-]*$/i;
|
|
40
|
+
/** A phone's or a computer's screenshot, named for when it was taken. */ const SCREENSHOT_NAME = /^screen ?shot[\s_-]+\d{4}-\d{2}-\d{2}\b/i;
|
|
41
|
+
/** An id a phone's or a site builder's upload is named by. */ const UUID_NAME = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
42
|
+
/**
|
|
43
|
+
* Whether a picture's alt text is only its file's name (AGL-4152): what a
|
|
44
|
+
* builder fills in where its owner described nothing — "IMG_2459.jpeg",
|
|
45
|
+
* "Screenshot 2026-09-27 at 10.37.16 AM.png", a phone's id. It says nothing
|
|
46
|
+
* of what the picture shows, so it is no description of it.
|
|
47
|
+
*/ export function aiSiteImportAltIsFileName(alt) {
|
|
48
|
+
const text = (alt != null ? alt : '').replace(/\s+/g, ' ').trim();
|
|
49
|
+
if (!text) return false;
|
|
50
|
+
return FILE_ENDING.test(text) || CAMERA_NAME.test(text) || SCREENSHOT_NAME.test(text) || UUID_NAME.test(text);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=ai-site-import-marks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-import-marks.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/** Words in a picture's file name or alt text that make it a mark, not a photo (AGL-4152). */\nconst MARK_WORDS = /(?:^|[^a-z])(?:logos?|logotype|badges?|emblems?|favicon|wordmark|icons?)(?:[^a-z]|$)/i\n\n/**\n * Whether a picture of the source is a brand's mark rather than a photo\n * (AGL-4152): its file name or its alt text calls it a logo, a badge, an\n * emblem, a wordmark or an icon. A mark is the source's words in a picture: a\n * cover, a photo band or any slot a redesign fills with a photo never takes\n * one, where a client's logo laid under a page's heading read as that page's\n * work. Its address is read by its last part, its words split where it runs\n * them together (\"ClientLogo.jpg\", \"client+logo.png\").\n */\nexport function aiSiteImportIsBrandMark(picture: { alt?: string | null; from?: string | null; url?: string | null }): boolean {\n const address = picture.from ?? picture.url ?? ''\n let file = address.split(/[?#]/)[0]?.split('/').pop() ?? ''\n try {\n file = decodeURIComponent(file.replace(/\\+/g, ' '))\n } catch {\n file = file.replace(/\\+/g, ' ')\n }\n const split = (text: string) => text.replace(/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g, ' ')\n return MARK_WORDS.test(split(file)) || MARK_WORDS.test(split(picture.alt ?? ''))\n}\n\n/** A picture file's own ending: what an upload's name ends in, never a description's. */\nconst FILE_ENDING = /\\.(?:jpe?g|jfif|png|gif|webp|avif|heic|heif|tiff?|bmp|svg)$/i\n\n/** The names a camera, a phone or a screenshot gives a file before anyone describes it: \"IMG_2459\", \"DSC01234\", \"PXL_20260927_101500\". */\nconst CAMERA_NAME = /^(?:img|dsc|dscn|dscf|pxl|mvimg|gopr|dji|sam|wp|vid)[\\s_-]?\\d[\\d_-]*$/i\n\n/** A phone's or a computer's screenshot, named for when it was taken. */\nconst SCREENSHOT_NAME = /^screen ?shot[\\s_-]+\\d{4}-\\d{2}-\\d{2}\\b/i\n\n/** An id a phone's or a site builder's upload is named by. */\nconst UUID_NAME = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\n/**\n * Whether a picture's alt text is only its file's name (AGL-4152): what a\n * builder fills in where its owner described nothing — \"IMG_2459.jpeg\",\n * \"Screenshot 2026-09-27 at 10.37.16 AM.png\", a phone's id. It says nothing\n * of what the picture shows, so it is no description of it.\n */\nexport function aiSiteImportAltIsFileName(alt: string | null | undefined): boolean {\n const text = (alt ?? '').replace(/\\s+/g, ' ').trim()\n if (!text) return false\n return FILE_ENDING.test(text) || CAMERA_NAME.test(text) || SCREENSHOT_NAME.test(text) || UUID_NAME.test(text)\n}\n"],"names":["MARK_WORDS","aiSiteImportIsBrandMark","picture","address","from","url","file","split","pop","decodeURIComponent","replace","text","test","alt","FILE_ENDING","CAMERA_NAME","SCREENSHOT_NAME","UUID_NAME","aiSiteImportAltIsFileName","trim"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,4FAA4F,GAC5F,MAAMA,aAAa;AAEnB;;;;;;;;CAQC,GACD,OAAO,SAASC,wBAAwBC,OAA2E;QACjGA,MAAAA,sBAQ6CA;QAPlDC;IADX,MAAMA,WAAUD,QAAAA,gBAAAA,QAAQE,IAAI,YAAZF,gBAAgBA,QAAQG,GAAG,YAA3BH,OAA+B;IAC/C,IAAII,iBAAOH,kBAAAA,QAAQI,KAAK,CAAC,OAAO,CAAC,EAAE,qBAAxBJ,gBAA0BI,KAAK,CAAC,KAAKC,GAAG,sBAAM;IACzD,IAAI;QACFF,OAAOG,mBAAmBH,KAAKI,OAAO,CAAC,OAAO;IAChD,EAAE,eAAM;QACNJ,OAAOA,KAAKI,OAAO,CAAC,OAAO;IAC7B;IACA,MAAMH,QAAQ,CAACI,OAAiBA,KAAKD,OAAO,CAAC,iDAAiD;IAC9F,OAAOV,WAAWY,IAAI,CAACL,MAAMD,UAAUN,WAAWY,IAAI,CAACL,OAAML,eAAAA,QAAQW,GAAG,YAAXX,eAAe;AAC9E;AAEA,uFAAuF,GACvF,MAAMY,cAAc;AAEpB,wIAAwI,GACxI,MAAMC,cAAc;AAEpB,uEAAuE,GACvE,MAAMC,kBAAkB;AAExB,4DAA4D,GAC5D,MAAMC,YAAY;AAElB;;;;;CAKC,GACD,OAAO,SAASC,0BAA0BL,GAA8B;IACtE,MAAMF,OAAO,CAACE,cAAAA,MAAO,IAAIH,OAAO,CAAC,QAAQ,KAAKS,IAAI;IAClD,IAAI,CAACR,MAAM,OAAO;IAClB,OAAOG,YAAYF,IAAI,CAACD,SAASI,YAAYH,IAAI,CAACD,SAASK,gBAAgBJ,IAAI,CAACD,SAASM,UAAUL,IAAI,CAACD;AAC1G"}
|
|
@@ -908,6 +908,14 @@ export interface AiSiteImportState {
|
|
|
908
908
|
* page says so.
|
|
909
909
|
*/
|
|
910
910
|
plan?: AiSiteImportPlan | null;
|
|
911
|
+
/**
|
|
912
|
+
* Why the plan did not pass, line by line (AGL-4152): each miss's code and
|
|
913
|
+
* what it says of the line it found, cut to 300 characters, at most 8, as a
|
|
914
|
+
* redesign's `redesignMissedWhy`. The answer is never stored, and the log
|
|
915
|
+
* names codes alone, so this is what a later read of the job has to
|
|
916
|
+
* diagnose a plan that fell back by. For the job's record; never shown.
|
|
917
|
+
*/
|
|
918
|
+
planMissedWhy?: string[] | null;
|
|
911
919
|
/** The owner saw the plan and started the build (AGL-4152): its proposed page is settled, in or out. */
|
|
912
920
|
planAccepted?: true;
|
|
913
921
|
/** Whether a slot nothing else fills may take a generated picture (AGL-4152); absent is `AI_SITE_IMPORT_GENERATED_PICTURES_DEFAULT`. */
|
|
@@ -1409,8 +1417,10 @@ export declare function aiSiteImportHasRoomForPage(state: Pick<AiSiteImportState
|
|
|
1409
1417
|
* The plan in, or the plan that did not pass (`null`). A proposed page takes
|
|
1410
1418
|
* its place in the wave's rows as a page of its own, new, with no source: its
|
|
1411
1419
|
* words are written from what the site says, so its one line is its purpose.
|
|
1420
|
+
* A plan that did not pass keeps why (`planMissedWhy`); one that passed
|
|
1421
|
+
* clears what an earlier miss said.
|
|
1412
1422
|
*/
|
|
1413
|
-
export declare function aiSiteImportPlanIn(state: AiSiteImportState, wave: Pick<AiSiteImportWave, 'index'>, plan: AiSiteImportPlan | null, at: string, draftId: string): AiSiteImportState;
|
|
1423
|
+
export declare function aiSiteImportPlanIn(state: AiSiteImportState, wave: Pick<AiSiteImportWave, 'index'>, plan: AiSiteImportPlan | null, at: string, draftId: string, why?: readonly string[] | null): AiSiteImportState;
|
|
1414
1424
|
/** A plan with its proposed page's row: pending, unless it is the one row a plan has already added. */
|
|
1415
1425
|
export declare function aiSiteImportPlanRow(state: Pick<AiSiteImportState, 'plan'>, items: readonly AiJobItemLedger[]): AiJobItemLedger[];
|
|
1416
1426
|
/**
|
|
@@ -1438,8 +1438,20 @@ const readChars = (read)=>{
|
|
|
1438
1438
|
* The plan in, or the plan that did not pass (`null`). A proposed page takes
|
|
1439
1439
|
* its place in the wave's rows as a page of its own, new, with no source: its
|
|
1440
1440
|
* words are written from what the site says, so its one line is its purpose.
|
|
1441
|
-
|
|
1442
|
-
|
|
1441
|
+
* A plan that did not pass keeps why (`planMissedWhy`); one that passed
|
|
1442
|
+
* clears what an earlier miss said.
|
|
1443
|
+
*/ export function aiSiteImportPlanIn(state, wave, plan, at, draftId, why) {
|
|
1444
|
+
if (!plan) return _extends({}, state, {
|
|
1445
|
+
plan
|
|
1446
|
+
}, (why == null ? void 0 : why.length) ? {
|
|
1447
|
+
planMissedWhy: why.slice(0, 8).map((line)=>line.slice(0, 300))
|
|
1448
|
+
} : state.planMissedWhy ? {
|
|
1449
|
+
planMissedWhy: null
|
|
1450
|
+
} : {});
|
|
1451
|
+
if (state.planMissedWhy) return aiSiteImportPlanIn(_extends({}, state, {
|
|
1452
|
+
planMissedWhy: null
|
|
1453
|
+
}), wave, plan, at, draftId);
|
|
1454
|
+
if (!plan.proposed) return _extends({}, state, {
|
|
1443
1455
|
plan
|
|
1444
1456
|
});
|
|
1445
1457
|
const proposed = plan.proposed;
|