@aglyn/plugins-ai 1.11.0 → 1.13.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.
Files changed (74) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-media-create.component.js +1 -1
  3. package/src/lib/components/ai-media-create.component.js.map +1 -1
  4. package/src/lib/components/ai-upsell-dialog.component.js +1 -1
  5. package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
  6. package/src/lib/jobs/ai-job-import-step.d.ts +1 -1
  7. package/src/lib/jobs/ai-job-import-step.js +37 -8
  8. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  9. package/src/lib/jobs/ai-job-privacy-step.js +2 -2
  10. package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
  11. package/src/lib/jobs/ai-site-import-compile.js +27 -37
  12. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  13. package/src/lib/jobs/ai-site-import-look.d.ts +19 -4
  14. package/src/lib/jobs/ai-site-import-look.js +162 -46
  15. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  16. package/src/lib/jobs/ai-theme-brand-inputs.d.ts +12 -0
  17. package/src/lib/jobs/ai-theme-brand-inputs.js +1 -1
  18. package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
  19. package/src/lib/layout-language/ai-layout-compiler.js +7 -1
  20. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  21. package/src/lib/model/ai-credit-estimate.d.ts +15 -0
  22. package/src/lib/model/ai-credit-estimate.js +13 -0
  23. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  24. package/src/lib/model/ai-site-import-fidelity.d.ts +46 -3
  25. package/src/lib/model/ai-site-import-fidelity.js +254 -62
  26. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  27. package/src/lib/model/ai-site-import-report.d.ts +7 -0
  28. package/src/lib/model/ai-site-import-report.js +17 -5
  29. package/src/lib/model/ai-site-import-report.js.map +1 -1
  30. package/src/lib/model/ai-site-import.d.ts +75 -4
  31. package/src/lib/model/ai-site-import.js +34 -11
  32. package/src/lib/model/ai-site-import.js.map +1 -1
  33. package/src/lib/model/ai-site-look.d.ts +16 -0
  34. package/src/lib/model/ai-site-look.js +76 -14
  35. package/src/lib/model/ai-site-look.js.map +1 -1
  36. package/src/lib/model/ai-upsell-copy.js +1 -1
  37. package/src/lib/model/ai-upsell-copy.js.map +1 -1
  38. package/src/lib/site-import/fixtures/aglyn-com-recordings.d.ts +2 -1
  39. package/src/lib/site-import/fixtures/aglyn-com-recordings.js +3 -2
  40. package/src/lib/site-import/fixtures/aglyn-com-recordings.js.map +1 -1
  41. package/src/lib/site-import/fixtures/site-import-crawl-recordings.d.ts +5 -0
  42. package/src/lib/site-import/fixtures/site-import-crawl-recordings.js +116 -3
  43. package/src/lib/site-import/fixtures/site-import-crawl-recordings.js.map +1 -1
  44. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +7 -0
  45. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +15 -0
  46. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  47. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +32 -0
  48. package/src/lib/site-import/fixtures/site-layout-recordings.js +59 -3
  49. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  50. package/src/lib/site-import/fixtures/site-look-slate.d.ts +2 -1
  51. package/src/lib/site-import/fixtures/site-look-slate.js +2 -1
  52. package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -1
  53. package/src/lib/site-import/site-import-crawl.d.ts +9 -1
  54. package/src/lib/site-import/site-import-crawl.js +128 -23
  55. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  56. package/src/lib/site-import/site-import-css.d.ts +89 -1
  57. package/src/lib/site-import/site-import-css.js +468 -28
  58. package/src/lib/site-import/site-import-css.js.map +1 -1
  59. package/src/lib/site-import/site-import-data-forms.d.ts +32 -0
  60. package/src/lib/site-import/site-import-data-forms.js +531 -0
  61. package/src/lib/site-import/site-import-data-forms.js.map +1 -0
  62. package/src/lib/site-import/site-import-html.d.ts +10 -1
  63. package/src/lib/site-import/site-import-html.js +21 -5
  64. package/src/lib/site-import/site-import-html.js.map +1 -1
  65. package/src/lib/site-import/site-import-layout.d.ts +9 -2
  66. package/src/lib/site-import/site-import-layout.js +383 -62
  67. package/src/lib/site-import/site-import-layout.js.map +1 -1
  68. package/src/lib/site-import/site-import-nav.js +17 -3
  69. package/src/lib/site-import/site-import-nav.js.map +1 -1
  70. package/src/lib/site-import/site-import-page.js +5 -0
  71. package/src/lib/site-import/site-import-page.js.map +1 -1
  72. package/src/lib/site-import/site-import-same-page.d.ts +41 -0
  73. package/src/lib/site-import/site-import-same-page.js +108 -0
  74. package/src/lib/site-import/site-import-same-page.js.map +1 -0
@@ -18,9 +18,10 @@
18
18
  * menu and stylesheet readers, and for the compile and fidelity specs that
19
19
  * read what they find.
20
20
  *
21
- * `site-layout/` holds five pages of aglyn.com as AglynBot read them on
22
- * 2026-10-28 and 2026-10-29 (home, product, pricing, contact, one blog post),
23
- * its pricing page again as it read on 2026-11-01, which a live import fell
21
+ * `site-layout/` holds four pages of aglyn.com as AglynBot read them on
22
+ * 2026-10-28 and 2026-10-29 (product, pricing, contact, one blog post), its
23
+ * home page as it read on 2026-11-05, which the 11/5 Keep my site import fell
24
+ * short on (AGL-4152), its pricing page again as it read on 2026-11-01, which a live import fell
24
25
  * short on (`livePricing`), its blog listing as it read on 2026-11-03, whose
25
26
  * cards crop their pictures to a height of their own (`blog`, AGL-4138), and
26
27
  * one page in the markup a Squarespace site is built with, written for these
@@ -31,6 +32,11 @@
31
32
  * `<video>` playing behind its opening, a YouTube frame, a `lite-youtube`
32
33
  * facade, a card's picture linking a Vimeo page, and an `og:video` in its
33
34
  * head.
35
+ * A garden firm that does not exist either, in the markup a visual grid builder
36
+ * writes (AGL-4152), places every block with a rule of its own on a 24-column
37
+ * grid, inside a `min-width` query: `grid-services` shows three cards and a row
38
+ * of pictures, `swapped-grid` a page whose written order is not the order a
39
+ * visitor reads, so each card's words sit after the next card's heading.
34
40
  *
35
41
  * The aglyn.com recordings keep what the `aglyn-com/` ones dropped and the
36
42
  * layout is made of: class names, inline icons and the page's own stylesheet.
@@ -53,6 +59,7 @@ const DIR = join(__dirname, 'site-layout');
53
59
  export const SITE_LAYOUT_AGLYN_ORIGIN = 'https://aglyn.com';
54
60
  export const SITE_LAYOUT_POTTERY_ORIGIN = 'https://www.tidewater-pottery.example';
55
61
  export const SITE_LAYOUT_BAKERY_ORIGIN = 'https://www.hearth-bakery.example';
62
+ export const SITE_LAYOUT_GARDEN_ORIGIN = 'https://www.fern-and-stone.example';
56
63
  /** The recorded pages, by name: the file and the address it was read from. */ export const SITE_LAYOUT_PAGES = {
57
64
  home: {
58
65
  file: 'aglyn-home.html',
@@ -89,8 +96,57 @@ export const SITE_LAYOUT_BAKERY_ORIGIN = 'https://www.hearth-bakery.example';
89
96
  bakery: {
90
97
  file: 'video-bakery.html',
91
98
  url: `${SITE_LAYOUT_BAKERY_ORIGIN}/`
99
+ },
100
+ gridServices: {
101
+ file: 'grid-services.html',
102
+ url: `${SITE_LAYOUT_GARDEN_ORIGIN}/`
103
+ },
104
+ swappedGrid: {
105
+ file: 'swapped-grid.html',
106
+ url: `${SITE_LAYOUT_GARDEN_ORIGIN}/plans`
92
107
  }
93
108
  };
109
+ /**
110
+ * Pages written for the reads of a site's brand and its forms (AGL-4152),
111
+ * about a bookkeeper that does not exist and in the markup of no builder, so
112
+ * the readers are never tuned to one site. They are not scored against a build
113
+ * as the pages above are.
114
+ *
115
+ * `vars-theme` links five stylesheets, saved beside it in `vars-theme/`: four
116
+ * of a site kit's shared widgets, whose loud colors are nobody's brand, then
117
+ * the site's own, the last link, whose colors and fonts are custom properties
118
+ * (comma triples and the modern spaced syntax) and whose buttons are styled
119
+ * through `:is()` and `:where()`. `json-form` has no `<form>`: its fields are
120
+ * JSON a script block holds, beside two arrays that only look like fields.
121
+ */ export const SITE_READ_ORIGIN = 'https://www.harbor-lane.example';
122
+ export const SITE_READ_VARS_THEME_URL = `${SITE_READ_ORIGIN}/`;
123
+ export const SITE_READ_JSON_FORM_URL = `${SITE_READ_ORIGIN}/contact`;
124
+ /** A written page's markup, by its file in `site-layout/`. */ export const siteReadPage = (file)=>readFileSync(join(DIR, file), 'utf8');
125
+ /** The `vars-theme` page's stylesheets, by the address its markup links each from, in link order. */ export const siteReadVarsThemeSheets = ()=>[
126
+ [
127
+ 'https://cdn.sitekit.example/universal/reset.css',
128
+ 'reset.css'
129
+ ],
130
+ [
131
+ 'https://cdn.sitekit.example/components/gallery.css',
132
+ 'gallery.css'
133
+ ],
134
+ [
135
+ 'https://cdn.sitekit.example/components/map.css',
136
+ 'map.css'
137
+ ],
138
+ [
139
+ 'https://cdn.sitekit.example/components/booking.css',
140
+ 'booking.css'
141
+ ],
142
+ [
143
+ 'https://assets.sitekit.example/sites/4182/site.css',
144
+ 'site.css'
145
+ ]
146
+ ].map(([url, file])=>({
147
+ url: url,
148
+ text: readFileSync(join(DIR, 'vars-theme', file), 'utf8')
149
+ }));
94
150
  const cache = new Map();
95
151
  /** One recorded page's markup. */ export function siteLayoutRecording(name) {
96
152
  const { file } = SITE_LAYOUT_PAGES[name];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/ai/src/lib/site-import/fixtures/site-layout-recordings.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 * Pages recorded with their layout (AGL-4106), for the specs of the layout,\n * menu and stylesheet readers, and for the compile and fidelity specs that\n * read what they find.\n *\n * `site-layout/` holds five pages of aglyn.com as AglynBot read them on\n * 2026-10-28 and 2026-10-29 (home, product, pricing, contact, one blog post),\n * its pricing page again as it read on 2026-11-01, which a live import fell\n * short on (`livePricing`), its blog listing as it read on 2026-11-03, whose\n * cards crop their pictures to a height of their own (`blog`, AGL-4138), and\n * one page in the markup a Squarespace site is built with, written for these\n * specs about a studio that does not exist, so the readers are never tuned to\n * one site's markup.\n * A bakery that does not exist either, in the markup a WordPress block theme\n * writes, shows a film of every kind the reader reads (AGL-4140): a\n * `<video>` playing behind its opening, a YouTube frame, a `lite-youtube`\n * facade, a card's picture linking a Vimeo page, and an `og:video` in its\n * head.\n *\n * The aglyn.com recordings keep what the `aglyn-com/` ones dropped and the\n * layout is made of: class names, inline icons and the page's own stylesheet.\n * Each was trimmed before it entered the repo: script bodies are gone (one\n * small inline script with a hostile line stands in for them; the\n * structured data stays), so are preload links, `data-*` attributes and\n * `srcset`s; the stylesheet keeps only the rules for classes the page uses\n * and the properties the readers read; class names the kept rules do not name\n * are dropped, a grid framework's own hints kept; the pricing page keeps the\n * first 14 rows of its plan table, and the product, pricing, contact and blog\n * pages their header menu without its panels and their footer's © line. The\n * blog listing keeps its first page of posts, a featured one and six cards,\n * without its search box and its newsletter band, inside the blog post's\n * header and footer. The home page keeps its header and footer whole, for\n * the menu reader. Every address, phone number, author and profile is a\n * placeholder.\n */\n\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nconst DIR = join(__dirname, 'site-layout')\n\nexport const SITE_LAYOUT_AGLYN_ORIGIN = 'https://aglyn.com'\nexport const SITE_LAYOUT_POTTERY_ORIGIN = 'https://www.tidewater-pottery.example'\nexport const SITE_LAYOUT_BAKERY_ORIGIN = 'https://www.hearth-bakery.example'\n\n/** The recorded pages, by name: the file and the address it was read from. */\nexport const SITE_LAYOUT_PAGES = {\n home: { file: 'aglyn-home.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/` },\n product: { file: 'aglyn-product.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/product` },\n pricing: { file: 'aglyn-pricing.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/pricing` },\n livePricing: { file: 'aglyn-pricing-2026-11.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/pricing` },\n contact: { file: 'aglyn-contact.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/contact` },\n post: { file: 'aglyn-blog-post.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/blog/multi-site-cost-sheet-2026` },\n blog: { file: 'aglyn-blog.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/blog` },\n pottery: { file: 'squarespace-pottery.html', url: `${SITE_LAYOUT_POTTERY_ORIGIN}/` },\n bakery: { file: 'video-bakery.html', url: `${SITE_LAYOUT_BAKERY_ORIGIN}/` },\n} as const\n\nexport type SiteLayoutPageName = keyof typeof SITE_LAYOUT_PAGES\n\nconst cache = new Map<string, string>()\n\n/** One recorded page's markup. */\nexport function siteLayoutRecording(name: SiteLayoutPageName): string {\n const { file } = SITE_LAYOUT_PAGES[name]\n const held = cache.get(file)\n if (held !== undefined) return held\n const text = readFileSync(join(DIR, file), 'utf8')\n cache.set(file, text)\n return text\n}\n\n/** Whether an address is on the recorded page's own site. */\nexport function siteLayoutSameSite(name: SiteLayoutPageName): (url: URL) => boolean {\n const origin = new URL(SITE_LAYOUT_PAGES[name].url).origin\n const bare = origin.replace('://www.', '://')\n const www = origin.replace('://', '://www.').replace('://www.www.', '://www.')\n return (url) => url.origin === origin || url.origin === bare || url.origin === www\n}\n"],"names":["readFileSync","join","DIR","__dirname","SITE_LAYOUT_AGLYN_ORIGIN","SITE_LAYOUT_POTTERY_ORIGIN","SITE_LAYOUT_BAKERY_ORIGIN","SITE_LAYOUT_PAGES","home","file","url","product","pricing","livePricing","contact","post","blog","pottery","bakery","cache","Map","siteLayoutRecording","name","held","get","undefined","text","set","siteLayoutSameSite","origin","URL","bare","replace","www"],"mappings":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,OAAOF;IAC/B,MAAMG,OAAO1B,aAAaC,KAAKC,KAAKO,OAAO;IAC3CU,MAAMQ,GAAG,CAAClB,MAAMiB;IAChB,OAAOA;AACT;AAEA,2DAA2D,GAC3D,OAAO,SAASE,mBAAmBN,IAAwB;IACzD,MAAMO,SAAS,IAAIC,IAAIvB,iBAAiB,CAACe,KAAK,CAACZ,GAAG,EAAEmB,MAAM;IAC1D,MAAME,OAAOF,OAAOG,OAAO,CAAC,WAAW;IACvC,MAAMC,MAAMJ,OAAOG,OAAO,CAAC,OAAO,WAAWA,OAAO,CAAC,eAAe;IACpE,OAAO,CAACtB,MAAQA,IAAImB,MAAM,KAAKA,UAAUnB,IAAImB,MAAM,KAAKE,QAAQrB,IAAImB,MAAM,KAAKI;AACjF"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/ai/src/lib/site-import/fixtures/site-layout-recordings.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 * Pages recorded with their layout (AGL-4106), for the specs of the layout,\n * menu and stylesheet readers, and for the compile and fidelity specs that\n * read what they find.\n *\n * `site-layout/` holds four pages of aglyn.com as AglynBot read them on\n * 2026-10-28 and 2026-10-29 (product, pricing, contact, one blog post), its\n * home page as it read on 2026-11-05, which the 11/5 Keep my site import fell\n * short on (AGL-4152), its pricing page again as it read on 2026-11-01, which a live import fell\n * short on (`livePricing`), its blog listing as it read on 2026-11-03, whose\n * cards crop their pictures to a height of their own (`blog`, AGL-4138), and\n * one page in the markup a Squarespace site is built with, written for these\n * specs about a studio that does not exist, so the readers are never tuned to\n * one site's markup.\n * A bakery that does not exist either, in the markup a WordPress block theme\n * writes, shows a film of every kind the reader reads (AGL-4140): a\n * `<video>` playing behind its opening, a YouTube frame, a `lite-youtube`\n * facade, a card's picture linking a Vimeo page, and an `og:video` in its\n * head.\n * A garden firm that does not exist either, in the markup a visual grid builder\n * writes (AGL-4152), places every block with a rule of its own on a 24-column\n * grid, inside a `min-width` query: `grid-services` shows three cards and a row\n * of pictures, `swapped-grid` a page whose written order is not the order a\n * visitor reads, so each card's words sit after the next card's heading.\n *\n * The aglyn.com recordings keep what the `aglyn-com/` ones dropped and the\n * layout is made of: class names, inline icons and the page's own stylesheet.\n * Each was trimmed before it entered the repo: script bodies are gone (one\n * small inline script with a hostile line stands in for them; the\n * structured data stays), so are preload links, `data-*` attributes and\n * `srcset`s; the stylesheet keeps only the rules for classes the page uses\n * and the properties the readers read; class names the kept rules do not name\n * are dropped, a grid framework's own hints kept; the pricing page keeps the\n * first 14 rows of its plan table, and the product, pricing, contact and blog\n * pages their header menu without its panels and their footer's © line. The\n * blog listing keeps its first page of posts, a featured one and six cards,\n * without its search box and its newsletter band, inside the blog post's\n * header and footer. The home page keeps its header and footer whole, for\n * the menu reader. Every address, phone number, author and profile is a\n * placeholder.\n */\n\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nconst DIR = join(__dirname, 'site-layout')\n\nexport const SITE_LAYOUT_AGLYN_ORIGIN = 'https://aglyn.com'\nexport const SITE_LAYOUT_POTTERY_ORIGIN = 'https://www.tidewater-pottery.example'\nexport const SITE_LAYOUT_BAKERY_ORIGIN = 'https://www.hearth-bakery.example'\nexport const SITE_LAYOUT_GARDEN_ORIGIN = 'https://www.fern-and-stone.example'\n\n/** The recorded pages, by name: the file and the address it was read from. */\nexport const SITE_LAYOUT_PAGES = {\n home: { file: 'aglyn-home.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/` },\n product: { file: 'aglyn-product.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/product` },\n pricing: { file: 'aglyn-pricing.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/pricing` },\n livePricing: { file: 'aglyn-pricing-2026-11.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/pricing` },\n contact: { file: 'aglyn-contact.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/contact` },\n post: { file: 'aglyn-blog-post.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/blog/multi-site-cost-sheet-2026` },\n blog: { file: 'aglyn-blog.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/blog` },\n pottery: { file: 'squarespace-pottery.html', url: `${SITE_LAYOUT_POTTERY_ORIGIN}/` },\n bakery: { file: 'video-bakery.html', url: `${SITE_LAYOUT_BAKERY_ORIGIN}/` },\n gridServices: { file: 'grid-services.html', url: `${SITE_LAYOUT_GARDEN_ORIGIN}/` },\n swappedGrid: { file: 'swapped-grid.html', url: `${SITE_LAYOUT_GARDEN_ORIGIN}/plans` },\n} as const\n\nexport type SiteLayoutPageName = keyof typeof SITE_LAYOUT_PAGES\n\n/**\n * Pages written for the reads of a site's brand and its forms (AGL-4152),\n * about a bookkeeper that does not exist and in the markup of no builder, so\n * the readers are never tuned to one site. They are not scored against a build\n * as the pages above are.\n *\n * `vars-theme` links five stylesheets, saved beside it in `vars-theme/`: four\n * of a site kit's shared widgets, whose loud colors are nobody's brand, then\n * the site's own, the last link, whose colors and fonts are custom properties\n * (comma triples and the modern spaced syntax) and whose buttons are styled\n * through `:is()` and `:where()`. `json-form` has no `<form>`: its fields are\n * JSON a script block holds, beside two arrays that only look like fields.\n */\nexport const SITE_READ_ORIGIN = 'https://www.harbor-lane.example'\n\nexport const SITE_READ_VARS_THEME_URL = `${SITE_READ_ORIGIN}/`\nexport const SITE_READ_JSON_FORM_URL = `${SITE_READ_ORIGIN}/contact`\n\n/** A written page's markup, by its file in `site-layout/`. */\nexport const siteReadPage = (file: 'vars-theme.html' | 'json-form.html'): string => readFileSync(join(DIR, file), 'utf8')\n\n/** The `vars-theme` page's stylesheets, by the address its markup links each from, in link order. */\nexport const siteReadVarsThemeSheets = (): Array<{ url: string; text: string }> =>\n [\n ['https://cdn.sitekit.example/universal/reset.css', 'reset.css'],\n ['https://cdn.sitekit.example/components/gallery.css', 'gallery.css'],\n ['https://cdn.sitekit.example/components/map.css', 'map.css'],\n ['https://cdn.sitekit.example/components/booking.css', 'booking.css'],\n ['https://assets.sitekit.example/sites/4182/site.css', 'site.css'],\n ].map(([url, file]) => ({ url: url as string, text: readFileSync(join(DIR, 'vars-theme', file as string), 'utf8') }))\n\nconst cache = new Map<string, string>()\n\n/** One recorded page's markup. */\nexport function siteLayoutRecording(name: SiteLayoutPageName): string {\n const { file } = SITE_LAYOUT_PAGES[name]\n const held = cache.get(file)\n if (held !== undefined) return held\n const text = readFileSync(join(DIR, file), 'utf8')\n cache.set(file, text)\n return text\n}\n\n/** Whether an address is on the recorded page's own site. */\nexport function siteLayoutSameSite(name: SiteLayoutPageName): (url: URL) => boolean {\n const origin = new URL(SITE_LAYOUT_PAGES[name].url).origin\n const bare = origin.replace('://www.', '://')\n const www = origin.replace('://', '://www.').replace('://www.www.', '://www.')\n return (url) => url.origin === origin || url.origin === bare || url.origin === www\n}\n"],"names":["readFileSync","join","DIR","__dirname","SITE_LAYOUT_AGLYN_ORIGIN","SITE_LAYOUT_POTTERY_ORIGIN","SITE_LAYOUT_BAKERY_ORIGIN","SITE_LAYOUT_GARDEN_ORIGIN","SITE_LAYOUT_PAGES","home","file","url","product","pricing","livePricing","contact","post","blog","pottery","bakery","gridServices","swappedGrid","SITE_READ_ORIGIN","SITE_READ_VARS_THEME_URL","SITE_READ_JSON_FORM_URL","siteReadPage","siteReadVarsThemeSheets","map","text","cache","Map","siteLayoutRecording","name","held","get","undefined","set","siteLayoutSameSite","origin","URL","bare","replace","www"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCC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* plain markup of no builder's (`site-look/slate-home.html`): a dark slate
20
20
  * hero and a second slate band, a near-black closing band, light cyan filled
21
21
  * buttons set in capitals under dark words, and a hero heading held to 12 em
22
- * inside a 1200 px column. What the reader keeps of it, and the theme Keep my
22
+ * inside a 1200 px column. Its stylesheet says its dark scheme, under a media
23
+ * query and a class on the root (AGL-4152). What the reader keeps of it, and the theme Keep my
23
24
  * site draws from that, is held by `site-import-layout.spec.ts` and
24
25
  * `ai-site-import-look.spec.ts`.
25
26
  */
@@ -20,7 +20,8 @@ import { join } from "node:path";
20
20
  * plain markup of no builder's (`site-look/slate-home.html`): a dark slate
21
21
  * hero and a second slate band, a near-black closing band, light cyan filled
22
22
  * buttons set in capitals under dark words, and a hero heading held to 12 em
23
- * inside a 1200 px column. What the reader keeps of it, and the theme Keep my
23
+ * inside a 1200 px column. Its stylesheet says its dark scheme, under a media
24
+ * query and a class on the root (AGL-4152). What the reader keeps of it, and the theme Keep my
24
25
  * site draws from that, is held by `site-import-layout.spec.ts` and
25
26
  * `ai-site-import-look.spec.ts`.
26
27
  */ export const SITE_LOOK_SLATE_URL = 'https://www.slate-studio.example/';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/ai/src/lib/site-import/fixtures/site-look-slate.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\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\n/**\n * A home page drawn the way the 11/4 Keep my site evidence was (AGL-4152), in\n * plain markup of no builder's (`site-look/slate-home.html`): a dark slate\n * hero and a second slate band, a near-black closing band, light cyan filled\n * buttons set in capitals under dark words, and a hero heading held to 12 em\n * inside a 1200 px column. What the reader keeps of it, and the theme Keep my\n * site draws from that, is held by `site-import-layout.spec.ts` and\n * `ai-site-import-look.spec.ts`.\n */\n\nexport const SITE_LOOK_SLATE_URL = 'https://www.slate-studio.example/'\n\nexport const SITE_LOOK_SLATE_HTML = readFileSync(join(__dirname, 'site-look', 'slate-home.html'), 'utf8')\n"],"names":["readFileSync","join","SITE_LOOK_SLATE_URL","SITE_LOOK_SLATE_HTML","__dirname"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,YAAY,QAAQ,UAAS;AACtC,SAASC,IAAI,QAAQ,YAAW;AAEhC;;;;;;;;CAQC,GAED,OAAO,MAAMC,sBAAsB,oCAAmC;AAEtE,OAAO,MAAMC,uBAAuBH,aAAaC,KAAKG,WAAW,aAAa,oBAAoB,QAAO"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/ai/src/lib/site-import/fixtures/site-look-slate.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\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\n/**\n * A home page drawn the way the 11/4 Keep my site evidence was (AGL-4152), in\n * plain markup of no builder's (`site-look/slate-home.html`): a dark slate\n * hero and a second slate band, a near-black closing band, light cyan filled\n * buttons set in capitals under dark words, and a hero heading held to 12 em\n * inside a 1200 px column. Its stylesheet says its dark scheme, under a media\n * query and a class on the root (AGL-4152). What the reader keeps of it, and the theme Keep my\n * site draws from that, is held by `site-import-layout.spec.ts` and\n * `ai-site-import-look.spec.ts`.\n */\n\nexport const SITE_LOOK_SLATE_URL = 'https://www.slate-studio.example/'\n\nexport const SITE_LOOK_SLATE_HTML = readFileSync(join(__dirname, 'site-look', 'slate-home.html'), 'utf8')\n"],"names":["readFileSync","join","SITE_LOOK_SLATE_URL","SITE_LOOK_SLATE_HTML","__dirname"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,YAAY,QAAQ,UAAS;AACtC,SAASC,IAAI,QAAQ,YAAW;AAEhC;;;;;;;;;CASC,GAED,OAAO,MAAMC,sBAAsB,oCAAmC;AAEtE,OAAO,MAAMC,uBAAuBH,aAAaC,KAAKG,WAAW,aAAa,oBAAoB,QAAO"}
@@ -43,6 +43,8 @@ export declare const SITE_IMPORT_DEFAULTS: {
43
43
  readonly requestTimeoutMs: 8000;
44
44
  readonly robotsMaxBytes: number;
45
45
  readonly sitemapMaxBytes: number;
46
+ /** All the distinct stylesheets one crawl holds at once (AGL-4152): a site's pages share theirs, and one that does not stops here. */
47
+ readonly stylesheetsMaxBytes: number;
46
48
  /** Sitemap documents read, an index's children included: an index of six children is seven. */
47
49
  readonly maxSitemaps: 24;
48
50
  /** URLs a sitemap may contribute to the queue. */
@@ -68,7 +70,11 @@ export type SiteImportSkipReason =
68
70
  /** No answer, a private address, or a refused address. */
69
71
  | 'unreachable'
70
72
  /** Never asked for: a stop (time, bytes, the page budget) came first (AGL-4083). */
71
- | 'not-reached';
73
+ | 'not-reached'
74
+ /** Another address of a page already found (AGL-4152). */
75
+ | 'duplicate'
76
+ /** The cart, checkout or account screen the site's platform makes (AGL-4152). */
77
+ | 'system-page';
72
78
  export interface SiteImportSkipped {
73
79
  url: string;
74
80
  reason: SiteImportSkipReason;
@@ -77,6 +83,8 @@ export interface SiteImportSkipped {
77
83
  location?: string;
78
84
  /** Whose edge turned an error answer away, when it said (AGL-4083). */
79
85
  edge?: PublicFetchEdge;
86
+ /** The page a `duplicate` is another address of (AGL-4152). */
87
+ sameAs?: string;
80
88
  }
81
89
  export interface SiteImportPage {
82
90
  /** The address the page was read from, after any same-site redirect. */
@@ -60,13 +60,20 @@ var _process_env_SITE_IMPORT_BOT_INFO_URL;
60
60
  * - **No sign-in pages.** A page with a password field is refused and
61
61
  * reported; forms with payment fields, scripts, iframes and embeds never
62
62
  * reach the inventory (site-import-html.ts).
63
+ * - **Pages, not addresses (AGL-4152).** Another address of a page already
64
+ * found, and a platform's own cart or account screen, are reported and
65
+ * take nothing from the page budget (site-import-same-page.ts). Addresses a
66
+ * link adds a query to wait for the rest. The home page is always a page,
67
+ * and a wave's read is exactly the pages it asks for.
63
68
  *=========================================*/ import { lookalikeBrandForHost } from "@aglyn/shared-util-email/outbound-phishing-screen";
64
69
  import { fenceUntrustedText } from "@aglyn/shared-util-tools/untrusted-text";
65
- import { AI_THEME_REFERENCE_STYLESHEETS, AI_THEME_STYLESHEET_MAX_BYTES, fetchPublicTextDetailed } from "../jobs/ai-theme-brand-inputs.js";
70
+ import { fetchPublicTextDetailed } from "../jobs/ai-theme-brand-inputs.js";
66
71
  import { extractSiteImportPage, readMetaValues } from "./site-import-html.js";
67
72
  import { AGLYN_BOT_TOKEN, parseRobotsTxt, parseSitemap, robotsAllows, robotsRulesFor } from "./site-import-robots.js";
68
73
  import { NO_SITE_IMPORT_HEADERS, siteImportEdgeHeadersFor } from "./site-import-edge.js";
74
+ import { siteImportReadStylesheets } from "./site-import-css.js";
69
75
  import { siteImportLayout, siteImportLookOf } from "./site-import-layout.js";
76
+ import { siteImportAddressOf, siteImportCanonicalBelieved, siteImportCanonicalClaim, siteImportContentSignature, siteImportIsSystemScreen } from "./site-import-same-page.js";
70
77
  import { siteImportFooterColumns, siteImportNavTree } from "./site-import-nav.js";
71
78
  /**
72
79
  * Where the bot's user agent points a site owner who wants to know what it is
@@ -90,6 +97,7 @@ export const SITE_IMPORT_DEFAULTS = {
90
97
  /** One request's own clock, inside the whole crawl's. */ requestTimeoutMs: 8000,
91
98
  robotsMaxBytes: 256 * 1024,
92
99
  sitemapMaxBytes: 4 * 1024 * 1024,
100
+ /** All the distinct stylesheets one crawl holds at once (AGL-4152): a site's pages share theirs, and one that does not stops here. */ stylesheetsMaxBytes: 32 * 1024 * 1024,
93
101
  /** Sitemap documents read, an index's children included: an index of six children is seven. */ maxSitemaps: 24,
94
102
  /** URLs a sitemap may contribute to the queue. */ maxSitemapUrls: 2000,
95
103
  /** Reasons kept in `skipped` before the list stops growing: every address a sitemap may name. */ maxSkipped: 2000,
@@ -214,18 +222,21 @@ function skipReasonFor(result) {
214
222
  const sameSite = (url)=>origins.includes(url.origin) && url.protocol === 'https:';
215
223
  const remainingBytes = ()=>maxTotalBytes - inventory.bytesRead;
216
224
  const outOfTime = ()=>controller.signal.aborted || now() >= deadlineAt;
217
- const request = (url, accept, acceptHeader, maxBytes)=>fetchText(url, {
225
+ /** A stylesheet's read (`sheet`) may be cut at its cap and may go where its CDN sends it: every hop is checked as public all the same. */ const request = (url, accept, acceptHeader, maxBytes, sheet = false)=>fetchText(url, _extends({
218
226
  maxBytes,
219
227
  accept,
220
228
  acceptHeader,
221
229
  userAgent: AGLYN_BOT_USER_AGENT,
222
230
  headersFor,
223
231
  signal: controller.signal,
224
- timeoutMs: Math.max(1, Math.min(SITE_IMPORT_DEFAULTS.requestTimeoutMs, deadlineAt - now())),
232
+ timeoutMs: Math.max(1, Math.min(SITE_IMPORT_DEFAULTS.requestTimeoutMs, deadlineAt - now()))
233
+ }, sheet ? {} : {
225
234
  redirectAllowed: (_from, to)=>sameSite(to),
226
235
  refuseOver: true
227
- });
236
+ }));
237
+ /** Addresses taken in, read or not: one a page is waiting on that is here and is no page will never be. */ const takenIn = new Set();
228
238
  const skip = (entry)=>{
239
+ takenIn.add(siteImportAddressOf(entry.url));
229
240
  if (inventory.skipped.length < SITE_IMPORT_DEFAULTS.maxSkipped) inventory.skipped.push(entry);
230
241
  else inventory.skippedOverflow += 1;
231
242
  };
@@ -324,6 +335,7 @@ function skipReasonFor(result) {
324
335
  foundBy: 'home'
325
336
  }
326
337
  ];
338
+ /** Addresses a link adds a query to, which wait for every other (AGL-4152): a gallery's hundred never starve a page. */ const later = [];
327
339
  const queued = new Set(only != null ? only : [
328
340
  home
329
341
  ]);
@@ -361,24 +373,73 @@ function skipReasonFor(result) {
361
373
  if (remainingBytes() - reserved <= 0) return 'wait';
362
374
  return null;
363
375
  };
376
+ /** The page each address is, its other addresses included. */ const pageAt = new Map();
377
+ /** The first page found with each main content. */ const pageWith = new Map();
378
+ /** Pages whose canonical names an address not yet taken in. */ const waiting = [];
379
+ const place = (page, signature)=>{
380
+ inventory.pages.push(page);
381
+ pageAt.set(siteImportAddressOf(page.url), page);
382
+ if (signature && !pageWith.has(signature)) pageWith.set(signature, page);
383
+ };
384
+ const leaveSameAs = (url, page)=>{
385
+ pageAt.set(siteImportAddressOf(url), page);
386
+ skip({
387
+ url,
388
+ reason: 'duplicate',
389
+ sameAs: page.url
390
+ });
391
+ };
392
+ /** The page this address is another address of; `wait` for the one its canonical names; or `null`, its own page. */ const sameAs = (url, claim, signature)=>{
393
+ const same = signature ? pageWith.get(signature) : undefined;
394
+ if (same) return same;
395
+ if (!claim) return null;
396
+ const named = pageAt.get(siteImportAddressOf(claim));
397
+ if (named) return siteImportCanonicalBelieved(url, claim) ? named : null;
398
+ return takenIn.has(siteImportAddressOf(claim)) ? null : 'wait';
399
+ };
400
+ /** The waiting pages whose answer is in; `last`, all of them: what they named never came, so each stands. */ const settle = (last = false)=>{
401
+ for (const entry of [
402
+ ...waiting
403
+ ]){
404
+ const verdict = sameAs(entry.page.url, entry.claim, entry.signature);
405
+ if (verdict === 'wait' && !last) continue;
406
+ waiting.splice(waiting.indexOf(entry), 1);
407
+ if (verdict && verdict !== 'wait') leaveSameAs(entry.page.url, verdict);
408
+ else if (inventory.pages.length < maxPages) place(entry.page, entry.signature);
409
+ else {
410
+ stop != null ? stop : stop = 'page-budget';
411
+ skip({
412
+ url: entry.page.url,
413
+ reason: 'not-reached'
414
+ });
415
+ }
416
+ }
417
+ };
364
418
  const readLayout = (_options_layout = options.layout) != null ? _options_layout : !!only;
365
- /** Linked stylesheets, each asked once a crawl. */ const sheets = new Map();
366
- const stylesheet = (url)=>{
419
+ /** Linked stylesheets, as far as any page has read each: a sheet a page shares is asked no further than it was. */ const sheets = new Map();
420
+ let sheetBytes = 0;
421
+ const stylesheet = async (url, maxBytes)=>{
422
+ var _ref, _ref1, _ref2, _ref3, _ref4;
423
+ var _held_answer, _held_answer1;
367
424
  const held = sheets.get(url);
368
- if (held) return held;
369
- const room = Math.min(AI_THEME_STYLESHEET_MAX_BYTES, remainingBytes() - reserved);
370
- const asked = room <= 0 || outOfTime() ? Promise.resolve(null) : request(url, /text\/css|text\/plain/i, 'text/css,*/*;q=0.1', room).then((answer)=>{
371
- if (!answer.ok) return null;
372
- inventory.bytesRead += answer.bytes;
373
- return answer.text;
374
- }, ()=>null);
375
- sheets.set(url, asked);
376
- return asked;
425
+ if (held && (held.asked >= maxBytes || held.answer && !held.answer.truncated)) return held.answer;
426
+ const room = Math.min(maxBytes, SITE_IMPORT_DEFAULTS.stylesheetsMaxBytes - sheetBytes + ((_ref = held == null ? void 0 : (_held_answer = held.answer) == null ? void 0 : _held_answer.bytes) != null ? _ref : 0), remainingBytes() - reserved);
427
+ if (room <= 0 || outOfTime()) return (_ref1 = held == null ? void 0 : held.answer) != null ? _ref1 : null;
428
+ const read = await request(url, /text\/css|text\/plain/i, 'text/css,*/*;q=0.1', room, true).catch(()=>null);
429
+ if (read == null ? void 0 : read.ok) inventory.bytesRead += read.bytes;
430
+ const answer = (read == null ? void 0 : read.ok) ? read : (_ref2 = held == null ? void 0 : held.answer) != null ? _ref2 : null;
431
+ sheetBytes += ((_ref3 = answer == null ? void 0 : answer.bytes) != null ? _ref3 : 0) - ((_ref4 = held == null ? void 0 : (_held_answer1 = held.answer) == null ? void 0 : _held_answer1.bytes) != null ? _ref4 : 0);
432
+ sheets.set(url, {
433
+ asked: room,
434
+ answer
435
+ });
436
+ return answer;
377
437
  };
378
438
  /** Takes one asked page in: the inventory's next page, a skip, or the reason the read must stop. */ const takeIn = async ({ next, key, cap, page })=>{
379
439
  var _siteImportPageKey;
380
440
  const foundBy = next.foundBy;
381
441
  if (foundBy === 'home') homeIn = true;
442
+ takenIn.add(siteImportAddressOf(key));
382
443
  if (!page.ok) {
383
444
  if (page.refusal === 'too-large' && cap < maxPageBytes) {
384
445
  cutOff.push(key);
@@ -405,6 +466,7 @@ function skipReasonFor(result) {
405
466
  inventory.bytesRead += page.bytes;
406
467
  if (foundBy === 'home') preferred = new URL(page.url).origin;
407
468
  const finalKey = canon((_siteImportPageKey = siteImportPageKey(new URL(page.url), origins)) != null ? _siteImportPageKey : page.url);
469
+ takenIn.add(siteImportAddressOf(finalKey));
408
470
  if (finalKey !== key) {
409
471
  if (read.has(finalKey)) return null;
410
472
  read.add(finalKey);
@@ -435,17 +497,36 @@ function skipReasonFor(result) {
435
497
  links.push(linkKey);
436
498
  if (!only && !queued.has(linkKey)) {
437
499
  queued.add(linkKey);
438
- queue.push({
500
+ (new URL(linkKey).search ? later : queue).push({
439
501
  key: linkKey,
440
502
  foundBy: 'link'
441
503
  });
442
504
  }
443
505
  }
506
+ // Whether it is a page of its own (AGL-4152). What is not takes nothing from the budget.
507
+ const own = !only && !isHome;
508
+ if (own && siteImportIsSystemScreen(new URL(finalKey).pathname, extract)) {
509
+ attempts = Math.max(0, attempts - 1);
510
+ skip({
511
+ url: finalKey,
512
+ reason: 'system-page'
513
+ });
514
+ return null;
515
+ }
516
+ const signature = only ? null : siteImportContentSignature(extract);
517
+ const claim = own ? siteImportCanonicalClaim(extract.canonical, finalKey, (url)=>siteImportPageKey(url, origins)) : null;
518
+ const verdict = own ? sameAs(finalKey, claim, signature) : null;
519
+ if (verdict && verdict !== 'wait') {
520
+ attempts = Math.max(0, attempts - 1);
521
+ leaveSameAs(finalKey, verdict);
522
+ return null;
523
+ }
444
524
  // How the page is built (AGL-4106), through its own stylesheets.
445
525
  let built = {};
446
526
  if (extract.structure) {
447
- const linked = await Promise.all(extract.structure.stylesheets.filter((url)=>!/fonts\.googleapis\.com/i.test(url)).slice(0, AI_THEME_REFERENCE_STYLESHEETS).map(stylesheet));
448
- const css = linked.filter((text)=>typeof text === 'string');
527
+ const css = await siteImportReadStylesheets(extract.structure.stylesheets.filter((url)=>!/fonts\.googleapis\.com/i.test(url)), stylesheet, {
528
+ outOfTime
529
+ });
449
530
  const source = _extends({
450
531
  blocks: extract.blocks,
451
532
  organization: extract.organization,
@@ -469,7 +550,7 @@ function skipReasonFor(result) {
469
550
  });
470
551
  }
471
552
  }
472
- inventory.pages.push(_extends({}, built, {
553
+ const taken = _extends({}, built, {
473
554
  url: finalKey,
474
555
  path: new URL(finalKey).pathname,
475
556
  foundBy,
@@ -493,20 +574,39 @@ function skipReasonFor(result) {
493
574
  videos: extract.videos
494
575
  } : {}, {
495
576
  bytes: page.bytes
496
- }));
577
+ });
578
+ if (verdict === 'wait' && claim) {
579
+ // The page it names comes next, even if nothing else links it.
580
+ attempts = Math.max(0, attempts - 1);
581
+ waiting.push({
582
+ page: taken,
583
+ claim,
584
+ signature
585
+ });
586
+ if (!queued.has(claim) && !read.has(canon(claim))) {
587
+ queued.add(claim);
588
+ queue.unshift({
589
+ key: claim,
590
+ foundBy: 'link'
591
+ });
592
+ }
593
+ return null;
594
+ }
595
+ place(taken, signature);
497
596
  return null;
498
597
  };
499
598
  for(;;){
500
599
  var _ref;
501
600
  const width = homeIn ? SITE_IMPORT_DEFAULTS.concurrency : 1;
502
- while(!stop && queue.length && window.length < width){
601
+ while(!stop && (queue.length || later.length) && window.length < width){
602
+ var _queue_shift;
503
603
  const why = held();
504
604
  if (why === 'wait') break;
505
605
  if (why) {
506
606
  stop = why;
507
607
  break;
508
608
  }
509
- const next = queue.shift();
609
+ const next = (_queue_shift = queue.shift()) != null ? _queue_shift : later.shift();
510
610
  const key = canon(next.key);
511
611
  if (read.has(key)) continue;
512
612
  if (!allowed(key)) {
@@ -532,7 +632,9 @@ function skipReasonFor(result) {
532
632
  const asked = await window.shift();
533
633
  reserved -= asked.cap;
534
634
  stop = (_ref = await takeIn(asked)) != null ? _ref : stop;
635
+ settle();
535
636
  }
637
+ settle(true);
536
638
  inventory.stoppedBy = stop;
537
639
  // Whatever a stop left unread is said, never dropped; a wave's own read
538
640
  // leaves its unread pages for its next pass instead.
@@ -540,7 +642,10 @@ function skipReasonFor(result) {
540
642
  const unread = [
541
643
  ...cutOff
542
644
  ];
543
- for (const next of queue){
645
+ for (const next of [
646
+ ...queue,
647
+ ...later
648
+ ]){
544
649
  const key = canon(next.key);
545
650
  if (!read.has(key) && !unread.includes(key)) unread.push(key);
546
651
  }