@omniharmonic/openspace-cli 0.1.11 → 0.1.12

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.
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __osCreateRequire } from "node:module"; const require = __osCreateRequire(import.meta.url);
2
2
  import {
3
3
  generateAgentsMd
4
- } from "./chunk-FPW2XAQ5.js";
4
+ } from "./chunk-O55O7EA5.js";
5
5
  import "./chunk-26AZCID5.js";
6
6
  export {
7
7
  generateAgentsMd
8
8
  };
9
- //# sourceMappingURL=agents-md-OGGPLFGX.js.map
9
+ //# sourceMappingURL=agents-md-WR57UUCZ.js.map
package/dist/bin.js CHANGED
@@ -3,9 +3,9 @@ import { createRequire as __osCreateRequire } from "node:module"; const require
3
3
  import {
4
4
  processIo,
5
5
  run
6
- } from "./chunk-WK2BKRNV.js";
7
- import "./chunk-OS5MWJZG.js";
8
- import "./chunk-FPW2XAQ5.js";
6
+ } from "./chunk-RDBZSWAR.js";
7
+ import "./chunk-MN752KCH.js";
8
+ import "./chunk-O55O7EA5.js";
9
9
  import "./chunk-26AZCID5.js";
10
10
 
11
11
  // src/bin.ts
@@ -9105,6 +9105,40 @@ function parseTheme(css, bodyClasses = []) {
9105
9105
  return theme;
9106
9106
  }
9107
9107
 
9108
+ // ../import/src/html/icons.ts
9109
+ var DEFAULTS = /\/universal\/default-favicon|\/wp-includes\/images\/w-logo|favicon\.ico(?:[?#]|$)/i;
9110
+ function bestIcon(head, base) {
9111
+ if (!head) return void 0;
9112
+ const links = findAll(
9113
+ head,
9114
+ (e) => e.tagName === "link" && /(?:^|\s)(?:icon|apple-touch-icon(?:-precomposed)?|mask-icon)(?:\s|$)/i.test(
9115
+ attr(e, "rel") ?? ""
9116
+ ) && !!attr(e, "href")
9117
+ );
9118
+ const scored = links.map((e) => {
9119
+ let url;
9120
+ try {
9121
+ url = new URL(attr(e, "href"), base).toString().replace(/^http:/, "https:");
9122
+ } catch {
9123
+ return void 0;
9124
+ }
9125
+ if (!/^https:/.test(url) || DEFAULTS.test(url)) return void 0;
9126
+ const rel = (attr(e, "rel") ?? "").toLowerCase();
9127
+ const type = (attr(e, "type") ?? "").toLowerCase();
9128
+ if (rel.includes("mask-icon")) return { url, score: 1 };
9129
+ const svg = type.includes("svg") || /\.svg(?:[?#]|$)/i.test(url);
9130
+ if (/\.ico(?:[?#]|$)/i.test(url) || type.includes("x-icon")) return void 0;
9131
+ const size = Math.max(
9132
+ 0,
9133
+ ...(attr(e, "sizes") ?? "").split(/\s+/).map((s) => Number(/^(\d+)x\d+$/i.exec(s)?.[1] ?? 0))
9134
+ );
9135
+ const px = size || (rel.includes("apple-touch") ? 180 : 32);
9136
+ return { url, score: svg ? 1e4 : px };
9137
+ }).filter((x) => !!x);
9138
+ scored.sort((a, b) => b.score - a.score);
9139
+ return scored[0]?.url;
9140
+ }
9141
+
9108
9142
  // ../import/src/html/image.ts
9109
9143
  var MAX = 2400;
9110
9144
  function parseSrcset(srcset) {
@@ -9178,17 +9212,41 @@ function bestRendition(src, srcset, base) {
9178
9212
  return orig ? { url: orig, alternates: [plain] } : { url: plain, alternates: [] };
9179
9213
  }
9180
9214
  const sized = all.filter((e) => e.w).sort((a, b) => (b.w ?? 0) - (a.w ?? 0));
9181
- const ok = sized.filter((e) => (e.w ?? 0) <= MAX);
9215
+ const big = sized.filter((e) => (e.w ?? 0) >= MAX);
9216
+ const rest = sized.filter((e) => (e.w ?? 0) < MAX);
9182
9217
  const byDensity = all.filter((e) => e.x).sort((a, b) => (b.x ?? 0) - (a.x ?? 0));
9218
+ const wpOrig = [...sized, ...byDensity].map((e) => wpOriginal(e.url)).find(Boolean) ?? (plain ? wpOriginal(plain) : void 0);
9183
9219
  const ordered = [
9184
- ...ok.map((e) => e.url),
9220
+ ...big.length ? [big[big.length - 1].url] : [],
9221
+ ...!big.length && wpOrig ? [wpOrig] : [],
9222
+ ...rest.map((e) => e.url),
9185
9223
  ...byDensity.map((e) => e.url),
9186
9224
  ...plain ? [plain] : [],
9187
- ...sized.filter((e) => (e.w ?? 0) > MAX).map((e) => e.url)
9225
+ ...big.slice(0, -1).reverse().map((e) => e.url)
9188
9226
  ];
9189
9227
  const unique = [...new Set(ordered)];
9190
9228
  if (!unique.length) return void 0;
9191
- return { url: unique[0], alternates: unique.slice(1, 4) };
9229
+ return { url: unique[0], alternates: unique.slice(1, 5) };
9230
+ }
9231
+ function focalFromObjectPosition(style) {
9232
+ const m = /object-position\s*:\s*([^;]+)/i.exec(style ?? "");
9233
+ if (!m) return void 0;
9234
+ const KEY = { left: 0, top: 0, center: 0.5, right: 1, bottom: 1 };
9235
+ const parts = m[1].trim().split(/\s+/).slice(0, 2);
9236
+ const val = (p) => {
9237
+ if (p === void 0) return 0.5;
9238
+ if (p in KEY) return KEY[p];
9239
+ const pc = /^(-?[\d.]+)%$/.exec(p);
9240
+ return pc ? Math.min(1, Math.max(0, Number(pc[1]) / 100)) : void 0;
9241
+ };
9242
+ let [a, b] = parts;
9243
+ if ((a === "top" || a === "bottom") && (b === "left" || b === "right" || b === "center"))
9244
+ [a, b] = [b, a];
9245
+ const x = val(a);
9246
+ const y = val(b);
9247
+ if (x === void 0 || y === void 0) return void 0;
9248
+ if (Math.abs(x - 0.5) < 0.01 && Math.abs(y - 0.5) < 0.01) return void 0;
9249
+ return [Math.round(x * 1e3) / 1e3, Math.round(y * 1e3) / 1e3];
9192
9250
  }
9193
9251
  var LAZY_SRC = [
9194
9252
  "data-src",
@@ -9228,33 +9286,47 @@ function imageFromImg(el, base) {
9228
9286
  break;
9229
9287
  }
9230
9288
  }
9231
- const picture = el.tagName === "picture" ? el : void 0;
9232
- if (picture && !srcset.length) {
9233
- const source = find(picture, (e) => e.tagName === "source");
9234
- srcset = parseSrcset(attr(source, "srcset") ?? attr(source, "data-srcset"));
9289
+ const up = img.parentNode;
9290
+ const picture = el.tagName === "picture" ? el : up && isElement(up) && up.tagName === "picture" ? up : void 0;
9291
+ if (picture) {
9292
+ const sources = children(picture).filter((e) => e.tagName === "source");
9293
+ for (const source of sources) {
9294
+ if (/svg/i.test(attr(source, "type") ?? "")) continue;
9295
+ srcset.push(
9296
+ ...parseSrcset(attr(source, "srcset") ?? attr(source, "data-srcset")).filter(
9297
+ (e) => !isPlaceholder(e.url)
9298
+ )
9299
+ );
9300
+ }
9235
9301
  }
9236
9302
  if (!src && !srcset.length) return void 0;
9237
9303
  const best = bestRendition(src, srcset, base);
9238
9304
  if (!best) return void 0;
9239
9305
  const w = Number(attr(img, "width"));
9240
9306
  const h = Number(attr(img, "height"));
9307
+ const focal = focalFromObjectPosition(attr(img, "style"));
9241
9308
  return {
9242
9309
  url: best.url,
9243
9310
  alt: (attr(img, "alt") ?? "").replace(/\s+/g, " ").trim(),
9244
9311
  ...w > 0 && h > 0 ? { width: w, height: h } : {},
9245
- ...best.alternates.length ? { alternates: best.alternates } : {}
9312
+ ...best.alternates.length ? { alternates: best.alternates } : {},
9313
+ ...focal ? { focal } : {}
9246
9314
  };
9247
9315
  }
9248
9316
  function backgroundImageOf(el, base) {
9249
9317
  const style = attr(el, "style") ?? "";
9250
9318
  const m = /background(?:-image)?\s*:[^;]*url\(\s*['"]?([^'")]+)['"]?\s*\)/i.exec(style);
9251
- const raw = m?.[1] ?? attr(el, "data-bg") ?? attr(el, "data-background-image");
9319
+ const bgset = parseSrcset(attr(el, "data-bgset")).sort((a, b) => (b.w ?? 0) - (a.w ?? 0))[0]?.url;
9320
+ const raw = m?.[1] ?? attr(el, "data-bg") ?? attr(el, "data-background-image") ?? attr(el, "data-bg-src") ?? attr(el, "data-background") ?? bgset;
9252
9321
  if (!raw || isPlaceholder(raw)) return void 0;
9253
9322
  const best = bestRendition(raw, [], base);
9323
+ const pos = /background-position\s*:\s*([^;]+)/i.exec(style)?.[1];
9324
+ const focal = pos ? focalFromObjectPosition(`object-position:${pos}`) : void 0;
9254
9325
  return best ? {
9255
9326
  url: best.url,
9256
9327
  alt: "",
9257
- ...best.alternates.length ? { alternates: best.alternates } : {}
9328
+ ...best.alternates.length ? { alternates: best.alternates } : {},
9329
+ ...focal ? { focal } : {}
9258
9330
  } : void 0;
9259
9331
  }
9260
9332
 
@@ -10441,6 +10513,15 @@ var typeIs = (o, re) => [o["@type"]].flat().some((t) => typeof t === "string" &&
10441
10513
  var PLATFORM_SCRIPT_HOSTS = /squarespace|wix|parastorage|webflow|website-files|framer|jquery|cloudflare|jsdelivr|unpkg|googleapis\.com\/ajax|wp-includes|wp-content|shopify|gstatic\.com\/recaptcha|google\.com\/recaptcha|polyfill|carrd/i;
10442
10514
  function chromeHeader(body, header, base) {
10443
10515
  const h = header ? navFromHeader(header, base) : { nav: [] };
10516
+ const home = (href) => {
10517
+ try {
10518
+ const u = new URL(href, base);
10519
+ return u.origin === new URL(base).origin && /^\/?$/.test(u.pathname);
10520
+ } catch {
10521
+ return false;
10522
+ }
10523
+ };
10524
+ if (h.nav.length && h.nav.every((i) => i.type === "link" && home(i.href))) h.nav = [];
10444
10525
  if (!h.nav.length) {
10445
10526
  const nav = find(
10446
10527
  body,
@@ -10579,10 +10660,7 @@ ${styleAttrs.map((e) => `[inline]{${attr(e, "style")}}`).join("\n")}`;
10579
10660
  );
10580
10661
  }
10581
10662
  }
10582
- const favEl = find(
10583
- head,
10584
- (e) => e.tagName === "link" && /(?:^|\s)icon(?:\s|$)/i.test(attr(e, "rel") ?? "")
10585
- );
10663
+ const favicon = bestIcon(head, base);
10586
10664
  const htmlEl = root;
10587
10665
  const textLength = text(pruned).length;
10588
10666
  const seo = {
@@ -10600,7 +10678,7 @@ ${styleAttrs.map((e) => `[inline]{${attr(e, "style")}}`).join("\n")}`;
10600
10678
  seo,
10601
10679
  ...attr(htmlEl, "lang") ? { lang: attr(htmlEl, "lang") } : {},
10602
10680
  ...metaContent(head, "generator") ? { generator: metaContent(head, "generator") } : {},
10603
- ...favEl && attr(favEl, "href") ? { favicon: safeAbs(attr(favEl, "href"), base) } : {},
10681
+ ...favicon ? { favicon } : {},
10604
10682
  ...siteName ? { siteName } : {},
10605
10683
  header: chromeHeader(body, header, base),
10606
10684
  footer: footer ? footerSections(footer, base) : [],
@@ -11301,7 +11379,13 @@ function expandImageCards(rows) {
11301
11379
  function cardBlocks(card) {
11302
11380
  const out = [];
11303
11381
  const sub = card.html ? stripTags(card.html) : "";
11304
- if (card.title && card.title.length <= 40 && sub && sub.length <= 160)
11382
+ const sentence = /[.!?…]["”’)]?$/.test(sub) || sub.split(/\s+/).length > 12;
11383
+ if (card.title && card.title.length <= 40 && sub && sub.length <= 160 && sentence)
11384
+ out.push({
11385
+ kind: "text",
11386
+ html: `<p class="os-eyebrow">${escapeText2(card.title)}</p>${card.html ?? ""}`
11387
+ });
11388
+ else if (card.title && card.title.length <= 40 && sub && sub.length <= 160)
11305
11389
  out.push({ kind: "heading", text: sub, level: 2, eyebrow: card.title });
11306
11390
  else if (card.title || card.html)
11307
11391
  out.push({
@@ -11741,7 +11825,10 @@ function parsePage(html) {
11741
11825
  body,
11742
11826
  (e) => classes(e).some((c) => /member-area|members-only|sqs-member/.test(c))
11743
11827
  );
11744
- const favEl = find(head, (e) => e.tagName === "link" && /icon/.test(attr(e, "rel") ?? ""));
11828
+ const favicon = bestIcon(
11829
+ head,
11830
+ attr(canonicalEl, "href") ?? meta(head, "og:url") ?? "https://images.squarespace-cdn.com/"
11831
+ );
11745
11832
  const lang = attr(root, "lang");
11746
11833
  const ogTitle = meta(head, "og:title");
11747
11834
  return {
@@ -11768,7 +11855,7 @@ function parsePage(html) {
11768
11855
  inlineCss,
11769
11856
  ...customHeadCode ? { customHeadCode } : {},
11770
11857
  ...item ? { item } : {},
11771
- ...favEl && attr(favEl, "href") ? { favicon: attr(favEl, "href") } : {},
11858
+ ...favicon ? { favicon } : {},
11772
11859
  ...passwordForm ? { locked: "password" } : membersGate ? { locked: "members" } : {},
11773
11860
  ...version ? { version } : {}
11774
11861
  };
@@ -12364,6 +12451,7 @@ ${r.text}`;
12364
12451
  const budget = { left: opts.maxPages ?? 400 };
12365
12452
  const customCode = /* @__PURE__ */ new Set();
12366
12453
  const aliases = [];
12454
+ const homeAliases = /* @__PURE__ */ new Set();
12367
12455
  if (home.page.customHeadCode) customCode.add(home.page.customHeadCode);
12368
12456
  const visitTop = async (path, pre) => {
12369
12457
  if (handled.has(path) || budget.left <= 0) return;
@@ -12373,6 +12461,7 @@ ${r.text}`;
12373
12461
  if (!got) return;
12374
12462
  if (path !== "/" && got.page.bodyClasses.includes("homepage")) {
12375
12463
  aliases.push({ from: path, to: "/" });
12464
+ homeAliases.add(path);
12376
12465
  return;
12377
12466
  }
12378
12467
  const json = await getJson(path);
@@ -12420,7 +12509,10 @@ ${r.text}`;
12420
12509
  }
12421
12510
  }
12422
12511
  const itemPaths = all.filter(
12423
- (p) => (path === "/" ? /^\/(?:p\/[^/]+|\d{4}\/\d{1,2}\/\d{1,2}\/[^/]+)$/.test(p) : p.startsWith(`${path}/`)) && !handled.has(p) && !/\/(?:category|tag|tags|categories)\//.test(p.slice(path.length))
12512
+ (p) => (path === "/" ? (
12513
+ // A shop as the home page lists items under its own address too (`/shop/p/x`).
12514
+ (kind === "products" ? /^\/(?:[^/]+\/)?p\/[^/]+$/ : /^\/(?:p\/[^/]+|\d{4}\/\d{1,2}\/\d{1,2}\/[^/]+)$/).test(p)
12515
+ ) : p.startsWith(`${path}/`)) && !handled.has(p) && !/\/(?:category|tag|tags|categories)\//.test(p.slice(path.length))
12424
12516
  );
12425
12517
  for (const ip of itemPaths) {
12426
12518
  if (budget.left <= 0) break;
@@ -12489,6 +12581,11 @@ ${r.text}`;
12489
12581
  if (parent && prefixes.has(parent) && !handled.has(parent)) await visitTop(parent);
12490
12582
  if (handled.has(p)) continue;
12491
12583
  if (parent && collections.some((c) => c.path === parent)) continue;
12584
+ if (parent && homeAliases.has(parent) && collections.some((c) => c.path === "/")) {
12585
+ handled.add(p);
12586
+ aliases.push({ from: p, to: "/" });
12587
+ continue;
12588
+ }
12492
12589
  await visitTop(p);
12493
12590
  }
12494
12591
  if (budget.left <= 0)
@@ -12891,4 +12988,4 @@ export {
12891
12988
  crawlSquarespace,
12892
12989
  crawlGeneric
12893
12990
  };
12894
- //# sourceMappingURL=chunk-OS5MWJZG.js.map
12991
+ //# sourceMappingURL=chunk-MN752KCH.js.map