made-refine 0.2.20 → 0.2.21

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/utils.mjs CHANGED
@@ -320,10 +320,30 @@ function getSourceFromFiber(fiber) {
320
320
  if (fromDebugStack?.fileName) return fromDebugStack;
321
321
  return null;
322
322
  }
323
+ var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref");
324
+ var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
325
+ function resolveComponentName(type) {
326
+ let current = type;
327
+ for (let depth = 0; depth < 4 && current != null; depth++) {
328
+ const name = current.displayName || (typeof current === "function" ? current.name : void 0);
329
+ if (name) return name;
330
+ if (typeof current !== "object") return null;
331
+ if (current.$$typeof === REACT_MEMO_TYPE) {
332
+ current = current.type;
333
+ continue;
334
+ }
335
+ if (current.$$typeof === REACT_FORWARD_REF_TYPE) {
336
+ current = current.render;
337
+ continue;
338
+ }
339
+ return null;
340
+ }
341
+ return null;
342
+ }
323
343
  function buildFrame(fiber) {
324
344
  const type = fiber?.type;
325
345
  if (typeof type !== "function" && typeof type !== "object") return null;
326
- const name = type?.displayName || type?.name || null;
346
+ const name = resolveComponentName(type);
327
347
  if (!name || name === "Fragment") return null;
328
348
  const frame = { name };
329
349
  const source = getSourceFromFiber(fiber);
@@ -2411,7 +2431,7 @@ function buildElementContext(locator) {
2411
2431
  return buildLocatorContextLines(locator).join("\n");
2412
2432
  }
2413
2433
  function hasSessionEditChanges(edit) {
2414
- return Object.keys(edit.pendingStyles).length > 0 || Boolean(edit.textEdit) || Boolean(edit.move);
2434
+ return Object.keys(edit.pendingStyles).length > 0 || Boolean(edit.textEdit) || Boolean(edit.move) || Boolean(edit.deleted);
2415
2435
  }
2416
2436
  function partitionMultiSelectedEdits(elements, sessionEditsRef) {
2417
2437
  const editsWithChanges = [];
@@ -2933,7 +2953,7 @@ function buildMoveEntries(edits) {
2933
2953
  let noopMoveCount = 0;
2934
2954
  for (const edit of edits) {
2935
2955
  const move = edit.move;
2936
- if (!move) continue;
2956
+ if (!move || edit.deleted) continue;
2937
2957
  const subject = buildAnchorRef(
2938
2958
  getElementDisplayName(edit.element) || edit.locator.tagName,
2939
2959
  edit.locator.domSelector,
@@ -3101,19 +3121,22 @@ function getExportContentProfile(edits, comments, movePlanOrContext) {
3101
3121
  hasCssEdits: edits.some((e) => Object.keys(e.pendingStyles).length > 0),
3102
3122
  hasTextEdits: edits.some((e) => e.textEdit != null),
3103
3123
  hasMoves: moveOpCount > 0,
3104
- hasComments: comments.length > 0
3124
+ hasComments: comments.length > 0,
3125
+ hasDeletes: edits.some((e) => e.deleted)
3105
3126
  };
3106
3127
  }
3107
3128
  function buildExportInstruction(profile) {
3108
3129
  const { hasCssEdits, hasTextEdits, hasMoves, hasComments } = profile;
3109
- if (!hasCssEdits && !hasTextEdits && !hasMoves && !hasComments) return "";
3110
- if (!hasCssEdits && !hasTextEdits && !hasMoves) {
3130
+ const hasDeletes = Boolean(profile.hasDeletes);
3131
+ if (!hasCssEdits && !hasTextEdits && !hasMoves && !hasComments && !hasDeletes) return "";
3132
+ if (!hasCssEdits && !hasTextEdits && !hasMoves && !hasDeletes) {
3111
3133
  return hasComments ? "Address this feedback on the UI. Use the provided source location and selector to find each element in the codebase." : "";
3112
3134
  }
3113
3135
  const parts = [];
3114
3136
  if (hasCssEdits) parts.push("Apply the CSS changes to the targeted elements using the project's existing styling approach (Tailwind, CSS modules, etc.). Map values to existing CSS variables, design tokens, or utility classes already used in the project whenever possible.");
3115
3137
  if (hasTextEdits) parts.push("Update the text content as specified.");
3116
3138
  if (hasMoves) parts.push("Implement the move plan below directly in source code. For `structural_move`, reorder/reparent elements using the target anchors. For `layout_refactor`, apply the listed flex/grid refactor steps. Do NOT simulate movement with absolute positioning, left/top offsets, transform, or margin hacks.");
3139
+ if (hasDeletes) parts.push("Delete the elements marked for deletion from the source code \u2014 remove their markup/JSX (and any now-dead props, handlers, or imports they solely used).");
3117
3140
  if (hasComments) parts.push("Address the comments on the relevant elements.");
3118
3141
  return `${parts.join(" ")} Use the provided source locations, selectors, and context HTML to locate each element in the codebase.`;
3119
3142
  }
@@ -3148,6 +3171,13 @@ function buildSessionExport(edits, comments = [], options) {
3148
3171
  blocks.push(planLines.join("\n"));
3149
3172
  }
3150
3173
  for (const edit of edits) {
3174
+ if (edit.deleted) {
3175
+ const lines = buildLocatorContextLines(edit.locator);
3176
+ lines.push("");
3177
+ lines.push("action: delete this element \u2014 remove it from the source");
3178
+ blocks.push(lines.join("\n"));
3179
+ continue;
3180
+ }
3151
3181
  const moveIntent = getMoveIntentForEdit(edit, planContext);
3152
3182
  const hasMove = Boolean(moveIntent);
3153
3183
  const hasStyleOrText = Object.keys(edit.pendingStyles).length > 0 || edit.textEdit != null;