@fluid-app/fluid-cli-theme-dev 0.1.759 → 0.1.761

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/dist/index.mjs CHANGED
@@ -13680,12 +13680,17 @@ function declarePublication(api, themeId, slug, key, expectedRevision, entries)
13680
13680
  }
13681
13681
  /**
13682
13682
  * Compare local files, declared by the digest a publish would send, with
13683
- * what the branch serves. Nothing is uploaded or changed.
13683
+ * what the branch serves. Nothing is uploaded or changed. The text of
13684
+ * `memberConfiguration` files (members_sites.json and the files it names a
13685
+ * menu in) is sent so the server can compare them without menu slugs.
13684
13686
  */
13685
- async function compareBranch(api, themeId, slug, entries) {
13687
+ async function compareBranch(api, themeId, slug, entries, memberConfiguration = []) {
13686
13688
  return (await call(api.request(`${base(themeId)}/branches/${slug}/comparison`, {
13687
13689
  method: "POST",
13688
- body: { entries }
13690
+ body: memberConfiguration.length > 0 ? {
13691
+ entries,
13692
+ member_configuration: memberConfiguration
13693
+ } : { entries }
13689
13694
  }))).comparison;
13690
13695
  }
13691
13696
  /** Where a branch stands against its parent theme, and its latest promotion. */
@@ -13901,7 +13906,10 @@ async function publishToStaging(api, themeId, root, onProgress = () => {}) {
13901
13906
  * exception: the server stores the document it imported, re-encoded with
13902
13907
  * its own keys and layout, so `members_sites.json` is declared by the digest
13903
13908
  * of its JSON document instead (jsonDigest), which the server computes the
13904
- * same way. Staging-only paths a publish never sends (account pages,
13909
+ * same way. Staging navigates with its own copies of the live theme's menus,
13910
+ * so that document and the files it names a menu in are also sent as text
13911
+ * (memberConfigurationTexts), and the server compares them without menu
13912
+ * slugs. Staging-only paths a publish never sends (account pages,
13905
13913
  * numbered duplicates, files attached to a template) are left out, so they
13906
13914
  * do not read as a difference on every comparison, and so are binary files a
13907
13915
  * pull kept remote in `.fluid-assets.json` instead of downloading.
@@ -13944,7 +13952,7 @@ async function compareWithStaging(api, themeId, root) {
13944
13952
  }];
13945
13953
  });
13946
13954
  if (entries.length === 0) throw new Error("No theme files to compare.");
13947
- const compared = await compareBranch(api, themeId, branch.slug, entries);
13955
+ const compared = await compareBranch(api, themeId, branch.slug, entries, memberConfigurationTexts(plan));
13948
13956
  const keptRemote = keptRemoteAssets(root);
13949
13957
  const branchOnly = compared.branch_only.filter((path) => unpublishableReason(path) === null && !keptRemote.has(path));
13950
13958
  return {
@@ -13955,6 +13963,39 @@ async function compareWithStaging(api, themeId, root) {
13955
13963
  branchOnly
13956
13964
  };
13957
13965
  }
13966
+ /** The server's limits on member configuration text in one comparison. */
13967
+ const MAX_MEMBER_FILES = 5e3;
13968
+ const MAX_MEMBER_FILE_BYTES = 5 * 1024 * 1024;
13969
+ const MAX_MEMBER_TOTAL_BYTES = 25 * 1024 * 1024;
13970
+ /**
13971
+ * The text of members_sites.json and of each file its menu_references name,
13972
+ * as a publish would send them. None when there is no readable document, or
13973
+ * when the files are beyond what the server takes, so those files are
13974
+ * compared by digest instead of being refused.
13975
+ */
13976
+ function memberConfigurationTexts(plan) {
13977
+ const texts = /* @__PURE__ */ new Map();
13978
+ for (const entry of plan.entries) {
13979
+ if (!("sha256" in entry)) continue;
13980
+ const sent = plan.contents.get(entry.sha256);
13981
+ if (sent) texts.set(entry.path, Buffer.from(sent).toString("utf-8"));
13982
+ }
13983
+ const document = texts.get(MEMBER_CONFIGURATION_KEY);
13984
+ if (document === void 0) return [];
13985
+ let references;
13986
+ try {
13987
+ references = JSON.parse(document)?.menu_references;
13988
+ } catch {
13989
+ return [];
13990
+ }
13991
+ const files = [MEMBER_CONFIGURATION_KEY, ...new Set((Array.isArray(references) ? references : []).map((reference) => reference?.path).filter((path) => typeof path === "string"))].filter((path) => texts.has(path)).map((path) => ({
13992
+ path,
13993
+ content: texts.get(path)
13994
+ }));
13995
+ const sizes = files.map((file) => Buffer.byteLength(file.content, "utf-8"));
13996
+ const total = sizes.reduce((sum, size) => sum + size, 0);
13997
+ return files.length <= MAX_MEMBER_FILES && sizes.every((size) => size <= MAX_MEMBER_FILE_BYTES) && total <= MAX_MEMBER_TOTAL_BYTES ? files : [];
13998
+ }
13958
13999
  /**
13959
14000
  * The binary files a pull kept remote. An unreadable manifest lists none,
13960
14001
  * so the comparison errs towards reporting a difference.