@dooboostore/simple-boot-http-server-ssr
Version:
front end SPA frameworks SSR
31 lines • 1.4 kB
JavaScript
import { getSim } from '@dooboostore/simple-boot/decorators/SimDecorator';
import { AroundForceReturn } from '@dooboostore/simple-boot/decorators/aop/AOPDecorator';
import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';
export const LoadAroundBefore = (obj, propertyKey, args) => {
var _a, _b, _c;
const simstanceManager = obj._SimpleBoot_simstanceManager;
const simOption = obj._SimpleBoot_simOption;
const config = getSim(obj);
if (simstanceManager && simOption && (config === null || config === void 0 ? void 0 : config.scheme)) {
const key = config.scheme + '_' + propertyKey;
const type = ReflectUtils.getReturnType(obj, propertyKey);
const isHas = (key in ((_a = simOption.window.server_side_data) !== null && _a !== void 0 ? _a : {}));
if (isHas) {
const data = (_b = simOption.window.server_side_data) === null || _b === void 0 ? void 0 : _b[key];
(_c = simOption.window.server_side_data) === null || _c === void 0 ? true : delete _c[key];
let rdata;
if (type === Promise) {
rdata = Promise.resolve(data);
}
else {
rdata = data;
}
throw new AroundForceReturn(rdata);
}
else {
return args;
}
}
return args;
};
//# sourceMappingURL=LoadAroundBefore.js.map