@aglyn/plugins-ai 1.9.1 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/components/ai-job-requests.d.ts +5 -0
- package/src/lib/components/ai-job-requests.js +4 -0
- package/src/lib/components/ai-job-requests.js.map +1 -1
- package/src/lib/components/ai-site-build-page.component.js +10 -3
- package/src/lib/components/ai-site-build-page.component.js.map +1 -1
- package/src/lib/components/ai-site-import-finish.component.d.ts +40 -0
- package/src/lib/components/ai-site-import-finish.component.js +174 -0
- package/src/lib/components/ai-site-import-finish.component.js.map +1 -0
- package/src/lib/components/ai-site-import-job.component.d.ts +11 -3
- package/src/lib/components/ai-site-import-job.component.js +220 -135
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/components/ai-site-import-start.component.d.ts +11 -2
- package/src/lib/components/ai-site-import-start.component.js +27 -5
- package/src/lib/components/ai-site-import-start.component.js.map +1 -1
- package/src/lib/components/ai-site-start-card.component.js +1 -1
- package/src/lib/components/ai-site-start-card.component.js.map +1 -1
- package/src/lib/jobs/ai-build-capabilities.js +2 -2
- package/src/lib/jobs/ai-build-capabilities.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +2 -0
- package/src/lib/jobs/ai-job-import-step.js +31 -8
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.d.ts +40 -2
- package/src/lib/jobs/ai-job-page-language.js +188 -9
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.js +2 -0
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-privacy-step.d.ts +5 -0
- package/src/lib/jobs/ai-job-privacy-step.js +9 -4
- package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
- package/src/lib/jobs/ai-job-text-step.d.ts +7 -1
- package/src/lib/jobs/ai-job-text-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.d.ts +13 -2
- package/src/lib/jobs/ai-site-import-compile.js +115 -21
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +5 -1
- package/src/lib/jobs/ai-site-import-document.js +5 -1
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +16 -4
- package/src/lib/jobs/ai-site-import-look.js +54 -13
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/jobs/ai-site-import-wording.d.ts +187 -0
- package/src/lib/jobs/ai-site-import-wording.js +747 -0
- package/src/lib/jobs/ai-site-import-wording.js.map +1 -0
- package/src/lib/layout-language/ai-layout-compiler.d.ts +12 -1
- package/src/lib/layout-language/ai-layout-compiler.js +29 -30
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +211 -2
- package/src/lib/model/ai-site-import-fidelity.js +1011 -14
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-report.d.ts +52 -1
- package/src/lib/model/ai-site-import-report.js +102 -5
- package/src/lib/model/ai-site-import-report.js.map +1 -1
- package/src/lib/model/ai-site-import-view.d.ts +62 -2
- package/src/lib/model/ai-site-import-view.js +83 -4
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +122 -6
- package/src/lib/model/ai-site-import.js +202 -9
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +51 -0
- package/src/lib/model/ai-site-look.js +205 -29
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +19 -0
- package/src/lib/runtime/ai-doctrine-validators.js +25 -0
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-doctrine.js +4 -1
- package/src/lib/runtime/ai-doctrine.js.map +1 -1
- package/src/lib/server/ai-allotments.js +4 -2
- package/src/lib/server/ai-allotments.js.map +1 -1
- package/src/lib/server/ai-jobs-resume.js +32 -5
- package/src/lib/server/ai-jobs-resume.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +36 -10
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +48 -4
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-look-slate.d.ts +27 -0
- package/src/lib/site-import/fixtures/site-look-slate.js +29 -0
- package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -0
- package/src/lib/site-import/site-import-layout.d.ts +19 -5
- package/src/lib/site-import/site-import-layout.js +137 -16
- package/src/lib/site-import/site-import-layout.js.map +1 -1
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import type { AiJobItemLedger } from './ai-jobs.types';
|
|
18
|
+
import type { AiSiteImportFinish, AiSiteImportWords } from './ai-site-import';
|
|
19
|
+
import { type SiteImportFidelityTheme } from './ai-site-import-fidelity';
|
|
18
20
|
type Dict = Record<string, any>;
|
|
19
21
|
/** The look line's facts, as a site stores them and an import ran them. */
|
|
20
22
|
export interface SiteImportLookReport {
|
|
@@ -32,11 +34,60 @@ export interface SiteImportLookReport {
|
|
|
32
34
|
secondary: string | null;
|
|
33
35
|
tertiary: string | null;
|
|
34
36
|
fonts: string[];
|
|
37
|
+
/** What Keep my site pins of the source's look (AGL-4152), source beside theme; absent where the import read no look of its source. */
|
|
38
|
+
pins?: SiteImportLookPins;
|
|
35
39
|
}
|
|
36
40
|
/** The look a site wears: its base theme with what was saved over it, and which job saved it. */
|
|
37
41
|
export declare function siteImportLookReport(host: Dict, state: Dict | null | undefined): SiteImportLookReport;
|
|
38
|
-
/** The look line of the report: what the site wears, and whether it is this job's. */
|
|
42
|
+
/** The look line of the report: what the site wears, and whether it is this job's; and what Keep my site pins, source → theme, where the import read its source's look (AGL-4152). */
|
|
39
43
|
export declare function siteImportLookLine(host: Dict, state: Dict | null | undefined, jobId: string): string;
|
|
44
|
+
/** One pin of the look: the source's, the theme's, and how far apart (OKLab ΔE, for a color). */
|
|
45
|
+
export interface SiteImportLookPin {
|
|
46
|
+
source: string | null;
|
|
47
|
+
theme: string | null;
|
|
48
|
+
delta: number | null;
|
|
49
|
+
}
|
|
50
|
+
/** The look's pins, the source's beside the theme's: its grounds, its filled buttons' fill, label and case. */
|
|
51
|
+
export interface SiteImportLookPins {
|
|
52
|
+
ground: SiteImportLookPin;
|
|
53
|
+
darkGround: SiteImportLookPin;
|
|
54
|
+
buttonFill: SiteImportLookPin;
|
|
55
|
+
buttonText: SiteImportLookPin;
|
|
56
|
+
buttonCase: SiteImportLookPin;
|
|
57
|
+
/** Where the theme's side was read: the site's theme as stored, or computed from its site style. */
|
|
58
|
+
from: SiteImportFidelityTheme['from'] | null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The theme a built site's pages are drawn in, for the fidelity (AGL-4152):
|
|
62
|
+
* the theme it stores, its override resolved; else, where it stores none,
|
|
63
|
+
* one computed from its site style (`siteStyle`) over the starter theme, and
|
|
64
|
+
* marked so. `null` for a site with neither.
|
|
65
|
+
*/
|
|
66
|
+
export declare function siteImportFidelityThemeFor(host: Dict): SiteImportFidelityTheme | null;
|
|
67
|
+
/**
|
|
68
|
+
* What Keep my site pins of the source's look (AGL-4152), the source's as
|
|
69
|
+
* the reader read it (`home.look`) beside the theme's: the page ground, the
|
|
70
|
+
* dark ground, a filled button's fill and label, and its case. `null` where
|
|
71
|
+
* the import read no look of its source.
|
|
72
|
+
*/
|
|
73
|
+
export declare function siteImportLookPins(host: Dict, state: Dict | null | undefined): SiteImportLookPins | null;
|
|
74
|
+
/** The pins as the look line prints them: each source → theme, a color with its ΔE and whether it moved past 0.05. */
|
|
75
|
+
export declare function siteImportLookPinsLine(pins: SiteImportLookPins): string;
|
|
76
|
+
/**
|
|
77
|
+
* How a page of an import was finished (AGL-4152), as the report scores it:
|
|
78
|
+
* what was asked for on the command line, else what its wave was stamped
|
|
79
|
+
* with at its start, else the import's own; an import that names none reads
|
|
80
|
+
* as Keep my site. Its words are improved where the page says so, else where
|
|
81
|
+
* its wave (or the import) improved them under Improve it.
|
|
82
|
+
*/
|
|
83
|
+
export declare function siteImportPageFinish(state: Dict, page: Dict, asked?: {
|
|
84
|
+
finish?: AiSiteImportFinish | null;
|
|
85
|
+
words?: AiSiteImportWords | null;
|
|
86
|
+
}): {
|
|
87
|
+
finish: AiSiteImportFinish;
|
|
88
|
+
words: AiSiteImportWords;
|
|
89
|
+
from: 'asked' | 'wave' | 'import' | 'default';
|
|
90
|
+
};
|
|
40
91
|
/** One kind of page's cost, as `AI_MEASURED_IMPORT_CREDITS` holds it. */
|
|
41
92
|
export interface SiteImportCreditsMeasured {
|
|
42
93
|
count: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
1
2
|
/**
|
|
2
3
|
* @license
|
|
3
4
|
* Copyright 2026 Aglyn LLC
|
|
@@ -23,7 +24,10 @@
|
|
|
23
24
|
* beside it (`aiSaveSiteTheme`). The credits line printed a mean, while the
|
|
24
25
|
* table a quote is made of (`AI_MEASURED_IMPORT_CREDITS`) is a median and a
|
|
25
26
|
* p90.
|
|
26
|
-
*/ import {
|
|
27
|
+
*/ import { DEFAULT_SITE_THEME } from "@aglyn/aglyn/app-utils/default-site";
|
|
28
|
+
import { readThemeOverride, resolveSiteTheme } from "@aglyn/aglyn/app-utils/site-theme";
|
|
29
|
+
import { SITE_IMPORT_GROUND_DELTA, siteImportFidelityThemeOf, siteImportOklabDelta } from "./ai-site-import-fidelity.js";
|
|
30
|
+
import { aiSiteTheme } from "./ai-site-look.js";
|
|
27
31
|
const named = (value)=>typeof value === 'string' && value.trim() ? value : null;
|
|
28
32
|
/** The look a site wears: its base theme with what was saved over it, and which job saved it. */ export function siteImportLookReport(host, state) {
|
|
29
33
|
var _resolveSiteTheme, _ref, _host_siteStyle, _theme_fonts;
|
|
@@ -31,7 +35,8 @@ const named = (value)=>typeof value === 'string' && value.trim() ? value : null;
|
|
|
31
35
|
const theme = (_resolveSiteTheme = resolveSiteTheme(host)) != null ? _resolveSiteTheme : {};
|
|
32
36
|
const light = (_ref = (_theme_colorSchemes = theme['colorSchemes']) == null ? void 0 : _theme_colorSchemes['light']) != null ? _ref : {};
|
|
33
37
|
const style = (_host_siteStyle = host['siteStyle']) != null ? _host_siteStyle : null;
|
|
34
|
-
|
|
38
|
+
const pins = siteImportLookPins(host, state);
|
|
39
|
+
return _extends({
|
|
35
40
|
base: named(style == null ? void 0 : style['base']),
|
|
36
41
|
override: !!readThemeOverride(host),
|
|
37
42
|
jobId: named(style == null ? void 0 : style['jobId']),
|
|
@@ -44,9 +49,11 @@ const named = (value)=>typeof value === 'string' && value.trim() ? value : null;
|
|
|
44
49
|
var _font_family;
|
|
45
50
|
return String((_font_family = font['family']) != null ? _font_family : '');
|
|
46
51
|
}).filter(Boolean)
|
|
47
|
-
}
|
|
52
|
+
}, pins ? {
|
|
53
|
+
pins
|
|
54
|
+
} : {});
|
|
48
55
|
}
|
|
49
|
-
/** The look line of the report: what the site wears, and whether it is this job's. */ export function siteImportLookLine(host, state, jobId) {
|
|
56
|
+
/** The look line of the report: what the site wears, and whether it is this job's; and what Keep my site pins, source → theme, where the import read its source's look (AGL-4152). */ export function siteImportLookLine(host, state, jobId) {
|
|
50
57
|
var _look_base, _look_base1, _look_pass;
|
|
51
58
|
const look = siteImportLookReport(host, state);
|
|
52
59
|
const colors = [
|
|
@@ -61,7 +68,97 @@ const named = (value)=>typeof value === 'string' && value.trim() ? value : null;
|
|
|
61
68
|
const fonts = look.fonts.join(', ') || 'not set';
|
|
62
69
|
const wearing = look.override ? `an override over the ${(_look_base = look.base) != null ? _look_base : 'site'} base` : `the ${(_look_base1 = look.base) != null ? _look_base1 : 'site'} base, no override`;
|
|
63
70
|
const whose = look.jobId ? look.jobId === jobId ? 'saved by this job' : `saved by job ${look.jobId}, not this one` : 'saved by no job';
|
|
64
|
-
return `${(_look_pass = look.pass) != null ? _look_pass : 'not run'}; ${colors}${brand}; ${fonts}; ${wearing}; ${whose}`;
|
|
71
|
+
return `${(_look_pass = look.pass) != null ? _look_pass : 'not run'}; ${colors}${brand}; ${fonts}; ${wearing}; ${whose}${look.pins ? `; ${siteImportLookPinsLine(look.pins)}` : ''}`;
|
|
72
|
+
}
|
|
73
|
+
/** Whether a stored site style holds what its colors are drawn from. */ function isStyle(value) {
|
|
74
|
+
const style = value;
|
|
75
|
+
return !!style && typeof style === 'object' && typeof style.seed === 'number' && typeof style.ground === 'string' && typeof style.chroma === 'string' && typeof style.hue === 'number';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The theme a built site's pages are drawn in, for the fidelity (AGL-4152):
|
|
79
|
+
* the theme it stores, its override resolved; else, where it stores none,
|
|
80
|
+
* one computed from its site style (`siteStyle`) over the starter theme, and
|
|
81
|
+
* marked so. `null` for a site with neither.
|
|
82
|
+
*/ export function siteImportFidelityThemeFor(host) {
|
|
83
|
+
const stored = siteImportFidelityThemeOf(resolveSiteTheme(host), 'theme');
|
|
84
|
+
if (stored) return stored;
|
|
85
|
+
const style = host['siteStyle'];
|
|
86
|
+
return isStyle(style) ? siteImportFidelityThemeOf(aiSiteTheme(style, DEFAULT_SITE_THEME), 'style') : null;
|
|
87
|
+
}
|
|
88
|
+
const hexOrNull = (value)=>typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value) ? value.toLowerCase() : null;
|
|
89
|
+
/** A color pin: the two colors and how far apart. */ function colorPin(source, theme) {
|
|
90
|
+
const from = hexOrNull(source);
|
|
91
|
+
const to = hexOrNull(theme);
|
|
92
|
+
return {
|
|
93
|
+
source: from,
|
|
94
|
+
theme: to,
|
|
95
|
+
delta: from && to ? Math.round(siteImportOklabDelta(from, to) * 1000) / 1000 : null
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* What Keep my site pins of the source's look (AGL-4152), the source's as
|
|
100
|
+
* the reader read it (`home.look`) beside the theme's: the page ground, the
|
|
101
|
+
* dark ground, a filled button's fill and label, and its case. `null` where
|
|
102
|
+
* the import read no look of its source.
|
|
103
|
+
*/ export function siteImportLookPins(host, state) {
|
|
104
|
+
var _ref, _ref1, _ref2, _theme_button_fill, _theme_button_label, _ref3;
|
|
105
|
+
var _state_home, _theme_dark;
|
|
106
|
+
const facts = state == null ? void 0 : (_state_home = state['home']) == null ? void 0 : _state_home['look'];
|
|
107
|
+
if (!facts || typeof facts !== 'object') return null;
|
|
108
|
+
const theme = siteImportFidelityThemeFor(host);
|
|
109
|
+
const wanted = facts['buttonCase'] === 'upper' || facts['buttonCase'] === 'none' ? facts['buttonCase'] : null;
|
|
110
|
+
const drawn = (_ref = theme == null ? void 0 : theme.button.case) != null ? _ref : null;
|
|
111
|
+
return {
|
|
112
|
+
ground: colorPin(facts['background'], (_ref1 = theme == null ? void 0 : theme.light.ground) != null ? _ref1 : null),
|
|
113
|
+
darkGround: colorPin(facts['darkBackground'], (_ref2 = theme == null ? void 0 : (_theme_dark = theme.dark) == null ? void 0 : _theme_dark.ground) != null ? _ref2 : null),
|
|
114
|
+
buttonFill: colorPin(facts['buttonFill'], theme ? (_theme_button_fill = theme.button.fill) != null ? _theme_button_fill : theme.light.brand : null),
|
|
115
|
+
buttonText: colorPin(facts['buttonText'], theme ? (_theme_button_label = theme.button.label) != null ? _theme_button_label : theme.light.onBrand : null),
|
|
116
|
+
buttonCase: {
|
|
117
|
+
source: wanted,
|
|
118
|
+
theme: drawn,
|
|
119
|
+
delta: null
|
|
120
|
+
},
|
|
121
|
+
from: (_ref3 = theme == null ? void 0 : theme.from) != null ? _ref3 : null
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** The pins as the look line prints them: each source → theme, a color with its ΔE and whether it moved past 0.05. */ export function siteImportLookPinsLine(pins) {
|
|
125
|
+
const one = (name, pin)=>{
|
|
126
|
+
var _pin_source, _pin_theme;
|
|
127
|
+
const said = `${name} ${(_pin_source = pin.source) != null ? _pin_source : 'not read'} → ${(_pin_theme = pin.theme) != null ? _pin_theme : 'not set'}`;
|
|
128
|
+
if (pin.delta !== null) return `${said} (ΔE ${pin.delta.toFixed(3)}, ${pin.delta <= SITE_IMPORT_GROUND_DELTA ? 'kept' : 'moved'})`;
|
|
129
|
+
return pin.source && pin.theme ? `${said} (${pin.source === pin.theme ? 'kept' : 'moved'})` : said;
|
|
130
|
+
};
|
|
131
|
+
const where = pins.from === 'style' ? ', the theme computed from the site style' : pins.from === null ? ', no theme to read' : '';
|
|
132
|
+
return `pins ${[
|
|
133
|
+
one('ground', pins.ground),
|
|
134
|
+
one('darkGround', pins.darkGround),
|
|
135
|
+
one('buttonFill', pins.buttonFill),
|
|
136
|
+
one('buttonText', pins.buttonText),
|
|
137
|
+
one('buttonCase', pins.buttonCase)
|
|
138
|
+
].join(', ')}${where}`;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* How a page of an import was finished (AGL-4152), as the report scores it:
|
|
142
|
+
* what was asked for on the command line, else what its wave was stamped
|
|
143
|
+
* with at its start, else the import's own; an import that names none reads
|
|
144
|
+
* as Keep my site. Its words are improved where the page says so, else where
|
|
145
|
+
* its wave (or the import) improved them under Improve it.
|
|
146
|
+
*/ export function siteImportPageFinish(state, page, asked = {}) {
|
|
147
|
+
var _find, _state_waves, _ref, _ref1, _asked_finish, _ref2, _ref3, _asked_words;
|
|
148
|
+
const finishOf = (value)=>value === 'keep' || value === 'improve' ? value : null;
|
|
149
|
+
const wave = (_find = ((_state_waves = state['waves']) != null ? _state_waves : []).find((entry)=>entry['index'] === page['wave'])) != null ? _find : null;
|
|
150
|
+
const stamped = finishOf(wave == null ? void 0 : wave['finish']);
|
|
151
|
+
const own = finishOf(state['finish']);
|
|
152
|
+
const finish = (_ref = (_ref1 = (_asked_finish = asked.finish) != null ? _asked_finish : stamped) != null ? _ref1 : own) != null ? _ref : 'keep';
|
|
153
|
+
const from = asked.finish ? 'asked' : stamped ? 'wave' : own ? 'import' : 'default';
|
|
154
|
+
const pageWords = page['wording'] === 'kept' || page['wording'] === 'improved' ? page['wording'] : null;
|
|
155
|
+
const switched = ((_ref2 = wave == null ? void 0 : wave['wording']) != null ? _ref2 : state['wording']) === true;
|
|
156
|
+
const words = (_ref3 = (_asked_words = asked.words) != null ? _asked_words : pageWords) != null ? _ref3 : finish === 'improve' && switched ? 'improved' : 'kept';
|
|
157
|
+
return {
|
|
158
|
+
finish,
|
|
159
|
+
words,
|
|
160
|
+
from
|
|
161
|
+
};
|
|
65
162
|
}
|
|
66
163
|
/** The middle value of what is sorted: the two middle ones' mean, for an even count. */ function median(sorted) {
|
|
67
164
|
const middle = Math.floor(sorted.length / 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-import-report.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 the fidelity report says of a built site beside its scores (AGL-4109),\n * pure so a spec reads it: the look the site wears and what its pages cost.\n *\n * The 11/1 report read `host.theme`, the base an import starts from, and said\n * the site wore the starter's indigo while it rendered the source's blue. The\n * look an import saves is `themeOverride` over that base, with `siteStyle`\n * beside it (`aiSaveSiteTheme`). The credits line printed a mean, while the\n * table a quote is made of (`AI_MEASURED_IMPORT_CREDITS`) is a median and a\n * p90.\n */\n\nimport { readThemeOverride, resolveSiteTheme } from '@aglyn/aglyn/app-utils/site-theme'\nimport type { AiJobItemLedger } from './ai-jobs.types'\n\ntype Dict = Record<string, any>\n\n/** The look line's facts, as a site stores them and an import ran them. */\nexport interface SiteImportLookReport {\n /** The base theme the site was given: `siteStyle.base`, or `null` where it holds no style. */\n base: string | null\n /** Whether a look is saved over the base. */\n override: boolean\n /** The job whose look the site wears: `siteStyle.jobId`. */\n jobId: string | null\n /** The source's brand color the look was drawn from: `siteStyle.brand`. */\n brand: string | null\n /** What the import's look pass came to: `look.theme`. */\n pass: string | null\n primary: string | null\n secondary: string | null\n tertiary: string | null\n fonts: string[]\n}\n\nconst named = (value: unknown): string | null => (typeof value === 'string' && value.trim() ? value : null)\n\n/** The look a site wears: its base theme with what was saved over it, and which job saved it. */\nexport function siteImportLookReport(host: Dict, state: Dict | null | undefined): SiteImportLookReport {\n const theme = (resolveSiteTheme(host) ?? {}) as Dict\n const light = (theme['colorSchemes']?.['light'] ?? {}) as Dict\n const style = (host['siteStyle'] ?? null) as Dict | null\n return {\n base: named(style?.['base']),\n override: !!readThemeOverride(host),\n jobId: named(style?.['jobId']),\n brand: named(style?.['brand']),\n pass: named(state?.['look']?.['theme']),\n primary: named(light['primary']?.['main']),\n secondary: named(light['secondary']?.['main']),\n tertiary: named(light['tertiary']?.['main']),\n fonts: ((theme['fonts'] ?? []) as Dict[]).map((font) => String(font['family'] ?? '')).filter(Boolean),\n }\n}\n\n/** The look line of the report: what the site wears, and whether it is this job's. */\nexport function siteImportLookLine(host: Dict, state: Dict | null | undefined, jobId: string): string {\n const look = siteImportLookReport(host, state)\n const colors = (['primary', 'secondary', 'tertiary'] as const).map((key) => `${key} ${look[key] ?? 'not set'}`).join(', ')\n const brand = look.brand ? `, drawn from ${look.brand}` : ''\n const fonts = look.fonts.join(', ') || 'not set'\n const wearing = look.override ? `an override over the ${look.base ?? 'site'} base` : `the ${look.base ?? 'site'} base, no override`\n const whose = look.jobId ? (look.jobId === jobId ? 'saved by this job' : `saved by job ${look.jobId}, not this one`) : 'saved by no job'\n return `${look.pass ?? 'not run'}; ${colors}${brand}; ${fonts}; ${wearing}; ${whose}`\n}\n\n/** One kind of page's cost, as `AI_MEASURED_IMPORT_CREDITS` holds it. */\nexport interface SiteImportCreditsMeasured {\n count: number\n median: number\n p90: number\n mean: number\n}\n\n/** The middle value of what is sorted: the two middle ones' mean, for an even count. */\nfunction median(sorted: readonly number[]): number {\n const middle = Math.floor(sorted.length / 2)\n return sorted.length % 2 ? (sorted[middle] as number) : ((sorted[middle - 1] as number) + (sorted[middle] as number)) / 2\n}\n\n/**\n * What each kind of page cost by the ledger, as the table a quote is read\n * from is measured: over the items that came through and gave nothing back,\n * grouped by how their page was built. The p90 is the nearest rank.\n */\nexport function siteImportCreditsMeasured(\n state: { pages: ReadonlyArray<{ slot: string; build?: string | null }> },\n items: ReadonlyArray<Pick<AiJobItemLedger, 'slot' | 'status' | 'creditsSpent' | 'creditsRefunded'>>,\n): Partial<Record<'arranged' | 'copied', SiteImportCreditsMeasured>> {\n const buildOf = new Map(state.pages.map((page) => [page.slot, page.build ?? null]))\n const out: Partial<Record<'arranged' | 'copied', SiteImportCreditsMeasured>> = {}\n for (const build of ['arranged', 'copied'] as const) {\n const each = items\n .filter((item) => buildOf.get(item.slot) === build && item.status === 'succeeded' && !(Number(item.creditsRefunded) > 0))\n .map((item) => Number(item.creditsSpent ?? 0))\n .sort((a, b) => a - b)\n if (!each.length) continue\n const total = each.reduce((sum, value) => sum + value, 0)\n out[build] = { count: each.length, median: median(each), p90: each[Math.ceil(each.length * 0.9) - 1] as number, mean: total / each.length }\n }\n return out\n}\n\nconst credits = (value: number) => (Number.isInteger(value) ? String(value) : value.toFixed(1))\n\n/** The credits line of the report: each kind of page's count, median, p90 and mean. */\nexport function siteImportCreditsLine(measured: ReturnType<typeof siteImportCreditsMeasured>): string {\n const parts = (['arranged', 'copied'] as const).flatMap((build) => {\n const row = measured[build]\n return row ? [`${row.count} ${build}, median ${credits(row.median)}, p90 ${credits(row.p90)}, mean ${credits(row.mean)}`] : []\n })\n return parts.length ? parts.join('; ') : 'no page in yet'\n}\n"],"names":["readThemeOverride","resolveSiteTheme","named","value","trim","siteImportLookReport","host","state","theme","light","style","base","override","jobId","brand","pass","primary","secondary","tertiary","fonts","map","font","String","filter","Boolean","siteImportLookLine","look","colors","key","join","wearing","whose","median","sorted","middle","Math","floor","length","siteImportCreditsMeasured","items","buildOf","Map","pages","page","slot","build","out","each","item","get","status","Number","creditsRefunded","creditsSpent","sort","a","b","total","reduce","sum","count","p90","ceil","mean","credits","isInteger","toFixed","siteImportCreditsLine","measured","parts","flatMap","row"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;CAUC,GAED,SAASA,iBAAiB,EAAEC,gBAAgB,QAAQ,oCAAmC;AAuBvF,MAAMC,QAAQ,CAACC,QAAmC,OAAOA,UAAU,YAAYA,MAAMC,IAAI,KAAKD,QAAQ;AAEtG,+FAA+F,GAC/F,OAAO,SAASE,qBAAqBC,IAAU,EAAEC,KAA8B;QAC9DN,yBAEAK,iBAUJE;QAXIA,qBAODD,aACGE,gBACEA,kBACDA;IAXlB,MAAMD,SAASP,oBAAAA,iBAAiBK,iBAAjBL,oBAA0B,CAAC;IAC1C,MAAMQ,iBAASD,sBAAAA,KAAK,CAAC,eAAe,qBAArBA,mBAAuB,CAAC,QAAQ,mBAAI,CAAC;IACpD,MAAME,SAASJ,kBAAAA,IAAI,CAAC,YAAY,YAAjBA,kBAAqB;IACpC,OAAO;QACLK,MAAMT,MAAMQ,yBAAAA,KAAO,CAAC,OAAO;QAC3BE,UAAU,CAAC,CAACZ,kBAAkBM;QAC9BO,OAAOX,MAAMQ,yBAAAA,KAAO,CAAC,QAAQ;QAC7BI,OAAOZ,MAAMQ,yBAAAA,KAAO,CAAC,QAAQ;QAC7BK,MAAMb,MAAMK,0BAAAA,cAAAA,KAAO,CAAC,OAAO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Kd,IAAI,CAACZ,KAAK2B,IAAI,CAACf,KAAKV,MAAM,GAAG,OAAO,EAAE;YAAY0B,MAAMN,QAAQV,KAAKV,MAAM;QAAC;IAC5I;IACA,OAAOS;AACT;AAEA,MAAMkB,UAAU,CAAC7D,QAAmBgD,OAAOc,SAAS,CAAC9D,SAASmB,OAAOnB,SAASA,MAAM+D,OAAO,CAAC;AAE5F,qFAAqF,GACrF,OAAO,SAASC,sBAAsBC,QAAsD;IAC1F,MAAMC,QAAQ,AAAC;QAAC;QAAY;KAAS,CAAWC,OAAO,CAAC,CAACzB;QACvD,MAAM0B,MAAMH,QAAQ,CAACvB,MAAM;QAC3B,OAAO0B,MAAM;YAAC,GAAGA,IAAIX,KAAK,CAAC,CAAC,EAAEf,MAAM,SAAS,EAAEmB,QAAQO,IAAIvC,MAAM,EAAE,MAAM,EAAEgC,QAAQO,IAAIV,GAAG,EAAE,OAAO,EAAEG,QAAQO,IAAIR,IAAI,GAAG;SAAC,GAAG,EAAE;IAChI;IACA,OAAOM,MAAMhC,MAAM,GAAGgC,MAAMxC,IAAI,CAAC,QAAQ;AAC3C"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-import-report.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 the fidelity report says of a built site beside its scores (AGL-4109),\n * pure so a spec reads it: the look the site wears and what its pages cost.\n *\n * The 11/1 report read `host.theme`, the base an import starts from, and said\n * the site wore the starter's indigo while it rendered the source's blue. The\n * look an import saves is `themeOverride` over that base, with `siteStyle`\n * beside it (`aiSaveSiteTheme`). The credits line printed a mean, while the\n * table a quote is made of (`AI_MEASURED_IMPORT_CREDITS`) is a median and a\n * p90.\n */\n\nimport { DEFAULT_SITE_THEME } from '@aglyn/aglyn/app-utils/default-site'\nimport { readThemeOverride, resolveSiteTheme } from '@aglyn/aglyn/app-utils/site-theme'\nimport type { AiJobItemLedger } from './ai-jobs.types'\nimport type { AiSiteImportFinish, AiSiteImportWords } from './ai-site-import'\nimport { SITE_IMPORT_GROUND_DELTA, siteImportFidelityThemeOf, siteImportOklabDelta, type SiteImportFidelityTheme } from './ai-site-import-fidelity'\nimport { aiSiteTheme, type AiSiteStyle } from './ai-site-look'\n\ntype Dict = Record<string, any>\n\n/** The look line's facts, as a site stores them and an import ran them. */\nexport interface SiteImportLookReport {\n /** The base theme the site was given: `siteStyle.base`, or `null` where it holds no style. */\n base: string | null\n /** Whether a look is saved over the base. */\n override: boolean\n /** The job whose look the site wears: `siteStyle.jobId`. */\n jobId: string | null\n /** The source's brand color the look was drawn from: `siteStyle.brand`. */\n brand: string | null\n /** What the import's look pass came to: `look.theme`. */\n pass: string | null\n primary: string | null\n secondary: string | null\n tertiary: string | null\n fonts: string[]\n /** What Keep my site pins of the source's look (AGL-4152), source beside theme; absent where the import read no look of its source. */\n pins?: SiteImportLookPins\n}\n\nconst named = (value: unknown): string | null => (typeof value === 'string' && value.trim() ? value : null)\n\n/** The look a site wears: its base theme with what was saved over it, and which job saved it. */\nexport function siteImportLookReport(host: Dict, state: Dict | null | undefined): SiteImportLookReport {\n const theme = (resolveSiteTheme(host) ?? {}) as Dict\n const light = (theme['colorSchemes']?.['light'] ?? {}) as Dict\n const style = (host['siteStyle'] ?? null) as Dict | null\n const pins = siteImportLookPins(host, state)\n return {\n base: named(style?.['base']),\n override: !!readThemeOverride(host),\n jobId: named(style?.['jobId']),\n brand: named(style?.['brand']),\n pass: named(state?.['look']?.['theme']),\n primary: named(light['primary']?.['main']),\n secondary: named(light['secondary']?.['main']),\n tertiary: named(light['tertiary']?.['main']),\n fonts: ((theme['fonts'] ?? []) as Dict[]).map((font) => String(font['family'] ?? '')).filter(Boolean),\n ...(pins ? { pins } : {}),\n }\n}\n\n/** The look line of the report: what the site wears, and whether it is this job's; and what Keep my site pins, source → theme, where the import read its source's look (AGL-4152). */\nexport function siteImportLookLine(host: Dict, state: Dict | null | undefined, jobId: string): string {\n const look = siteImportLookReport(host, state)\n const colors = (['primary', 'secondary', 'tertiary'] as const).map((key) => `${key} ${look[key] ?? 'not set'}`).join(', ')\n const brand = look.brand ? `, drawn from ${look.brand}` : ''\n const fonts = look.fonts.join(', ') || 'not set'\n const wearing = look.override ? `an override over the ${look.base ?? 'site'} base` : `the ${look.base ?? 'site'} base, no override`\n const whose = look.jobId ? (look.jobId === jobId ? 'saved by this job' : `saved by job ${look.jobId}, not this one`) : 'saved by no job'\n return `${look.pass ?? 'not run'}; ${colors}${brand}; ${fonts}; ${wearing}; ${whose}${look.pins ? `; ${siteImportLookPinsLine(look.pins)}` : ''}`\n}\n\n/*------------------------------------------\n * What Keep my site pins (AGL-4152)\n *-----------------------------------------*/\n\n/** One pin of the look: the source's, the theme's, and how far apart (OKLab ΔE, for a color). */\nexport interface SiteImportLookPin {\n source: string | null\n theme: string | null\n delta: number | null\n}\n\n/** The look's pins, the source's beside the theme's: its grounds, its filled buttons' fill, label and case. */\nexport interface SiteImportLookPins {\n ground: SiteImportLookPin\n darkGround: SiteImportLookPin\n buttonFill: SiteImportLookPin\n buttonText: SiteImportLookPin\n buttonCase: SiteImportLookPin\n /** Where the theme's side was read: the site's theme as stored, or computed from its site style. */\n from: SiteImportFidelityTheme['from'] | null\n}\n\n/** Whether a stored site style holds what its colors are drawn from. */\nfunction isStyle(value: unknown): value is AiSiteStyle {\n const style = value as Partial<AiSiteStyle> | null\n return !!style && typeof style === 'object' && typeof style.seed === 'number' && typeof style.ground === 'string' && typeof style.chroma === 'string' && typeof style.hue === 'number'\n}\n\n/**\n * The theme a built site's pages are drawn in, for the fidelity (AGL-4152):\n * the theme it stores, its override resolved; else, where it stores none,\n * one computed from its site style (`siteStyle`) over the starter theme, and\n * marked so. `null` for a site with neither.\n */\nexport function siteImportFidelityThemeFor(host: Dict): SiteImportFidelityTheme | null {\n const stored = siteImportFidelityThemeOf(resolveSiteTheme(host), 'theme')\n if (stored) return stored\n const style = host['siteStyle']\n return isStyle(style) ? siteImportFidelityThemeOf(aiSiteTheme(style, DEFAULT_SITE_THEME), 'style') : null\n}\n\nconst hexOrNull = (value: unknown): string | null => (typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value) ? value.toLowerCase() : null)\n\n/** A color pin: the two colors and how far apart. */\nfunction colorPin(source: unknown, theme: string | null): SiteImportLookPin {\n const from = hexOrNull(source)\n const to = hexOrNull(theme)\n return { source: from, theme: to, delta: from && to ? Math.round(siteImportOklabDelta(from, to) * 1000) / 1000 : null }\n}\n\n/**\n * What Keep my site pins of the source's look (AGL-4152), the source's as\n * the reader read it (`home.look`) beside the theme's: the page ground, the\n * dark ground, a filled button's fill and label, and its case. `null` where\n * the import read no look of its source.\n */\nexport function siteImportLookPins(host: Dict, state: Dict | null | undefined): SiteImportLookPins | null {\n const facts = state?.['home']?.['look'] as Dict | null | undefined\n if (!facts || typeof facts !== 'object') return null\n const theme = siteImportFidelityThemeFor(host)\n const wanted = facts['buttonCase'] === 'upper' || facts['buttonCase'] === 'none' ? (facts['buttonCase'] as string) : null\n const drawn = theme?.button.case ?? null\n return {\n ground: colorPin(facts['background'], theme?.light.ground ?? null),\n darkGround: colorPin(facts['darkBackground'], theme?.dark?.ground ?? null),\n buttonFill: colorPin(facts['buttonFill'], theme ? (theme.button.fill ?? theme.light.brand) : null),\n buttonText: colorPin(facts['buttonText'], theme ? (theme.button.label ?? theme.light.onBrand) : null),\n buttonCase: { source: wanted, theme: drawn, delta: null },\n from: theme?.from ?? null,\n }\n}\n\n/** The pins as the look line prints them: each source → theme, a color with its ΔE and whether it moved past 0.05. */\nexport function siteImportLookPinsLine(pins: SiteImportLookPins): string {\n const one = (name: string, pin: SiteImportLookPin) => {\n const said = `${name} ${pin.source ?? 'not read'} → ${pin.theme ?? 'not set'}`\n if (pin.delta !== null) return `${said} (ΔE ${pin.delta.toFixed(3)}, ${pin.delta <= SITE_IMPORT_GROUND_DELTA ? 'kept' : 'moved'})`\n return pin.source && pin.theme ? `${said} (${pin.source === pin.theme ? 'kept' : 'moved'})` : said\n }\n const where = pins.from === 'style' ? ', the theme computed from the site style' : pins.from === null ? ', no theme to read' : ''\n return `pins ${[one('ground', pins.ground), one('darkGround', pins.darkGround), one('buttonFill', pins.buttonFill), one('buttonText', pins.buttonText), one('buttonCase', pins.buttonCase)].join(', ')}${where}`\n}\n\n/**\n * How a page of an import was finished (AGL-4152), as the report scores it:\n * what was asked for on the command line, else what its wave was stamped\n * with at its start, else the import's own; an import that names none reads\n * as Keep my site. Its words are improved where the page says so, else where\n * its wave (or the import) improved them under Improve it.\n */\nexport function siteImportPageFinish(\n state: Dict,\n page: Dict,\n asked: { finish?: AiSiteImportFinish | null; words?: AiSiteImportWords | null } = {},\n): { finish: AiSiteImportFinish; words: AiSiteImportWords; from: 'asked' | 'wave' | 'import' | 'default' } {\n const finishOf = (value: unknown): AiSiteImportFinish | null => (value === 'keep' || value === 'improve' ? value : null)\n const wave = ((state['waves'] ?? []) as Dict[]).find((entry) => entry['index'] === page['wave']) ?? null\n const stamped = finishOf(wave?.['finish'])\n const own = finishOf(state['finish'])\n const finish = asked.finish ?? stamped ?? own ?? 'keep'\n const from = asked.finish ? 'asked' : stamped ? 'wave' : own ? 'import' : 'default'\n const pageWords = page['wording'] === 'kept' || page['wording'] === 'improved' ? (page['wording'] as AiSiteImportWords) : null\n const switched = (wave?.['wording'] ?? state['wording']) === true\n const words = asked.words ?? pageWords ?? (finish === 'improve' && switched ? 'improved' : 'kept')\n return { finish, words, from }\n}\n\n/** One kind of page's cost, as `AI_MEASURED_IMPORT_CREDITS` holds it. */\nexport interface SiteImportCreditsMeasured {\n count: number\n median: number\n p90: number\n mean: number\n}\n\n/** The middle value of what is sorted: the two middle ones' mean, for an even count. */\nfunction median(sorted: readonly number[]): number {\n const middle = Math.floor(sorted.length / 2)\n return sorted.length % 2 ? (sorted[middle] as number) : ((sorted[middle - 1] as number) + (sorted[middle] as number)) / 2\n}\n\n/**\n * What each kind of page cost by the ledger, as the table a quote is read\n * from is measured: over the items that came through and gave nothing back,\n * grouped by how their page was built. The p90 is the nearest rank.\n */\nexport function siteImportCreditsMeasured(\n state: { pages: ReadonlyArray<{ slot: string; build?: string | null }> },\n items: ReadonlyArray<Pick<AiJobItemLedger, 'slot' | 'status' | 'creditsSpent' | 'creditsRefunded'>>,\n): Partial<Record<'arranged' | 'copied', SiteImportCreditsMeasured>> {\n const buildOf = new Map(state.pages.map((page) => [page.slot, page.build ?? null]))\n const out: Partial<Record<'arranged' | 'copied', SiteImportCreditsMeasured>> = {}\n for (const build of ['arranged', 'copied'] as const) {\n const each = items\n .filter((item) => buildOf.get(item.slot) === build && item.status === 'succeeded' && !(Number(item.creditsRefunded) > 0))\n .map((item) => Number(item.creditsSpent ?? 0))\n .sort((a, b) => a - b)\n if (!each.length) continue\n const total = each.reduce((sum, value) => sum + value, 0)\n out[build] = { count: each.length, median: median(each), p90: each[Math.ceil(each.length * 0.9) - 1] as number, mean: total / each.length }\n }\n return out\n}\n\nconst credits = (value: number) => (Number.isInteger(value) ? String(value) : value.toFixed(1))\n\n/** The credits line of the report: each kind of page's count, median, p90 and mean. */\nexport function siteImportCreditsLine(measured: ReturnType<typeof siteImportCreditsMeasured>): string {\n const parts = (['arranged', 'copied'] as const).flatMap((build) => {\n const row = measured[build]\n return row ? [`${row.count} ${build}, median ${credits(row.median)}, p90 ${credits(row.p90)}, mean ${credits(row.mean)}`] : []\n })\n return parts.length ? parts.join('; ') : 'no page in yet'\n}\n"],"names":["DEFAULT_SITE_THEME","readThemeOverride","resolveSiteTheme","SITE_IMPORT_GROUND_DELTA","siteImportFidelityThemeOf","siteImportOklabDelta","aiSiteTheme","named","value","trim","siteImportLookReport","host","state","theme","light","style","pins","siteImportLookPins","base","override","jobId","brand","pass","primary","secondary","tertiary","fonts","map","font","String","filter","Boolean","siteImportLookLine","look","colors","key","join","wearing","whose","siteImportLookPinsLine","isStyle","seed","ground","chroma","hue","siteImportFidelityThemeFor","stored","hexOrNull","test","toLowerCase","colorPin","source","from","to","delta","Math","round","facts","wanted","drawn","button","case","darkGround","dark","buttonFill","fill","buttonText","label","onBrand","buttonCase","one","name","pin","said","toFixed","where","siteImportPageFinish","page","asked","finishOf","wave","find","entry","stamped","own","finish","pageWords","switched","words","median","sorted","middle","floor","length","siteImportCreditsMeasured","items","buildOf","Map","pages","slot","build","out","each","item","get","status","Number","creditsRefunded","creditsSpent","sort","a","b","total","reduce","sum","count","p90","ceil","mean","credits","isInteger","siteImportCreditsLine","measured","parts","flatMap","row"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;CAUC,GAED,SAASA,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,oCAAmC;AAGvF,SAASC,wBAAwB,EAAEC,yBAAyB,EAAEC,oBAAoB,QAAsC,+BAA2B;AACnJ,SAASC,WAAW,QAA0B,oBAAgB;AAwB9D,MAAMC,QAAQ,CAACC,QAAmC,OAAOA,UAAU,YAAYA,MAAMC,IAAI,KAAKD,QAAQ;AAEtG,+FAA+F,GAC/F,OAAO,SAASE,qBAAqBC,IAAU,EAAEC,KAA8B;QAC9DV,yBAEAS,iBAWJE;QAZIA,qBAQDD,aACGE,gBACEA,kBACDA;IAZlB,MAAMD,SAASX,oBAAAA,iBAAiBS,iBAAjBT,oBAA0B,CAAC;IAC1C,MAAMY,iBAASD,sBAAAA,KAAK,CAAC,eAAe,qBAArBA,mBAAuB,CAAC,QAAQ,mBAAI,CAAC;IACpD,MAAME,SAASJ,kBAAAA,IAAI,CAAC,YAAY,YAAjBA,kBAAqB;IACpC,MA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AAM9B,MAAM,GAAG8B,MAAMvF,IAAI,CAAC,QAAQ;AAC3C"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import type { AiJobSummary } from './ai-jobs.types';
|
|
18
|
-
import { type AiSiteImportLeftOutReason, type AiSiteImportState, type AiSiteImportWave } from './ai-site-import';
|
|
18
|
+
import { type AiSiteImportChoice, type AiSiteImportFinish, type AiSiteImportLeftOutReason, type AiSiteImportState, type AiSiteImportWave } from './ai-site-import';
|
|
19
19
|
/** A domain ownership claim, as the ownership door answers it. */
|
|
20
20
|
export interface AiSiteImportClaim {
|
|
21
21
|
domain: string;
|
|
@@ -120,7 +120,11 @@ export interface AiSiteImportRowView {
|
|
|
120
120
|
oldPage: string;
|
|
121
121
|
/** "1,204 of 1,310 words", once the page is in and the step has counted them. */
|
|
122
122
|
words: string | null;
|
|
123
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* "Copied as it is" or "Arranged by Aglyn AI", once the step has chosen;
|
|
125
|
+
* "Arranged and reworded by Aglyn AI" once its wave improved its words, and
|
|
126
|
+
* "Arranged by Aglyn AI · Words kept" for a policy page on such a wave (AGL-4152).
|
|
127
|
+
*/
|
|
124
128
|
build: string | null;
|
|
125
129
|
}
|
|
126
130
|
/**
|
|
@@ -133,6 +137,8 @@ export declare function aiSiteImportPhotosText(photos: {
|
|
|
133
137
|
reused: number;
|
|
134
138
|
skipped?: number;
|
|
135
139
|
} | null | undefined): string | null;
|
|
140
|
+
/** What the row of a page whose words were improved says in place of its word count (AGL-4152). */
|
|
141
|
+
export declare const AI_SITE_IMPORT_REWORDED_WORDS = "Every fact kept";
|
|
136
142
|
/** One wave's rows, the header and footer first where the wave builds them. */
|
|
137
143
|
export declare function aiSiteImportWaveRows(job: Pick<AiJobSummary, 'items' | 'siteImport' | 'status'>, wave: AiSiteImportWave): AiSiteImportRowView[];
|
|
138
144
|
/**
|
|
@@ -178,3 +184,57 @@ export declare function aiSiteImportStartAllAction(job: Pick<AiJobSummary, 'site
|
|
|
178
184
|
quote: string;
|
|
179
185
|
waves: number;
|
|
180
186
|
} | null;
|
|
187
|
+
/** What Bring my site asks, and what each answer means, as the console draws it. */
|
|
188
|
+
export declare const AI_SITE_IMPORT_FINISH_COPY: {
|
|
189
|
+
readonly heading: "How should your new site look?";
|
|
190
|
+
readonly keep: {
|
|
191
|
+
readonly label: "Keep my site";
|
|
192
|
+
readonly description: `Your pages stay laid out as they are, in your site\u2019s colors, buttons and fonts. ${string} tidies spacing, type and color so every page reads well. Every word stays as you wrote it.`;
|
|
193
|
+
};
|
|
194
|
+
readonly improve: {
|
|
195
|
+
readonly label: "Improve it";
|
|
196
|
+
readonly description: `${string} AI redesigns each page with your pictures, menus and forms, in a theme built around your brand.`;
|
|
197
|
+
};
|
|
198
|
+
readonly wording: {
|
|
199
|
+
readonly label: "Also improve my wording";
|
|
200
|
+
readonly description: `${string} AI rewrites the headings, paragraphs and buttons of your main pages so they read better. Every name, price, number, date, address, phone number and email stays exactly as you wrote it. Quotes, policies, tables and forms keep every word.`;
|
|
201
|
+
};
|
|
202
|
+
readonly helper: "You can change this before each wave.";
|
|
203
|
+
/** The job page's line before it opens the choice: "How your new site looks: Keep my site". */
|
|
204
|
+
readonly current: "How your new site looks";
|
|
205
|
+
readonly change: "Change";
|
|
206
|
+
};
|
|
207
|
+
/** The choice in a few words: "Keep my site", "Improve it", or "Improve it, and my wording". */
|
|
208
|
+
export declare function aiSiteImportChoiceText(choice: AiSiteImportChoice): string;
|
|
209
|
+
/** How a wave was built, as its heading says it: "Keep my site", "Improved", or "Improved, wording too". */
|
|
210
|
+
export declare function aiSiteImportBuiltText(choice: AiSiteImportChoice): string;
|
|
211
|
+
/**
|
|
212
|
+
* A wave's heading (AGL-4152): once it has started, its name and how it was
|
|
213
|
+
* built, "Main pages · Keep my site"; before, its name alone, since how it is
|
|
214
|
+
* built is still the owner's to change.
|
|
215
|
+
*/
|
|
216
|
+
export declare function aiSiteImportWaveHeading(state: Pick<AiSiteImportState, 'finish' | 'wording'> | null | undefined, wave: AiSiteImportWave): string;
|
|
217
|
+
/** What a running wave's page says it does with each page, the way the wave is built (AGL-4152). */
|
|
218
|
+
export declare function aiSiteImportRunningLede(choice: AiSiteImportChoice): string;
|
|
219
|
+
/**
|
|
220
|
+
* What Also improve my wording adds (AGL-4152): for a wave, its pages'
|
|
221
|
+
* rewrites, "Adds about 162 AI credits to this wave."; before the site is
|
|
222
|
+
* read, a main page's.
|
|
223
|
+
*/
|
|
224
|
+
export declare function aiSiteImportWordingCreditsText(scope: {
|
|
225
|
+
job: Pick<AiJobSummary, 'items' | 'siteImport'>;
|
|
226
|
+
wave: AiSiteImportWave;
|
|
227
|
+
} | null): string;
|
|
228
|
+
/**
|
|
229
|
+
* The choice as Bring my site draws it (AGL-4152): the finish, and where the
|
|
230
|
+
* Also improve my wording switch sits, which counts only under Improve it, so
|
|
231
|
+
* a person who picks Keep my site and then Improve it finds it on.
|
|
232
|
+
*/
|
|
233
|
+
export interface AiSiteImportFinishField {
|
|
234
|
+
finish: AiSiteImportFinish;
|
|
235
|
+
wording: boolean;
|
|
236
|
+
}
|
|
237
|
+
/** The field an import's page opens with: the import's choice, the switch on where it was never turned off under Improve it. */
|
|
238
|
+
export declare function aiSiteImportFinishFieldOf(state: Pick<AiSiteImportState, 'finish' | 'wording'> | null | undefined): AiSiteImportFinishField;
|
|
239
|
+
/** The choice a field asks for: its wording only under Improve it. */
|
|
240
|
+
export declare function aiSiteImportFieldChoice(field: AiSiteImportFinishField): AiSiteImportChoice;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* specs hold them.
|
|
24
24
|
*=========================================*/ import { PLATFORM_BRAND_NAME } from "@aglyn/aglyn/app-utils/platform-brand";
|
|
25
25
|
import { aiCreditRangeText } from "./ai-credit-estimate.js";
|
|
26
|
-
import { AI_SITE_IMPORT_FRAME_SLOT, AI_SITE_IMPORT_LEFT_OUT_COPY, AI_SITE_IMPORT_LEFT_OUT_REASONS, AI_SITE_IMPORT_UNREAD_REASONS, aiSiteImportNextWave, aiSiteImportPagesText, aiSiteImportQuoteText, aiSiteImportReadStops, aiSiteImportReadVerdictMessage, aiSiteImportReadVerdictReason, aiSiteImportRemainingCreditRange, aiSiteImportReviewWave, aiSiteImportRunningWave, aiSiteImportWaveCreditRange, aiSiteImportWaveOwed } from "./ai-site-import.js";
|
|
26
|
+
import { AI_SITE_IMPORT_FRAME_SLOT, AI_SITE_IMPORT_LEFT_OUT_COPY, AI_SITE_IMPORT_LEFT_OUT_REASONS, AI_SITE_IMPORT_DEFAULT_CHOICE, AI_SITE_IMPORT_UNREAD_REASONS, aiSiteImportChoiceOf, aiSiteImportNextWave, aiSiteImportPagesText, aiSiteImportQuoteText, aiSiteImportReadStops, aiSiteImportReadVerdictMessage, aiSiteImportReadVerdictReason, aiSiteImportRemainingCreditRange, aiSiteImportReviewWave, aiSiteImportRunningWave, aiSiteImportWaveChoice, aiSiteImportWaveCreditRange, aiSiteImportWaveOwed, aiSiteImportWordingCredits, aiSiteImportWordingPages } from "./ai-site-import.js";
|
|
27
27
|
/** What the card says to a plan that does not include it. */ export const AI_SITE_IMPORT_PLAN_COPY = 'Bring your current website in, every page and photo, on any paid plan. Upgrade to bring yours in.';
|
|
28
28
|
/** What the card says to a member who cannot. */ export const AI_SITE_IMPORT_ROLE_COPY = 'Only the workspace owner or an admin can bring a site in.';
|
|
29
29
|
/**
|
|
@@ -130,8 +130,17 @@ function rowState(row, active) {
|
|
|
130
130
|
}
|
|
131
131
|
const BUILD_COPY = {
|
|
132
132
|
copied: 'Copied as it is',
|
|
133
|
-
arranged: `Arranged by ${PLATFORM_BRAND_NAME} AI
|
|
133
|
+
arranged: `Arranged by ${PLATFORM_BRAND_NAME} AI`,
|
|
134
|
+
/** A main page whose wording was improved (AGL-4152). */ reworded: `Arranged and reworded by ${PLATFORM_BRAND_NAME} AI`,
|
|
135
|
+
/** A policy page on a wave that improved the wording of the rest: it keeps every word. */ wordsKept: `Arranged by ${PLATFORM_BRAND_NAME} AI · Words kept`
|
|
134
136
|
};
|
|
137
|
+
/** A page's build as its row says it, with whether its words were improved where its wave improved wording (AGL-4152). */ function buildCopy(page, choice) {
|
|
138
|
+
if (!page.build) return null;
|
|
139
|
+
if (page.build === 'arranged' && page.wording === 'improved') return BUILD_COPY.reworded;
|
|
140
|
+
if (page.build === 'arranged' && page.wording === 'kept' && choice.wording) return BUILD_COPY.wordsKept;
|
|
141
|
+
return BUILD_COPY[page.build];
|
|
142
|
+
}
|
|
143
|
+
/** What the row of a page whose words were improved says in place of its word count (AGL-4152). */ export const AI_SITE_IMPORT_REWORDED_WORDS = 'Every fact kept';
|
|
135
144
|
/** One wave's rows, the header and footer first where the wave builds them. */ export function aiSiteImportWaveRows(job, wave) {
|
|
136
145
|
var _job_items;
|
|
137
146
|
const state = job.siteImport;
|
|
@@ -147,6 +156,7 @@ const BUILD_COPY = {
|
|
|
147
156
|
return true;
|
|
148
157
|
};
|
|
149
158
|
const rows = [];
|
|
159
|
+
const choice = aiSiteImportWaveChoice(state, wave);
|
|
150
160
|
if (wave.frame && state.frame) {
|
|
151
161
|
var _ref, _ref1, _ref2;
|
|
152
162
|
var _row_failure;
|
|
@@ -182,8 +192,9 @@ const BUILD_COPY = {
|
|
|
182
192
|
outputId: (_ref5 = row == null ? void 0 : row.outputs[0]) != null ? _ref5 : null,
|
|
183
193
|
oldPage: page.url,
|
|
184
194
|
// Beside the old page's own words, its main region's as the wave read them: its menu and footer are the site's (AGL-4084).
|
|
185
|
-
|
|
186
|
-
|
|
195
|
+
// A page whose words were improved keeps its facts, not its count (AGL-4152).
|
|
196
|
+
words: page.brought ? page.wording === 'improved' ? AI_SITE_IMPORT_REWORDED_WORDS : `${page.brought.words.toLocaleString('en-US')} of ${((_ref6 = (_page_read = page.read) == null ? void 0 : _page_read.words) != null ? _ref6 : page.words).toLocaleString('en-US')} words` : null,
|
|
197
|
+
build: buildCopy(page, choice)
|
|
187
198
|
});
|
|
188
199
|
}
|
|
189
200
|
return rows;
|
|
@@ -293,5 +304,73 @@ const BUILD_COPY = {
|
|
|
293
304
|
waves
|
|
294
305
|
};
|
|
295
306
|
}
|
|
307
|
+
/*------------------------------------------
|
|
308
|
+
* Keep my site, or Improve it (AGL-4152)
|
|
309
|
+
*-----------------------------------------*/ /** What Bring my site asks, and what each answer means, as the console draws it. */ export const AI_SITE_IMPORT_FINISH_COPY = {
|
|
310
|
+
heading: 'How should your new site look?',
|
|
311
|
+
keep: {
|
|
312
|
+
label: 'Keep my site',
|
|
313
|
+
description: `Your pages stay laid out as they are, in your site’s colors, buttons and fonts. ${PLATFORM_BRAND_NAME} tidies spacing, type and color so every page reads well. Every word stays as you wrote it.`
|
|
314
|
+
},
|
|
315
|
+
improve: {
|
|
316
|
+
label: 'Improve it',
|
|
317
|
+
description: `${PLATFORM_BRAND_NAME} AI redesigns each page with your pictures, menus and forms, in a theme built around your brand.`
|
|
318
|
+
},
|
|
319
|
+
wording: {
|
|
320
|
+
label: 'Also improve my wording',
|
|
321
|
+
description: `${PLATFORM_BRAND_NAME} AI rewrites the headings, paragraphs and buttons of your main pages so they read better. Every name, price, number, date, address, phone number and email stays exactly as you wrote it. Quotes, policies, tables and forms keep every word.`
|
|
322
|
+
},
|
|
323
|
+
helper: 'You can change this before each wave.',
|
|
324
|
+
/** The job page's line before it opens the choice: "How your new site looks: Keep my site". */ current: 'How your new site looks',
|
|
325
|
+
change: 'Change'
|
|
326
|
+
};
|
|
327
|
+
/** The choice in a few words: "Keep my site", "Improve it", or "Improve it, and my wording". */ export function aiSiteImportChoiceText(choice) {
|
|
328
|
+
if (choice.finish === 'keep') return AI_SITE_IMPORT_FINISH_COPY.keep.label;
|
|
329
|
+
return choice.wording ? `${AI_SITE_IMPORT_FINISH_COPY.improve.label}, and my wording` : AI_SITE_IMPORT_FINISH_COPY.improve.label;
|
|
330
|
+
}
|
|
331
|
+
/** How a wave was built, as its heading says it: "Keep my site", "Improved", or "Improved, wording too". */ export function aiSiteImportBuiltText(choice) {
|
|
332
|
+
if (choice.finish === 'keep') return AI_SITE_IMPORT_FINISH_COPY.keep.label;
|
|
333
|
+
return choice.wording ? 'Improved, wording too' : 'Improved';
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* A wave's heading (AGL-4152): once it has started, its name and how it was
|
|
337
|
+
* built, "Main pages · Keep my site"; before, its name alone, since how it is
|
|
338
|
+
* built is still the owner's to change.
|
|
339
|
+
*/ export function aiSiteImportWaveHeading(state, wave) {
|
|
340
|
+
if (!wave.startedAt) return wave.label;
|
|
341
|
+
return `${wave.label} · ${aiSiteImportBuiltText(aiSiteImportWaveChoice(state, wave))}`;
|
|
342
|
+
}
|
|
343
|
+
/** What a running wave's page says it does with each page, the way the wave is built (AGL-4152). */ export function aiSiteImportRunningLede(choice) {
|
|
344
|
+
const review = 'You review the wave when it is in.';
|
|
345
|
+
if (choice.finish === 'keep') return `Each page keeps its layout and every word as you wrote it, in your site’s own look. ${review}`;
|
|
346
|
+
return choice.wording ? `${PLATFORM_BRAND_NAME} AI redesigns each page and improves its wording, keeping every name, price, number, date, address, phone number and email as you wrote it. ${review}` : `${PLATFORM_BRAND_NAME} AI redesigns each page with its own words, pictures, menus and forms. ${review}`;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* What Also improve my wording adds (AGL-4152): for a wave, its pages'
|
|
350
|
+
* rewrites, "Adds about 162 AI credits to this wave."; before the site is
|
|
351
|
+
* read, a main page's.
|
|
352
|
+
*/ export function aiSiteImportWordingCreditsText(scope) {
|
|
353
|
+
var _scope_job_items;
|
|
354
|
+
if (!(scope == null ? void 0 : scope.job.siteImport)) return `About ${aiSiteImportWordingCredits(1).likely.toLocaleString('en-US')} more AI credits for each main page.`;
|
|
355
|
+
const pages = aiSiteImportWordingPages(scope.job.siteImport, scope.wave, {
|
|
356
|
+
finish: 'improve',
|
|
357
|
+
wording: true
|
|
358
|
+
}, (_scope_job_items = scope.job.items) != null ? _scope_job_items : null);
|
|
359
|
+
if (!pages) return 'This wave’s pages keep every word, so it adds no AI credits.';
|
|
360
|
+
return `Adds about ${aiSiteImportWordingCredits(pages).likely.toLocaleString('en-US')} AI credits to this wave.`;
|
|
361
|
+
}
|
|
362
|
+
/** The field an import's page opens with: the import's choice, the switch on where it was never turned off under Improve it. */ export function aiSiteImportFinishFieldOf(state) {
|
|
363
|
+
const choice = aiSiteImportChoiceOf(state);
|
|
364
|
+
return choice.finish === 'improve' ? choice : {
|
|
365
|
+
finish: 'keep',
|
|
366
|
+
wording: AI_SITE_IMPORT_DEFAULT_CHOICE.wording
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
/** The choice a field asks for: its wording only under Improve it. */ export function aiSiteImportFieldChoice(field) {
|
|
370
|
+
return {
|
|
371
|
+
finish: field.finish,
|
|
372
|
+
wording: field.finish === 'improve' && field.wording
|
|
373
|
+
};
|
|
374
|
+
}
|
|
296
375
|
|
|
297
376
|
//# sourceMappingURL=ai-site-import-view.js.map
|