clava 0.6.4 → 0.7.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.
package/dist/index.js CHANGED
@@ -256,9 +256,9 @@ function formatCreationStack(frame) {
256
256
  }
257
257
  function isInternalCreationFrame(line) {
258
258
  if (line.includes("captureCreationFrame")) return true;
259
- if (line.startsWith("at buildComponent ")) return true;
260
- if (line.startsWith("at buildComponent(")) return true;
261
- if (line.startsWith("buildComponent@")) return true;
259
+ if (line.startsWith("at buildRecipe ")) return true;
260
+ if (line.startsWith("at buildRecipe(")) return true;
261
+ if (line.startsWith("buildRecipe@")) return true;
262
262
  if (line.startsWith("at cv ")) return true;
263
263
  if (line.startsWith("at cv(")) return true;
264
264
  if (line.startsWith("cv@")) return true;
@@ -310,7 +310,7 @@ function warnRefineLimit({ creationFrame, unstableChanges }) {
310
310
  }
311
311
  if (creationFrame) {
312
312
  const creationStack = formatCreationStack(creationFrame);
313
- if (creationStack) message += `\nComponent created at:\n${creationStack}`;
313
+ if (creationStack) message += `\nRecipe created at:\n${creationStack}`;
314
314
  }
315
315
  console.warn(message);
316
316
  }
@@ -402,7 +402,7 @@ function getVariantValueKey(value) {
402
402
  if (typeof value === "boolean") return String(value);
403
403
  }
404
404
  const EMPTY_KEYS = [];
405
- function isComponentKeySource(source) {
405
+ function isRecipeKeySource(source) {
406
406
  if (!source) return false;
407
407
  if (typeof source !== "object" && typeof source !== "function") return false;
408
408
  const typed = source;
@@ -410,10 +410,10 @@ function isComponentKeySource(source) {
410
410
  if (!Array.isArray(typed.propKeys)) return false;
411
411
  return Array.isArray(typed.variantKeys);
412
412
  }
413
- function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
413
+ function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
414
414
  const sourcesLength = sources.length;
415
415
  const results = [];
416
- let stylingClaimed = selfIsComponent;
416
+ let stylingClaimed = selfIsRecipe;
417
417
  const selfResult = {};
418
418
  const selfKeysLength = selfKeys.length;
419
419
  for (let i = 0; i < selfKeysLength; i++) {
@@ -425,11 +425,11 @@ function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
425
425
  for (let s = 0; s < sourcesLength; s++) {
426
426
  const source = sources[s];
427
427
  const sourceResult = {};
428
- let sourceIsComponent = false;
428
+ let sourceIsRecipe = false;
429
429
  let effectiveKeys;
430
430
  if (Array.isArray(source)) effectiveKeys = source;
431
- else if (isComponentKeySource(source)) {
432
- sourceIsComponent = true;
431
+ else if (isRecipeKeySource(source)) {
432
+ sourceIsRecipe = true;
433
433
  effectiveKeys = stylingClaimed ? source.variantKeys : source.propKeys;
434
434
  } else effectiveKeys = EMPTY_KEYS;
435
435
  const effectiveKeysLength = effectiveKeys.length;
@@ -439,7 +439,7 @@ function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
439
439
  }
440
440
  results.push(sourceResult);
441
441
  effectiveKeyArrays.push(effectiveKeys);
442
- if (sourceIsComponent && !stylingClaimed) stylingClaimed = true;
442
+ if (sourceIsRecipe && !stylingClaimed) stylingClaimed = true;
443
443
  }
444
444
  const rest = {};
445
445
  const propKeys = Object.keys(props);
@@ -461,7 +461,7 @@ function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
461
461
  }
462
462
  const splitProps = ((props, source1, ...sources) => {
463
463
  if (Array.isArray(source1)) return splitPropsImpl(source1, false, props, sources);
464
- if (isComponentKeySource(source1)) return splitPropsImpl(source1.propKeys, true, props, sources);
464
+ if (isRecipeKeySource(source1)) return splitPropsImpl(source1.propKeys, true, props, sources);
465
465
  return splitPropsImpl(EMPTY_KEYS, false, props, sources);
466
466
  });
467
467
  function buildPrebuiltVariant(variantDef) {
@@ -491,7 +491,7 @@ function buildPrebuiltVariant(variantDef) {
491
491
  function create(params = {}) {
492
492
  const transformClass = getOwn(params, "transformClass") ?? identityClass;
493
493
  const cx = (...classes) => transformClass(clsx(classes));
494
- const buildComponent = (config = {}) => {
494
+ const buildRecipe = (config = {}) => {
495
495
  const extend = getOwn(config, "extend");
496
496
  const variants = getOwn(config, "variants");
497
497
  const refine = getOwn(config, "refine");
@@ -1072,72 +1072,72 @@ function create(params = {}) {
1072
1072
  functionVariantKeys,
1073
1073
  computedDefaultKeys
1074
1074
  };
1075
- const initComponent = (c, propKeys, style) => {
1076
- c.class = classFn;
1077
- c.style = style;
1078
- c.getVariants = getVariants;
1079
- c.variantKeys = variantKeys;
1080
- c.propKeys = propKeys;
1081
- c[META_KEY] = meta;
1082
- return c;
1075
+ const initRecipe = (recipe, propKeys, style) => {
1076
+ recipe.class = classFn;
1077
+ recipe.style = style;
1078
+ recipe.getVariants = getVariants;
1079
+ recipe.variantKeys = variantKeys;
1080
+ recipe.propKeys = propKeys;
1081
+ recipe[META_KEY] = meta;
1082
+ return recipe;
1083
1083
  };
1084
- const defaultComponent = ((props = {}) => {
1084
+ const defaultRecipe = ((props = {}) => {
1085
1085
  const { className, style } = computeResult(props);
1086
1086
  return {
1087
1087
  class: className,
1088
1088
  style
1089
1089
  };
1090
1090
  });
1091
- initComponent(defaultComponent, inputPropsKeys, (props = {}) => {
1091
+ initRecipe(defaultRecipe, inputPropsKeys, (props = {}) => {
1092
1092
  return computeResult(props).style;
1093
1093
  });
1094
- const jsxComponent = ((props = {}) => {
1094
+ const jsxRecipe = ((props = {}) => {
1095
1095
  const { className, style } = computeResult(props);
1096
1096
  return {
1097
1097
  className,
1098
1098
  style
1099
1099
  };
1100
1100
  });
1101
- initComponent(jsxComponent, [
1101
+ initRecipe(jsxRecipe, [
1102
1102
  "className",
1103
1103
  "style",
1104
1104
  ...variantKeys
1105
1105
  ], (props = {}) => computeResult(props).style);
1106
- const htmlComponent = ((props = {}) => {
1106
+ const htmlRecipe = ((props = {}) => {
1107
1107
  const { className, style } = computeResult(props);
1108
1108
  return {
1109
1109
  class: className,
1110
1110
  style: styleValueToHTMLStyle(style)
1111
1111
  };
1112
1112
  });
1113
- initComponent(htmlComponent, [
1113
+ initRecipe(htmlRecipe, [
1114
1114
  "class",
1115
1115
  "style",
1116
1116
  ...variantKeys
1117
1117
  ], (props = {}) => styleValueToHTMLStyle(computeResult(props).style));
1118
- const htmlObjComponent = ((props = {}) => {
1118
+ const htmlObjRecipe = ((props = {}) => {
1119
1119
  const { className, style } = computeResult(props);
1120
1120
  return {
1121
1121
  class: className,
1122
1122
  style: styleValueToHTMLObjStyle(style)
1123
1123
  };
1124
1124
  });
1125
- initComponent(htmlObjComponent, [
1125
+ initRecipe(htmlObjRecipe, [
1126
1126
  "class",
1127
1127
  "style",
1128
1128
  ...variantKeys
1129
1129
  ], (props = {}) => styleValueToHTMLObjStyle(computeResult(props).style));
1130
- defaultComponent.jsx = jsxComponent;
1131
- defaultComponent.html = htmlComponent;
1132
- defaultComponent.htmlObj = htmlObjComponent;
1130
+ defaultRecipe.jsx = jsxRecipe;
1131
+ defaultRecipe.html = htmlRecipe;
1132
+ defaultRecipe.htmlObj = htmlObjRecipe;
1133
1133
  return {
1134
- component: defaultComponent,
1134
+ recipe: defaultRecipe,
1135
1135
  meta
1136
1136
  };
1137
1137
  };
1138
1138
  return build(initialExtensions);
1139
1139
  };
1140
- const cv = (config = {}) => buildComponent(config).component;
1140
+ const cv = (config = {}) => buildRecipe(config).recipe;
1141
1141
  return {
1142
1142
  cv,
1143
1143
  cx