New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@projectproxima/plugin-loader

Package Overview
Dependencies
Maintainers
5
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@projectproxima/plugin-loader - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

103

dist/bundle.esm.js
import { jsx, Fragment } from 'react/jsx-runtime';
import React, { createContext, useContext, useRef, useState, useCallback, useEffect, useMemo, forwardRef, useImperativeHandle, Component as Component$1 } from 'react';
import { useServerSDK } from '@projectproxima/plugin-sdk';
import { useServerSDK, ProximaSDK } from '@projectproxima/plugin-sdk';
import axios from 'axios';

@@ -216,2 +216,4 @@ import { noop } from 'lodash';

var actionRef = useRef(null);
var keyRef = useRef(null);
var qiankunInstanceRef = useRef(null);
var appLifeCycleStatus = useRef({

@@ -230,3 +232,3 @@ beforeMount: false,

var startLoadPlugin = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
var e_1, status_1;
var e_1, errorReason;
return __generator(this, function (_a) {

@@ -249,15 +251,7 @@ switch (_a.label) {

e_1 = _a.sent();
if (!e_1.response) {
setServerStatus({
error: true,
reason: "NONE",
});
}
else {
status_1 = e_1.response.status;
setServerStatus({
error: true,
reason: status_1,
});
}
errorReason = e_1.response ? e_1.response.status : "NONE";
setServerStatus({
error: true,
reason: errorReason,
});
setLoading(false);

@@ -269,2 +263,31 @@ return [3 /*break*/, 4];

}); }, [axios, url]);
var resetLifeCycleStatus = function () {
appLifeCycleStatus.current = {
beforeMount: false,
mount: false,
afterMount: false,
mountError: false,
};
};
var registerPluginSDK = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
var proximaSDK;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof window !== "undefined")) return [3 /*break*/, 2];
proximaSDK = new ProximaSDK({ sdkServer: server });
return [4 /*yield*/, server.register({
type: "micro",
module: moduleKey,
instance: proximaSDK,
frame: qiankunProps.frame,
context: qiankunProps.context || {},
})];
case 1:
_a.sent();
return [2 /*return*/, proximaSDK];
case 2: return [2 /*return*/];
}
});
}); }, [moduleKey, qiankunProps.context, qiankunProps.frame, server]);
// 用于同一个页面切换插件时,loading初始化

@@ -275,5 +298,3 @@ useEffect(function () {

useEffect(function () {
var app;
var appLifeCycle = appLifeCycleStatus.current;
if (appLifeCycle.beforeMount) ;
if (!serverStatus.error && !appLifeCycle.beforeMount) {

@@ -283,29 +304,8 @@ appLifeCycle.beforeMount = true;

var route_1 = url.split("#")[1]; // hash子路由传给子应用,用于子应用默认跳转的地址
var registerPlugin = function () { return __awaiter(void 0, void 0, void 0, function () {
var proximaSDK, ProximaSDK;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof window !== "undefined")) return [3 /*break*/, 2];
ProximaSDK = require("@projectproxima/plugin-sdk").ProximaSDK;
proximaSDK = new ProximaSDK({ sdkServer: server });
return [4 /*yield*/, server.register({
type: "micro",
module: moduleKey,
instance: proximaSDK,
frame: qiankunProps.frame,
context: qiankunProps.context || {},
})];
case 1:
_a.sent();
return [2 /*return*/, proximaSDK];
case 2: return [2 /*return*/];
}
});
}); };
registerPlugin().then(function (sdk) {
var _a;
registerPluginSDK().then(function (sdk) {
var _a, _b, _c;
var initProps = __assign(__assign({}, globalInitProps), { route: route_1, sdk: sdk });
if (sdk) {
app = loadMicroApp_1({
keyRef.current = qiankunProps.frame.key;
var app_1 = loadMicroApp_1({
name: "app_" + Date.now(),

@@ -316,3 +316,5 @@ entry: url,

});
(_a = app === null || app === void 0 ? void 0 : app.mountPromise) === null || _a === void 0 ? void 0 : _a.catch(function () {
(_c = (_b = (_a = app_1 === null || app_1 === void 0 ? void 0 : app_1.mountPromise) === null || _a === void 0 ? void 0 : _a.then(function () {
qiankunInstanceRef.current = app_1;
})) === null || _b === void 0 ? void 0 : _b.catch(function () {
appLifeCycle.mountError = true;

@@ -323,3 +325,3 @@ setServerStatus({

});
}).finally(function () {
})) === null || _c === void 0 ? void 0 : _c.finally(function () {
setLoading(false);

@@ -332,8 +334,15 @@ appLifeCycle.mount = true;

return function () {
if (app && !appLifeCycle.beforeMount) {
server.unRegister(moduleKey, qiankunProps.frame.key);
app === null || app === void 0 ? void 0 : app.unmount();
var currentPluginKey = qiankunProps.frame.key;
var prevQiankunInstance = qiankunInstanceRef.current;
if ((prevQiankunInstance && !appLifeCycle.beforeMount) ||
(keyRef.current && keyRef.current !== currentPluginKey)) {
server.unRegister(moduleKey, keyRef.current);
resetLifeCycleStatus();
if (prevQiankunInstance.getStatus() === "MOUNTED") {
prevQiankunInstance === null || prevQiankunInstance === void 0 ? void 0 : prevQiankunInstance.unmount();
}
}
};
}, [
registerPluginSDK,
moduleKey,

@@ -340,0 +349,0 @@ server,

@@ -221,2 +221,4 @@ (function (global, factory) {

var actionRef = React.useRef(null);
var keyRef = React.useRef(null);
var qiankunInstanceRef = React.useRef(null);
var appLifeCycleStatus = React.useRef({

@@ -235,3 +237,3 @@ beforeMount: false,

var startLoadPlugin = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
var e_1, status_1;
var e_1, errorReason;
return __generator(this, function (_a) {

@@ -254,15 +256,7 @@ switch (_a.label) {

e_1 = _a.sent();
if (!e_1.response) {
setServerStatus({
error: true,
reason: "NONE",
});
}
else {
status_1 = e_1.response.status;
setServerStatus({
error: true,
reason: status_1,
});
}
errorReason = e_1.response ? e_1.response.status : "NONE";
setServerStatus({
error: true,
reason: errorReason,
});
setLoading(false);

@@ -274,2 +268,31 @@ return [3 /*break*/, 4];

}); }, [axios, url]);
var resetLifeCycleStatus = function () {
appLifeCycleStatus.current = {
beforeMount: false,
mount: false,
afterMount: false,
mountError: false,
};
};
var registerPluginSDK = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
var proximaSDK;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof window !== "undefined")) return [3 /*break*/, 2];
proximaSDK = new pluginSdk.ProximaSDK({ sdkServer: server });
return [4 /*yield*/, server.register({
type: "micro",
module: moduleKey,
instance: proximaSDK,
frame: qiankunProps.frame,
context: qiankunProps.context || {},
})];
case 1:
_a.sent();
return [2 /*return*/, proximaSDK];
case 2: return [2 /*return*/];
}
});
}); }, [moduleKey, qiankunProps.context, qiankunProps.frame, server]);
// 用于同一个页面切换插件时,loading初始化

@@ -280,5 +303,3 @@ React.useEffect(function () {

React.useEffect(function () {
var app;
var appLifeCycle = appLifeCycleStatus.current;
if (appLifeCycle.beforeMount) ;
if (!serverStatus.error && !appLifeCycle.beforeMount) {

@@ -288,29 +309,8 @@ appLifeCycle.beforeMount = true;

var route_1 = url.split("#")[1]; // hash子路由传给子应用,用于子应用默认跳转的地址
var registerPlugin = function () { return __awaiter(void 0, void 0, void 0, function () {
var proximaSDK, ProximaSDK;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof window !== "undefined")) return [3 /*break*/, 2];
ProximaSDK = require("@projectproxima/plugin-sdk").ProximaSDK;
proximaSDK = new ProximaSDK({ sdkServer: server });
return [4 /*yield*/, server.register({
type: "micro",
module: moduleKey,
instance: proximaSDK,
frame: qiankunProps.frame,
context: qiankunProps.context || {},
})];
case 1:
_a.sent();
return [2 /*return*/, proximaSDK];
case 2: return [2 /*return*/];
}
});
}); };
registerPlugin().then(function (sdk) {
var _a;
registerPluginSDK().then(function (sdk) {
var _a, _b, _c;
var initProps = __assign(__assign({}, globalInitProps), { route: route_1, sdk: sdk });
if (sdk) {
app = loadMicroApp_1({
keyRef.current = qiankunProps.frame.key;
var app_1 = loadMicroApp_1({
name: "app_" + Date.now(),

@@ -321,3 +321,5 @@ entry: url,

});
(_a = app === null || app === void 0 ? void 0 : app.mountPromise) === null || _a === void 0 ? void 0 : _a.catch(function () {
(_c = (_b = (_a = app_1 === null || app_1 === void 0 ? void 0 : app_1.mountPromise) === null || _a === void 0 ? void 0 : _a.then(function () {
qiankunInstanceRef.current = app_1;
})) === null || _b === void 0 ? void 0 : _b.catch(function () {
appLifeCycle.mountError = true;

@@ -328,3 +330,3 @@ setServerStatus({

});
}).finally(function () {
})) === null || _c === void 0 ? void 0 : _c.finally(function () {
setLoading(false);

@@ -337,8 +339,15 @@ appLifeCycle.mount = true;

return function () {
if (app && !appLifeCycle.beforeMount) {
server.unRegister(moduleKey, qiankunProps.frame.key);
app === null || app === void 0 ? void 0 : app.unmount();
var currentPluginKey = qiankunProps.frame.key;
var prevQiankunInstance = qiankunInstanceRef.current;
if ((prevQiankunInstance && !appLifeCycle.beforeMount) ||
(keyRef.current && keyRef.current !== currentPluginKey)) {
server.unRegister(moduleKey, keyRef.current);
resetLifeCycleStatus();
if (prevQiankunInstance.getStatus() === "MOUNTED") {
prevQiankunInstance === null || prevQiankunInstance === void 0 ? void 0 : prevQiankunInstance.unmount();
}
}
};
}, [
registerPluginSDK,
moduleKey,

@@ -345,0 +354,0 @@ server,

@@ -221,2 +221,4 @@ (function (global, factory) {

var actionRef = React.useRef(null);
var keyRef = React.useRef(null);
var qiankunInstanceRef = React.useRef(null);
var appLifeCycleStatus = React.useRef({

@@ -235,3 +237,3 @@ beforeMount: false,

var startLoadPlugin = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
var e_1, status_1;
var e_1, errorReason;
return __generator(this, function (_a) {

@@ -254,15 +256,7 @@ switch (_a.label) {

e_1 = _a.sent();
if (!e_1.response) {
setServerStatus({
error: true,
reason: "NONE",
});
}
else {
status_1 = e_1.response.status;
setServerStatus({
error: true,
reason: status_1,
});
}
errorReason = e_1.response ? e_1.response.status : "NONE";
setServerStatus({
error: true,
reason: errorReason,
});
setLoading(false);

@@ -274,2 +268,31 @@ return [3 /*break*/, 4];

}); }, [axios, url]);
var resetLifeCycleStatus = function () {
appLifeCycleStatus.current = {
beforeMount: false,
mount: false,
afterMount: false,
mountError: false,
};
};
var registerPluginSDK = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
var proximaSDK;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof window !== "undefined")) return [3 /*break*/, 2];
proximaSDK = new pluginSdk.ProximaSDK({ sdkServer: server });
return [4 /*yield*/, server.register({
type: "micro",
module: moduleKey,
instance: proximaSDK,
frame: qiankunProps.frame,
context: qiankunProps.context || {},
})];
case 1:
_a.sent();
return [2 /*return*/, proximaSDK];
case 2: return [2 /*return*/];
}
});
}); }, [moduleKey, qiankunProps.context, qiankunProps.frame, server]);
// 用于同一个页面切换插件时,loading初始化

@@ -280,5 +303,3 @@ React.useEffect(function () {

React.useEffect(function () {
var app;
var appLifeCycle = appLifeCycleStatus.current;
if (appLifeCycle.beforeMount) ;
if (!serverStatus.error && !appLifeCycle.beforeMount) {

@@ -288,29 +309,8 @@ appLifeCycle.beforeMount = true;

var route_1 = url.split("#")[1]; // hash子路由传给子应用,用于子应用默认跳转的地址
var registerPlugin = function () { return __awaiter(void 0, void 0, void 0, function () {
var proximaSDK, ProximaSDK;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof window !== "undefined")) return [3 /*break*/, 2];
ProximaSDK = require("@projectproxima/plugin-sdk").ProximaSDK;
proximaSDK = new ProximaSDK({ sdkServer: server });
return [4 /*yield*/, server.register({
type: "micro",
module: moduleKey,
instance: proximaSDK,
frame: qiankunProps.frame,
context: qiankunProps.context || {},
})];
case 1:
_a.sent();
return [2 /*return*/, proximaSDK];
case 2: return [2 /*return*/];
}
});
}); };
registerPlugin().then(function (sdk) {
var _a;
registerPluginSDK().then(function (sdk) {
var _a, _b, _c;
var initProps = __assign(__assign({}, globalInitProps), { route: route_1, sdk: sdk });
if (sdk) {
app = loadMicroApp_1({
keyRef.current = qiankunProps.frame.key;
var app_1 = loadMicroApp_1({
name: "app_" + Date.now(),

@@ -321,3 +321,5 @@ entry: url,

});
(_a = app === null || app === void 0 ? void 0 : app.mountPromise) === null || _a === void 0 ? void 0 : _a.catch(function () {
(_c = (_b = (_a = app_1 === null || app_1 === void 0 ? void 0 : app_1.mountPromise) === null || _a === void 0 ? void 0 : _a.then(function () {
qiankunInstanceRef.current = app_1;
})) === null || _b === void 0 ? void 0 : _b.catch(function () {
appLifeCycle.mountError = true;

@@ -328,3 +330,3 @@ setServerStatus({

});
}).finally(function () {
})) === null || _c === void 0 ? void 0 : _c.finally(function () {
setLoading(false);

@@ -337,8 +339,15 @@ appLifeCycle.mount = true;

return function () {
if (app && !appLifeCycle.beforeMount) {
server.unRegister(moduleKey, qiankunProps.frame.key);
app === null || app === void 0 ? void 0 : app.unmount();
var currentPluginKey = qiankunProps.frame.key;
var prevQiankunInstance = qiankunInstanceRef.current;
if ((prevQiankunInstance && !appLifeCycle.beforeMount) ||
(keyRef.current && keyRef.current !== currentPluginKey)) {
server.unRegister(moduleKey, keyRef.current);
resetLifeCycleStatus();
if (prevQiankunInstance.getStatus() === "MOUNTED") {
prevQiankunInstance === null || prevQiankunInstance === void 0 ? void 0 : prevQiankunInstance.unmount();
}
}
};
}, [
registerPluginSDK,
moduleKey,

@@ -345,0 +354,0 @@ server,

{
"name": "@projectproxima/plugin-loader",
"version": "0.2.0",
"version": "0.2.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/bundle.js",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc