@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
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
import type { AiLayoutSection } from '../layout-language/ai-layout-language';
|
|
18
|
+
/**
|
|
19
|
+
* A redesigned section's calls to action, each once and each where it belongs
|
|
20
|
+
* (AGL-4152), whatever the answer and the source's kept groups gave:
|
|
21
|
+
*
|
|
22
|
+
* - Buttons placed in a row's columns under a group that runs the row's width,
|
|
23
|
+
* with nothing else in those columns, sit in the cards they go to where each
|
|
24
|
+
* goes where exactly one card does, else together under the group: a row of
|
|
25
|
+
* two buttons under three cards read as a grid half filled.
|
|
26
|
+
* - A link with the same words to the same place on every item of a group
|
|
27
|
+
* (each review's "See more reviews") is shown once, as a button after the
|
|
28
|
+
* group, unless the section already has that button. Where only some items
|
|
29
|
+
* carry it, each is that item's own action and stays.
|
|
30
|
+
* - The same button twice in a section is shown once, the first.
|
|
31
|
+
* - Two buttons side by side to the same place are one: the one with the
|
|
32
|
+
* header's words where one has them, else the first. Of buttons side by
|
|
33
|
+
* side, only the first is filled; the rest are outlined.
|
|
34
|
+
*/
|
|
35
|
+
export declare function aiSiteImportSectionActions(section: Pick<AiLayoutSection, 'cols' | 'blocks'>, cta?: string | null): Pick<AiLayoutSection, 'cols' | 'blocks'>;
|
|
@@ -0,0 +1,215 @@
|
|
|
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
|
+
* A PAGE'S CALLS TO ACTION UNDER IMPROVE IT (AGL-4152).
|
|
18
|
+
*
|
|
19
|
+
* The mechanical tidying of a section's buttons, the same whether a
|
|
20
|
+
* redesign drew the page or the page kept its source's layout: each call to
|
|
21
|
+
* action once, where it belongs. No model is asked; nothing is reworded.
|
|
22
|
+
*=========================================*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
23
|
+
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
24
|
+
const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim() : '';
|
|
25
|
+
/** A button's words and where it goes, as one key: two that share it are the same action. */ const actionKey = (text, to)=>`${clean(text).toLowerCase()}\u0000${to != null ? to : ''}`;
|
|
26
|
+
/** Whether a button is drawn filled: the compiler's default, `primary` or `large`. */ const filled = (block)=>block.kind === 'button' && (block.style === undefined || block.style === 'primary' || block.style === 'large');
|
|
27
|
+
/**
|
|
28
|
+
* A redesigned section's calls to action, each once and each where it belongs
|
|
29
|
+
* (AGL-4152), whatever the answer and the source's kept groups gave:
|
|
30
|
+
*
|
|
31
|
+
* - Buttons placed in a row's columns under a group that runs the row's width,
|
|
32
|
+
* with nothing else in those columns, sit in the cards they go to where each
|
|
33
|
+
* goes where exactly one card does, else together under the group: a row of
|
|
34
|
+
* two buttons under three cards read as a grid half filled.
|
|
35
|
+
* - A link with the same words to the same place on every item of a group
|
|
36
|
+
* (each review's "See more reviews") is shown once, as a button after the
|
|
37
|
+
* group, unless the section already has that button. Where only some items
|
|
38
|
+
* carry it, each is that item's own action and stays.
|
|
39
|
+
* - The same button twice in a section is shown once, the first.
|
|
40
|
+
* - Two buttons side by side to the same place are one: the one with the
|
|
41
|
+
* header's words where one has them, else the first. Of buttons side by
|
|
42
|
+
* side, only the first is filled; the rest are outlined.
|
|
43
|
+
*/ export function aiSiteImportSectionActions(section, cta) {
|
|
44
|
+
let { cols, blocks } = section;
|
|
45
|
+
// Buttons in columns under a group across the row.
|
|
46
|
+
const placed = blocks.filter((block)=>block.col !== undefined);
|
|
47
|
+
const group = blocks.find((block)=>{
|
|
48
|
+
var _ref;
|
|
49
|
+
var _block_items;
|
|
50
|
+
return block.col === undefined && ((_ref = (_block_items = block.items) == null ? void 0 : _block_items.length) != null ? _ref : 0) >= 2 && block.kind !== 'list' && block.kind !== 'faq';
|
|
51
|
+
});
|
|
52
|
+
if (cols && cols.length >= 2 && group && placed.length && placed.every((block)=>block.kind === 'button')) {
|
|
53
|
+
const items = group.items;
|
|
54
|
+
const cards = placed.map((button)=>items.flatMap((item, at)=>{
|
|
55
|
+
var _item_links;
|
|
56
|
+
return button.to && item.to === button.to && !((_item_links = item.links) == null ? void 0 : _item_links.length) ? [
|
|
57
|
+
at
|
|
58
|
+
] : [];
|
|
59
|
+
}));
|
|
60
|
+
const own = cards.every((found)=>found.length === 1) && new Set(cards.map((found)=>found[0])).size === cards.length;
|
|
61
|
+
if (own) {
|
|
62
|
+
const into = new Map(placed.map((button, at)=>{
|
|
63
|
+
var _cards_at;
|
|
64
|
+
return [
|
|
65
|
+
(_cards_at = cards[at]) == null ? void 0 : _cards_at[0],
|
|
66
|
+
button
|
|
67
|
+
];
|
|
68
|
+
}));
|
|
69
|
+
const carded = _extends({}, group, {
|
|
70
|
+
items: items.map((item, at)=>{
|
|
71
|
+
var _ref;
|
|
72
|
+
var _into_get;
|
|
73
|
+
return into.has(at) ? _extends({}, item, {
|
|
74
|
+
links: [
|
|
75
|
+
{
|
|
76
|
+
text: (_ref = (_into_get = into.get(at)) == null ? void 0 : _into_get.text) != null ? _ref : '',
|
|
77
|
+
to: item.to,
|
|
78
|
+
style: 'secondary'
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}) : item;
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
blocks = blocks.flatMap((block)=>block === group ? [
|
|
85
|
+
carded
|
|
86
|
+
] : placed.includes(block) ? [] : [
|
|
87
|
+
block
|
|
88
|
+
]);
|
|
89
|
+
} else blocks = blocks.map((block)=>placed.includes(block) ? ((_0)=>{
|
|
90
|
+
let { col: _col } = _0, rest = _object_without_properties_loose(_0, [
|
|
91
|
+
"col"
|
|
92
|
+
]);
|
|
93
|
+
return rest;
|
|
94
|
+
})(block) : block);
|
|
95
|
+
cols = undefined;
|
|
96
|
+
}
|
|
97
|
+
// A link repeated across a group's items, once after the group.
|
|
98
|
+
const buttons = new Set(blocks.flatMap((block)=>block.kind === 'button' ? [
|
|
99
|
+
actionKey(block.text, block.to)
|
|
100
|
+
] : []));
|
|
101
|
+
blocks = blocks.flatMap((block)=>{
|
|
102
|
+
const items = block.items;
|
|
103
|
+
if (!items || items.length < 2) return [
|
|
104
|
+
block
|
|
105
|
+
];
|
|
106
|
+
const counted = new Map();
|
|
107
|
+
for (const item of items){
|
|
108
|
+
var _item_links;
|
|
109
|
+
for (const key of new Set(((_item_links = item.links) != null ? _item_links : []).map((link)=>actionKey(link.text, link.to)))){
|
|
110
|
+
var _ref;
|
|
111
|
+
var _item_links1;
|
|
112
|
+
const link = (_item_links1 = item.links) == null ? void 0 : _item_links1.find((entry)=>actionKey(entry.text, entry.to) === key);
|
|
113
|
+
const was = counted.get(key);
|
|
114
|
+
if (link) counted.set(key, _extends({
|
|
115
|
+
text: link.text
|
|
116
|
+
}, link.to ? {
|
|
117
|
+
to: link.to
|
|
118
|
+
} : {}, link.style ? {
|
|
119
|
+
style: link.style
|
|
120
|
+
} : {}, {
|
|
121
|
+
on: ((_ref = was == null ? void 0 : was.on) != null ? _ref : 0) + 1
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const repeated = new Map([
|
|
126
|
+
...counted
|
|
127
|
+
].filter(([, entry])=>entry.on === items.length));
|
|
128
|
+
if (!repeated.size) return [
|
|
129
|
+
block
|
|
130
|
+
];
|
|
131
|
+
const stripped = items.map((item)=>{
|
|
132
|
+
var _item_links;
|
|
133
|
+
if (!((_item_links = item.links) == null ? void 0 : _item_links.length)) return item;
|
|
134
|
+
const links = item.links.filter((link)=>!repeated.has(actionKey(link.text, link.to)));
|
|
135
|
+
const { links: _links } = item, rest = _object_without_properties_loose(item, [
|
|
136
|
+
"links"
|
|
137
|
+
]);
|
|
138
|
+
return links.length ? _extends({}, rest, {
|
|
139
|
+
links
|
|
140
|
+
}) : rest;
|
|
141
|
+
});
|
|
142
|
+
const after = [
|
|
143
|
+
...repeated
|
|
144
|
+
].flatMap(([key, entry])=>{
|
|
145
|
+
if (buttons.has(key)) return [];
|
|
146
|
+
buttons.add(key);
|
|
147
|
+
return [
|
|
148
|
+
_extends({
|
|
149
|
+
kind: 'button',
|
|
150
|
+
text: entry.text
|
|
151
|
+
}, entry.to ? {
|
|
152
|
+
to: entry.to
|
|
153
|
+
} : {}, entry.style ? {
|
|
154
|
+
style: entry.style
|
|
155
|
+
} : {}, block.col !== undefined ? {
|
|
156
|
+
col: block.col
|
|
157
|
+
} : {})
|
|
158
|
+
];
|
|
159
|
+
});
|
|
160
|
+
return [
|
|
161
|
+
_extends({}, block, {
|
|
162
|
+
items: stripped
|
|
163
|
+
}),
|
|
164
|
+
...after
|
|
165
|
+
];
|
|
166
|
+
});
|
|
167
|
+
// The same button twice, once.
|
|
168
|
+
const seen = new Set();
|
|
169
|
+
blocks = blocks.filter((block)=>{
|
|
170
|
+
if (block.kind !== 'button' || !block.to) return true;
|
|
171
|
+
const key = actionKey(block.text, block.to);
|
|
172
|
+
if (seen.has(key)) return false;
|
|
173
|
+
seen.add(key);
|
|
174
|
+
return true;
|
|
175
|
+
});
|
|
176
|
+
// Buttons side by side: one to each place, the first filled.
|
|
177
|
+
const wanted = clean(cta).toLowerCase();
|
|
178
|
+
const out = [];
|
|
179
|
+
for (const block of blocks){
|
|
180
|
+
const before = out[out.length - 1];
|
|
181
|
+
if (block.kind === 'button' && (before == null ? void 0 : before.kind) === 'button' && before.col === block.col) {
|
|
182
|
+
var _out_, _out_1;
|
|
183
|
+
// Back over the run this button stands in.
|
|
184
|
+
let start = out.length - 1;
|
|
185
|
+
while(start > 0 && ((_out_ = out[start - 1]) == null ? void 0 : _out_.kind) === 'button' && ((_out_1 = out[start - 1]) == null ? void 0 : _out_1.col) === block.col)start -= 1;
|
|
186
|
+
const run = out.slice(start);
|
|
187
|
+
const same = block.to ? run.findIndex((entry)=>entry.to === block.to) : -1;
|
|
188
|
+
if (same !== -1) {
|
|
189
|
+
// The header's words win the place; the run keeps its first button's place and fill.
|
|
190
|
+
const kept = run[same];
|
|
191
|
+
if (wanted && clean(block.text).toLowerCase() === wanted && clean(kept.text).toLowerCase() !== wanted) {
|
|
192
|
+
const { style: _style } = block, words = _object_without_properties_loose(block, [
|
|
193
|
+
"style"
|
|
194
|
+
]);
|
|
195
|
+
out[start + same] = _extends({}, words, kept.style ? {
|
|
196
|
+
style: kept.style
|
|
197
|
+
} : {});
|
|
198
|
+
}
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
out.push(run.some(filled) && filled(block) ? _extends({}, block, {
|
|
202
|
+
style: 'secondary'
|
|
203
|
+
}) : block);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
out.push(block);
|
|
207
|
+
}
|
|
208
|
+
return _extends({}, cols ? {
|
|
209
|
+
cols
|
|
210
|
+
} : {}, {
|
|
211
|
+
blocks: out
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
//# sourceMappingURL=ai-site-import-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-actions.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'S CALLS TO ACTION UNDER IMPROVE IT (AGL-4152).\n *\n * The mechanical tidying of a section's buttons, the same whether a\n * redesign drew the page or the page kept its source's layout: each call to\n * action once, where it belongs. No model is asked; nothing is reworded.\n *=========================================*/\n\nimport type { AiLayoutBlock, AiLayoutItem, AiLayoutSection } from '../layout-language/ai-layout-language'\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\n/** A button's words and where it goes, as one key: two that share it are the same action. */\nconst actionKey = (text: string | undefined, to: string | undefined): string => `${clean(text).toLowerCase()}\\u0000${to ?? ''}`\n\n/** Whether a button is drawn filled: the compiler's default, `primary` or `large`. */\nconst filled = (block: AiLayoutBlock): boolean => block.kind === 'button' && (block.style === undefined || block.style === 'primary' || block.style === 'large')\n\n/**\n * A redesigned section's calls to action, each once and each where it belongs\n * (AGL-4152), whatever the answer and the source's kept groups gave:\n *\n * - Buttons placed in a row's columns under a group that runs the row's width,\n * with nothing else in those columns, sit in the cards they go to where each\n * goes where exactly one card does, else together under the group: a row of\n * two buttons under three cards read as a grid half filled.\n * - A link with the same words to the same place on every item of a group\n * (each review's \"See more reviews\") is shown once, as a button after the\n * group, unless the section already has that button. Where only some items\n * carry it, each is that item's own action and stays.\n * - The same button twice in a section is shown once, the first.\n * - Two buttons side by side to the same place are one: the one with the\n * header's words where one has them, else the first. Of buttons side by\n * side, only the first is filled; the rest are outlined.\n */\nexport function aiSiteImportSectionActions(section: Pick<AiLayoutSection, 'cols' | 'blocks'>, cta?: string | null): Pick<AiLayoutSection, 'cols' | 'blocks'> {\n let { cols, blocks } = section\n // Buttons in columns under a group across the row.\n const placed = blocks.filter((block) => block.col !== undefined)\n const group = blocks.find((block) => block.col === undefined && (block.items?.length ?? 0) >= 2 && block.kind !== 'list' && block.kind !== 'faq')\n if (cols && cols.length >= 2 && group && placed.length && placed.every((block) => block.kind === 'button')) {\n const items = group.items as AiLayoutItem[]\n const cards = placed.map((button) => items.flatMap((item, at) => (button.to && item.to === button.to && !item.links?.length ? [at] : [])))\n const own = cards.every((found) => found.length === 1) && new Set(cards.map((found) => found[0])).size === cards.length\n if (own) {\n const into = new Map(placed.map((button, at) => [cards[at]?.[0] as number, button]))\n const carded = { ...group, items: items.map((item, at) => (into.has(at) ? { ...item, links: [{ text: into.get(at)?.text ?? '', to: item.to as string, style: 'secondary' as const }] } : item)) }\n blocks = blocks.flatMap((block) => (block === group ? [carded] : placed.includes(block) ? [] : [block]))\n } else blocks = blocks.map((block) => (placed.includes(block) ? (({ col: _col, ...rest }) => rest)(block) : block))\n cols = undefined\n }\n // A link repeated across a group's items, once after the group.\n const buttons = new Set(blocks.flatMap((block) => (block.kind === 'button' ? [actionKey(block.text, block.to)] : [])))\n blocks = blocks.flatMap((block) => {\n const items = block.items\n if (!items || items.length < 2) return [block]\n const counted = new Map<string, { text: string; to?: string; style?: AiLayoutBlock['style']; on: number }>()\n for (const item of items) {\n for (const key of new Set((item.links ?? []).map((link) => actionKey(link.text, link.to)))) {\n const link = item.links?.find((entry) => actionKey(entry.text, entry.to) === key)\n const was = counted.get(key)\n if (link) counted.set(key, { text: link.text, ...(link.to ? { to: link.to } : {}), ...(link.style ? { style: link.style } : {}), on: (was?.on ?? 0) + 1 })\n }\n }\n const repeated = new Map([...counted].filter(([, entry]) => entry.on === items.length))\n if (!repeated.size) return [block]\n const stripped = items.map((item) => {\n if (!item.links?.length) return item\n const links = item.links.filter((link) => !repeated.has(actionKey(link.text, link.to)))\n const { links: _links, ...rest } = item\n return links.length ? { ...rest, links } : rest\n })\n const after = [...repeated].flatMap(([key, entry]): AiLayoutBlock[] => {\n if (buttons.has(key)) return []\n buttons.add(key)\n return [{ kind: 'button', text: entry.text, ...(entry.to ? { to: entry.to } : {}), ...(entry.style ? { style: entry.style } : {}), ...(block.col !== undefined ? { col: block.col } : {}) }]\n })\n return [{ ...block, items: stripped }, ...after]\n })\n // The same button twice, once.\n const seen = new Set<string>()\n blocks = blocks.filter((block) => {\n if (block.kind !== 'button' || !block.to) return true\n const key = actionKey(block.text, block.to)\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n // Buttons side by side: one to each place, the first filled.\n const wanted = clean(cta).toLowerCase()\n const out: AiLayoutBlock[] = []\n for (const block of blocks) {\n const before = out[out.length - 1]\n if (block.kind === 'button' && before?.kind === 'button' && before.col === block.col) {\n // Back over the run this button stands in.\n let start = out.length - 1\n while (start > 0 && out[start - 1]?.kind === 'button' && out[start - 1]?.col === block.col) start -= 1\n const run = out.slice(start)\n const same = block.to ? run.findIndex((entry) => entry.to === block.to) : -1\n if (same !== -1) {\n // The header's words win the place; the run keeps its first button's place and fill.\n const kept = run[same] as AiLayoutBlock\n if (wanted && clean(block.text).toLowerCase() === wanted && clean(kept.text).toLowerCase() !== wanted) {\n const { style: _style, ...words } = block\n out[start + same] = { ...words, ...(kept.style ? { style: kept.style } : {}) }\n }\n continue\n }\n out.push(run.some(filled) && filled(block) ? { ...block, style: 'secondary' } : block)\n continue\n }\n out.push(block)\n }\n return { ...(cols ? { cols } : {}), blocks: out }\n}\n"],"names":["clean","text","replace","trim","actionKey","to","toLowerCase","filled","block","kind","style","undefined","aiSiteImportSectionActions","section","cta","cols","blocks","placed","filter","col","group","find","items","length","every","cards","map","button","flatMap","item","at","links","own","found","Set","size","into","Map","carded","has","get","includes","_col","rest","buttons","counted","key","link","entry","was","set","on","repeated","stripped","_links","after","add","seen","wanted","out","before","start","run","slice","same","findIndex","kept","_style","words","push","some"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;2CAM2C;;AAI3C,MAAMA,QAAQ,CAACC,OAA2B,OAAOA,SAAS,WAAWA,KAAKC,OAAO,CAAC,QAAQ,KAAKC,IAAI,KAAK;AAExG,2FAA2F,GAC3F,MAAMC,YAAY,CAACH,MAA0BI,KAAmC,GAAGL,MAAMC,MAAMK,WAAW,GAAG,MAAM,EAAED,aAAAA,KAAM,IAAI;AAE/H,oFAAoF,GACpF,MAAME,SAAS,CAACC,QAAkCA,MAAMC,IAAI,KAAK,YAAaD,CAAAA,MAAME,KAAK,KAAKC,aAAaH,MAAME,KAAK,KAAK,aAAaF,MAAME,KAAK,KAAK,OAAM;AAE9J;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASE,2BAA2BC,OAAiD,EAAEC,GAAmB;IAC/G,IAAI,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGH;IACvB,mDAAmD;IACnD,MAAMI,SAASD,OAAOE,MAAM,CAAC,CAACV,QAAUA,MAAMW,GAAG,KAAKR;IACtD,MAAMS,QAAQJ,OAAOK,IAAI,CAAC,CAACb;;YAAsCA;eAA5BA,MAAMW,GAAG,KAAKR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AOoD,UAAU1D,MAAMkE,KAAKjE,IAAI,EAAEK,WAAW,OAAOoD,QAAQ;oBACrG,MAAM,EAAEhD,OAAOyD,MAAM,EAAY,GAAG3D,OAAV4D,yCAAU5D;;;oBACpCmD,GAAG,CAACE,QAAQG,KAAK,GAAG,aAAKI,OAAWF,KAAKxD,KAAK,GAAG;wBAAEA,OAAOwD,KAAKxD,KAAK;oBAAC,IAAI,CAAC;gBAC5E;gBACA;YACF;YACAiD,IAAIU,IAAI,CAACP,IAAIQ,IAAI,CAAC/D,WAAWA,OAAOC,SAAS,aAAKA;gBAAOE,OAAO;iBAAgBF;YAChF;QACF;QACAmD,IAAIU,IAAI,CAAC7D;IACX;IACA,OAAO,aAAMO,OAAO;QAAEA;IAAK,IAAI,CAAC;QAAIC,QAAQ2C;;AAC9C"}
|
|
@@ -112,6 +112,13 @@ export interface MapScope {
|
|
|
112
112
|
}
|
|
113
113
|
/** Where a link of the source goes on the new site, in the compiler's words; `undefined` where it can go nowhere a page may send a visitor. */
|
|
114
114
|
export declare function aiSiteImportLinkTo(scope: Pick<MapScope, 'doc' | 'pathTo'>, href: string | undefined): string | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* What a picture whose source named it only by its file is described as
|
|
117
|
+
* (AGL-4152): the page it is on and which of its pictures it is, which is
|
|
118
|
+
* all that is known of it, never a guess at what it shows. Empty where the
|
|
119
|
+
* page has no title, so the picture is drawn as decoration.
|
|
120
|
+
*/
|
|
121
|
+
export declare function aiSiteImportPhotoAlt(doc: Pick<AiSiteImportDocument, 'title' | 'blocks'>, ref: SiteImportLineRef): string;
|
|
115
122
|
/** A picture line as the library holds it; marks it taken, and missing where the library holds none. */
|
|
116
123
|
export declare function aiSiteImportTakePicture(scope: MapScope, ref: SiteImportLineRef | undefined, href?: string, fit?: SiteImportPictureFit): AiLayoutPicture | null;
|
|
117
124
|
/**
|
|
@@ -59,8 +59,10 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
|
|
|
59
59
|
import { aiCompileLayoutPage } from "../layout-language/ai-layout-compiler.js";
|
|
60
60
|
import { AI_LAYOUT_GROUP_STYLES, AI_LAYOUT_IMPORT_HEROES, AI_LAYOUT_MAX_COLS } from "../layout-language/ai-layout-language.js";
|
|
61
61
|
import { AI_SITE_IMPORT_LABEL_MAX_CHARS, SITE_IMPORT_PLAY_WORDS, siteImportFilmSource, siteImportWidthOf } from "../model/ai-site-import.js";
|
|
62
|
+
import { aiSiteImportAltIsFileName } from "../model/ai-site-import-marks.js";
|
|
62
63
|
import { aiHexOklch } from "../model/ai-site-look.js";
|
|
63
64
|
import { aiModelAtLeastStepTier } from "../providers/routing.js";
|
|
65
|
+
import { aiSiteImportSectionActions } from "./ai-site-import-actions.js";
|
|
64
66
|
import { AI_SITE_IMPORT_DOC_MAX_NODES, AI_SITE_IMPORT_LABEL_CHARS, aiSiteImportDocLines, aiSiteImportTextParts, aiSiteImportWordsIn } from "./ai-site-import-document.js";
|
|
65
67
|
const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim() : '';
|
|
66
68
|
/** Whether a block is a line of the page: a link inside a sentence is in its sentence. */ function isLine(block) {
|
|
@@ -478,6 +480,21 @@ const OPEN_STYLES = new Set([
|
|
|
478
480
|
if (measure && measure !== 'xl') out.measure = measure;
|
|
479
481
|
return Object.keys(out).length ? out : undefined;
|
|
480
482
|
}
|
|
483
|
+
/** A picture's alt text where it describes the picture: a file's name does not (AGL-4152). */ const described = (alt)=>{
|
|
484
|
+
const text = clean(alt != null ? alt : '');
|
|
485
|
+
return text && !aiSiteImportAltIsFileName(text) ? text : '';
|
|
486
|
+
};
|
|
487
|
+
/**
|
|
488
|
+
* What a picture whose source named it only by its file is described as
|
|
489
|
+
* (AGL-4152): the page it is on and which of its pictures it is, which is
|
|
490
|
+
* all that is known of it, never a guess at what it shows. Empty where the
|
|
491
|
+
* page has no title, so the picture is drawn as decoration.
|
|
492
|
+
*/ export function aiSiteImportPhotoAlt(doc, ref) {
|
|
493
|
+
const title = clean(doc.title);
|
|
494
|
+
if (!title) return '';
|
|
495
|
+
const at = doc.blocks.slice(0, ref + 1).filter((block)=>block.kind === 'image').length;
|
|
496
|
+
return `${title} photo ${Math.max(1, at)}`;
|
|
497
|
+
}
|
|
481
498
|
/** A picture line as the library holds it; marks it taken, and missing where the library holds none. */ export function aiSiteImportTakePicture(scope, ref, href, fit) {
|
|
482
499
|
if (ref === undefined || scope.used.has(ref)) return null;
|
|
483
500
|
const block = scope.doc.blocks[ref];
|
|
@@ -488,7 +505,7 @@ const OPEN_STYLES = new Set([
|
|
|
488
505
|
scope.missing.add(ref);
|
|
489
506
|
return null;
|
|
490
507
|
}
|
|
491
|
-
const alt =
|
|
508
|
+
const alt = (described(block.alt) || described(photo.alt) || (aiSiteImportAltIsFileName(block.alt || photo.alt) ? aiSiteImportPhotoAlt(scope.doc, ref) : '')).slice(0, 200);
|
|
492
509
|
const ratio = photo.width && photo.height ? photo.width / photo.height : 0;
|
|
493
510
|
const to = aiSiteImportLinkTo(scope, href);
|
|
494
511
|
const framed = pictureFitOf(photo, fit);
|
|
@@ -1534,6 +1551,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
|
|
|
1534
1551
|
const pageFilm = layout.sections.reduce((found, section)=>found != null ? found : firstFilm(scope, section.nodes), null);
|
|
1535
1552
|
const sections = layout.sections.map((section, index)=>{
|
|
1536
1553
|
var _ref, _firstFilm, _section_absoluteBand, _ref1, _ref2;
|
|
1554
|
+
var _doc_plan_nav_primaryCta, _doc_plan;
|
|
1537
1555
|
const given = (_ref = answer == null ? void 0 : answer.sections[index]) != null ? _ref : null;
|
|
1538
1556
|
scope.answer = given;
|
|
1539
1557
|
scope.groupAt = 0;
|
|
@@ -1585,6 +1603,18 @@ const HEX = /^#[0-9a-f]{6}$/i;
|
|
|
1585
1603
|
const source = reading ? 'start' : section.align;
|
|
1586
1604
|
// The source's own heading measure for its opening's words, on a page kept as it is (AGL-4152).
|
|
1587
1605
|
const measure = hero && !improve ? aiSiteImportHeroMeasure(section) : null;
|
|
1606
|
+
const cols = row.cols && blocks.some((block)=>block.col !== undefined) ? row.cols : undefined;
|
|
1607
|
+
// Improved, each call to action once and in its place, as a redesign's are (AGL-4152): a page whose
|
|
1608
|
+
// redesign fell back keeps its layout, never each review's own "See more reviews".
|
|
1609
|
+
const tidy = improve ? aiSiteImportSectionActions(_extends({}, cols ? {
|
|
1610
|
+
cols
|
|
1611
|
+
} : {}, {
|
|
1612
|
+
blocks: mergeLists(blocks)
|
|
1613
|
+
}), (_doc_plan = doc.plan) == null ? void 0 : (_doc_plan_nav_primaryCta = _doc_plan.nav.primaryCta) == null ? void 0 : _doc_plan_nav_primaryCta.label) : _extends({}, cols ? {
|
|
1614
|
+
cols
|
|
1615
|
+
} : {}, {
|
|
1616
|
+
blocks: mergeLists(blocks)
|
|
1617
|
+
});
|
|
1588
1618
|
return _extends({
|
|
1589
1619
|
band,
|
|
1590
1620
|
// Kept as it is, a section keeps the source's alignment (AGL-4152); improved, the answer's.
|
|
@@ -1592,10 +1622,10 @@ const HEX = /^#[0-9a-f]{6}$/i;
|
|
|
1592
1622
|
// As wide as the source runs (AGL-4083), or the theme's own on a page its owner asked improved (AGL-4152);
|
|
1593
1623
|
// where it sets no cap, a page's width, a long read's measure.
|
|
1594
1624
|
width: (_ref2 = improve ? null : siteImportWidthOf(section.width)) != null ? _ref2 : reading ? 'md' : 'lg'
|
|
1595
|
-
},
|
|
1596
|
-
cols:
|
|
1625
|
+
}, tidy.cols ? {
|
|
1626
|
+
cols: tidy.cols
|
|
1597
1627
|
} : {}, {
|
|
1598
|
-
blocks:
|
|
1628
|
+
blocks: tidy.blocks
|
|
1599
1629
|
}, hero ? {
|
|
1600
1630
|
hero
|
|
1601
1631
|
} : {}, measure ? {
|