@aglyn/plugins-ai 1.7.0 → 1.9.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/activity/ai-activity.js +4 -2
- package/src/lib/activity/ai-activity.js.map +1 -1
- package/src/lib/components/ai-credits-card.component.d.ts +4 -3
- package/src/lib/components/ai-credits-card.component.js +13 -12
- package/src/lib/components/ai-credits-card.component.js.map +1 -1
- package/src/lib/components/ai-site-import-job.component.js +14 -5
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.d.ts +2 -2
- package/src/lib/components/ai-upsell-dialog.component.js +3 -3
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/components/staff-org-ai-card.component.js +2 -2
- package/src/lib/components/staff-org-ai-card.component.js.map +1 -1
- package/src/lib/declarations.d.ts +2 -2
- package/src/lib/declarations.js +10 -9
- package/src/lib/declarations.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +28 -2
- package/src/lib/jobs/ai-job-import-step.js +170 -14
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-language.js +2 -0
- package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.js +6 -2
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.d.ts +13 -3
- package/src/lib/jobs/ai-site-import-compile.js +339 -27
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +3 -1
- package/src/lib/jobs/ai-site-import-document.js +42 -1
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +9 -0
- package/src/lib/jobs/ai-site-import-look.js +89 -6
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.d.ts +16 -0
- package/src/lib/layout-language/ai-layout-compiler.js +378 -56
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame-source.d.ts +88 -2
- package/src/lib/layout-language/ai-layout-frame-source.js +591 -30
- package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame.js +30 -18
- package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +74 -3
- package/src/lib/layout-language/ai-layout-language.js +5 -3
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/layout-language/ai-layout-store.d.ts +8 -0
- package/src/lib/layout-language/ai-layout-store.js +32 -6
- package/src/lib/layout-language/ai-layout-store.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +31 -1
- package/src/lib/model/ai-site-import-fidelity.js +347 -25
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-view.js +4 -3
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +205 -6
- package/src/lib/model/ai-site-import.js +161 -5
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +8 -1
- package/src/lib/model/ai-site-look.js +8 -5
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/model/ai-upsell-copy.js +4 -3
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/plan-entitlements.d.ts +3 -3
- package/src/lib/plan-entitlements.js +1 -1
- package/src/lib/plan-entitlements.js.map +1 -1
- package/src/lib/providers/model-choice.d.ts +6 -3
- package/src/lib/providers/model-choice.js +8 -4
- package/src/lib/providers/model-choice.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -1
- package/src/lib/runtime/ai-doctrine-validators.js +25 -2
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +19 -2
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/runtime/ai-page-links.d.ts +15 -0
- package/src/lib/runtime/ai-page-links.js +48 -0
- package/src/lib/runtime/ai-page-links.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +35 -6
- 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 +9 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +24 -5
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-crawl.d.ts +3 -1
- package/src/lib/site-import/site-import-crawl.js +8 -3
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +20 -0
- package/src/lib/site-import/site-import-css.js +106 -0
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-html.d.ts +39 -0
- package/src/lib/site-import/site-import-html.js +515 -5
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +16 -6
- package/src/lib/site-import/site-import-layout.js +528 -52
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-nav.js +286 -24
- package/src/lib/site-import/site-import-nav.js.map +1 -1
- package/src/lib/site-import/site-import-page.js +3 -0
- package/src/lib/site-import/site-import-page.js.map +1 -1
- package/src/lib/usage/assist-credits.d.ts +5 -4
- package/src/lib/usage/assist-credits.js +5 -4
- package/src/lib/usage/assist-credits.js.map +1 -1
- package/src/lib/usage/staff-org-ai-view.js +6 -6
- package/src/lib/usage/staff-org-ai-view.js.map +1 -1
- package/src/lib/usage/staff-org-ai.d.ts +4 -4
- package/src/lib/usage/staff-org-ai.js +8 -7
- package/src/lib/usage/staff-org-ai.js.map +1 -1
- package/src/lib/usage/staff-org-usage-ai.js +2 -2
- package/src/lib/usage/staff-org-usage-ai.js.map +1 -1
|
@@ -48,6 +48,7 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
|
|
|
48
48
|
* planned, quoted or spent: a site seen without its home page is not the
|
|
49
49
|
* site. The person is told why and checks again.
|
|
50
50
|
*=========================================*/ import { PLATFORM_BRAND_NAME } from "@aglyn/aglyn/app-utils/platform-brand";
|
|
51
|
+
import { videoEmbedOf } from "@aglyn/aglyn/plugin-manager/video-embed-provider";
|
|
51
52
|
import { aiCreditRangeOrdered, aiCreditRangeText, AI_MEASURED_IMPORT_CREDITS } from "./ai-credit-estimate.js";
|
|
52
53
|
/** The job kind. */ export const AI_SITE_IMPORT_KIND = 'import';
|
|
53
54
|
/** The input naming the proved domain the job brings in. */ export const AI_SITE_IMPORT_DOMAIN_INPUT = 'domain';
|
|
@@ -144,6 +145,9 @@ export const SITE_IMPORT_GROUP_KINDS = [
|
|
|
144
145
|
case 'picture':
|
|
145
146
|
out.push(node.line);
|
|
146
147
|
break;
|
|
148
|
+
case 'video':
|
|
149
|
+
if (node.poster !== undefined) out.push(node.poster);
|
|
150
|
+
break;
|
|
147
151
|
case 'row':
|
|
148
152
|
for (const cell of node.cells)visit(cell.nodes);
|
|
149
153
|
break;
|
|
@@ -175,10 +179,20 @@ export const SITE_IMPORT_GROUP_KINDS = [
|
|
|
175
179
|
* short): references past the cut are dropped, and what is left empty goes.
|
|
176
180
|
*/ export function siteImportLayoutWithin(layout, count) {
|
|
177
181
|
const keep = (ref)=>ref >= 0 && ref < count;
|
|
178
|
-
const sections = layout.sections.map((section)=>
|
|
182
|
+
const sections = layout.sections.map((section)=>{
|
|
183
|
+
const { backdrop } = section;
|
|
184
|
+
// A film behind the words keeps its place; a poster past the cut goes (AGL-4140).
|
|
185
|
+
const behind = (backdrop == null ? void 0 : backdrop.kind) === 'video' && backdrop.poster !== undefined && !keep(backdrop.poster) ? {
|
|
186
|
+
backdrop: {
|
|
187
|
+
kind: 'video',
|
|
188
|
+
video: backdrop.video
|
|
189
|
+
}
|
|
190
|
+
} : {};
|
|
191
|
+
return _extends({}, section, behind, {
|
|
179
192
|
nodes: siteImportFilterNodes(section.nodes, keep),
|
|
180
193
|
lines: section.lines.filter(keep)
|
|
181
|
-
})
|
|
194
|
+
});
|
|
195
|
+
}).filter((section)=>section.lines.length);
|
|
182
196
|
return _extends({}, layout, {
|
|
183
197
|
sections
|
|
184
198
|
});
|
|
@@ -196,6 +210,19 @@ export const SITE_IMPORT_GROUP_KINDS = [
|
|
|
196
210
|
return [
|
|
197
211
|
node
|
|
198
212
|
];
|
|
213
|
+
case 'video':
|
|
214
|
+
{
|
|
215
|
+
// The film stays where it sat; a poster past the cut goes.
|
|
216
|
+
if (node.poster === undefined || keep(node.poster)) return [
|
|
217
|
+
node
|
|
218
|
+
];
|
|
219
|
+
const { poster: _poster } = node, rest = _object_without_properties_loose(node, [
|
|
220
|
+
"poster"
|
|
221
|
+
]);
|
|
222
|
+
return [
|
|
223
|
+
rest
|
|
224
|
+
];
|
|
225
|
+
}
|
|
199
226
|
case 'row':
|
|
200
227
|
{
|
|
201
228
|
const cells = node.cells.map((cell)=>({
|
|
@@ -209,7 +236,7 @@ export const SITE_IMPORT_GROUP_KINDS = [
|
|
|
209
236
|
}
|
|
210
237
|
case 'group':
|
|
211
238
|
{
|
|
212
|
-
const items = node.items.map((item)=>trimItem(item, keep)).filter((item)=>item.lines.length || item.icon !== undefined);
|
|
239
|
+
const items = node.items.map((item)=>trimItem(item, keep)).filter((item)=>item.lines.length || item.icon !== undefined || item.video !== undefined);
|
|
213
240
|
return items.length ? [
|
|
214
241
|
_extends({}, node, {
|
|
215
242
|
items
|
|
@@ -259,6 +286,8 @@ function trimItem(item, keep) {
|
|
|
259
286
|
'badge',
|
|
260
287
|
'period'
|
|
261
288
|
])if (out[key] !== undefined && !keep(out[key])) delete out[key];
|
|
289
|
+
if (out.image === undefined) delete out.imageFit;
|
|
290
|
+
if (out.figure === undefined) delete out.figureMuted;
|
|
262
291
|
for (const key of [
|
|
263
292
|
'text',
|
|
264
293
|
'list',
|
|
@@ -274,6 +303,129 @@ function trimItem(item, keep) {
|
|
|
274
303
|
else delete out.ctas;
|
|
275
304
|
return out;
|
|
276
305
|
}
|
|
306
|
+
/*------------------------------------------
|
|
307
|
+
* A page's videos (AGL-4140)
|
|
308
|
+
*-----------------------------------------*/ /** The words that name a control as one that plays a film: a facade's label, a "Watch the film" button. */ export const SITE_IMPORT_PLAY_WORDS = /\b(?:play|watch|video|film)\b/i;
|
|
309
|
+
/**
|
|
310
|
+
* Where a video of a page brought in plays from on the new page, or `null`
|
|
311
|
+
* where the Video element cannot play it: a link to a video host whose
|
|
312
|
+
* player the element frames (`hosted`), else the file the old site serves at
|
|
313
|
+
* an https address, which the new page plays from that address. A video on
|
|
314
|
+
* any other host is shown as its poster, linking to it.
|
|
315
|
+
*/ export function siteImportFilmSource(video) {
|
|
316
|
+
var _video_embed, _video_src;
|
|
317
|
+
if (!video) return null;
|
|
318
|
+
const embed = (_video_embed = video.embed) == null ? void 0 : _video_embed.trim();
|
|
319
|
+
if (embed && videoEmbedOf(embed)) return {
|
|
320
|
+
src: embed,
|
|
321
|
+
hosted: true
|
|
322
|
+
};
|
|
323
|
+
const file = (_video_src = video.src) == null ? void 0 : _video_src.trim();
|
|
324
|
+
return file && /^https:\/\//i.test(file) ? {
|
|
325
|
+
src: file,
|
|
326
|
+
hosted: false
|
|
327
|
+
} : null;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* The films a page brought in plays from the old site's own address
|
|
331
|
+
* (AGL-4140): the https file of each video its layout places where it sits or
|
|
332
|
+
* in an item, which the Video element plays because its poster is in the
|
|
333
|
+
* library. A film on a host's player, one behind a section's words (drawn as
|
|
334
|
+
* its poster), and one with no poster the library holds play nothing from
|
|
335
|
+
* the old site. The rule the compile places a film by (`filmPlaces`).
|
|
336
|
+
*/ export function aiSiteImportOwnFilms(read, photos) {
|
|
337
|
+
var _ref;
|
|
338
|
+
const videos = (_ref = read == null ? void 0 : read.videos) != null ? _ref : [];
|
|
339
|
+
if (!videos.length || !(read == null ? void 0 : read.layout)) return [];
|
|
340
|
+
const held = new Set(photos.flatMap((photo)=>photo.from ? [
|
|
341
|
+
photo.from
|
|
342
|
+
] : []));
|
|
343
|
+
const out = [];
|
|
344
|
+
const place = (video, poster)=>{
|
|
345
|
+
var _read_blocks;
|
|
346
|
+
const source = siteImportFilmSource(videos[video]);
|
|
347
|
+
const block = poster === undefined ? undefined : (_read_blocks = read.blocks) == null ? void 0 : _read_blocks[poster];
|
|
348
|
+
if (source && !source.hosted && (block == null ? void 0 : block.kind) === 'image' && held.has(block.url) && !out.includes(source.src)) out.push(source.src);
|
|
349
|
+
};
|
|
350
|
+
const visit = (nodes)=>{
|
|
351
|
+
for (const node of nodes){
|
|
352
|
+
if (node.kind === 'video') place(node.video, node.poster);
|
|
353
|
+
else if (node.kind === 'row') for (const cell of node.cells)visit(cell.nodes);
|
|
354
|
+
else if (node.kind === 'tabs') for (const tab of node.tabs)visit(tab.panel);
|
|
355
|
+
else if (node.kind === 'group') {
|
|
356
|
+
for (const item of node.items)if (item.video !== undefined) place(item.video, item.image);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
for (const section of read.layout.sections)visit(section.nodes);
|
|
361
|
+
return out;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* The most hosts a site approves of one kind: `APPROVED_IMAGE_HOSTS_MAX` in
|
|
365
|
+
* `security-origins.js`, the tenant policy's own ceiling, which a spec holds
|
|
366
|
+
* this to.
|
|
367
|
+
*/ export const SITE_IMPORT_APPROVED_HOSTS_MAX = 50;
|
|
368
|
+
/**
|
|
369
|
+
* A host as the Security tab keeps one and the tenant's policy reads it
|
|
370
|
+
* (`normalizeApprovedImageHost` in `security-origins.js`, which a spec holds
|
|
371
|
+
* this to): lowercase, a hostname with at least one dot and a letter-only
|
|
372
|
+
* last label, an optional leading `*.`, and no scheme, path, port or
|
|
373
|
+
* separator; `null` for anything else.
|
|
374
|
+
*/ export function siteImportApprovedHost(value) {
|
|
375
|
+
if (typeof value !== 'string') return null;
|
|
376
|
+
const host = value.trim().toLowerCase();
|
|
377
|
+
if (!host || host.length > 253) return null;
|
|
378
|
+
if (/[\s;,/\\?#@:]/.test(host)) return null;
|
|
379
|
+
const bare = host.startsWith('*.') ? host.slice(2) : host;
|
|
380
|
+
if (!bare || bare === '*') return null;
|
|
381
|
+
return /^(?=.{1,253}$)([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/.test(bare) ? host : null;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* A site's approved media hosts with the old site's film hosts added
|
|
385
|
+
* (AGL-4140): every entry the owner has kept as it is and where it is, each
|
|
386
|
+
* new host once, after them, within `SITE_IMPORT_APPROVED_HOSTS_MAX`; `null`
|
|
387
|
+
* when nothing is added.
|
|
388
|
+
*/ export function siteImportApprovedHostsWith(current, addresses) {
|
|
389
|
+
const owner = Array.isArray(current) ? current.filter((entry)=>typeof entry === 'string') : [];
|
|
390
|
+
const have = new Set(owner.map((entry)=>entry.trim().toLowerCase()));
|
|
391
|
+
const out = [
|
|
392
|
+
...owner
|
|
393
|
+
];
|
|
394
|
+
const hostnameOf = (address)=>{
|
|
395
|
+
try {
|
|
396
|
+
return new URL(address).hostname;
|
|
397
|
+
} catch (unused) {
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
for (const address of addresses){
|
|
402
|
+
const host = siteImportApprovedHost(hostnameOf(address));
|
|
403
|
+
if (!host || have.has(host) || out.length >= SITE_IMPORT_APPROVED_HOSTS_MAX) continue;
|
|
404
|
+
have.add(host);
|
|
405
|
+
out.push(host);
|
|
406
|
+
}
|
|
407
|
+
return out.length > owner.length ? out : null;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* What a page's row says of its videos (AGL-4140), or `null`: a film the old
|
|
411
|
+
* site serves itself plays from there, the owner may move it, and its address
|
|
412
|
+
* was approved for the site to play (`approved`, once the host write is in);
|
|
413
|
+
* a film the source showed no poster for is left out, since its poster is the
|
|
414
|
+
* button a visitor presses, and the owner may add it with one.
|
|
415
|
+
*/ export function aiSiteImportVideoNote(videos, own = {
|
|
416
|
+
films: 0,
|
|
417
|
+
approved: false
|
|
418
|
+
}) {
|
|
419
|
+
const posterless = (videos != null ? videos : []).filter((video)=>siteImportFilmSource(video) && !video.poster).length;
|
|
420
|
+
const approved = own.approved ? ' Its address was added to Approved media hosts in Admin → Security, so it plays on your new site.' : '';
|
|
421
|
+
const notes = [
|
|
422
|
+
own.films === 1 ? `A video on this page plays from your old site's address; pick it from your media library to move it.${approved}` : '',
|
|
423
|
+
own.films > 1 ? `Videos on this page play from your old site's address; pick each from your media library to move it.${approved ? ' Their addresses were added to Approved media hosts in Admin → Security, so they play on your new site.' : ''}` : '',
|
|
424
|
+
posterless === 1 ? 'A video on this page had no poster picture, so it was left out: add it with the Video element and pick a poster for it.' : '',
|
|
425
|
+
posterless > 1 ? 'Videos on this page had no poster picture, so they were left out: add each with the Video element and pick a poster for it.' : ''
|
|
426
|
+
].filter(Boolean);
|
|
427
|
+
return notes.length ? notes.join(' ') : null;
|
|
428
|
+
}
|
|
277
429
|
/** A layout with its icons' drawings dropped, for a page that must be lighter. */ export function siteImportLayoutWithoutDrawings(layout) {
|
|
278
430
|
return _extends({}, layout, {
|
|
279
431
|
icons: layout.icons.map((icon)=>icon.svg ? {
|
|
@@ -953,7 +1105,9 @@ const readChars = (read)=>{
|
|
|
953
1105
|
blocks: [],
|
|
954
1106
|
forms: [],
|
|
955
1107
|
layout: null
|
|
956
|
-
}
|
|
1108
|
+
}, read.videos ? {
|
|
1109
|
+
videos: []
|
|
1110
|
+
} : {})
|
|
957
1111
|
}, page.photos ? {
|
|
958
1112
|
photos: _extends({}, page.photos, {
|
|
959
1113
|
assets: []
|
|
@@ -1003,7 +1157,9 @@ const readChars = (read)=>{
|
|
|
1003
1157
|
blocks: [],
|
|
1004
1158
|
forms: [],
|
|
1005
1159
|
layout: null
|
|
1006
|
-
}
|
|
1160
|
+
}, page.read.videos ? {
|
|
1161
|
+
videos: []
|
|
1162
|
+
} : {})
|
|
1007
1163
|
}) : page)
|
|
1008
1164
|
});
|
|
1009
1165
|
}
|