simple-boot-http-ssr
Advanced tools
Comparing version 1.0.3 to 1.0.4
export declare const LoadAroundBefore: (obj: any, propertyKey: string, args: any[]) => any[]; |
@@ -8,3 +8,3 @@ "use strict"; | ||
var LoadAroundBefore = function (obj, propertyKey, args) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
var simstanceManager = obj._SimpleBoot_simstanceManager; | ||
@@ -16,6 +16,7 @@ var simOption = obj._SimpleBoot_simOption; | ||
var type = ReflectUtils_1.ReflectUtils.getReturnType(obj, propertyKey); | ||
var data = (_a = simOption.window['server_side_data']) === null || _a === void 0 ? void 0 : _a[key]; | ||
(_b = simOption.window['server_side_data']) === null || _b === void 0 ? true : delete _b[key]; | ||
if (data) { | ||
var rdata = undefined; | ||
var isHas = (key in ((_a = simOption.window.server_side_data) !== null && _a !== void 0 ? _a : {})); | ||
if (isHas) { | ||
var 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]; | ||
var rdata = void 0; | ||
if (type === Promise) { | ||
@@ -22,0 +23,0 @@ rdata = Promise.resolve(data); |
export declare const SaveAroundAfter: (obj: any, propertyKey: string, args: any[], beforeReturn: any) => any; | ||
export declare const getStorage: (window: Window) => any; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -1,3 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { IncomingMessage, ServerResponse } from 'http'; | ||
import { RequestResponse } from 'simple-boot-http-server/models/RequestResponse'; | ||
@@ -20,2 +18,3 @@ import { SimpleBootHttpSSRFactory } from '../SimpleBootHttpSSRFactory'; | ||
domExcludes: ConstructorType<any>[]; | ||
ssrExcludeFilter?: (rr: RequestResponse) => boolean; | ||
}; | ||
@@ -27,5 +26,6 @@ export declare class SSRFilter implements Filter { | ||
private simpleBootFrontQueue; | ||
private indexHTML; | ||
constructor(factory: FactoryAndParams, otherInstanceSim: Map<ConstructorType<any>, any>); | ||
pushQueue(): Promise<void>; | ||
before(req: IncomingMessage, res: ServerResponse, app: SimpleBootHttpServer): Promise<boolean>; | ||
before(rr: RequestResponse): Promise<boolean>; | ||
writeOkHtmlAndEnd({ rr, status }: { | ||
@@ -35,3 +35,3 @@ rr: RequestResponse; | ||
}, html: string): void; | ||
after(req: IncomingMessage, res: ServerResponse, app: SimpleBootHttpServer, sw: boolean): Promise<boolean>; | ||
after(rr: RequestResponse, app: SimpleBootHttpServer, sw: boolean): Promise<boolean>; | ||
} |
@@ -40,3 +40,2 @@ "use strict"; | ||
exports.SSRFilter = void 0; | ||
var RequestResponse_1 = require("simple-boot-http-server/models/RequestResponse"); | ||
var HttpHeaders_1 = require("simple-boot-http-server/codes/HttpHeaders"); | ||
@@ -75,2 +74,3 @@ var JsdomInitializer_1 = require("../initializers/JsdomInitializer"); | ||
}); | ||
this.indexHTML = JsdomInitializer_1.JsdomInitializer.loadFile(this.factory.frontDistPath, 'index.html'); | ||
} | ||
@@ -102,21 +102,25 @@ SSRFilter.prototype.pushQueue = function () { | ||
}; | ||
SSRFilter.prototype.before = function (req, res, app) { | ||
SSRFilter.prototype.before = function (rr) { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rr, simpleBootFront, data, html, serverSideData, data_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var simpleBootFront, data, html, serverSideData, data_1; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
rr = new RequestResponse_1.RequestResponse(req, res); | ||
if (!(rr.reqHasAcceptHeader(Mimes_1.Mimes.TextHtml) || rr.reqHasAcceptHeader(Mimes_1.Mimes.All))) return [3, 8]; | ||
if ((_b = (_a = this.factory).ssrExcludeFilter) === null || _b === void 0 ? void 0 : _b.call(_a, rr)) { | ||
this.writeOkHtmlAndEnd({ rr: rr }, this.indexHTML); | ||
return [2, false]; | ||
} | ||
if (!this.simpleBootFrontQueue.isEmpty()) return [3, 2]; | ||
return [4, this.pushQueue()]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
_c.sent(); | ||
_c.label = 2; | ||
case 2: return [4, this.simpleBootFrontQueue.dequeue()]; | ||
case 3: | ||
simpleBootFront = _a.sent(); | ||
_a.label = 4; | ||
simpleBootFront = _c.sent(); | ||
_c.label = 4; | ||
case 4: | ||
_a.trys.push([4, , 6, 7]); | ||
_c.trys.push([4, , 6, 7]); | ||
simpleBootFront.option.window.ssrUse = true; | ||
@@ -126,3 +130,3 @@ delete simpleBootFront.option.window.server_side_data; | ||
case 5: | ||
data = _a.sent(); | ||
data = _c.sent(); | ||
html = simpleBootFront.option.window.document.documentElement.outerHTML; | ||
@@ -163,3 +167,3 @@ serverSideData = simpleBootFront.option.window.server_side_data; | ||
}; | ||
SSRFilter.prototype.after = function (req, res, app, sw) { | ||
SSRFilter.prototype.after = function (rr, app, sw) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -166,0 +170,0 @@ return __generator(this, function (_a) { |
@@ -6,3 +6,4 @@ import * as JSDOM from 'jsdom'; | ||
constructor(frontDistPath: string, reconfigureSettings?: JSDOM.ReconfigureSettings | undefined); | ||
static loadFile(distPath: string, filePath: string): string; | ||
run(): JSDOM.JSDOM; | ||
} |
@@ -34,4 +34,7 @@ "use strict"; | ||
} | ||
JsdomInitializer.loadFile = function (distPath, filePath) { | ||
return fs_1.default.readFileSync(path_1.default.join(distPath, filePath), 'utf8'); | ||
}; | ||
JsdomInitializer.prototype.run = function () { | ||
var indexHTML = fs_1.default.readFileSync(path_1.default.join(this.frontDistPath, 'index.html'), 'utf8'); | ||
var indexHTML = JsdomInitializer.loadFile(this.frontDistPath, 'index.html'); | ||
var jsdom = new JSDOM.JSDOM(indexHTML); | ||
@@ -38,0 +41,0 @@ if (this.reconfigureSettings) { |
import { HttpServerOption } from 'simple-boot-http-server/option/HttpServerOption'; | ||
export declare class HttpSSRServerOption extends HttpServerOption { | ||
} |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "simple-boot-http-ssr", | ||
"version": "1.0.3", | ||
"main": "SimpleBootHttpSSR.js", | ||
"version": "1.0.4", | ||
"main": "SimpleBootHttpSSRServer.js", | ||
"license": "MIT", | ||
@@ -83,4 +83,5 @@ "description": "front end SPA frameworks SSR", | ||
"jsdom": "^18.1.1", | ||
"simple-boot-http-server": "1.0.3" | ||
"simple-boot-front": "1.0.100", | ||
"simple-boot-http-server": "1.0.4" | ||
} | ||
} |
@@ -0,0 +0,0 @@ SIMPLE-BOOT-HTTP-SSR |
@@ -0,0 +0,0 @@ import { SimpleBootFront } from 'simple-boot-front/SimpleBootFront'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -6,3 +6,3 @@ import { ConstructorType } from 'simple-boot-core/types/Types'; | ||
constructor(rootRouter: ConstructorType<Object>, option?: HttpServerOption); | ||
run(otherInstanceSim?: Map<ConstructorType<any>, any>): Promise<void>; | ||
run(otherInstanceSim?: Map<ConstructorType<any>, any>): Promise<this>; | ||
} |
@@ -17,2 +17,38 @@ "use strict"; | ||
})(); | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -27,5 +63,10 @@ exports.SimpleBootHttpSSRServer = void 0; | ||
SimpleBootHttpSSRServer.prototype.run = function (otherInstanceSim) { | ||
var oi = new Map(); | ||
otherInstanceSim === null || otherInstanceSim === void 0 ? void 0 : otherInstanceSim.forEach(function (value, key) { return oi.set(key, value); }); | ||
return _super.prototype.run.call(this, oi); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var oi; | ||
return __generator(this, function (_a) { | ||
oi = new Map(); | ||
otherInstanceSim === null || otherInstanceSim === void 0 ? void 0 : otherInstanceSim.forEach(function (value, key) { return oi.set(key, value); }); | ||
return [2, _super.prototype.run.call(this, oi)]; | ||
}); | ||
}); | ||
}; | ||
@@ -32,0 +73,0 @@ return SimpleBootHttpSSRServer; |
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
33003
523
0
3
16
+ Addedsimple-boot-front@1.0.100
+ Addedsimple-boot-front@1.0.100(transitive)
+ Addedsimple-boot-http-server@1.0.4(transitive)
- Removedsimple-boot-front@1.0.99(transitive)
- Removedsimple-boot-http-server@1.0.3(transitive)