@builderx/bridge
Advanced tools
Comparing version 0.1.11 to 0.1.12
@@ -86,3 +86,3 @@ "use strict"; | ||
if (((_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.type) == 'setDOMStyleUntilHMR') { | ||
var doms = document.querySelectorAll('[data-path="' + event.data.payload.path + '"]'); | ||
var doms = document.querySelectorAll('[data-bx-path="' + event.data.payload.path + '"]'); | ||
Array.from(doms).forEach((dom) => { | ||
@@ -140,4 +140,4 @@ updateDOMUntilHMR(dom, event.data.payload.style); | ||
const memoizedProps = fiberNode.memoizedProps; | ||
if (memoizedProps && 'data-path' in memoizedProps) { | ||
dataPath = memoizedProps['data-path']; | ||
if (memoizedProps && 'data-bx-path' in memoizedProps) { | ||
dataPath = memoizedProps['data-bx-path']; | ||
if (dataPath && inLayers.includes(dataPath)) { | ||
@@ -153,3 +153,3 @@ element = getDomNodeFromFiber(fiberNode); | ||
element = elementAtPoint; | ||
dataPath = fiberNode === null || fiberNode === void 0 ? void 0 : fiberNode.memoizedProps['data-path']; | ||
dataPath = fiberNode === null || fiberNode === void 0 ? void 0 : fiberNode.memoizedProps['data-bx-path']; | ||
} | ||
@@ -188,3 +188,3 @@ if (element) { | ||
containerData.children.push({ | ||
path: ((_a = childFiberNode.memoizedProps) === null || _a === void 0 ? void 0 : _a['data-path']) || '', | ||
path: ((_a = childFiberNode.memoizedProps) === null || _a === void 0 ? void 0 : _a['data-bx-path']) || '', | ||
width: childRect.width, | ||
@@ -213,3 +213,3 @@ height: childRect.height, | ||
else { | ||
domNode = document.querySelector(`[data-path="${path}"]`); | ||
domNode = document.querySelector(`[data-bx-path="${path}"]`); | ||
} | ||
@@ -275,5 +275,5 @@ return domNode; | ||
const bodyElement = document.querySelector('body'); | ||
const rootElement = bodyElement === null || bodyElement === void 0 ? void 0 : bodyElement.querySelector('[data-path]'); | ||
const rootElement = bodyElement === null || bodyElement === void 0 ? void 0 : bodyElement.querySelector('[data-bx-path]'); | ||
if (!rootElement) { | ||
console.error('No element with data-path attribute found'); | ||
console.error('No element with data-bx-path attribute found'); | ||
return null; | ||
@@ -306,3 +306,3 @@ } | ||
if (fiber.memoizedProps && | ||
fiber.memoizedProps['data-path'] === targetPath) { | ||
fiber.memoizedProps['data-bx-path'] === targetPath) { | ||
return fiber; | ||
@@ -337,3 +337,3 @@ } | ||
var _a, _b, _c; | ||
const fiber = getFiberNodeInOwner(child._owner, (_a = child.props) === null || _a === void 0 ? void 0 : _a['data-path'], child); | ||
const fiber = getFiberNodeInOwner(child._owner, (_a = child.props) === null || _a === void 0 ? void 0 : _a['data-bx-path'], child); | ||
if (!fiber && !isValidElement(child)) { | ||
@@ -345,3 +345,3 @@ return null; | ||
displayName: getComponentName(child), | ||
path: ((_b = child.props) === null || _b === void 0 ? void 0 : _b['data-path']) || null, | ||
path: ((_b = child.props) === null || _b === void 0 ? void 0 : _b['data-bx-path']) || null, | ||
fiber: withFiber ? fiber : null, | ||
@@ -403,3 +403,3 @@ componentTree: componentTree, | ||
} | ||
return (((_a = element === null || element === void 0 ? void 0 : element.props) === null || _a === void 0 ? void 0 : _a['data-path']) === ((_b = fiberNode === null || fiberNode === void 0 ? void 0 : fiberNode.memoizedProps) === null || _b === void 0 ? void 0 : _b['data-path'])); | ||
return (((_a = element === null || element === void 0 ? void 0 : element.props) === null || _a === void 0 ? void 0 : _a['data-bx-path']) === ((_b = fiberNode === null || fiberNode === void 0 ? void 0 : fiberNode.memoizedProps) === null || _b === void 0 ? void 0 : _b['data-bx-path'])); | ||
}; | ||
@@ -435,7 +435,7 @@ // Check if propsChildren is an array or a single child | ||
var _a; | ||
if (!childChildren.some((existingChild) => { var _a; return existingChild.path === ((_a = memoizedChild === null || memoizedChild === void 0 ? void 0 : memoizedChild.props) === null || _a === void 0 ? void 0 : _a['data-path']); })) { | ||
if (!childChildren.some((existingChild) => { var _a; return existingChild.path === ((_a = memoizedChild === null || memoizedChild === void 0 ? void 0 : memoizedChild.props) === null || _a === void 0 ? void 0 : _a['data-bx-path']); })) { | ||
childChildren.push({ | ||
displayName: getComponentName(memoizedChild), | ||
debugInfo: getDebugInfo(memoizedChild === null || memoizedChild === void 0 ? void 0 : memoizedChild._owner), | ||
path: ((_a = memoizedChild === null || memoizedChild === void 0 ? void 0 : memoizedChild.props) === null || _a === void 0 ? void 0 : _a['data-path']) || null, | ||
path: ((_a = memoizedChild === null || memoizedChild === void 0 ? void 0 : memoizedChild.props) === null || _a === void 0 ? void 0 : _a['data-bx-path']) || null, | ||
props: Object.assign({}, memoizedChild === null || memoizedChild === void 0 ? void 0 : memoizedChild.props), | ||
@@ -450,3 +450,3 @@ _owner: memoizedChild === null || memoizedChild === void 0 ? void 0 : memoizedChild._owner, | ||
debugInfo: getDebugInfo(child), | ||
path: ((_b = child.memoizedProps) === null || _b === void 0 ? void 0 : _b['data-path']) || null, | ||
path: ((_b = child.memoizedProps) === null || _b === void 0 ? void 0 : _b['data-bx-path']) || null, | ||
props: Object.assign(Object.assign({}, child.memoizedProps), { children: childChildren }), | ||
@@ -472,3 +472,3 @@ componentTree: fiberChildren.componentTree, | ||
debugInfo: getDebugInfo(fiber), | ||
path: ((_a = fiber.memoizedProps) === null || _a === void 0 ? void 0 : _a['data-path']) || null, | ||
path: ((_a = fiber.memoizedProps) === null || _a === void 0 ? void 0 : _a['data-bx-path']) || null, | ||
fiber: withFiber ? fiber : null, | ||
@@ -488,7 +488,7 @@ children: [], | ||
} | ||
// Check if this fiber node has a data-path | ||
// Check if this fiber node has a data-bx-path | ||
const hasDataPath = fiber.memoizedProps && | ||
fiber.memoizedProps['data-path'] && | ||
((_a = fiber.memoizedProps['data-path']) === null || _a === void 0 ? void 0 : _a.includes('node_modules')) === false; | ||
// If this node doesn't have a data-path, check its children | ||
fiber.memoizedProps['data-bx-path'] && | ||
((_a = fiber.memoizedProps['data-bx-path']) === null || _a === void 0 ? void 0 : _a.includes('node_modules')) === false; | ||
// If this node doesn't have a data-bx-path, check its children | ||
if (!hasDataPath) { | ||
@@ -501,3 +501,3 @@ const childElement = fiber.child | ||
} | ||
// If no child has a data-path, check the next sibling | ||
// If no child has a data-bx-path, check the next sibling | ||
return fiber.sibling | ||
@@ -507,7 +507,7 @@ ? buildReactElementTree(fiber.sibling, withFiber) | ||
} | ||
// If we reach here, this node has a data-path, so we build the element | ||
// If we reach here, this node has a data-bx-path, so we build the element | ||
const element = { | ||
displayName: getComponentName(fiber), | ||
debugInfo: getDebugInfo(fiber), | ||
path: fiber.memoizedProps['data-path'], | ||
path: fiber.memoizedProps['data-bx-path'], | ||
fiber: withFiber ? fiber : null, | ||
@@ -521,3 +521,3 @@ componentTree: buildReactFiberTree(fiber, withFiber), | ||
if (key !== 'children' && | ||
key !== 'data-path' && | ||
key !== 'data-bx-path' && | ||
typeof value !== 'function') { | ||
@@ -524,0 +524,0 @@ element.props[key] = value; |
{ | ||
"name": "@builderx/bridge", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -107,3 +107,3 @@ declare global { | ||
var doms = document.querySelectorAll( | ||
'[data-path="' + event.data.payload.path + '"]' | ||
'[data-bx-path="' + event.data.payload.path + '"]' | ||
); | ||
@@ -180,4 +180,4 @@ | ||
const memoizedProps = fiberNode.memoizedProps; | ||
if (memoizedProps && 'data-path' in memoizedProps) { | ||
dataPath = memoizedProps['data-path']; | ||
if (memoizedProps && 'data-bx-path' in memoizedProps) { | ||
dataPath = memoizedProps['data-bx-path']; | ||
if (dataPath && inLayers.includes(dataPath)) { | ||
@@ -192,3 +192,3 @@ element = getDomNodeFromFiber(fiberNode); | ||
element = elementAtPoint; | ||
dataPath = fiberNode?.memoizedProps['data-path']; | ||
dataPath = fiberNode?.memoizedProps['data-bx-path']; | ||
} | ||
@@ -232,3 +232,3 @@ | ||
containerData.children.push({ | ||
path: childFiberNode.memoizedProps?.['data-path'] || '', | ||
path: childFiberNode.memoizedProps?.['data-bx-path'] || '', | ||
width: childRect.width, | ||
@@ -261,3 +261,3 @@ height: childRect.height, | ||
} else { | ||
domNode = document.querySelector(`[data-path="${path}"]`); | ||
domNode = document.querySelector(`[data-bx-path="${path}"]`); | ||
} | ||
@@ -338,7 +338,7 @@ return domNode; | ||
const bodyElement = document.querySelector('body'); | ||
const rootElement = bodyElement?.querySelector('[data-path]'); | ||
const rootElement = bodyElement?.querySelector('[data-bx-path]'); | ||
if (!rootElement) { | ||
console.error('No element with data-path attribute found'); | ||
console.error('No element with data-bx-path attribute found'); | ||
return null; | ||
@@ -386,3 +386,3 @@ } | ||
fiber.memoizedProps && | ||
fiber.memoizedProps['data-path'] === targetPath | ||
fiber.memoizedProps['data-bx-path'] === targetPath | ||
) { | ||
@@ -430,3 +430,3 @@ return fiber; | ||
child._owner, | ||
child.props?.['data-path'], | ||
child.props?.['data-bx-path'], | ||
child | ||
@@ -443,3 +443,3 @@ ); | ||
displayName: getComponentName(child), | ||
path: child.props?.['data-path'] || null, | ||
path: child.props?.['data-bx-path'] || null, | ||
fiber: withFiber ? fiber : null, | ||
@@ -514,3 +514,3 @@ componentTree: componentTree, | ||
return ( | ||
element?.props?.['data-path'] === fiberNode?.memoizedProps?.['data-path'] | ||
element?.props?.['data-bx-path'] === fiberNode?.memoizedProps?.['data-bx-path'] | ||
); | ||
@@ -559,3 +559,3 @@ }; | ||
(existingChild: any) => | ||
existingChild.path === memoizedChild?.props?.['data-path'] | ||
existingChild.path === memoizedChild?.props?.['data-bx-path'] | ||
) | ||
@@ -566,3 +566,3 @@ ) { | ||
debugInfo: getDebugInfo(memoizedChild?._owner), | ||
path: memoizedChild?.props?.['data-path'] || null, | ||
path: memoizedChild?.props?.['data-bx-path'] || null, | ||
props: { ...memoizedChild?.props }, | ||
@@ -578,3 +578,3 @@ _owner: memoizedChild?._owner, | ||
debugInfo: getDebugInfo(child), | ||
path: child.memoizedProps?.['data-path'] || null, | ||
path: child.memoizedProps?.['data-bx-path'] || null, | ||
props: { ...child.memoizedProps, children: childChildren }, | ||
@@ -604,3 +604,3 @@ componentTree: fiberChildren.componentTree, | ||
debugInfo: getDebugInfo(fiber), | ||
path: fiber.memoizedProps?.['data-path'] || null, | ||
path: fiber.memoizedProps?.['data-bx-path'] || null, | ||
fiber: withFiber ? fiber : null, | ||
@@ -627,10 +627,10 @@ children: [], | ||
// Check if this fiber node has a data-path | ||
// Check if this fiber node has a data-bx-path | ||
const hasDataPath = | ||
fiber.memoizedProps && | ||
fiber.memoizedProps['data-path'] && | ||
fiber.memoizedProps['data-path']?.includes('node_modules') === false; | ||
fiber.memoizedProps['data-bx-path'] && | ||
fiber.memoizedProps['data-bx-path']?.includes('node_modules') === false; | ||
// If this node doesn't have a data-path, check its children | ||
// If this node doesn't have a data-bx-path, check its children | ||
if (!hasDataPath) { | ||
@@ -643,3 +643,3 @@ const childElement = fiber.child | ||
} | ||
// If no child has a data-path, check the next sibling | ||
// If no child has a data-bx-path, check the next sibling | ||
return fiber.sibling | ||
@@ -650,7 +650,7 @@ ? buildReactElementTree(fiber.sibling, withFiber) | ||
// If we reach here, this node has a data-path, so we build the element | ||
// If we reach here, this node has a data-bx-path, so we build the element | ||
const element: any = { | ||
displayName: getComponentName(fiber), | ||
debugInfo: getDebugInfo(fiber), | ||
path: fiber.memoizedProps['data-path'], | ||
path: fiber.memoizedProps['data-bx-path'], | ||
fiber: withFiber ? fiber : null, | ||
@@ -666,3 +666,3 @@ componentTree: buildReactFiberTree(fiber, withFiber), | ||
key !== 'children' && | ||
key !== 'data-path' && | ||
key !== 'data-bx-path' && | ||
typeof value !== 'function' | ||
@@ -669,0 +669,0 @@ ) { |
Sorry, the diff of this file is not supported yet
82736