@plurid/plurid-react-server 0.0.0-6 → 0.0.0-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const DEFAULT_SERVER_PORT: number;
|
|
2
2
|
export declare const DEFAULT_SERVER_OPTIONS_SERVER_NAME = "Plurid Server";
|
|
3
|
+
export declare const DEFAULT_SERVER_OPTIONS_HOSTNAME = "origin";
|
|
3
4
|
export declare const DEFAULT_SERVER_OPTIONS_QUIET = false;
|
|
4
5
|
export declare const DEFAULT_SERVER_OPTIONS_COMPRESSION = true;
|
|
5
6
|
export declare const DEFAULT_SERVER_OPTIONS_OPEN = false;
|
|
@@ -9,6 +10,7 @@ export declare const DEFAULT_SERVER_OPTIONS_STILLS_DIRECTORY = "stills";
|
|
|
9
10
|
export declare const DEFAULT_SERVER_OPTIONS_GATEWAY = "/gateway";
|
|
10
11
|
export declare const DEFAULT_SERVER_OPTIONS: {
|
|
11
12
|
SERVER_NAME: string;
|
|
13
|
+
HOSTNAME: string;
|
|
12
14
|
QUIET: boolean;
|
|
13
15
|
COMPRESSION: boolean;
|
|
14
16
|
OPEN: boolean;
|
|
@@ -11,6 +11,11 @@ export declare type DebugLevels = 'none' | 'error' | 'warn' | 'info';
|
|
|
11
11
|
export interface PluridServerOptions {
|
|
12
12
|
/** To be used for logging. Default `Plurid Server` */
|
|
13
13
|
serverName: string;
|
|
14
|
+
/**
|
|
15
|
+
* The hostname of the server exposed to the internet, e.g. `example.com`,
|
|
16
|
+
* to be used in plurid plane links.
|
|
17
|
+
*/
|
|
18
|
+
hostname: string;
|
|
14
19
|
/**
|
|
15
20
|
* To log or not to log to the console.
|
|
16
21
|
*/
|
package/distribution/index.es.js
CHANGED
|
@@ -18,6 +18,8 @@ import { routing } from "@plurid/plurid-engine";
|
|
|
18
18
|
|
|
19
19
|
import { PluridProvider, PluridRouterStatic, serverComputeMetastate } from "@plurid/plurid-react";
|
|
20
20
|
|
|
21
|
+
import { minify } from "html-minifier";
|
|
22
|
+
|
|
21
23
|
import React from "react";
|
|
22
24
|
|
|
23
25
|
import { renderToString } from "react-dom/server";
|
|
@@ -100,6 +102,8 @@ const DEFAULT_SERVER_PORT = process.env.PORT ? parseInt(process.env.PORT) : 8080
|
|
|
100
102
|
|
|
101
103
|
const DEFAULT_SERVER_OPTIONS_SERVER_NAME = "Plurid Server";
|
|
102
104
|
|
|
105
|
+
const DEFAULT_SERVER_OPTIONS_HOSTNAME = "origin";
|
|
106
|
+
|
|
103
107
|
const DEFAULT_SERVER_OPTIONS_QUIET = false;
|
|
104
108
|
|
|
105
109
|
const DEFAULT_SERVER_OPTIONS_COMPRESSION = true;
|
|
@@ -116,6 +120,7 @@ const DEFAULT_SERVER_OPTIONS_GATEWAY = "/gateway";
|
|
|
116
120
|
|
|
117
121
|
const DEFAULT_SERVER_OPTIONS = {
|
|
118
122
|
SERVER_NAME: DEFAULT_SERVER_OPTIONS_SERVER_NAME,
|
|
123
|
+
HOSTNAME: DEFAULT_SERVER_OPTIONS_HOSTNAME,
|
|
119
124
|
QUIET: DEFAULT_SERVER_OPTIONS_QUIET,
|
|
120
125
|
COMPRESSION: DEFAULT_SERVER_OPTIONS_COMPRESSION,
|
|
121
126
|
OPEN: DEFAULT_SERVER_OPTIONS_OPEN,
|
|
@@ -154,7 +159,9 @@ const defaultStillerOptions = {
|
|
|
154
159
|
ignore: []
|
|
155
160
|
};
|
|
156
161
|
|
|
157
|
-
const cleanTemplate = template => template
|
|
162
|
+
const cleanTemplate = template => minify(template, {
|
|
163
|
+
collapseWhitespace: true
|
|
164
|
+
});
|
|
158
165
|
|
|
159
166
|
const resolveBackgroundStyle = store => {
|
|
160
167
|
var _a;
|
|
@@ -364,7 +371,7 @@ class PluridServer {
|
|
|
364
371
|
this.isoMatcher = new PluridIsoMatcher({
|
|
365
372
|
routes: this.routes,
|
|
366
373
|
routePlanes: this.planes
|
|
367
|
-
});
|
|
374
|
+
}, this.options.hostname);
|
|
368
375
|
this.configureServer();
|
|
369
376
|
this.handleEndpoints();
|
|
370
377
|
process.addListener("SIGINT", (() => {
|
|
@@ -724,8 +731,9 @@ class PluridServer {
|
|
|
724
731
|
renderApplication(isoMatch, preserveResult, matchedPlane) {
|
|
725
732
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
726
733
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
734
|
+
const globals = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.globals;
|
|
727
735
|
const mergedHtmlLanguage = ((_a = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.template) === null || _a === void 0 ? void 0 : _a.htmlLanguage) || ((_b = this.template) === null || _b === void 0 ? void 0 : _b.htmlLanguage);
|
|
728
|
-
const pluridMetastate = serverComputeMetastate(isoMatch, this.routes);
|
|
736
|
+
const pluridMetastate = serverComputeMetastate(isoMatch, this.routes, globals);
|
|
729
737
|
const {content: content, styles: styles} = yield this.getContentAndStyles(isoMatch, pluridMetastate, preserveResult, matchedPlane);
|
|
730
738
|
const stringedStyles = this.styles.reduce(((accumulator, style) => accumulator + style), "");
|
|
731
739
|
const preserveStyles = ((_d = (_c = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.template) === null || _c === void 0 ? void 0 : _c.styles) === null || _d === void 0 ? void 0 : _d.join(" ")) || "";
|
|
@@ -741,7 +749,6 @@ class PluridServer {
|
|
|
741
749
|
const mergedHeadScripts = [ ...headScripts, ...((_j = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.template) === null || _j === void 0 ? void 0 : _j.headScripts) || [] ];
|
|
742
750
|
const bodyScripts = ((_k = this.template) === null || _k === void 0 ? void 0 : _k.bodyScripts) || [];
|
|
743
751
|
const mergedBodyScripts = [ ...bodyScripts, ...((_l = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.template) === null || _l === void 0 ? void 0 : _l.bodyScripts) || [] ];
|
|
744
|
-
const globals = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.globals;
|
|
745
752
|
const renderer = new PluridRenderer({
|
|
746
753
|
htmlLanguage: mergedHtmlLanguage,
|
|
747
754
|
head: head,
|
|
@@ -824,6 +831,7 @@ class PluridServer {
|
|
|
824
831
|
var _a, _b;
|
|
825
832
|
const options = {
|
|
826
833
|
serverName: (partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.serverName) || DEFAULT_SERVER_OPTIONS.SERVER_NAME,
|
|
834
|
+
hostname: (partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.hostname) || DEFAULT_SERVER_OPTIONS.HOSTNAME,
|
|
827
835
|
quiet: (partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.quiet) || DEFAULT_SERVER_OPTIONS.QUIET,
|
|
828
836
|
debug: (partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.debug) ? partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.debug : environment.production ? "error" : "info",
|
|
829
837
|
compression: (_a = partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.compression) !== null && _a !== void 0 ? _a : DEFAULT_SERVER_OPTIONS.COMPRESSION,
|
package/distribution/index.js
CHANGED
|
@@ -24,6 +24,8 @@ var pluridEngine = require("@plurid/plurid-engine");
|
|
|
24
24
|
|
|
25
25
|
var pluridReact = require("@plurid/plurid-react");
|
|
26
26
|
|
|
27
|
+
var htmlMinifier = require("html-minifier");
|
|
28
|
+
|
|
27
29
|
var React = require("react");
|
|
28
30
|
|
|
29
31
|
var server = require("react-dom/server");
|
|
@@ -148,6 +150,8 @@ const DEFAULT_SERVER_PORT = process.env.PORT ? parseInt(process.env.PORT) : 8080
|
|
|
148
150
|
|
|
149
151
|
const DEFAULT_SERVER_OPTIONS_SERVER_NAME = "Plurid Server";
|
|
150
152
|
|
|
153
|
+
const DEFAULT_SERVER_OPTIONS_HOSTNAME = "origin";
|
|
154
|
+
|
|
151
155
|
const DEFAULT_SERVER_OPTIONS_QUIET = false;
|
|
152
156
|
|
|
153
157
|
const DEFAULT_SERVER_OPTIONS_COMPRESSION = true;
|
|
@@ -164,6 +168,7 @@ const DEFAULT_SERVER_OPTIONS_GATEWAY = "/gateway";
|
|
|
164
168
|
|
|
165
169
|
const DEFAULT_SERVER_OPTIONS = {
|
|
166
170
|
SERVER_NAME: DEFAULT_SERVER_OPTIONS_SERVER_NAME,
|
|
171
|
+
HOSTNAME: DEFAULT_SERVER_OPTIONS_HOSTNAME,
|
|
167
172
|
QUIET: DEFAULT_SERVER_OPTIONS_QUIET,
|
|
168
173
|
COMPRESSION: DEFAULT_SERVER_OPTIONS_COMPRESSION,
|
|
169
174
|
OPEN: DEFAULT_SERVER_OPTIONS_OPEN,
|
|
@@ -202,7 +207,9 @@ const defaultStillerOptions = {
|
|
|
202
207
|
ignore: []
|
|
203
208
|
};
|
|
204
209
|
|
|
205
|
-
const cleanTemplate = template =>
|
|
210
|
+
const cleanTemplate = template => htmlMinifier.minify(template, {
|
|
211
|
+
collapseWhitespace: true
|
|
212
|
+
});
|
|
206
213
|
|
|
207
214
|
const resolveBackgroundStyle = store => {
|
|
208
215
|
var _a;
|
|
@@ -416,7 +423,7 @@ class PluridServer {
|
|
|
416
423
|
this.isoMatcher = new PluridIsoMatcher({
|
|
417
424
|
routes: this.routes,
|
|
418
425
|
routePlanes: this.planes
|
|
419
|
-
});
|
|
426
|
+
}, this.options.hostname);
|
|
420
427
|
this.configureServer();
|
|
421
428
|
this.handleEndpoints();
|
|
422
429
|
process.addListener("SIGINT", (() => {
|
|
@@ -776,8 +783,9 @@ class PluridServer {
|
|
|
776
783
|
renderApplication(isoMatch, preserveResult, matchedPlane) {
|
|
777
784
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
778
785
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
786
|
+
const globals = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.globals;
|
|
779
787
|
const mergedHtmlLanguage = ((_a = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.template) === null || _a === void 0 ? void 0 : _a.htmlLanguage) || ((_b = this.template) === null || _b === void 0 ? void 0 : _b.htmlLanguage);
|
|
780
|
-
const pluridMetastate = pluridReact.serverComputeMetastate(isoMatch, this.routes);
|
|
788
|
+
const pluridMetastate = pluridReact.serverComputeMetastate(isoMatch, this.routes, globals);
|
|
781
789
|
const {content: content, styles: styles} = yield this.getContentAndStyles(isoMatch, pluridMetastate, preserveResult, matchedPlane);
|
|
782
790
|
const stringedStyles = this.styles.reduce(((accumulator, style) => accumulator + style), "");
|
|
783
791
|
const preserveStyles = ((_d = (_c = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.template) === null || _c === void 0 ? void 0 : _c.styles) === null || _d === void 0 ? void 0 : _d.join(" ")) || "";
|
|
@@ -793,7 +801,6 @@ class PluridServer {
|
|
|
793
801
|
const mergedHeadScripts = [ ...headScripts, ...((_j = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.template) === null || _j === void 0 ? void 0 : _j.headScripts) || [] ];
|
|
794
802
|
const bodyScripts = ((_k = this.template) === null || _k === void 0 ? void 0 : _k.bodyScripts) || [];
|
|
795
803
|
const mergedBodyScripts = [ ...bodyScripts, ...((_l = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.template) === null || _l === void 0 ? void 0 : _l.bodyScripts) || [] ];
|
|
796
|
-
const globals = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.globals;
|
|
797
804
|
const renderer = new PluridRenderer({
|
|
798
805
|
htmlLanguage: mergedHtmlLanguage,
|
|
799
806
|
head: head,
|
|
@@ -876,6 +883,7 @@ class PluridServer {
|
|
|
876
883
|
var _a, _b;
|
|
877
884
|
const options = {
|
|
878
885
|
serverName: (partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.serverName) || DEFAULT_SERVER_OPTIONS.SERVER_NAME,
|
|
886
|
+
hostname: (partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.hostname) || DEFAULT_SERVER_OPTIONS.HOSTNAME,
|
|
879
887
|
quiet: (partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.quiet) || DEFAULT_SERVER_OPTIONS.QUIET,
|
|
880
888
|
debug: (partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.debug) ? partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.debug : environment.production ? "error" : "info",
|
|
881
889
|
compression: (_a = partialOptions === null || partialOptions === void 0 ? void 0 : partialOptions.compression) !== null && _a !== void 0 ? _a : DEFAULT_SERVER_OPTIONS.COMPRESSION,
|
|
@@ -25,7 +25,7 @@ declare class PluridServer {
|
|
|
25
25
|
private isoMatcher;
|
|
26
26
|
constructor(configuration: PluridServerConfiguration);
|
|
27
27
|
static analysis(pluridServer: PluridServer): {
|
|
28
|
-
routes: PluridRoute<PluridReactComponent<any, import("@plurid/plurid-data").PluridPlaneComponentProperty | import("@plurid/plurid-data").PluridRouteComponentProperty
|
|
28
|
+
routes: PluridRoute<PluridReactComponent<any, import("@plurid/plurid-data").PluridPlaneComponentProperty | import("@plurid/plurid-data").PluridRouteComponentProperty>, any>[];
|
|
29
29
|
options: PluridServerOptions;
|
|
30
30
|
};
|
|
31
31
|
start(port?: string | number): Server;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plurid/plurid-react-server",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-9",
|
|
4
4
|
"description": "React implementation of Plurid to view and explore the web in three dimensions with server-side rendering",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plurid",
|
|
@@ -71,63 +71,65 @@
|
|
|
71
71
|
"body-parser": "^1.20.0",
|
|
72
72
|
"compression": "^1.7.4",
|
|
73
73
|
"detect-port": "^1.3.0",
|
|
74
|
-
"express": "^4.
|
|
74
|
+
"express": "^4.18.1",
|
|
75
|
+
"html-minifier": "^4.0.0",
|
|
75
76
|
"open": "^8.4.0"
|
|
76
77
|
},
|
|
77
78
|
"devDependencies": {
|
|
78
|
-
"@apollo/client": "^3.
|
|
79
|
-
"@babel/core": "^7.
|
|
79
|
+
"@apollo/client": "^3.6.9",
|
|
80
|
+
"@babel/core": "^7.18.6",
|
|
80
81
|
"@plurid/elementql": "^0.0.0-1",
|
|
81
82
|
"@plurid/elementql-client-react": "^0.0.0-1",
|
|
82
|
-
"@plurid/plurid-data": "0.0.0-
|
|
83
|
-
"@plurid/plurid-engine": "0.0.0-
|
|
84
|
-
"@plurid/plurid-functions": "0.0.0-
|
|
83
|
+
"@plurid/plurid-data": "0.0.0-14",
|
|
84
|
+
"@plurid/plurid-engine": "0.0.0-12",
|
|
85
|
+
"@plurid/plurid-functions": "0.0.0-25",
|
|
85
86
|
"@plurid/plurid-functions-react": "0.0.0-5",
|
|
86
|
-
"@plurid/plurid-icons-react": "0.0.0-
|
|
87
|
+
"@plurid/plurid-icons-react": "0.0.0-4",
|
|
87
88
|
"@plurid/plurid-pubsub": "0.0.0-6",
|
|
88
|
-
"@plurid/plurid-react": "0.0.0-
|
|
89
|
+
"@plurid/plurid-react": "0.0.0-22",
|
|
89
90
|
"@plurid/plurid-themes": "0.0.0-2",
|
|
90
|
-
"@plurid/plurid-ui-components-react": "0.0.0-
|
|
91
|
-
"@plurid/plurid-ui-state-react": "0.0.0-
|
|
91
|
+
"@plurid/plurid-ui-components-react": "0.0.0-13",
|
|
92
|
+
"@plurid/plurid-ui-state-react": "0.0.0-3",
|
|
92
93
|
"@redux-devtools/extension": "^3.2.2",
|
|
93
|
-
"@rollup/plugin-node-resolve": "^13.
|
|
94
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
94
95
|
"@types/body-parser": "^1.19.2",
|
|
95
96
|
"@types/compression": "^1.7.2",
|
|
96
97
|
"@types/detect-port": "^1.3.2",
|
|
97
98
|
"@types/express": "^4.17.13",
|
|
98
99
|
"@types/hammerjs": "^2.0.41",
|
|
99
|
-
"@types/
|
|
100
|
-
"@types/
|
|
101
|
-
"@types/
|
|
102
|
-
"@types/react
|
|
100
|
+
"@types/html-minifier": "^4.0.2",
|
|
101
|
+
"@types/jest": "^28.1.6",
|
|
102
|
+
"@types/node": "^18.0.5",
|
|
103
|
+
"@types/react": "^18.0.15",
|
|
104
|
+
"@types/react-dom": "^18.0.6",
|
|
103
105
|
"@types/react-redux": "^7.1.24",
|
|
104
106
|
"@types/react-stripe-elements": "^6.0.6",
|
|
105
107
|
"@types/styled-components": "^5.1.25",
|
|
106
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
107
|
-
"@typescript-eslint/parser": "^5.
|
|
108
|
+
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
|
109
|
+
"@typescript-eslint/parser": "^5.30.6",
|
|
108
110
|
"@zerollup/ts-transform-paths": "^1.7.18",
|
|
109
111
|
"cross-fetch": "^3.1.5",
|
|
110
|
-
"eslint": "^8.
|
|
111
|
-
"graphql": "^16.
|
|
112
|
+
"eslint": "^8.19.0",
|
|
113
|
+
"graphql": "^16.5.0",
|
|
112
114
|
"hammerjs": "^2.0.8",
|
|
113
|
-
"jest": "^
|
|
114
|
-
"jest-config": "^
|
|
115
|
-
"react": "^18.
|
|
116
|
-
"react-dom": "^18.
|
|
115
|
+
"jest": "^28.1.3",
|
|
116
|
+
"jest-config": "^28.1.3",
|
|
117
|
+
"react": "^18.2.0",
|
|
118
|
+
"react-dom": "^18.2.0",
|
|
117
119
|
"react-helmet-async": "^1.3.0",
|
|
118
|
-
"react-redux": "^
|
|
119
|
-
"redux": "^4.
|
|
120
|
+
"react-redux": "^8.0.2",
|
|
121
|
+
"redux": "^4.2.0",
|
|
120
122
|
"redux-thunk": "^2.4.1",
|
|
121
|
-
"rollup": "^2.
|
|
123
|
+
"rollup": "^2.77.0",
|
|
122
124
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
123
125
|
"rollup-plugin-terser": "^7.0.2",
|
|
124
|
-
"rollup-plugin-typescript2": "^0.
|
|
126
|
+
"rollup-plugin-typescript2": "^0.32.1",
|
|
125
127
|
"styled-components": "^5.3.5",
|
|
126
|
-
"ts-jest": "^
|
|
127
|
-
"ts-node": "^10.
|
|
128
|
-
"tslib": "^2.
|
|
128
|
+
"ts-jest": "^28.0.6",
|
|
129
|
+
"ts-node": "^10.9.1",
|
|
130
|
+
"tslib": "^2.4.0",
|
|
129
131
|
"ttypescript": "^1.5.13",
|
|
130
|
-
"typescript": "^4.
|
|
132
|
+
"typescript": "^4.7.4",
|
|
131
133
|
"typescript-transform-paths": "^3.3.1"
|
|
132
134
|
}
|
|
133
135
|
}
|