@aglyn/plugins-ai 1.12.0 → 1.14.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-media-create.component.js +1 -1
- package/src/lib/components/ai-media-create.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.js +1 -1
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.js +11 -1
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +23 -3
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +19 -4
- package/src/lib/jobs/ai-site-import-look.js +142 -45
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/jobs/ai-theme-brand-inputs.d.ts +12 -0
- package/src/lib/jobs/ai-theme-brand-inputs.js +1 -1
- package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +90 -8
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +8 -2
- package/src/lib/layout-language/ai-layout-language.js +4 -2
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +9 -0
- package/src/lib/model/ai-site-import-fidelity.js +64 -6
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +36 -1
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-upsell-copy.js +1 -1
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/runtime/site-inventory.js +2 -3
- package/src/lib/runtime/site-inventory.js.map +1 -1
- package/src/lib/server/assist-view-context.js +3 -3
- package/src/lib/server/assist-view-context.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +12 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +19 -9
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +32 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +55 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-concealed.d.ts +30 -0
- package/src/lib/site-import/site-import-concealed.js +231 -0
- package/src/lib/site-import/site-import-concealed.js.map +1 -0
- package/src/lib/site-import/site-import-crawl.d.ts +5 -1
- package/src/lib/site-import/site-import-crawl.js +35 -18
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +81 -0
- package/src/lib/site-import/site-import-css.js +456 -27
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-data-forms.d.ts +32 -0
- package/src/lib/site-import/site-import-data-forms.js +531 -0
- package/src/lib/site-import/site-import-data-forms.js.map +1 -0
- package/src/lib/site-import/site-import-html.d.ts +36 -1
- package/src/lib/site-import/site-import-html.js +264 -54
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +1 -1
- package/src/lib/site-import/site-import-layout.js +490 -44
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-nav.js +17 -3
- package/src/lib/site-import/site-import-nav.js.map +1 -1
- package/src/lib/site-import/site-import-page.js +2 -0
- package/src/lib/site-import/site-import-page.js.map +1 -1
- package/src/lib/testing/stand-in-dataset-index.js +6 -2
- package/src/lib/testing/stand-in-dataset-index.js.map +1 -1
|
@@ -29,7 +29,8 @@ export declare const AI_SITE_IMPORT_LOGO_HEIGHT = 192;
|
|
|
29
29
|
export declare const AI_SITE_IMPORT_LOGO_MAX_BYTES: number;
|
|
30
30
|
type Fetch = (url: string, options: PublicFetchOptions) => Promise<PublicFetchResult>;
|
|
31
31
|
/**
|
|
32
|
-
* The home page and its
|
|
32
|
+
* The home page and its stylesheets, every one to the crawl's byte budget
|
|
33
|
+
* (AGL-4152), read as AglynBot (AGL-4084).
|
|
33
34
|
* `headersFor` is asked for every request and every redirect hop, as the
|
|
34
35
|
* crawl asks it (`aiSiteImportLookHeaders`: the edge header only to the
|
|
35
36
|
* site's own origins). `null` when the page cannot be read.
|
|
@@ -56,7 +57,7 @@ export declare function aiSiteImportBrandColors(page: Pick<AiReferencePage, 'htm
|
|
|
56
57
|
* (`aiSiteColors`): aglyn.com's light blue buttons, under white words at
|
|
57
58
|
* 2.4:1, come out at the deeper blue of its own links.
|
|
58
59
|
*/
|
|
59
|
-
export declare function aiSiteImportBrandOf(facts: Pick<SiteImportLookFacts, 'buttonFill' | 'link'> | null | undefined): {
|
|
60
|
+
export declare function aiSiteImportBrandOf(facts: (Pick<SiteImportLookFacts, 'buttonFill' | 'link'> & Pick<Partial<SiteImportLookFacts>, 'palette'>) | null | undefined): {
|
|
60
61
|
brand: string;
|
|
61
62
|
accent: string | null;
|
|
62
63
|
} | null;
|
|
@@ -66,8 +67,11 @@ export declare function aiSiteImportBrandOf(facts: Pick<SiteImportLookFacts, 'bu
|
|
|
66
67
|
* strongest color as the brand. What the reader found of its look
|
|
67
68
|
* (`facts`, AGL-4108) pins it closer: its buttons' fill as the brand and its
|
|
68
69
|
* links' color as the accent, its eyebrows' own color as the third, and its
|
|
69
|
-
* own fonts where the catalog has them (`fonts`).
|
|
70
|
-
*
|
|
70
|
+
* own fonts where the catalog has them (`fonts`). Its pictures' colors
|
|
71
|
+
* (`pictures`, AGL-4152) stand in for a brand where its facts show none. `null`
|
|
72
|
+
* where nothing showed a color to carry a brand, unless asked to draw the look
|
|
73
|
+
* from the seed alone (`draw`), which the pass does rather than leave the site
|
|
74
|
+
* in the stock theme.
|
|
71
75
|
*
|
|
72
76
|
* How the owner asked the site to be finished (AGL-4152) says what else:
|
|
73
77
|
* - **Keep my site** (`keep`, and an import that names none) pins the rest
|
|
@@ -85,6 +89,8 @@ export declare function aiSiteImportStyle(site: AiSiteInspirationSite | null, in
|
|
|
85
89
|
facts?: SiteImportLookFacts | null;
|
|
86
90
|
fonts?: AiSiteStyle['sourceFonts'];
|
|
87
91
|
finish?: AiSiteImportFinish | null;
|
|
92
|
+
pictures?: readonly string[];
|
|
93
|
+
draw?: boolean;
|
|
88
94
|
}): AiSiteStyle | null;
|
|
89
95
|
/** A family's facts, as the theme font catalog answers them. */
|
|
90
96
|
export type AiSiteImportFontFacts = (family: string) => Promise<ThemeFontFacts | undefined>;
|
|
@@ -122,7 +128,16 @@ export interface AiSiteImportLookDeps {
|
|
|
122
128
|
writeHost?: (firestore: FirebaseFirestore.Firestore, hostId: string, updates: Record<string, unknown>) => Promise<void>;
|
|
123
129
|
/** Re-fans the rows every site list reads a site's icon from (AGL-3972), after the look sets one. */
|
|
124
130
|
syncMemberships?: (orgId: string, hostId: string) => Promise<void>;
|
|
131
|
+
/** A picture in the library's dominant colors (AGL-4152); `null` where it cannot be read. */
|
|
132
|
+
pictureColors?: AiSiteImportPictureColors;
|
|
125
133
|
}
|
|
134
|
+
/** A picture in the site's library's dominant colors (`dominantColorsFromPixels`). */
|
|
135
|
+
export type AiSiteImportPictureColors = (photo: AiSiteImportPhoto, input: {
|
|
136
|
+
firestore: FirebaseFirestore.Firestore;
|
|
137
|
+
hostId: string;
|
|
138
|
+
orgId: string;
|
|
139
|
+
signal?: AbortSignal;
|
|
140
|
+
}) => Promise<readonly string[] | null>;
|
|
126
141
|
/** The most pictures the home page's menus bring into the library (AGL-4139). */
|
|
127
142
|
export declare const AI_SITE_IMPORT_MENU_PICTURES = 4;
|
|
128
143
|
/** The pictures the home page's menus show (AGL-4139), each once, the first few: a featured card's. */
|
|
@@ -43,9 +43,15 @@
|
|
|
43
43
|
* listing it was created with: an owner's own words are never written
|
|
44
44
|
* over.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* A bare read never leaves the stock theme (AGL-4152). A source with no color
|
|
47
|
+
* of its own to read (no colorful button, link or declared palette) takes its brand from its logo's dominant colorful hue, then its hero photo's,
|
|
48
|
+
* read from the library's copy. With no picture to read either, what its
|
|
49
|
+
* stylesheets use most decides, and with none of that the site still gets the
|
|
50
|
+
* seed's own look for its kind of site, as a guided start with no answer does,
|
|
51
|
+
* and the look says so (`from`). An owner's chosen theme is still kept.
|
|
52
|
+
*
|
|
53
|
+
* Nothing here fails a wave: a logo that cannot be brought in leaves the header
|
|
54
|
+
* its name.
|
|
49
55
|
*=========================================*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
50
56
|
import { themeFontFacts } from "@aglyn/aglyn/plugin-manager/plugin-theme-font-catalog";
|
|
51
57
|
import { syncHostProjectionForMembers } from "@aglyn/tenant-data-admin/server/host-memberships";
|
|
@@ -54,17 +60,21 @@ import { aiSiteKindFor } from "../model/ai-site-kinds.js";
|
|
|
54
60
|
import { aiHexOklch, aiSiteSeed, aiSiteStyleFor } from "../model/ai-site-look.js";
|
|
55
61
|
import { aiSiteIsStarterSrc } from "../model/ai-site-photos.js";
|
|
56
62
|
import { AGLYN_BOT_USER_AGENT, siteImportOrigins } from "../site-import/site-import-crawl.js";
|
|
63
|
+
import { siteImportReadStylesheets } from "../site-import/site-import-css.js";
|
|
57
64
|
import { NO_SITE_IMPORT_HEADERS, siteImportEdgeHeadersFor } from "../site-import/site-import-edge.js";
|
|
65
|
+
import { siteImportStylesheetLinks } from "../site-import/site-import-html.js";
|
|
58
66
|
import { bringInSiteImportPhotos, siteImportImageKey, siteImportLogoUrl } from "../site-import/site-import-images.js";
|
|
59
67
|
import { aiSaveSiteTheme, aiWorkspaceSiteStyles } from "./ai-job-site-look.js";
|
|
60
68
|
import { aiSiteInspirationLookPins } from "./ai-site-inspiration.js";
|
|
61
69
|
import { aiSiteInspirationSignals } from "./ai-site-inspiration-signals.js";
|
|
62
|
-
import { AI_THEME_BRAND_COLORS_PER_SOURCE, AI_THEME_REFERENCE_MAX_BYTES,
|
|
70
|
+
import { AI_THEME_BRAND_COLORS_PER_SOURCE, AI_THEME_REFERENCE_MAX_BYTES, AI_THEME_THEME_COLOR_WEIGHT, fetchPublicTextDetailed, logoMediaLocation, rankBrandColors, readLogoColors } from "./ai-theme-brand-inputs.js";
|
|
63
71
|
/** The height an SVG logo is drawn at as a picture: crisp at twice the header's 40. */ export const AI_SITE_IMPORT_LOGO_HEIGHT = 192;
|
|
64
72
|
/** The largest logo file read. */ export const AI_SITE_IMPORT_LOGO_MAX_BYTES = 1024 * 1024;
|
|
65
73
|
/** One read's own clock in the look pass. */ const LOOK_READ_MS = 8000;
|
|
74
|
+
/** The clock on starting the home page's stylesheets' reads: however many it links, a pass waits no longer than this and one read's own. */ const LOOK_SHEETS_MS = 12000;
|
|
66
75
|
/**
|
|
67
|
-
* The home page and its
|
|
76
|
+
* The home page and its stylesheets, every one to the crawl's byte budget
|
|
77
|
+
* (AGL-4152), read as AglynBot (AGL-4084).
|
|
68
78
|
* `headersFor` is asked for every request and every redirect hop, as the
|
|
69
79
|
* crawl asks it (`aiSiteImportLookHeaders`: the edge header only to the
|
|
70
80
|
* site's own origins). `null` when the page cannot be read.
|
|
@@ -84,11 +94,10 @@ import { AI_THEME_BRAND_COLORS_PER_SOURCE, AI_THEME_REFERENCE_MAX_BYTES, AI_THEM
|
|
|
84
94
|
} : {})).catch(()=>null);
|
|
85
95
|
const page = await read(url, AI_THEME_REFERENCE_MAX_BYTES, /text\/html|application\/xhtml\+xml/i);
|
|
86
96
|
if (!(page == null ? void 0 : page.ok)) return null;
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
97
|
+
const startedAt = Date.now();
|
|
98
|
+
const stylesheets = await siteImportReadStylesheets(siteImportStylesheetLinks(page.text, page.url), (sheet, maxBytes)=>read(sheet, maxBytes, /text\/css|text\/plain/i), {
|
|
99
|
+
outOfTime: ()=>Date.now() - startedAt >= LOOK_SHEETS_MS
|
|
100
|
+
});
|
|
92
101
|
return {
|
|
93
102
|
url: page.url,
|
|
94
103
|
html: page.text,
|
|
@@ -147,13 +156,16 @@ const colorful = (hex)=>!!hex && /^#[0-9a-f]{6}$/i.test(hex) && aiHexOklch(hex).
|
|
|
147
156
|
* (`aiSiteColors`): aglyn.com's light blue buttons, under white words at
|
|
148
157
|
* 2.4:1, come out at the deeper blue of its own links.
|
|
149
158
|
*/ export function aiSiteImportBrandOf(facts) {
|
|
159
|
+
var _ref, _ref1, _ref2;
|
|
150
160
|
const fill = colorful(facts == null ? void 0 : facts.buttonFill) ? (facts == null ? void 0 : facts.buttonFill).toLowerCase() : null;
|
|
151
161
|
const link = colorful(facts == null ? void 0 : facts.link) ? (facts == null ? void 0 : facts.link).toLowerCase() : null;
|
|
152
|
-
|
|
162
|
+
// What its root declares its brand to be (AGL-4152), where nothing on its home page draws it.
|
|
163
|
+
const palette = ((_ref = facts == null ? void 0 : facts.palette) != null ? _ref : []).filter(colorful).map((hex)=>hex.toLowerCase());
|
|
164
|
+
const brand = (_ref1 = fill != null ? fill : link) != null ? _ref1 : palette[0];
|
|
153
165
|
if (!brand) return null;
|
|
154
166
|
return {
|
|
155
167
|
brand,
|
|
156
|
-
accent: link && link !== brand ? link : null
|
|
168
|
+
accent: (_ref2 = link && link !== brand ? link : palette.find((hex)=>hex !== brand)) != null ? _ref2 : null
|
|
157
169
|
};
|
|
158
170
|
}
|
|
159
171
|
const solidHex = (value)=>value && /^#[0-9a-f]{6}$/i.test(value) ? value.toLowerCase() : null;
|
|
@@ -163,8 +175,11 @@ const solidHex = (value)=>value && /^#[0-9a-f]{6}$/i.test(value) ? value.toLower
|
|
|
163
175
|
* strongest color as the brand. What the reader found of its look
|
|
164
176
|
* (`facts`, AGL-4108) pins it closer: its buttons' fill as the brand and its
|
|
165
177
|
* links' color as the accent, its eyebrows' own color as the third, and its
|
|
166
|
-
* own fonts where the catalog has them (`fonts`).
|
|
167
|
-
*
|
|
178
|
+
* own fonts where the catalog has them (`fonts`). Its pictures' colors
|
|
179
|
+
* (`pictures`, AGL-4152) stand in for a brand where its facts show none. `null`
|
|
180
|
+
* where nothing showed a color to carry a brand, unless asked to draw the look
|
|
181
|
+
* from the seed alone (`draw`), which the pass does rather than leave the site
|
|
182
|
+
* in the stock theme.
|
|
168
183
|
*
|
|
169
184
|
* How the owner asked the site to be finished (AGL-4152) says what else:
|
|
170
185
|
* - **Keep my site** (`keep`, and an import that names none) pins the rest
|
|
@@ -175,11 +190,16 @@ const solidHex = (value)=>value && /^#[0-9a-f]{6}$/i.test(value) ? value.toLower
|
|
|
175
190
|
* and the fonts, so the base that suits the kind of site shows with its own
|
|
176
191
|
* corners, buttons, grounds and eyebrows.
|
|
177
192
|
*/ export function aiSiteImportStyle(site, input) {
|
|
178
|
-
var _input_facts, _input_avoid;
|
|
193
|
+
var _input_facts, _ref, _aiSiteImportBrandOf, _input_avoid;
|
|
194
|
+
var _input_pictures, _input_pictures_;
|
|
179
195
|
const facts = (_input_facts = input.facts) != null ? _input_facts : null;
|
|
180
196
|
const finish = input.finish === 'improve' ? 'improve' : 'keep';
|
|
181
|
-
const
|
|
182
|
-
|
|
197
|
+
const pictured = ((_input_pictures = input.pictures) == null ? void 0 : _input_pictures[0]) ? {
|
|
198
|
+
brand: input.pictures[0].toLowerCase(),
|
|
199
|
+
accent: (_ref = (_input_pictures_ = input.pictures[1]) == null ? void 0 : _input_pictures_.toLowerCase()) != null ? _ref : null
|
|
200
|
+
} : null;
|
|
201
|
+
const own = (_aiSiteImportBrandOf = aiSiteImportBrandOf(facts)) != null ? _aiSiteImportBrandOf : pictured;
|
|
202
|
+
if (!site && !own && !input.draw) return null;
|
|
183
203
|
const kind = aiSiteKindFor(input.description);
|
|
184
204
|
const signals = site ? aiSiteInspirationLookPins({
|
|
185
205
|
v: 1,
|
|
@@ -218,7 +238,7 @@ const solidHex = (value)=>value && /^#[0-9a-f]{6}$/i.test(value) ? value.toLower
|
|
|
218
238
|
// it — and their own color, where it is one, as the theme's third.
|
|
219
239
|
if (facts && finish === 'keep') pins.eyebrow = 'caps';
|
|
220
240
|
if (colorful(facts == null ? void 0 : facts.eyebrow)) pins.tertiary = (facts == null ? void 0 : facts.eyebrow).toLowerCase();
|
|
221
|
-
if (!pins.brand) return null;
|
|
241
|
+
if (!pins.brand && !input.draw) return null;
|
|
222
242
|
const style = aiSiteStyleFor({
|
|
223
243
|
kind,
|
|
224
244
|
answer: {},
|
|
@@ -326,6 +346,26 @@ const solidHex = (value)=>value && /^#[0-9a-f]{6}$/i.test(value) ? value.toLower
|
|
|
326
346
|
if (image === undefined || image === null) return true;
|
|
327
347
|
return typeof image === 'string' && (!image.trim() || aiSiteIsStarterSrc(image));
|
|
328
348
|
}
|
|
349
|
+
/** The library's copy of a picture, decoded where `sharp` is shipped (`readLogoColors`, AGL-4048). */ const pictureColorsOf = async (photo, { firestore, hostId, orgId, signal })=>{
|
|
350
|
+
const location = logoMediaLocation(photo.src, hostId, orgId);
|
|
351
|
+
if (!location) return null;
|
|
352
|
+
return readLogoColors(firestore, location, hostId, AbortSignal.any([
|
|
353
|
+
AbortSignal.timeout(LOOK_READ_MS),
|
|
354
|
+
...signal ? [
|
|
355
|
+
signal
|
|
356
|
+
] : []
|
|
357
|
+
]));
|
|
358
|
+
};
|
|
359
|
+
/** A read of a picture's colorful colors: none where it has none, or cannot be read. */ async function colorfulColorsOf(photo, read, input) {
|
|
360
|
+
const colors = await read(photo, input).catch((error)=>{
|
|
361
|
+
console.warn('[site-import] a picture’s colors could not be read', {
|
|
362
|
+
hostId: input.hostId,
|
|
363
|
+
error
|
|
364
|
+
});
|
|
365
|
+
return null;
|
|
366
|
+
});
|
|
367
|
+
return (colors != null ? colors : []).filter(colorful).map((hex)=>hex.toLowerCase());
|
|
368
|
+
}
|
|
329
369
|
/** The most pictures the home page's menus bring into the library (AGL-4139). */ export const AI_SITE_IMPORT_MENU_PICTURES = 4;
|
|
330
370
|
/** The pictures the home page's menus show (AGL-4139), each once, the first few: a featured card's. */ export function aiSiteImportMenuPictures(home) {
|
|
331
371
|
var _ref;
|
|
@@ -449,7 +489,7 @@ async function writeHostDoc(firestore, hostId, updates) {
|
|
|
449
489
|
}
|
|
450
490
|
}
|
|
451
491
|
/** The look pass (AGL-4084): the theme, the logo and the listing, from the owner's own home page. No model. */ export async function aiRunSiteImportLook(input, deps = {}) {
|
|
452
|
-
var _deps_others, _home_look, _input_finish,
|
|
492
|
+
var _deps_others, _home_look, _deps_ingest, _input_finish, _deps_save, _deps_readHost, _facts_palette, _ref;
|
|
453
493
|
const { firestore, hostId, home } = input;
|
|
454
494
|
const headersFor = await aiSiteImportLookHeaders(input.domain, deps);
|
|
455
495
|
const seed = aiSiteSeed(input.jobId);
|
|
@@ -472,25 +512,6 @@ async function writeHostDoc(firestore, hostId, updates) {
|
|
|
472
512
|
// What the reader found of its look, its buttons, ground and fonts (AGL-4108).
|
|
473
513
|
const facts = (_home_look = home.look) != null ? _home_look : null;
|
|
474
514
|
const fonts = await aiSiteImportSourceFonts(facts, deps.fontFacts);
|
|
475
|
-
const style = aiSiteImportStyle(site, {
|
|
476
|
-
seed,
|
|
477
|
-
description: `${home.siteName} ${home.description}`,
|
|
478
|
-
avoid,
|
|
479
|
-
facts,
|
|
480
|
-
fonts,
|
|
481
|
-
finish: (_input_finish = input.finish) != null ? _input_finish : null
|
|
482
|
-
});
|
|
483
|
-
let theme = 'unread';
|
|
484
|
-
if (style) {
|
|
485
|
-
var _deps_save;
|
|
486
|
-
const saved = await ((_deps_save = deps.save) != null ? _deps_save : aiSaveSiteTheme)(firestore, {
|
|
487
|
-
hostId,
|
|
488
|
-
jobId: input.jobId,
|
|
489
|
-
style
|
|
490
|
-
});
|
|
491
|
-
if (saved.write === 'missing') throw new Error(`site ${hostId} vanished while its look was brought in`);
|
|
492
|
-
theme = saved.write === 'kept' ? 'kept' : 'applied';
|
|
493
|
-
}
|
|
494
515
|
const ingest = (_deps_ingest = deps.ingest) != null ? _deps_ingest : null;
|
|
495
516
|
const logo = home.brand.logo ? await aiSiteImportLogo(_extends({
|
|
496
517
|
hostId,
|
|
@@ -508,9 +529,82 @@ async function writeHostDoc(firestore, hostId, updates) {
|
|
|
508
529
|
} : {}, deps.rasterize ? {
|
|
509
530
|
rasterize: deps.rasterize
|
|
510
531
|
} : {})) : null;
|
|
532
|
+
// No color of its own (AGL-4152): its logo's colorful colors, else its hero photo's, else its share picture's.
|
|
533
|
+
let pictures = [];
|
|
534
|
+
let from = 'source';
|
|
535
|
+
if (!aiSiteImportBrandOf(facts)) {
|
|
536
|
+
var _deps_pictureColors;
|
|
537
|
+
const read = (_deps_pictureColors = deps.pictureColors) != null ? _deps_pictureColors : pictureColorsOf;
|
|
538
|
+
const asked = _extends({
|
|
539
|
+
firestore,
|
|
540
|
+
hostId,
|
|
541
|
+
orgId: input.orgId
|
|
542
|
+
}, input.signal ? {
|
|
543
|
+
signal: input.signal
|
|
544
|
+
} : {});
|
|
545
|
+
const ofLogo = logo ? await colorfulColorsOf(logo, read, asked) : [];
|
|
546
|
+
if (ofLogo.length) {
|
|
547
|
+
pictures = ofLogo.slice(0, 2);
|
|
548
|
+
from = 'logo';
|
|
549
|
+
} else {
|
|
550
|
+
for (const image of [
|
|
551
|
+
home.hero,
|
|
552
|
+
home.ogImage ? {
|
|
553
|
+
url: home.ogImage,
|
|
554
|
+
alt: ''
|
|
555
|
+
} : null
|
|
556
|
+
]){
|
|
557
|
+
if (!image) continue;
|
|
558
|
+
const { assets } = await bringInSiteImportPhotos(_extends({
|
|
559
|
+
hostId,
|
|
560
|
+
uid: input.uid,
|
|
561
|
+
domain: input.domain,
|
|
562
|
+
images: [
|
|
563
|
+
image
|
|
564
|
+
],
|
|
565
|
+
deadlineAt: Date.now() + LOOK_READ_MS
|
|
566
|
+
}, input.signal ? {
|
|
567
|
+
signal: input.signal
|
|
568
|
+
} : {}), _extends({
|
|
569
|
+
ingest
|
|
570
|
+
}, deps.fetch ? {
|
|
571
|
+
fetch: deps.fetch
|
|
572
|
+
} : {}));
|
|
573
|
+
const ofPhoto = assets[0] ? await colorfulColorsOf(assets[0], read, asked) : [];
|
|
574
|
+
if (!ofPhoto.length) continue;
|
|
575
|
+
pictures = ofPhoto.slice(0, 1);
|
|
576
|
+
from = 'photo';
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
const described = {
|
|
582
|
+
seed,
|
|
583
|
+
description: `${home.siteName} ${home.description}`,
|
|
584
|
+
avoid,
|
|
585
|
+
facts,
|
|
586
|
+
fonts,
|
|
587
|
+
finish: (_input_finish = input.finish) != null ? _input_finish : null,
|
|
588
|
+
pictures
|
|
589
|
+
};
|
|
590
|
+
let style = aiSiteImportStyle(site, described);
|
|
591
|
+
// Nothing anywhere to read a color from: the seed's look for its kind, never the stock theme.
|
|
592
|
+
if (!style) {
|
|
593
|
+
style = aiSiteImportStyle(site, _extends({}, described, {
|
|
594
|
+
draw: true
|
|
595
|
+
}));
|
|
596
|
+
from = 'seed';
|
|
597
|
+
}
|
|
598
|
+
const saved = await ((_deps_save = deps.save) != null ? _deps_save : aiSaveSiteTheme)(firestore, {
|
|
599
|
+
hostId,
|
|
600
|
+
jobId: input.jobId,
|
|
601
|
+
style
|
|
602
|
+
});
|
|
603
|
+
if (saved.write === 'missing') throw new Error(`site ${hostId} vanished while its look was brought in`);
|
|
604
|
+
const theme = saved.write === 'kept' ? 'kept' : 'applied';
|
|
511
605
|
// The pictures its menus show, in the library like its pages' photos (AGL-4139), for the header's panels.
|
|
512
606
|
const menuImages = aiSiteImportMenuPictures(home);
|
|
513
|
-
const
|
|
607
|
+
const menuPictures = menuImages.length ? (await bringInSiteImportPhotos(_extends({
|
|
514
608
|
hostId,
|
|
515
609
|
uid: input.uid,
|
|
516
610
|
domain: input.domain,
|
|
@@ -593,33 +687,36 @@ async function writeHostDoc(firestore, hostId, updates) {
|
|
|
593
687
|
}
|
|
594
688
|
}
|
|
595
689
|
}
|
|
596
|
-
const drawn =
|
|
690
|
+
const drawn = _extends({}, typeof style.headerAlign === 'string' ? {
|
|
597
691
|
headerAlign: style.headerAlign
|
|
598
692
|
} : {}, typeof style.rhythm === 'string' ? {
|
|
599
693
|
rhythm: style.rhythm
|
|
600
694
|
} : {}, typeof style.motion === 'string' ? {
|
|
601
695
|
motion: style.motion
|
|
602
|
-
} : {})
|
|
696
|
+
} : {});
|
|
603
697
|
const colors = [
|
|
604
698
|
...new Set([
|
|
605
699
|
...facts ? [
|
|
606
700
|
facts.buttonFill,
|
|
607
701
|
facts.link,
|
|
608
|
-
facts.eyebrow
|
|
702
|
+
facts.eyebrow,
|
|
703
|
+
...(_facts_palette = facts.palette) != null ? _facts_palette : []
|
|
609
704
|
].filter(colorful).map((hex)=>hex.toLowerCase()) : [],
|
|
705
|
+
...pictures,
|
|
610
706
|
...(_ref = site == null ? void 0 : site.colors) != null ? _ref : []
|
|
611
707
|
])
|
|
612
708
|
];
|
|
613
709
|
return _extends({
|
|
614
710
|
at: input.at,
|
|
615
711
|
theme,
|
|
712
|
+
from,
|
|
616
713
|
colors,
|
|
617
714
|
logo
|
|
618
|
-
},
|
|
619
|
-
pictures
|
|
715
|
+
}, menuPictures.length ? {
|
|
716
|
+
pictures: menuPictures
|
|
620
717
|
} : {}, {
|
|
621
718
|
seo,
|
|
622
|
-
seed: style
|
|
719
|
+
seed: style.seed,
|
|
623
720
|
style: drawn
|
|
624
721
|
});
|
|
625
722
|
}
|