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