@clutch-creator/bridge
Advanced tools
Comparing version 5.0.0-rc.6 to 5.0.0-rc.7
162
index.js
@@ -1,1 +0,161 @@ | ||
module.exports=function(t){var n={};function o(r){if(n[r])return n[r].exports;else{var e=n[r]={i:r,l:!1,exports:{}};return t[r].call(e.exports,e,e.exports,o),e.l=!0,e.exports}}return o.m=t,o.c=n,o.d=function(r,e,t){if(!o.o(r,e))Object.defineProperty(r,e,{enumerable:!0,get:t})},o.r=function(r){if("undefined"!=typeof Symbol&&Symbol.toStringTag)Object.defineProperty(r,Symbol.toStringTag,{value:"Module"});Object.defineProperty(r,"__esModule",{value:!0})},o.t=function(e,r){if(1&r)e=o(e);if(8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)o.d(t,n,function(r){return e[r]}.bind(null,n));return t},o.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return o.d(e,"a",e),e},o.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},o.p="",o(o.s=4)}([function(r,e){r.exports=require("react")},function(r,e){r.exports=require("@babel/runtime/helpers/defineProperty")},function(r,e){r.exports=require("@babel/runtime/helpers/slicedToArray")},function(r,e){r.exports=require("classnames")},function(r,e,t){"use strict";t.r(e),t.d(e,"cx",function(){return o}),t.d(e,"tryCatch",function(){return u}),t.d(e,"useReport",function(){return i}),t.d(e,"getReport",function(){return b});var e=t(1),c=t.n(e),e=t(2),f=t.n(e),e=t(3),e=t.n(e),a=t(0);function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?n(Object(t),!0).forEach(function(r){c()(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):n(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var l="undefined"!=typeof window&&(null==(t=window.__CLUTCH_INSPECTOR__)?void 0:t.v1),o=e.a;function u(r){var e;try{if("function"!=typeof r)throw new Error("Code property on an instance is not exporting a function");for(var t=arguments.length,n=new Array(1<t?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];e=r.apply(void 0,n)}catch(r){console.error(r)}return e}var s=function(r){return(null==(r=String(r).match(/(.+?)#(.+?)#(.*)/))?void 0:r.slice(1))||[]},d=0,i=function(r,e,t,n,o){var e=p({},e),u=e["data-d"];if(o)e.ref=o;delete e["data-d"];var c=Object(a.useRef)(null);if(!c.current)c.current=(o=s(o=u),o=f()(o,2),i=o[0],o=o[1],(i&&"0"!==i?"".concat(i,".").concat(o):o||"0")||String(d)),d+=1;var i={instanceId:r,propertyName:"COMPOSITION",props:e,vars:t,variants:n};if(null!=l&&l.report)l.report([c.current,r,"none"].join("#"),i);return Object(a.useEffect)(function(){if(null!=l&&l.cancelDropReports&&c.current)l.cancelDropReports(c.current);return function(){if(null!=l&&l.dropReports&&c.current)l.dropReports(c.current)}},[u]),[i,Object(a.useCallback)(function(r,e,t){e=[c.current,e,t].join("#");if(null!=l&&l.report)l.report(e,r);return e},[c.current]),e]},b=function(r,e,t,n,o){var u=t.vars;if(null!=o&&o.length)if(u=p(p({},t.vars),{},c()({},n,o[0])),1<o.length)u["".concat(n,"Args")]=o;return[{instanceId:r,propertyName:e,vars:u,parentReport:t},u]}}]); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
cx: function() { | ||
return cx; | ||
}, | ||
tryCatch: function() { | ||
return tryCatch; | ||
}, | ||
useReport: function() { | ||
return useReport; | ||
}, | ||
getReport: function() { | ||
return getReport; | ||
} | ||
}); | ||
var _defineProperty = require("@swc/helpers/lib/_define_property.js").default; | ||
var _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default; | ||
var _objectSpread = require("@swc/helpers/lib/_object_spread.js").default; | ||
var _objectSpreadProps = require("@swc/helpers/lib/_object_spread_props.js").default; | ||
var _slicedToArray = require("@swc/helpers/lib/_sliced_to_array.js").default; | ||
var _toConsumableArray = require("@swc/helpers/lib/_to_consumable_array.js").default; | ||
var _react = require("react"); | ||
var _classnames = /*#__PURE__*/ _interopRequireDefault(require("classnames")); | ||
"use client"; | ||
var ref; | ||
/** | ||
* Get the clutch inspector at the current version | ||
*/ var INSPECTOR = typeof window !== "undefined" && ((ref = window.__CLUTCH_INSPECTOR__) === null || ref === void 0 ? void 0 : ref.v1); | ||
var cx = _classnames.default; | ||
function tryCatch(fn) { | ||
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
var result; | ||
try { | ||
if (typeof fn !== "function") { | ||
throw new Error("Code property on an instance is not exporting a function"); | ||
} | ||
result = fn.apply(void 0, _toConsumableArray(args)); | ||
} catch (err) { | ||
// eslint-disable-next-line | ||
console.error(err); | ||
} | ||
return result; | ||
} | ||
/** | ||
* deserializeDebugKey - deserializes a debug key string | ||
* composed of ${scopeId}#${id}#${customKey} | ||
* | ||
* @param {String} debugKey | ||
* | ||
* @returns {Array<String>} [scopeId, id, customKey] | ||
*/ var deserializeDebugKey = function(debugKey) { | ||
var ref; | ||
return ((ref = String(debugKey).match(/(.+?)#(.+?)#(.*)/)) === null || ref === void 0 ? void 0 : ref.slice(1)) || []; | ||
}; | ||
/** | ||
* calculateScope - calculates next scope id based on debugKey | ||
* | ||
* @param {String} debugKey | ||
* | ||
* @returns {String} new scopeId | ||
*/ var calculateScope = function(debugKey) { | ||
var ref = _slicedToArray(deserializeDebugKey(debugKey), 2), previousScope = ref[0], rootInstanceId = ref[1]; | ||
return previousScope && previousScope !== "0" ? "".concat(previousScope, ".").concat(rootInstanceId) : rootInstanceId || "0"; | ||
}; | ||
var instanceCounter = 0; | ||
var useReport = function(instanceId, propsArg, vars, variants, ref) { | ||
var props = _objectSpread({}, propsArg); | ||
var dataD = props["data-d"]; | ||
if (ref) { | ||
props.ref = ref; | ||
} | ||
delete props["data-d"]; | ||
// calculate owner scope id | ||
var ownerScopeIdRef = (0, _react.useRef)(null); | ||
if (!ownerScopeIdRef.current) { | ||
ownerScopeIdRef.current = calculateScope(dataD) || String(instanceCounter); | ||
instanceCounter += 1; | ||
} | ||
// own report (master instance) | ||
var report = { | ||
instanceId: instanceId, | ||
propertyName: "COMPOSITION", | ||
props: props, | ||
vars: vars, | ||
variants: variants | ||
}; | ||
if (INSPECTOR === null || INSPECTOR === void 0 ? void 0 : INSPECTOR.report) { | ||
INSPECTOR.report([ | ||
ownerScopeIdRef.current, | ||
instanceId, | ||
"none" | ||
].join("#"), report); | ||
} | ||
// drop reports logic | ||
(0, _react.useEffect)(function() { | ||
if ((INSPECTOR === null || INSPECTOR === void 0 ? void 0 : INSPECTOR.cancelDropReports) && ownerScopeIdRef.current) { | ||
INSPECTOR.cancelDropReports(ownerScopeIdRef.current); | ||
} | ||
return function() { | ||
if ((INSPECTOR === null || INSPECTOR === void 0 ? void 0 : INSPECTOR.dropReports) && ownerScopeIdRef.current) { | ||
INSPECTOR.dropReports(ownerScopeIdRef.current); | ||
} | ||
}; | ||
}, [ | ||
dataD | ||
]); | ||
// get key handler for children instances | ||
var getKey = (0, _react.useCallback)(function(childReport, childId, customKey) { | ||
var key = [ | ||
ownerScopeIdRef.current, | ||
childId, | ||
customKey | ||
].join("#"); | ||
if (INSPECTOR === null || INSPECTOR === void 0 ? void 0 : INSPECTOR.report) { | ||
INSPECTOR.report(key, childReport); | ||
} | ||
return key; | ||
}, [ | ||
ownerScopeIdRef.current | ||
]); | ||
return [ | ||
report, | ||
getKey, | ||
props | ||
]; | ||
}; | ||
var getReport = function(instanceId, propertyName, parentReport, newVariablesName, newVars) { | ||
var vars = parentReport.vars; | ||
if (newVars === null || newVars === void 0 ? void 0 : newVars.length) { | ||
vars = _objectSpreadProps(_objectSpread({}, parentReport.vars), _defineProperty({}, newVariablesName, newVars[0])); | ||
// in case the render props pass multiple arguments | ||
// we include a new namespace with the full vars list | ||
if (newVars.length > 1) { | ||
vars["".concat(newVariablesName, "Args")] = newVars; | ||
} | ||
} | ||
var report = { | ||
instanceId: instanceId, | ||
propertyName: propertyName, | ||
vars: vars, | ||
parentReport: parentReport | ||
}; | ||
return [ | ||
report, | ||
vars | ||
]; | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@clutch-creator/bridge", | ||
"version": "5.0.0-rc.6", | ||
"version": "5.0.0-rc.7", | ||
"description": "Clutch Bridge", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "yarn prettier && yarn lint", | ||
"build": "webpack --config webpack.config.js", | ||
"prettier": "prettier --config ./.prettierrc --check ./src/**/*", | ||
"lint": "./node_modules/.bin/eslint src/**", | ||
"prepublish": "yarn test && yarn build" | ||
}, | ||
"repository": { | ||
@@ -25,2 +18,3 @@ "type": "git", | ||
"@babel/core": "^7.1.6", | ||
"@babel/eslint-parser": "^7.19.1", | ||
"@babel/plugin-proposal-class-properties": "^7.1.0", | ||
@@ -32,4 +26,4 @@ "@babel/plugin-proposal-object-rest-spread": "^7.0.0", | ||
"@babel/preset-react": "^7.0.0", | ||
"babel-eslint": "^10.0.1", | ||
"babel-loader": "^8.0.4", | ||
"@swc/cli": "^0.1.57", | ||
"@swc/core": "^1.3.11", | ||
"eslint": "^5.9.0", | ||
@@ -44,10 +38,6 @@ "eslint-config-airbnb": "^17.1.0", | ||
"prettier": "^1.15.2", | ||
"react": ">=16.8", | ||
"uglifyjs-webpack-plugin": "^2.0.1", | ||
"webpack": "^4.26.1", | ||
"webpack-cli": "^3.1.2", | ||
"webpack-node-externals": "^1.7.2" | ||
"react": ">=16.8" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.6.3", | ||
"@swc/helpers": "^0.4.12", | ||
"classnames": "^2.2.6" | ||
@@ -57,3 +47,11 @@ }, | ||
"react": ">=16.8" | ||
} | ||
} | ||
}, | ||
"scripts": { | ||
"test": "pnpm prettier && pnpm lint", | ||
"build": "swc ./src/index.js -o ./index.js -s", | ||
"prettier": "prettier --config ./.prettierrc --check ./src/**/*", | ||
"lint": "pnpm eslint src/**", | ||
"prepublish": "pnpm test && pnpm build" | ||
}, | ||
"readme": "# Clutch Bridge\n\nLibrary built to be used as a dependency for users shift projects that makes the connection between the user application and the Clutch IDE. Mostly used inside library specific shift extensions.\n\n## Installation\n\n```bash\nyarn\n```\n\n## Build\n\n```bash\nyarn build\n```\n\n## Test\n\n```bash\nyarn test\n```\n" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
137370
20
6
158
2
+ Added@swc/helpers@^0.4.12
+ Added@swc/helpers@0.4.37(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@babel/runtime@^7.6.3
- Removed@babel/runtime@7.26.0(transitive)
- Removedregenerator-runtime@0.14.1(transitive)