@plurid/plurid-react-server 0.0.0-10 → 0.0.0-13
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.
- package/distribution/data/interfaces/external/index.d.ts +4 -4
- package/distribution/data/interfaces/internal/index.d.ts +2 -0
- package/distribution/index.es.js +16 -32
- package/distribution/index.js +16 -56
- package/distribution/objects/ContentGenerator/index.d.ts +0 -2
- package/distribution/objects/Renderer/index.d.ts +1 -0
- package/package.json +22 -22
|
@@ -65,11 +65,10 @@ export interface PluridServerOptions {
|
|
|
65
65
|
stiller: PluridStillerOptions;
|
|
66
66
|
}
|
|
67
67
|
export declare type PluridServerPartialOptions = Partial<PluridServerOptions>;
|
|
68
|
-
export interface PluridServerService<P = any> {
|
|
68
|
+
export interface PluridServerService<P = any, PP = any> {
|
|
69
69
|
name: string;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
properties?: P;
|
|
70
|
+
Provider: P;
|
|
71
|
+
properties?: PP;
|
|
73
72
|
}
|
|
74
73
|
export interface PluridServerConfiguration {
|
|
75
74
|
routes: PluridRoute<PluridReactComponent>[];
|
|
@@ -126,6 +125,7 @@ export interface PluridServerTemplateConfiguration {
|
|
|
126
125
|
* Default: `__PRELOADED_PLURID_METASTATE__`
|
|
127
126
|
*/
|
|
128
127
|
defaultPreloadedPluridMetastate?: string;
|
|
128
|
+
minify?: boolean;
|
|
129
129
|
}
|
|
130
130
|
export interface PluridStillerOptions {
|
|
131
131
|
/**
|
|
@@ -19,6 +19,7 @@ export interface PluridRendererConfiguration {
|
|
|
19
19
|
defaultPreloadedPluridMetastate: string | undefined;
|
|
20
20
|
pluridMetastate: string;
|
|
21
21
|
globals: Record<string, string> | undefined;
|
|
22
|
+
minify: boolean | undefined;
|
|
22
23
|
}
|
|
23
24
|
export interface StillerOptions {
|
|
24
25
|
host: string;
|
|
@@ -78,4 +79,5 @@ export interface RendererTemplateData {
|
|
|
78
79
|
defaultPreloadedPluridMetastate: string;
|
|
79
80
|
pluridMetastate: string;
|
|
80
81
|
globals: Record<string, string>;
|
|
82
|
+
minify: boolean;
|
|
81
83
|
}
|
package/distribution/index.es.js
CHANGED
|
@@ -160,7 +160,9 @@ const defaultStillerOptions = {
|
|
|
160
160
|
};
|
|
161
161
|
|
|
162
162
|
const cleanTemplate = template => minify(template, {
|
|
163
|
-
collapseWhitespace: true
|
|
163
|
+
collapseWhitespace: true,
|
|
164
|
+
conservativeCollapse: true,
|
|
165
|
+
collapseInlineTagWhitespace: false
|
|
164
166
|
});
|
|
165
167
|
|
|
166
168
|
const resolveBackgroundStyle = store => {
|
|
@@ -213,15 +215,18 @@ const NOT_FOUND_TEMPLATE = cleanTemplate(`\n<!DOCTYPE html>\n<html>\n <head>\
|
|
|
213
215
|
const SERVER_ERROR_TEMPLATE = cleanTemplate(`\n<!DOCTYPE html>\n<html>\n <head>\n <title>[500] Server Error</title>\n <style>\n html, body {\n margin: 0;\n background: #242b33;\n color: #ddd;\n user-select: none;\n }\n\n .error {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n font-family: 'Ubuntu', -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto;\n }\n </style>\n </head>\n\n <body>\n <div class="error">[500] Server Error</div>\n </body>\n</html>\n`);
|
|
214
216
|
|
|
215
217
|
const template = data => {
|
|
216
|
-
const {htmlLanguage: htmlLanguage, head: head, htmlAttributes: htmlAttributes, bodyAttributes: bodyAttributes, defaultStyle: defaultStyle, styles: styles, headScripts: headScripts, bodyScripts: bodyScripts, vendorScriptSource: vendorScriptSource, mainScriptSource: mainScriptSource, root: root, content: content, defaultPreloadedPluridMetastate: defaultPreloadedPluridMetastate, pluridMetastate: pluridMetastate, globals: globals} = data;
|
|
218
|
+
const {htmlLanguage: htmlLanguage, head: head, htmlAttributes: htmlAttributes, bodyAttributes: bodyAttributes, defaultStyle: defaultStyle, styles: styles, headScripts: headScripts, bodyScripts: bodyScripts, vendorScriptSource: vendorScriptSource, mainScriptSource: mainScriptSource, root: root, content: content, defaultPreloadedPluridMetastate: defaultPreloadedPluridMetastate, pluridMetastate: pluridMetastate, globals: globals, minify: minify} = data;
|
|
217
219
|
const injectedGlobals = globalsInjector(globals);
|
|
218
220
|
const templateString = `\n<!DOCTYPE html>\n<html lang="${htmlLanguage}" ${htmlAttributes}>\n <head>\n ${head}\n\n ${defaultStyle && `<style>\n ${defaultStyle}\n </style>`}\n\n ${styles}\n\n ${headScripts.join("\n")}\n\n <script src="${vendorScriptSource}"><\/script>\n <script defer src="${mainScriptSource}"><\/script>\n </head>\n <body ${bodyAttributes}>\n <div id="${root}">${content}</div>\n\n <script>\n ${injectedGlobals}\n window.${defaultPreloadedPluridMetastate} = ${pluridMetastate};\n <\/script>\n\n ${bodyScripts.join("\n")}\n </body>\n</html>\n `;
|
|
221
|
+
if (!minify) {
|
|
222
|
+
return templateString;
|
|
223
|
+
}
|
|
219
224
|
return cleanTemplate(templateString);
|
|
220
225
|
};
|
|
221
226
|
|
|
222
227
|
class PluridRenderer {
|
|
223
228
|
constructor(configuration) {
|
|
224
|
-
const {htmlLanguage: htmlLanguage, head: head, htmlAttributes: htmlAttributes, bodyAttributes: bodyAttributes, defaultStyle: defaultStyle, styles: styles, headScripts: headScripts, bodyScripts: bodyScripts, vendorScriptSource: vendorScriptSource, mainScriptSource: mainScriptSource, content: content, root: root, defaultPreloadedPluridMetastate: defaultPreloadedPluridMetastate, pluridMetastate: pluridMetastate, globals: globals} = configuration;
|
|
229
|
+
const {htmlLanguage: htmlLanguage, head: head, htmlAttributes: htmlAttributes, bodyAttributes: bodyAttributes, defaultStyle: defaultStyle, styles: styles, headScripts: headScripts, bodyScripts: bodyScripts, vendorScriptSource: vendorScriptSource, mainScriptSource: mainScriptSource, content: content, root: root, defaultPreloadedPluridMetastate: defaultPreloadedPluridMetastate, pluridMetastate: pluridMetastate, globals: globals, minify: minify} = configuration;
|
|
225
230
|
const {gradientBackground: gradientBackground, gradientForeground: gradientForeground} = resolveBackgroundStyle("");
|
|
226
231
|
const defaultStyleBasic = `\n body {\n background: radial-gradient(ellipse at center, ${gradientBackground} 0%, ${gradientForeground} 100%);\n height: 100%;\n margin: 0;\n }\n `;
|
|
227
232
|
this.htmlLanguage = htmlLanguage || DEFAULT_RENDERER_LANGUAGE;
|
|
@@ -239,6 +244,7 @@ class PluridRenderer {
|
|
|
239
244
|
this.defaultPreloadedPluridMetastate = defaultPreloadedPluridMetastate || DEFAULT__PRELOADED_PLURID_METASTATE__;
|
|
240
245
|
this.pluridMetastate = pluridMetastate || DEFAULT_RENDERER_PLURID_STATE;
|
|
241
246
|
this.globals = globals !== null && globals !== void 0 ? globals : {};
|
|
247
|
+
this.minify = minify !== null && minify !== void 0 ? minify : true;
|
|
242
248
|
}
|
|
243
249
|
html() {
|
|
244
250
|
const data = {
|
|
@@ -256,7 +262,8 @@ class PluridRenderer {
|
|
|
256
262
|
content: this.content,
|
|
257
263
|
defaultPreloadedPluridMetastate: this.defaultPreloadedPluridMetastate,
|
|
258
264
|
pluridMetastate: this.pluridMetastate,
|
|
259
|
-
globals: this.globals
|
|
265
|
+
globals: this.globals,
|
|
266
|
+
minify: this.minify
|
|
260
267
|
};
|
|
261
268
|
return template(data);
|
|
262
269
|
}
|
|
@@ -274,18 +281,10 @@ const wrapping = (WrappedComponent, WrappeeComponent, properties) => class exten
|
|
|
274
281
|
class PluridContentGenerator {
|
|
275
282
|
constructor(data) {
|
|
276
283
|
this.data = data;
|
|
277
|
-
this.importProviders();
|
|
278
284
|
}
|
|
279
285
|
render() {
|
|
280
286
|
var _a;
|
|
281
287
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
282
|
-
if (!this.providers) {
|
|
283
|
-
yield this.importProviders();
|
|
284
|
-
}
|
|
285
|
-
if (!this.providers) {
|
|
286
|
-
console.log("Plurid Server Error :: Providers not loaded");
|
|
287
|
-
return "";
|
|
288
|
-
}
|
|
289
288
|
const {pluridMetastate: pluridMetastate, routes: routes, planes: planes, exterior: exterior, shell: shell, gateway: gateway, gatewayEndpoint: gatewayEndpoint, gatewayQuery: gatewayQuery, helmet: helmet, services: services, stylesheet: stylesheet, preserveResult: preserveResult, matchedPlane: matchedPlane, pathname: pathname, hostname: hostname} = this.data;
|
|
290
289
|
const RoutedApplication = () => React.createElement(PluridProvider, {
|
|
291
290
|
metastate: pluridMetastate
|
|
@@ -306,7 +305,7 @@ class PluridContentGenerator {
|
|
|
306
305
|
});
|
|
307
306
|
for (const service of services) {
|
|
308
307
|
const preserveProperties = (_a = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.providers) === null || _a === void 0 ? void 0 : _a[service.name];
|
|
309
|
-
Wrap = wrapping(
|
|
308
|
+
Wrap = wrapping(service.Provider, Wrap, Object.assign(Object.assign({}, service.properties), preserveProperties));
|
|
310
309
|
}
|
|
311
310
|
const content = renderToString(React.createElement(StyleSheetManager, {
|
|
312
311
|
sheet: stylesheet.instance
|
|
@@ -314,22 +313,6 @@ class PluridContentGenerator {
|
|
|
314
313
|
return content;
|
|
315
314
|
}));
|
|
316
315
|
}
|
|
317
|
-
importProviders() {
|
|
318
|
-
return __awaiter(this, void 0, void 0, (function*() {
|
|
319
|
-
const providers = {};
|
|
320
|
-
for (const service of this.data.services) {
|
|
321
|
-
try {
|
|
322
|
-
const importedService = yield import(service.package);
|
|
323
|
-
const ImportedServiceProvider = service.provider === "default" ? importedService : importedService[service.provider];
|
|
324
|
-
providers[service.name] = ImportedServiceProvider;
|
|
325
|
-
} catch (error) {
|
|
326
|
-
console.log(`Plurid Server Error :: Service '${service.name}' from '${service.package}' could not be imported.`);
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
this.providers = providers;
|
|
331
|
-
}));
|
|
332
|
-
}
|
|
333
316
|
}
|
|
334
317
|
|
|
335
318
|
const resolveElementFromPlaneMatch = (planeMatch, elementqlEndpoint) => {
|
|
@@ -730,11 +713,11 @@ class PluridServer {
|
|
|
730
713
|
}));
|
|
731
714
|
}
|
|
732
715
|
renderApplication(isoMatch, preserveResult, matchedPlane) {
|
|
733
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
716
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
734
717
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
735
718
|
const globals = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.globals;
|
|
736
719
|
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);
|
|
737
|
-
const pluridMetastate = serverComputeMetastate(isoMatch, this.routes, globals);
|
|
720
|
+
const pluridMetastate = yield serverComputeMetastate(isoMatch, this.routes, globals);
|
|
738
721
|
const {content: content, styles: styles} = yield this.getContentAndStyles(isoMatch, pluridMetastate, preserveResult, matchedPlane);
|
|
739
722
|
const stringedStyles = this.styles.reduce(((accumulator, style) => accumulator + style), "");
|
|
740
723
|
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(" ")) || "";
|
|
@@ -765,7 +748,8 @@ class PluridServer {
|
|
|
765
748
|
content: content,
|
|
766
749
|
defaultPreloadedPluridMetastate: (_r = this.template) === null || _r === void 0 ? void 0 : _r.defaultPreloadedPluridMetastate,
|
|
767
750
|
pluridMetastate: JSON.stringify(pluridMetastate),
|
|
768
|
-
globals: globals
|
|
751
|
+
globals: globals,
|
|
752
|
+
minify: (_s = this.template) === null || _s === void 0 ? void 0 : _s.minify
|
|
769
753
|
});
|
|
770
754
|
return renderer;
|
|
771
755
|
}));
|
package/distribution/index.js
CHANGED
|
@@ -44,26 +44,6 @@ function _interopDefaultLegacy(e) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
function _interopNamespace(e) {
|
|
48
|
-
if (e && e.__esModule) return e;
|
|
49
|
-
var n = Object.create(null);
|
|
50
|
-
if (e) {
|
|
51
|
-
Object.keys(e).forEach((function(k) {
|
|
52
|
-
if (k !== "default") {
|
|
53
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
54
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function() {
|
|
57
|
-
return e[k];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
n["default"] = e;
|
|
64
|
-
return Object.freeze(n);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
47
|
var fs__default = _interopDefaultLegacy(fs);
|
|
68
48
|
|
|
69
49
|
var path__default = _interopDefaultLegacy(path);
|
|
@@ -208,7 +188,9 @@ const defaultStillerOptions = {
|
|
|
208
188
|
};
|
|
209
189
|
|
|
210
190
|
const cleanTemplate = template => htmlMinifier.minify(template, {
|
|
211
|
-
collapseWhitespace: true
|
|
191
|
+
collapseWhitespace: true,
|
|
192
|
+
conservativeCollapse: true,
|
|
193
|
+
collapseInlineTagWhitespace: false
|
|
212
194
|
});
|
|
213
195
|
|
|
214
196
|
const resolveBackgroundStyle = store => {
|
|
@@ -261,15 +243,18 @@ const NOT_FOUND_TEMPLATE = cleanTemplate(`\n<!DOCTYPE html>\n<html>\n <head>\
|
|
|
261
243
|
const SERVER_ERROR_TEMPLATE = cleanTemplate(`\n<!DOCTYPE html>\n<html>\n <head>\n <title>[500] Server Error</title>\n <style>\n html, body {\n margin: 0;\n background: #242b33;\n color: #ddd;\n user-select: none;\n }\n\n .error {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n font-family: 'Ubuntu', -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto;\n }\n </style>\n </head>\n\n <body>\n <div class="error">[500] Server Error</div>\n </body>\n</html>\n`);
|
|
262
244
|
|
|
263
245
|
const template = data => {
|
|
264
|
-
const {htmlLanguage: htmlLanguage, head: head, htmlAttributes: htmlAttributes, bodyAttributes: bodyAttributes, defaultStyle: defaultStyle, styles: styles, headScripts: headScripts, bodyScripts: bodyScripts, vendorScriptSource: vendorScriptSource, mainScriptSource: mainScriptSource, root: root, content: content, defaultPreloadedPluridMetastate: defaultPreloadedPluridMetastate, pluridMetastate: pluridMetastate, globals: globals} = data;
|
|
246
|
+
const {htmlLanguage: htmlLanguage, head: head, htmlAttributes: htmlAttributes, bodyAttributes: bodyAttributes, defaultStyle: defaultStyle, styles: styles, headScripts: headScripts, bodyScripts: bodyScripts, vendorScriptSource: vendorScriptSource, mainScriptSource: mainScriptSource, root: root, content: content, defaultPreloadedPluridMetastate: defaultPreloadedPluridMetastate, pluridMetastate: pluridMetastate, globals: globals, minify: minify} = data;
|
|
265
247
|
const injectedGlobals = globalsInjector(globals);
|
|
266
248
|
const templateString = `\n<!DOCTYPE html>\n<html lang="${htmlLanguage}" ${htmlAttributes}>\n <head>\n ${head}\n\n ${defaultStyle && `<style>\n ${defaultStyle}\n </style>`}\n\n ${styles}\n\n ${headScripts.join("\n")}\n\n <script src="${vendorScriptSource}"><\/script>\n <script defer src="${mainScriptSource}"><\/script>\n </head>\n <body ${bodyAttributes}>\n <div id="${root}">${content}</div>\n\n <script>\n ${injectedGlobals}\n window.${defaultPreloadedPluridMetastate} = ${pluridMetastate};\n <\/script>\n\n ${bodyScripts.join("\n")}\n </body>\n</html>\n `;
|
|
249
|
+
if (!minify) {
|
|
250
|
+
return templateString;
|
|
251
|
+
}
|
|
267
252
|
return cleanTemplate(templateString);
|
|
268
253
|
};
|
|
269
254
|
|
|
270
255
|
class PluridRenderer {
|
|
271
256
|
constructor(configuration) {
|
|
272
|
-
const {htmlLanguage: htmlLanguage, head: head, htmlAttributes: htmlAttributes, bodyAttributes: bodyAttributes, defaultStyle: defaultStyle, styles: styles, headScripts: headScripts, bodyScripts: bodyScripts, vendorScriptSource: vendorScriptSource, mainScriptSource: mainScriptSource, content: content, root: root, defaultPreloadedPluridMetastate: defaultPreloadedPluridMetastate, pluridMetastate: pluridMetastate, globals: globals} = configuration;
|
|
257
|
+
const {htmlLanguage: htmlLanguage, head: head, htmlAttributes: htmlAttributes, bodyAttributes: bodyAttributes, defaultStyle: defaultStyle, styles: styles, headScripts: headScripts, bodyScripts: bodyScripts, vendorScriptSource: vendorScriptSource, mainScriptSource: mainScriptSource, content: content, root: root, defaultPreloadedPluridMetastate: defaultPreloadedPluridMetastate, pluridMetastate: pluridMetastate, globals: globals, minify: minify} = configuration;
|
|
273
258
|
const {gradientBackground: gradientBackground, gradientForeground: gradientForeground} = resolveBackgroundStyle("");
|
|
274
259
|
const defaultStyleBasic = `\n body {\n background: radial-gradient(ellipse at center, ${gradientBackground} 0%, ${gradientForeground} 100%);\n height: 100%;\n margin: 0;\n }\n `;
|
|
275
260
|
this.htmlLanguage = htmlLanguage || DEFAULT_RENDERER_LANGUAGE;
|
|
@@ -287,6 +272,7 @@ class PluridRenderer {
|
|
|
287
272
|
this.defaultPreloadedPluridMetastate = defaultPreloadedPluridMetastate || DEFAULT__PRELOADED_PLURID_METASTATE__;
|
|
288
273
|
this.pluridMetastate = pluridMetastate || DEFAULT_RENDERER_PLURID_STATE;
|
|
289
274
|
this.globals = globals !== null && globals !== void 0 ? globals : {};
|
|
275
|
+
this.minify = minify !== null && minify !== void 0 ? minify : true;
|
|
290
276
|
}
|
|
291
277
|
html() {
|
|
292
278
|
const data = {
|
|
@@ -304,7 +290,8 @@ class PluridRenderer {
|
|
|
304
290
|
content: this.content,
|
|
305
291
|
defaultPreloadedPluridMetastate: this.defaultPreloadedPluridMetastate,
|
|
306
292
|
pluridMetastate: this.pluridMetastate,
|
|
307
|
-
globals: this.globals
|
|
293
|
+
globals: this.globals,
|
|
294
|
+
minify: this.minify
|
|
308
295
|
};
|
|
309
296
|
return template(data);
|
|
310
297
|
}
|
|
@@ -322,18 +309,10 @@ const wrapping = (WrappedComponent, WrappeeComponent, properties) => class exten
|
|
|
322
309
|
class PluridContentGenerator {
|
|
323
310
|
constructor(data) {
|
|
324
311
|
this.data = data;
|
|
325
|
-
this.importProviders();
|
|
326
312
|
}
|
|
327
313
|
render() {
|
|
328
314
|
var _a;
|
|
329
315
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
330
|
-
if (!this.providers) {
|
|
331
|
-
yield this.importProviders();
|
|
332
|
-
}
|
|
333
|
-
if (!this.providers) {
|
|
334
|
-
console.log("Plurid Server Error :: Providers not loaded");
|
|
335
|
-
return "";
|
|
336
|
-
}
|
|
337
316
|
const {pluridMetastate: pluridMetastate, routes: routes, planes: planes, exterior: exterior, shell: shell, gateway: gateway, gatewayEndpoint: gatewayEndpoint, gatewayQuery: gatewayQuery, helmet: helmet, services: services, stylesheet: stylesheet, preserveResult: preserveResult, matchedPlane: matchedPlane, pathname: pathname, hostname: hostname} = this.data;
|
|
338
317
|
const RoutedApplication = () => React__default["default"].createElement(pluridReact.PluridProvider, {
|
|
339
318
|
metastate: pluridMetastate
|
|
@@ -354,7 +333,7 @@ class PluridContentGenerator {
|
|
|
354
333
|
});
|
|
355
334
|
for (const service of services) {
|
|
356
335
|
const preserveProperties = (_a = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.providers) === null || _a === void 0 ? void 0 : _a[service.name];
|
|
357
|
-
Wrap = wrapping(
|
|
336
|
+
Wrap = wrapping(service.Provider, Wrap, Object.assign(Object.assign({}, service.properties), preserveProperties));
|
|
358
337
|
}
|
|
359
338
|
const content = server.renderToString(React__default["default"].createElement(styledComponents.StyleSheetManager, {
|
|
360
339
|
sheet: stylesheet.instance
|
|
@@ -362,26 +341,6 @@ class PluridContentGenerator {
|
|
|
362
341
|
return content;
|
|
363
342
|
}));
|
|
364
343
|
}
|
|
365
|
-
importProviders() {
|
|
366
|
-
return __awaiter(this, void 0, void 0, (function*() {
|
|
367
|
-
const providers = {};
|
|
368
|
-
for (const service of this.data.services) {
|
|
369
|
-
try {
|
|
370
|
-
const importedService = yield function(t) {
|
|
371
|
-
return Promise.resolve().then((function() {
|
|
372
|
-
return _interopNamespace(require(t));
|
|
373
|
-
}));
|
|
374
|
-
}(service.package);
|
|
375
|
-
const ImportedServiceProvider = service.provider === "default" ? importedService : importedService[service.provider];
|
|
376
|
-
providers[service.name] = ImportedServiceProvider;
|
|
377
|
-
} catch (error) {
|
|
378
|
-
console.log(`Plurid Server Error :: Service '${service.name}' from '${service.package}' could not be imported.`);
|
|
379
|
-
continue;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
this.providers = providers;
|
|
383
|
-
}));
|
|
384
|
-
}
|
|
385
344
|
}
|
|
386
345
|
|
|
387
346
|
const resolveElementFromPlaneMatch = (planeMatch, elementqlEndpoint) => {
|
|
@@ -782,11 +741,11 @@ class PluridServer {
|
|
|
782
741
|
}));
|
|
783
742
|
}
|
|
784
743
|
renderApplication(isoMatch, preserveResult, matchedPlane) {
|
|
785
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
744
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
786
745
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
787
746
|
const globals = preserveResult === null || preserveResult === void 0 ? void 0 : preserveResult.globals;
|
|
788
747
|
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);
|
|
789
|
-
const pluridMetastate = pluridReact.serverComputeMetastate(isoMatch, this.routes, globals);
|
|
748
|
+
const pluridMetastate = yield pluridReact.serverComputeMetastate(isoMatch, this.routes, globals);
|
|
790
749
|
const {content: content, styles: styles} = yield this.getContentAndStyles(isoMatch, pluridMetastate, preserveResult, matchedPlane);
|
|
791
750
|
const stringedStyles = this.styles.reduce(((accumulator, style) => accumulator + style), "");
|
|
792
751
|
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(" ")) || "";
|
|
@@ -817,7 +776,8 @@ class PluridServer {
|
|
|
817
776
|
content: content,
|
|
818
777
|
defaultPreloadedPluridMetastate: (_r = this.template) === null || _r === void 0 ? void 0 : _r.defaultPreloadedPluridMetastate,
|
|
819
778
|
pluridMetastate: JSON.stringify(pluridMetastate),
|
|
820
|
-
globals: globals
|
|
779
|
+
globals: globals,
|
|
780
|
+
minify: (_s = this.template) === null || _s === void 0 ? void 0 : _s.minify
|
|
821
781
|
});
|
|
822
782
|
return renderer;
|
|
823
783
|
}));
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { PluridContentGeneratorData } from "../../data/interfaces";
|
|
2
2
|
declare class PluridContentGenerator {
|
|
3
3
|
private data;
|
|
4
|
-
private providers;
|
|
5
4
|
constructor(data: PluridContentGeneratorData);
|
|
6
5
|
render(): Promise<string>;
|
|
7
|
-
private importProviders;
|
|
8
6
|
}
|
|
9
7
|
export default PluridContentGenerator;
|
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-13",
|
|
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",
|
|
@@ -77,20 +77,20 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@apollo/client": "^3.6.9",
|
|
80
|
-
"@babel/core": "^7.18.
|
|
80
|
+
"@babel/core": "^7.18.13",
|
|
81
81
|
"@plurid/elementql": "^0.0.0-1",
|
|
82
82
|
"@plurid/elementql-client-react": "^0.0.0-1",
|
|
83
|
-
"@plurid/plurid-data": "0.0.0-
|
|
84
|
-
"@plurid/plurid-engine": "0.0.0-
|
|
85
|
-
"@plurid/plurid-functions": "0.0.0-
|
|
83
|
+
"@plurid/plurid-data": "0.0.0-17",
|
|
84
|
+
"@plurid/plurid-engine": "0.0.0-16",
|
|
85
|
+
"@plurid/plurid-functions": "0.0.0-30",
|
|
86
86
|
"@plurid/plurid-functions-react": "0.0.0-5",
|
|
87
|
-
"@plurid/plurid-icons-react": "0.0.0-
|
|
88
|
-
"@plurid/plurid-pubsub": "0.0.0-
|
|
89
|
-
"@plurid/plurid-react": "0.0.0-
|
|
87
|
+
"@plurid/plurid-icons-react": "0.0.0-5",
|
|
88
|
+
"@plurid/plurid-pubsub": "0.0.0-8",
|
|
89
|
+
"@plurid/plurid-react": "0.0.0-25",
|
|
90
90
|
"@plurid/plurid-themes": "0.0.0-2",
|
|
91
|
-
"@plurid/plurid-ui-components-react": "0.0.0-
|
|
92
|
-
"@plurid/plurid-ui-state-react": "0.0.0-
|
|
93
|
-
"@redux-devtools/extension": "^3.2.
|
|
91
|
+
"@plurid/plurid-ui-components-react": "0.0.0-17",
|
|
92
|
+
"@plurid/plurid-ui-state-react": "0.0.0-7",
|
|
93
|
+
"@redux-devtools/extension": "^3.2.3",
|
|
94
94
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
95
95
|
"@types/body-parser": "^1.19.2",
|
|
96
96
|
"@types/compression": "^1.7.2",
|
|
@@ -98,19 +98,19 @@
|
|
|
98
98
|
"@types/express": "^4.17.13",
|
|
99
99
|
"@types/hammerjs": "^2.0.41",
|
|
100
100
|
"@types/html-minifier": "^4.0.2",
|
|
101
|
-
"@types/jest": "^28.1.
|
|
102
|
-
"@types/node": "^18.
|
|
103
|
-
"@types/react": "^18.0.
|
|
101
|
+
"@types/jest": "^28.1.8",
|
|
102
|
+
"@types/node": "^18.7.13",
|
|
103
|
+
"@types/react": "^18.0.17",
|
|
104
104
|
"@types/react-dom": "^18.0.6",
|
|
105
105
|
"@types/react-redux": "^7.1.24",
|
|
106
106
|
"@types/react-stripe-elements": "^6.0.6",
|
|
107
|
-
"@types/styled-components": "^5.1.
|
|
108
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
109
|
-
"@typescript-eslint/parser": "^5.
|
|
107
|
+
"@types/styled-components": "^5.1.26",
|
|
108
|
+
"@typescript-eslint/eslint-plugin": "^5.34.0",
|
|
109
|
+
"@typescript-eslint/parser": "^5.34.0",
|
|
110
110
|
"@zerollup/ts-transform-paths": "^1.7.18",
|
|
111
111
|
"cross-fetch": "^3.1.5",
|
|
112
|
-
"eslint": "^8.
|
|
113
|
-
"graphql": "^16.
|
|
112
|
+
"eslint": "^8.22.0",
|
|
113
|
+
"graphql": "^16.6.0",
|
|
114
114
|
"hammerjs": "^2.0.8",
|
|
115
115
|
"jest": "^28.1.3",
|
|
116
116
|
"jest-config": "^28.1.3",
|
|
@@ -120,12 +120,12 @@
|
|
|
120
120
|
"react-redux": "^8.0.2",
|
|
121
121
|
"redux": "^4.2.0",
|
|
122
122
|
"redux-thunk": "^2.4.1",
|
|
123
|
-
"rollup": "^2.
|
|
123
|
+
"rollup": "^2.78.1",
|
|
124
124
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
125
125
|
"rollup-plugin-terser": "^7.0.2",
|
|
126
|
-
"rollup-plugin-typescript2": "^0.
|
|
126
|
+
"rollup-plugin-typescript2": "^0.33.0",
|
|
127
127
|
"styled-components": "^5.3.5",
|
|
128
|
-
"ts-jest": "^28.0.
|
|
128
|
+
"ts-jest": "^28.0.8",
|
|
129
129
|
"ts-node": "^10.9.1",
|
|
130
130
|
"tslib": "^2.4.0",
|
|
131
131
|
"ttypescript": "^1.5.13",
|