anymorph 0.13.0 → 0.15.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 (2) hide show
  1. package/dist/index.js +37 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12309,8 +12309,40 @@ var require_src = __commonJS({
12309
12309
  }
12310
12310
  }
12311
12311
  }
12312
+ function repairCmsMdxComponentContracts2(mdx) {
12313
+ let out = mdx;
12314
+ for (const [component, contract] of Object.entries(CMS_MDX_COMPONENT_CONTRACTS2)) {
12315
+ if (!contract.props) continue;
12316
+ for (const [prop, propContract] of Object.entries(contract.props)) {
12317
+ if (!Array.isArray(propContract.allowedValues)) continue;
12318
+ if (typeof propContract.defaultValue !== "string") continue;
12319
+ out = repairEnumComponentProp(
12320
+ out,
12321
+ component,
12322
+ prop,
12323
+ propContract.allowedValues,
12324
+ propContract.defaultValue
12325
+ );
12326
+ }
12327
+ }
12328
+ return out;
12329
+ }
12330
+ var TAG_BODY = `(?:"[^"]*"|'[^']*'|\\{[^}]*\\}|[^>])*?`;
12331
+ function repairEnumComponentProp(mdx, component, prop, allowedValues, defaultValue) {
12332
+ const tagPattern = new RegExp(`<${escapeRegExp(component)}\\b${TAG_BODY}\\s*/?>`, "gs");
12333
+ const propValuePattern = new RegExp(
12334
+ `((?:^|\\s)${escapeRegExp(prop)}\\s*=\\s*)(?:"[^"]*"|'[^']*'|\\{\\s*["'][^"']*["']\\s*\\})`,
12335
+ "s"
12336
+ );
12337
+ return mdx.replace(tagPattern, (tag) => {
12338
+ const value = readStaticJsxStringProp(tag, prop);
12339
+ if (value === null) return tag;
12340
+ if (allowedValues.includes(value)) return tag;
12341
+ return tag.replace(propValuePattern, `$1"${defaultValue}"`);
12342
+ });
12343
+ }
12312
12344
  function findComponentAttrs(mdx, component) {
12313
- const tagPattern = new RegExp(`<${escapeRegExp(component)}\\b([^>]*?)\\s*/?>`, "gs");
12345
+ const tagPattern = new RegExp(`<${escapeRegExp(component)}\\b(${TAG_BODY})\\s*/?>`, "gs");
12314
12346
  const attrs = [];
12315
12347
  let match = tagPattern.exec(mdx);
12316
12348
  while (match !== null) {
@@ -12321,7 +12353,7 @@ var require_src = __commonJS({
12321
12353
  }
12322
12354
  function readStaticJsxStringProp(attrs, prop) {
12323
12355
  const propPattern = new RegExp(
12324
- `\\b${escapeRegExp(prop)}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|\\{\\s*["']([^"']*)["']\\s*\\})`,
12356
+ `(?:^|\\s)${escapeRegExp(prop)}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|\\{\\s*["']([^"']*)["']\\s*\\})`,
12325
12357
  "s"
12326
12358
  );
12327
12359
  const match = propPattern.exec(attrs);
@@ -13571,6 +13603,7 @@ var require_src = __commonJS({
13571
13603
  validateCmsThemeTokens: cmsThemeTokens.validateCmsThemeTokens,
13572
13604
  CMS_MDX_COMPONENT_CONTRACTS: CMS_MDX_COMPONENT_CONTRACTS2,
13573
13605
  validateCmsMdxComponentContracts: validateCmsMdxComponentContracts2,
13606
+ repairCmsMdxComponentContracts: repairCmsMdxComponentContracts2,
13574
13607
  CMS_RELATED_CONTENT_TITLE_BY_LANG: CMS_RELATED_CONTENT_TITLE_BY_LANG2,
13575
13608
  getCmsRelatedContentTitle: getCmsRelatedContentTitle2
13576
13609
  };
@@ -22591,6 +22624,7 @@ var normalizeCmsThemeTokens = import_index2.default.normalizeCmsThemeTokens;
22591
22624
  var validateCmsThemeTokens = import_index2.default.validateCmsThemeTokens;
22592
22625
  var CMS_MDX_COMPONENT_CONTRACTS = import_index2.default.CMS_MDX_COMPONENT_CONTRACTS;
22593
22626
  var validateCmsMdxComponentContracts = import_index2.default.validateCmsMdxComponentContracts;
22627
+ var repairCmsMdxComponentContracts = import_index2.default.repairCmsMdxComponentContracts;
22594
22628
  var CMS_RELATED_CONTENT_TITLE_BY_LANG = import_index2.default.CMS_RELATED_CONTENT_TITLE_BY_LANG;
22595
22629
  var getCmsRelatedContentTitle = import_index2.default.getCmsRelatedContentTitle;
22596
22630
  var reasonTagSchema = import_index2.default.reasonTagSchema;
@@ -46923,7 +46957,7 @@ function printScaffoldError(prefix, err) {
46923
46957
 
46924
46958
  // src/index.ts
46925
46959
  var program2 = new Command();
46926
- program2.name("anymorph").description("Check AI visibility and run local GEO strategy workflows").version("0.13.0");
46960
+ program2.name("anymorph").description("Check AI visibility and run local GEO strategy workflows").version("0.15.0");
46927
46961
  program2.command("login").description("Sign in to your Anymorph account").addHelpText(
46928
46962
  "after",
46929
46963
  `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymorph",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Check your brand's AI visibility across ChatGPT, Perplexity, Gemini, and more",
5
5
  "type": "module",
6
6
  "private": false,