@bridge-ds/core 0.13.0 → 0.16.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.
@@ -1209,7 +1209,7 @@ const DEFAULT_GOVERNANCE = {
1209
1209
  owners: { design: [], tech: [] }
1210
1210
  };
1211
1211
  const FLAT_TOKEN_KEYS = ["primitives", "brands", "semantic", "base", "density", "components", "contrastChecks"];
1212
- const CANONICAL_TOKEN_KEYS = ["root", "include", "exclude", "tiers", "layers"];
1212
+ const CANONICAL_TOKEN_KEYS = ["root", "include", "exclude", "tiers", "layers", "usage"];
1213
1213
  const FLAT_MODE_KEYS = ["brands", "themes", "densities", "defaults"];
1214
1214
  const AXIS_OF = { brands: "brand", themes: "theme", densities: "density" };
1215
1215
  class ConfigError extends Error {
@@ -1297,7 +1297,7 @@ function defineConfig(input) {
1297
1297
  const contrastFile = contrastPath ?? [root === "." ? "" : root, paths.contrastChecks].filter(Boolean).join("/");
1298
1298
  return {
1299
1299
  repo: parseRepoInput(input.repo, input.branch),
1300
- tokens: { ...paths, include: input.tokens?.include ?? ["**/*.tokens.json"], exclude: input.tokens?.exclude ?? [], tiers, layers },
1300
+ tokens: { ...paths, include: input.tokens?.include ?? ["**/*.tokens.json"], exclude: input.tokens?.exclude ?? [], tiers, layers, ...t.usage ? { usage: trimSlashes(t.usage) } : {} },
1301
1301
  axes,
1302
1302
  modes,
1303
1303
  contrast: { path: contrastFile, modes: input.contrast?.modes },
@@ -1307,7 +1307,8 @@ function defineConfig(input) {
1307
1307
  styleSuffix: input.components.styleSuffix ?? ".module.css",
1308
1308
  reference: input.components.reference,
1309
1309
  index: input.components.index,
1310
- specs: input.components.specs
1310
+ specs: input.components.specs,
1311
+ ...input.components.styles ? { styles: input.components.styles.map(trimSlashes) } : {}
1311
1312
  } : void 0,
1312
1313
  docs: { ...input.docs },
1313
1314
  changesets: pkg ? { dir: trimSlashes(input.changesets?.dir ?? ".changeset"), package: pkg } : void 0,
@@ -1332,6 +1333,7 @@ function defineConfig(input) {
1332
1333
  products: input.products?.length ? input.products.map((p) => ({ ...p })) : DEFAULT_PRODUCTS.map((p) => ({ ...p })),
1333
1334
  changes: input.changes === "direct" ? "direct" : DEFAULT_CHANGES_MODE,
1334
1335
  ...input.storybook?.url ? { storybook: { url: input.storybook.url.trim().replace(/\/+$/, "") } } : {},
1336
+ ...input.library?.public === true ? { library: { public: true } } : {},
1335
1337
  ...input.audit ? { audit: { ...input.audit } } : {},
1336
1338
  ...input.visualImpact ? { visualImpact: { mode: input.visualImpact.mode === "on-demand" ? "on-demand" : "auto" } } : {},
1337
1339
  ...input.integrations ? { integrations: { ...input.integrations } } : {},
@@ -1376,7 +1378,7 @@ function loadConfig(source) {
1376
1378
  if (!isObj(tokens)) problems.push('"tokens" must be an object');
1377
1379
  else
1378
1380
  for (const [k, v] of Object.entries(tokens)) {
1379
- if (FLAT_TOKEN_KEYS.includes(k) || k === "root") {
1381
+ if (FLAT_TOKEN_KEYS.includes(k) || k === "root" || k === "usage") {
1380
1382
  if (!isStr(v)) problems.push(`"tokens.${k}" must be a non-empty string`);
1381
1383
  } else if (k === "include" || k === "exclude") {
1382
1384
  if (!isStrList(v)) problems.push(`"tokens.${k}" must be a list of globs`);
@@ -1430,6 +1432,7 @@ function loadConfig(source) {
1430
1432
  problems.push('"contrast" must be { "path", "modes"? }');
1431
1433
  const comps = d.components;
1432
1434
  if (comps !== void 0 && (!isObj(comps) || !isStr(comps.dir))) problems.push('"components.dir" must be a non-empty string');
1435
+ if (isObj(comps) && comps.styles !== void 0 && !isStrList(comps.styles)) problems.push('"components.styles" must be a list of globs');
1433
1436
  const cs = d.changeset;
1434
1437
  if (cs !== void 0 && (!isObj(cs) || !isStr(cs.package))) problems.push('"changeset.package" must be a non-empty string');
1435
1438
  const css = d.changesets;
@@ -1462,6 +1465,14 @@ function loadConfig(source) {
1462
1465
  else if (!/^https:\/\/[^\s/]+/.test(sb.url.trim())) problems.push('"storybook.url" must start with https://, for example https://storybook.example.com');
1463
1466
  else for (const k of Object.keys(sb)) if (k !== "url") problems.push(`"storybook.${k}" is not a known key`);
1464
1467
  }
1468
+ const lib = d.library;
1469
+ if (lib !== void 0) {
1470
+ if (!isObj(lib)) problems.push('"library" must be an object, for example { "public": true }');
1471
+ else {
1472
+ if (lib.public !== void 0 && typeof lib.public !== "boolean") problems.push('"library.public" must be true or false');
1473
+ for (const k of Object.keys(lib)) if (k !== "public") problems.push(`"library.${k}" is not a known key`);
1474
+ }
1475
+ }
1465
1476
  problems.push(...productProblems(d.products));
1466
1477
  const audit = d.audit;
1467
1478
  if (audit !== void 0) {
@@ -1501,12 +1512,13 @@ function storybookUrl(config) {
1501
1512
  const prod = config?.previews?.production?.storybook?.trim();
1502
1513
  return prod && /^https:\/\//.test(prod) && !/\{\w+\}/.test(prod) ? prod.replace(/\/+$/, "") : void 0;
1503
1514
  }
1515
+ const libraryIsPublic = (config) => config?.library?.public === true;
1504
1516
  function toConfigJson(config, schema = "./packages/core/bridge.config.schema.json") {
1505
1517
  return {
1506
1518
  $schema: schema,
1507
1519
  version: 1,
1508
1520
  ...config.repo ? { repo: config.repo } : {},
1509
- tokens: { root: config.tokens.root, include: config.tokens.include, ...config.tokens.exclude.length ? { exclude: config.tokens.exclude } : {}, tiers: config.tokens.tiers, layers: config.tokens.layers.map((l) => l.optional ? l : { files: l.files }) },
1521
+ tokens: { root: config.tokens.root, include: config.tokens.include, ...config.tokens.exclude.length ? { exclude: config.tokens.exclude } : {}, tiers: config.tokens.tiers, layers: config.tokens.layers.map((l) => l.optional ? l : { files: l.files }), ...config.tokens.usage ? { usage: config.tokens.usage } : {} },
1510
1522
  modes: Object.fromEntries(Object.entries(config.axes).map(([k, a]) => [k, a.parity ? a : { values: a.values, default: a.default }])),
1511
1523
  ...config.contrast ? { contrast: config.contrast.modes ? config.contrast : { path: config.contrast.path } } : {},
1512
1524
  ...config.components ? { components: Object.fromEntries(Object.entries(config.components).filter(([, v]) => v !== void 0)) } : {},
@@ -1519,6 +1531,7 @@ function toConfigJson(config, schema = "./packages/core/bridge.config.schema.jso
1519
1531
  ...config.visualImpact ? { visualImpact: config.visualImpact } : {},
1520
1532
  changes: changesMode(config),
1521
1533
  ...config.storybook ? { storybook: config.storybook } : {},
1534
+ ...config.library ? { library: config.library } : {},
1522
1535
  ...config.products && !sameProducts(config.products, DEFAULT_PRODUCTS) ? { products: config.products } : {}
1523
1536
  };
1524
1537
  }
@@ -2939,7 +2952,7 @@ export {
2939
2952
  previewsSettled as Z,
2940
2953
  DEFAULT_TOKEN_PATHS as _,
2941
2954
  proposedTokenPath as a,
2942
- contextFor as a$,
2955
+ composePrBody as a$,
2943
2956
  buildTokenSet as a0,
2944
2957
  readPreviewComment as a1,
2945
2958
  linkStatus as a2,
@@ -2950,110 +2963,110 @@ export {
2950
2963
  withNeededBy as a7,
2951
2964
  withLink as a8,
2952
2965
  withPiecesRecord as a9,
2953
- RIGHTS as aA,
2954
- RIGHT_LABEL as aB,
2955
- RISK_TIER as aC,
2956
- TIER_ORDER as aD,
2957
- TeamDirectory as aE,
2958
- VISUAL_CHECK_LABEL as aF,
2959
- affectedContrast as aG,
2960
- aliasOf as aH,
2961
- appForProject as aI,
2962
- appUrl as aJ,
2963
- approverEntries as aK,
2964
- approverLists as aL,
2965
- baseBranchOf as aM,
2966
- branchName as aN,
2967
- branchSlug as aO,
2968
- canShip as aP,
2969
- changeKind as aQ,
2970
- changedModes as aR,
2971
- changesMode as aS,
2972
- clearRawDeep as aT,
2973
- colorToCss as aU,
2974
- colorsEqual as aV,
2975
- comboKey as aW,
2976
- commitMessage as aX,
2977
- compactJson as aY,
2978
- composePrBody as aZ,
2979
- composite as a_,
2966
+ PRIMITIVE_MODE as aA,
2967
+ PRODUCT_LABEL_PREFIX as aB,
2968
+ RIGHTS as aC,
2969
+ RIGHT_LABEL as aD,
2970
+ RISK_TIER as aE,
2971
+ TIER_ORDER as aF,
2972
+ TeamDirectory as aG,
2973
+ VISUAL_CHECK_LABEL as aH,
2974
+ affectedContrast as aI,
2975
+ aliasOf as aJ,
2976
+ appForProject as aK,
2977
+ appUrl as aL,
2978
+ approverEntries as aM,
2979
+ approverLists as aN,
2980
+ baseBranchOf as aO,
2981
+ branchName as aP,
2982
+ branchSlug as aQ,
2983
+ canShip as aR,
2984
+ changeKind as aS,
2985
+ changedModes as aT,
2986
+ changesMode as aU,
2987
+ clearRawDeep as aV,
2988
+ colorToCss as aW,
2989
+ colorsEqual as aX,
2990
+ comboKey as aY,
2991
+ commitMessage as aZ,
2992
+ compactJson as a_,
2980
2993
  productBranchSentence as aa,
2981
2994
  mergePiecesRecord as ab,
2982
2995
  productOfBranch as ac,
2983
2996
  defaultProduct as ad,
2984
2997
  slugify as ae,
2985
- AAA_MIN as af,
2986
- AA_MIN as ag,
2987
- CHANGES_MODES as ah,
2988
- CONTRAST_CELL_MAX as ai,
2989
- CONTRAST_CHECKS_FILE as aj,
2990
- ConfigError as ak,
2991
- DEFAULT_CHANGES_MODE as al,
2992
- DEFAULT_GOVERNANCE as am,
2993
- DEFAULT_OVERRIDE as an,
2994
- DEFAULT_PRODUCTS as ao,
2995
- DEFAULT_RIGHTS as ap,
2996
- DEFAULT_VISUAL_IMPACT as aq,
2997
- DTCG_TYPES as ar,
2998
- JsonParseError as as,
2999
- LINK_STATUS_TONE as at,
3000
- OWNER_GROUPS as au,
3001
- PREVIEW_APP_LABELS as av,
3002
- PREVIEW_COMMENT_MARKER as aw,
3003
- PREVIEW_PLACEHOLDERS as ax,
3004
- PRIMITIVE_MODE as ay,
3005
- PRODUCT_LABEL_PREFIX as az,
2998
+ defineConfig as af,
2999
+ globToRegExp as ag,
3000
+ ConfigError as ah,
3001
+ DEFAULT_CHANGES_MODE as ai,
3002
+ DEFAULT_OVERRIDE as aj,
3003
+ DEFAULT_PRODUCTS as ak,
3004
+ AAA_MIN as al,
3005
+ AA_MIN as am,
3006
+ CHANGES_MODES as an,
3007
+ CONTRAST_CELL_MAX as ao,
3008
+ CONTRAST_CHECKS_FILE as ap,
3009
+ DEFAULT_GOVERNANCE as aq,
3010
+ DEFAULT_RIGHTS as ar,
3011
+ DEFAULT_VISUAL_IMPACT as as,
3012
+ DTCG_TYPES as at,
3013
+ JsonParseError as au,
3014
+ LINK_STATUS_TONE as av,
3015
+ OWNER_GROUPS as aw,
3016
+ PREVIEW_APP_LABELS as ax,
3017
+ PREVIEW_COMMENT_MARKER as ay,
3018
+ PREVIEW_PLACEHOLDERS as az,
3006
3019
  modesOf as b,
3007
- sameProducts as b$,
3008
- contrastLevel as b0,
3009
- contrastPair as b1,
3010
- contrastRatio as b2,
3011
- defaultContext as b3,
3012
- defaultTitle as b4,
3013
- defineConfig as b5,
3014
- detectLayout as b6,
3015
- entriesFor as b7,
3016
- entryLabel as b8,
3017
- expandEntries as b9,
3018
- nearestQuestion as bA,
3019
- neededBySection as bB,
3020
- nodesEqual as bC,
3021
- normalizeRights as bD,
3022
- overrideKey as bE,
3023
- ownerEntryProblems as bF,
3024
- pairKey as bG,
3025
- parseDimension as bH,
3026
- parseJson as bI,
3027
- parseNeededBy as bJ,
3028
- parseOwnerEntry as bK,
3029
- parseVercelComment as bL,
3030
- piecesSection as bM,
3031
- plainEqual as bN,
3032
- previewComment as bO,
3033
- previewLinksOf as bP,
3034
- previewUrl as bQ,
3035
- productForPlace as bR,
3036
- productLabel as bS,
3037
- productMarks as bT,
3038
- productProblems as bU,
3039
- productsOf as bV,
3040
- projectOfLabel as bW,
3041
- protectedBranchesOf as bX,
3042
- renderedColor as bY,
3043
- rgbaToDtcg as bZ,
3044
- rightsProblems as b_,
3045
- expandOwners as ba,
3046
- fieldChanges as bb,
3047
- findProduct as bc,
3048
- findToken as bd,
3049
- findVercelComment as be,
3050
- flattenLayerFile as bf,
3051
- formatNumber as bg,
3052
- formatOwnerEntry as bh,
3053
- fromPlain as bi,
3054
- getChild as bj,
3055
- getEntry as bk,
3056
- globToRegExp as bl,
3020
+ rightsProblems as b$,
3021
+ composite as b0,
3022
+ contextFor as b1,
3023
+ contrastLevel as b2,
3024
+ contrastPair as b3,
3025
+ contrastRatio as b4,
3026
+ defaultContext as b5,
3027
+ defaultTitle as b6,
3028
+ detectLayout as b7,
3029
+ entriesFor as b8,
3030
+ entryLabel as b9,
3031
+ luminance as bA,
3032
+ nearestQuestion as bB,
3033
+ neededBySection as bC,
3034
+ nodesEqual as bD,
3035
+ normalizeRights as bE,
3036
+ overrideKey as bF,
3037
+ ownerEntryProblems as bG,
3038
+ pairKey as bH,
3039
+ parseDimension as bI,
3040
+ parseJson as bJ,
3041
+ parseNeededBy as bK,
3042
+ parseOwnerEntry as bL,
3043
+ parseVercelComment as bM,
3044
+ piecesSection as bN,
3045
+ plainEqual as bO,
3046
+ previewComment as bP,
3047
+ previewLinksOf as bQ,
3048
+ previewUrl as bR,
3049
+ productForPlace as bS,
3050
+ productLabel as bT,
3051
+ productMarks as bU,
3052
+ productProblems as bV,
3053
+ productsOf as bW,
3054
+ projectOfLabel as bX,
3055
+ protectedBranchesOf as bY,
3056
+ renderedColor as bZ,
3057
+ rgbaToDtcg as b_,
3058
+ expandEntries as ba,
3059
+ expandOwners as bb,
3060
+ fieldChanges as bc,
3061
+ findProduct as bd,
3062
+ findToken as be,
3063
+ findVercelComment as bf,
3064
+ flattenLayerFile as bg,
3065
+ formatNumber as bh,
3066
+ formatOwnerEntry as bi,
3067
+ fromPlain as bj,
3068
+ getChild as bk,
3069
+ getEntry as bl,
3057
3070
  groupsPhrase as bm,
3058
3071
  hexToRgba as bn,
3059
3072
  holdersOf as bo,
@@ -3067,36 +3080,37 @@ export {
3067
3080
  isVercelComment as bw,
3068
3081
  kindForMin as bx,
3069
3082
  layeredParityIssues as by,
3070
- luminance as bz,
3083
+ libraryIsPublic as bz,
3071
3084
  TIER_AXIS as c,
3072
- sameToken as c0,
3073
- serializeJson as c1,
3074
- shipPolicy as c2,
3075
- snapshotUrl as c3,
3076
- soloApprover as c4,
3077
- soloOwnerOf as c5,
3078
- soloOwnerSentence as c6,
3079
- storybookUrl as c7,
3080
- suggestNearestComment as c8,
3081
- summarizeTokenChange as c9,
3082
- tarballAssetName as ca,
3083
- tarballUrl as cb,
3084
- teamKey as cc,
3085
- teamKeyOf as cd,
3086
- teamUnreadableMessage as ce,
3087
- teamsIn as cf,
3088
- toAlias as cg,
3089
- toMap as ch,
3090
- toPlain as ci,
3091
- tokenBump as cj,
3092
- tokenNode as ck,
3093
- unreadableShipTeams as cl,
3094
- unreadableTeams as cm,
3095
- valueIn as cn,
3096
- valueToCss as co,
3097
- visualImpactProblems as cp,
3098
- whoCanShipSentence as cq,
3099
- whyItExists as cr,
3085
+ sameProducts as c0,
3086
+ sameToken as c1,
3087
+ serializeJson as c2,
3088
+ shipPolicy as c3,
3089
+ snapshotUrl as c4,
3090
+ soloApprover as c5,
3091
+ soloOwnerOf as c6,
3092
+ soloOwnerSentence as c7,
3093
+ storybookUrl as c8,
3094
+ suggestNearestComment as c9,
3095
+ summarizeTokenChange as ca,
3096
+ tarballAssetName as cb,
3097
+ tarballUrl as cc,
3098
+ teamKey as cd,
3099
+ teamKeyOf as ce,
3100
+ teamUnreadableMessage as cf,
3101
+ teamsIn as cg,
3102
+ toAlias as ch,
3103
+ toMap as ci,
3104
+ toPlain as cj,
3105
+ tokenBump as ck,
3106
+ tokenNode as cl,
3107
+ unreadableShipTeams as cm,
3108
+ unreadableTeams as cn,
3109
+ valueIn as co,
3110
+ valueToCss as cp,
3111
+ visualImpactProblems as cq,
3112
+ whoCanShipSentence as cr,
3113
+ whyItExists as cs,
3100
3114
  collectRefs as d,
3101
3115
  evaluatePairs as e,
3102
3116
  findReferenceProblems as f,
@@ -3121,4 +3135,4 @@ export {
3121
3135
  parseColor as y,
3122
3136
  rgbaToHex as z
3123
3137
  };
3124
- //# sourceMappingURL=prod-branch-6ftQWwdu.js.map
3138
+ //# sourceMappingURL=prod-branch-CSM0c2OF.js.map