@ones-open/bridge
Advanced tools
Comparing version 0.7.4-27607.928 to 2.1.0
@@ -1,6 +0,8 @@ | ||
import { MFDispatch, MFListener } from "@ones-open/event"; | ||
import React, { useEffect, useState } from "react"; | ||
import { useDashboardCardConfigInfo, useDashboardCardInfo } from "@ones-open/store"; | ||
import { MFDispatch, MFListener } from '@ones-open/event'; | ||
import { useDashboardCardConfigInfo, useDashboardCardInfo } from '@ones-open/store'; | ||
import { useEffect, useState } from 'react'; | ||
import { jsx, Fragment } from 'react/jsx-runtime'; | ||
const dispatchGlobalEvent = (type, props, config) => { | ||
MFDispatch("invoke:ones:global:event", { | ||
MFDispatch('invoke:ones:global:event', { | ||
type, | ||
@@ -10,6 +12,7 @@ props | ||
}; | ||
const modal = { | ||
createTask(modalProps) { | ||
dispatchGlobalEvent("modal", { | ||
type: "CreateTask", | ||
dispatchGlobalEvent('modal', { | ||
type: 'CreateTask', | ||
modalProps | ||
@@ -23,7 +26,7 @@ }); | ||
if (!(parentTaskUUID && parentTaskProjectUUID)) { | ||
const requiredProps = [parentTaskUUID ? "" : "parentTask.uuid", parentTaskProjectUUID ? "" : "parentTask.project_uuid"].filter((item) => !!item).join("and"); | ||
throw new Error(`[ones-mf] ${requiredProps} ${requiredProps.length > 1 ? "are" : "is"} required when calling modal.createSubTask`); | ||
const requiredProps = [parentTaskUUID ? '' : 'parentTask.uuid', parentTaskProjectUUID ? '' : 'parentTask.project_uuid'].filter(item => !!item).join('and'); | ||
throw new Error(`[ones-mf] ${requiredProps} ${requiredProps.length > 1 ? 'are' : 'is'} required when calling modal.createSubTask`); | ||
} | ||
dispatchGlobalEvent("modal", { | ||
type: "CreateSubTask", | ||
dispatchGlobalEvent('modal', { | ||
type: 'CreateSubTask', | ||
modalProps | ||
@@ -37,7 +40,7 @@ }); | ||
if (!(relatedTaskUUID && relatedTaskIssueTypeUUID)) { | ||
const requiredProps = [relatedTaskUUID ? "" : "relatedTask.uuid", relatedTaskIssueTypeUUID ? "" : "relatedTask.issue_type_uuid"].filter((item) => !!item).join("and"); | ||
throw new Error(`[ones-mf] ${requiredProps} ${requiredProps.length > 1 ? "are" : "is"} required when calling modal.createRelatedTask`); | ||
const requiredProps = [relatedTaskUUID ? '' : 'relatedTask.uuid', relatedTaskIssueTypeUUID ? '' : 'relatedTask.issue_type_uuid'].filter(item => !!item).join('and'); | ||
throw new Error(`[ones-mf] ${requiredProps} ${requiredProps.length > 1 ? 'are' : 'is'} required when calling modal.createRelatedTask`); | ||
} | ||
dispatchGlobalEvent("modal", { | ||
type: "CreateRelatedTask", | ||
dispatchGlobalEvent('modal', { | ||
type: 'CreateRelatedTask', | ||
modalProps | ||
@@ -47,8 +50,14 @@ }); | ||
}; | ||
function invokeProgressManager(config) { | ||
dispatchGlobalEvent("progressManager", void 0, config); | ||
dispatchGlobalEvent('progressManager', undefined, config); | ||
} | ||
// [æĩč¯įŽĄį-æĩč¯čŽĄå] | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function refreshList(listName, params, config) { | ||
MFDispatch(`ones:event:${listName}:refresh`, params, config); | ||
} | ||
class Lifecycle { | ||
@@ -62,5 +71,5 @@ /** | ||
onDestroy(callback) { | ||
var _window$__ONES_LIFECY, _lifecycle2$onDestroy; | ||
const lifecycle2 = (_window$__ONES_LIFECY = window.__ONES_LIFECYCLE__) !== null && _window$__ONES_LIFECY !== void 0 ? _window$__ONES_LIFECY : window.__ONES_LIFECYCLE__ = {}; | ||
const onDestroyCb = (_lifecycle2$onDestroy = lifecycle2.onDestroy) !== null && _lifecycle2$onDestroy !== void 0 ? _lifecycle2$onDestroy : lifecycle2.onDestroy = []; | ||
var _window$__ONES_LIFECY, _lifecycle$onDestroy; | ||
const lifecycle = (_window$__ONES_LIFECY = window.__ONES_LIFECYCLE__) !== null && _window$__ONES_LIFECY !== void 0 ? _window$__ONES_LIFECY : window.__ONES_LIFECYCLE__ = {}; | ||
const onDestroyCb = (_lifecycle$onDestroy = lifecycle.onDestroy) !== null && _lifecycle$onDestroy !== void 0 ? _lifecycle$onDestroy : lifecycle.onDestroy = []; | ||
onDestroyCb.push(callback); | ||
@@ -75,4 +84,10 @@ return () => { | ||
} | ||
/** | ||
* Instance of the current plugin module lifecycle | ||
*/ | ||
const lifecycle = new Lifecycle(); | ||
const useOnSubmitConfig = (callback) => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const useOnSubmitConfig = callback => { | ||
const { | ||
@@ -88,3 +103,3 @@ modalUUID | ||
}; | ||
const useCustomMenus = (menus) => { | ||
const useCustomMenus = menus => { | ||
const { | ||
@@ -94,10 +109,10 @@ setCustomMenus | ||
useEffect(() => { | ||
const menuKeys = /* @__PURE__ */ new Set([]); | ||
setCustomMenus === null || setCustomMenus === void 0 || setCustomMenus(menus.filter((item) => { | ||
const menuKeys = new Set([]); | ||
setCustomMenus === null || setCustomMenus === void 0 || setCustomMenus(menus.filter(item => { | ||
if (!item.key) { | ||
console.error("[ones-mf]", "menu.key is required"); | ||
console.error('[ones-mf]', 'menu.key is required'); | ||
return false; | ||
} | ||
if (menuKeys.has(item.key)) { | ||
console.error("[ones-mf]", "menu.key must be unique"); | ||
console.error('[ones-mf]', 'menu.key must be unique'); | ||
return false; | ||
@@ -118,6 +133,7 @@ } | ||
}; | ||
function Provider(props) { | ||
const [destroyed, setDestroyed] = useState(false); | ||
useEffect(() => { | ||
const clean = MFListener(`ones:event:inner:destroy:${window.__ONES_MF_NAME__}`, function() { | ||
const clean = MFListener(`ones:event:inner:destroy:${window.__ONES_MF_NAME__}`, function () { | ||
setDestroyed(true); | ||
@@ -127,12 +143,8 @@ }); | ||
}, []); | ||
return /* @__PURE__ */ React.createElement(React.Fragment, null, destroyed ? null : props.children); | ||
return /*#__PURE__*/jsx(Fragment, { | ||
children: destroyed ? null : props.children | ||
}); | ||
} | ||
Provider.displayName = "OPProvider"; | ||
export { | ||
Provider as OPProvider, | ||
dashboardCard, | ||
invokeProgressManager, | ||
lifecycle, | ||
modal, | ||
refreshList | ||
}; | ||
Provider.displayName = 'OPProvider'; | ||
export { Provider as OPProvider, dashboardCard, invokeProgressManager, lifecycle, modal, refreshList }; |
{ | ||
"name": "@ones-open/bridge", | ||
"version": "0.7.4-27607.928+cb600015", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -20,3 +20,3 @@ "type": "module", | ||
"tsc": "tsc && tsc-alias", | ||
"build": "pnpm run tsc && vite build" | ||
"build": "vite build --emptyOutDir && pnpm run tsc" | ||
}, | ||
@@ -38,12 +38,11 @@ "keywords": [ | ||
"peerDependencies": { | ||
"react": "^16.9.0 || ^17.0.0" | ||
"react": "^16.14.0 || ^17.0.0" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime-corejs3": "~7.22.6", | ||
"@ones-open/event": "0.13.1-27607.928+cb600015", | ||
"@ones-open/store": "0.14.3-27607.928+cb600015", | ||
"@types/lodash-es": "^4.17.6", | ||
"lodash-es": "~4.17.21" | ||
"@babel/runtime-corejs3": "^7.22.15", | ||
"@ones-open/event": "^2.1.0", | ||
"@ones-open/store": "^2.1.0", | ||
"@senojs/lodash": "^1.0.2" | ||
}, | ||
"gitHead": "cb6000157b4647ed4df97f24aedf38390684dd63" | ||
"gitHead": "a15f5cf783067b23ff384818c3270eabc8675d5c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5
6
1
56103
24
403
0
+ Added@senojs/lodash@^1.0.2
+ Added@babel/runtime@7.26.0(transitive)
+ Added@babel/runtime-corejs3@7.26.0(transitive)
+ Added@ones-open/event@2.1.1(transitive)
+ Added@ones-open/store@2.1.1(transitive)
+ Added@ones-open/utils@2.1.1(transitive)
+ Added@senojs/lodash@1.0.2(transitive)
+ Added@types/prop-types@15.7.14(transitive)
+ Added@types/react@17.0.83(transitive)
+ Added@types/react-dom@17.0.26(transitive)
+ Added@types/scheduler@0.16.8(transitive)
+ Addedcsstype@3.1.3(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedreact-dom@17.0.2(transitive)
+ Addedredux@4.1.2(transitive)
+ Addedscheduler@0.20.2(transitive)
- Removed@types/lodash-es@^4.17.6
- Removedlodash-es@~4.17.21
- Removed@babel/runtime-corejs3@7.22.15(transitive)
Updated@ones-open/event@^2.1.0
Updated@ones-open/store@^2.1.0