@nestjs-ssr/react 0.2.3 → 0.2.5
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/README.md +36 -33
- package/dist/cli/init.js +2 -1
- package/dist/cli/init.mjs +2 -1
- package/dist/client.d.mts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2 -2
- package/dist/client.mjs +2 -2
- package/dist/{index-Dq1yt0sX.d.mts → index-BMdluY1g.d.mts} +51 -39
- package/dist/{index-CaGD266H.d.ts → index-rl0S5kqW.d.ts} +51 -39
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +48 -43
- package/dist/index.mjs +48 -43
- package/dist/render/index.d.mts +1 -1
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.js +46 -41
- package/dist/render/index.mjs +46 -41
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1154,39 +1154,32 @@ exports.RenderModule = class _RenderModule {
|
|
|
1154
1154
|
__name(this, "RenderModule");
|
|
1155
1155
|
}
|
|
1156
1156
|
/**
|
|
1157
|
-
*
|
|
1157
|
+
* Configure the render module
|
|
1158
1158
|
*
|
|
1159
1159
|
* @param config - Optional render configuration
|
|
1160
1160
|
* @returns Dynamic module
|
|
1161
1161
|
*
|
|
1162
1162
|
* @example
|
|
1163
1163
|
* ```ts
|
|
1164
|
-
* // Zero config -
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
*
|
|
1164
|
+
* // Zero config - uses defaults
|
|
1165
|
+
* RenderModule.forRoot()
|
|
1166
|
+
*
|
|
1167
|
+
* // Enable streaming SSR
|
|
1168
|
+
* RenderModule.forRoot({ mode: 'stream' })
|
|
1168
1169
|
*
|
|
1169
1170
|
* // Enable HMR with proxy mode
|
|
1170
|
-
*
|
|
1171
|
-
*
|
|
1172
|
-
* RenderModule.register({
|
|
1173
|
-
* vite: { mode: 'proxy', port: 5173 }
|
|
1174
|
-
* })
|
|
1175
|
-
* ],
|
|
1171
|
+
* RenderModule.forRoot({
|
|
1172
|
+
* vite: { mode: 'proxy', port: 5173 }
|
|
1176
1173
|
* })
|
|
1177
1174
|
*
|
|
1178
|
-
* // Enable streaming SSR
|
|
1179
|
-
* RenderModule.register({ mode: 'stream' })
|
|
1180
|
-
*
|
|
1181
1175
|
* // Custom error pages
|
|
1182
|
-
* RenderModule.
|
|
1183
|
-
*
|
|
1184
|
-
*
|
|
1185
|
-
* errorPageProduction: MyCustomProdErrorPage,
|
|
1176
|
+
* RenderModule.forRoot({
|
|
1177
|
+
* errorPageDevelopment: DevErrorPage,
|
|
1178
|
+
* errorPageProduction: ProdErrorPage,
|
|
1186
1179
|
* })
|
|
1187
1180
|
* ```
|
|
1188
1181
|
*/
|
|
1189
|
-
static
|
|
1182
|
+
static forRoot(config) {
|
|
1190
1183
|
const providers = [
|
|
1191
1184
|
exports.RenderService,
|
|
1192
1185
|
exports.TemplateParserService,
|
|
@@ -1249,35 +1242,42 @@ exports.RenderModule = class _RenderModule {
|
|
|
1249
1242
|
};
|
|
1250
1243
|
}
|
|
1251
1244
|
/**
|
|
1252
|
-
*
|
|
1245
|
+
* Configure the render module with async factory
|
|
1253
1246
|
*
|
|
1254
|
-
* Use
|
|
1247
|
+
* Use when configuration depends on other services (database, config service, etc.)
|
|
1255
1248
|
*
|
|
1256
1249
|
* @param options - Async configuration options
|
|
1257
1250
|
* @returns Dynamic module
|
|
1258
1251
|
*
|
|
1259
1252
|
* @example
|
|
1260
1253
|
* ```ts
|
|
1261
|
-
* // Load
|
|
1262
|
-
* RenderModule.
|
|
1254
|
+
* // Load config from ConfigService
|
|
1255
|
+
* RenderModule.forRootAsync({
|
|
1256
|
+
* imports: [ConfigModule],
|
|
1257
|
+
* inject: [ConfigService],
|
|
1258
|
+
* useFactory: (config: ConfigService) => ({
|
|
1259
|
+
* mode: config.get('SSR_MODE'),
|
|
1260
|
+
* defaultHead: { title: config.get('APP_NAME') },
|
|
1261
|
+
* }),
|
|
1262
|
+
* })
|
|
1263
|
+
*
|
|
1264
|
+
* // Load from database
|
|
1265
|
+
* RenderModule.forRootAsync({
|
|
1263
1266
|
* imports: [TenantModule],
|
|
1264
|
-
* inject: [
|
|
1265
|
-
* useFactory: async (
|
|
1266
|
-
* const tenant = await
|
|
1267
|
+
* inject: [TenantService],
|
|
1268
|
+
* useFactory: async (tenantService: TenantService) => {
|
|
1269
|
+
* const tenant = await tenantService.getCurrent();
|
|
1267
1270
|
* return {
|
|
1268
1271
|
* defaultHead: {
|
|
1269
|
-
* title: tenant.
|
|
1270
|
-
*
|
|
1271
|
-
*
|
|
1272
|
-
* { rel: 'icon', href: tenant.favicon }
|
|
1273
|
-
* ]
|
|
1274
|
-
* }
|
|
1272
|
+
* title: tenant.name,
|
|
1273
|
+
* links: [{ rel: 'icon', href: tenant.favicon }],
|
|
1274
|
+
* },
|
|
1275
1275
|
* };
|
|
1276
|
-
* }
|
|
1276
|
+
* },
|
|
1277
1277
|
* })
|
|
1278
1278
|
* ```
|
|
1279
1279
|
*/
|
|
1280
|
-
static
|
|
1280
|
+
static forRootAsync(options) {
|
|
1281
1281
|
const configProvider = {
|
|
1282
1282
|
provide: "RENDER_CONFIG",
|
|
1283
1283
|
useFactory: options.useFactory,
|
|
@@ -1293,7 +1293,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1293
1293
|
provide: core.APP_INTERCEPTOR,
|
|
1294
1294
|
useClass: exports.RenderInterceptor
|
|
1295
1295
|
},
|
|
1296
|
-
// Vite configuration provider - reads from config
|
|
1297
1296
|
{
|
|
1298
1297
|
provide: "VITE_CONFIG",
|
|
1299
1298
|
useFactory: /* @__PURE__ */ __name((config) => config?.vite || {}, "useFactory"),
|
|
@@ -1301,7 +1300,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1301
1300
|
"RENDER_CONFIG"
|
|
1302
1301
|
]
|
|
1303
1302
|
},
|
|
1304
|
-
// SSR mode provider - reads from config
|
|
1305
1303
|
{
|
|
1306
1304
|
provide: "SSR_MODE",
|
|
1307
1305
|
useFactory: /* @__PURE__ */ __name((config) => config?.mode, "useFactory"),
|
|
@@ -1309,7 +1307,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1309
1307
|
"RENDER_CONFIG"
|
|
1310
1308
|
]
|
|
1311
1309
|
},
|
|
1312
|
-
// Error page providers - read from config
|
|
1313
1310
|
{
|
|
1314
1311
|
provide: "ERROR_PAGE_DEVELOPMENT",
|
|
1315
1312
|
useFactory: /* @__PURE__ */ __name((config) => config?.errorPageDevelopment, "useFactory"),
|
|
@@ -1324,7 +1321,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1324
1321
|
"RENDER_CONFIG"
|
|
1325
1322
|
]
|
|
1326
1323
|
},
|
|
1327
|
-
// Default head provider - reads from config
|
|
1328
1324
|
{
|
|
1329
1325
|
provide: "DEFAULT_HEAD",
|
|
1330
1326
|
useFactory: /* @__PURE__ */ __name((config) => config?.defaultHead, "useFactory"),
|
|
@@ -1332,7 +1328,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1332
1328
|
"RENDER_CONFIG"
|
|
1333
1329
|
]
|
|
1334
1330
|
},
|
|
1335
|
-
// Custom template provider - reads from config
|
|
1336
1331
|
{
|
|
1337
1332
|
provide: "CUSTOM_TEMPLATE",
|
|
1338
1333
|
useFactory: /* @__PURE__ */ __name((config) => config?.template, "useFactory"),
|
|
@@ -1340,7 +1335,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1340
1335
|
"RENDER_CONFIG"
|
|
1341
1336
|
]
|
|
1342
1337
|
},
|
|
1343
|
-
// Allowed headers provider - reads from config
|
|
1344
1338
|
{
|
|
1345
1339
|
provide: "ALLOWED_HEADERS",
|
|
1346
1340
|
useFactory: /* @__PURE__ */ __name((config) => config?.allowedHeaders || [], "useFactory"),
|
|
@@ -1348,7 +1342,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1348
1342
|
"RENDER_CONFIG"
|
|
1349
1343
|
]
|
|
1350
1344
|
},
|
|
1351
|
-
// Allowed cookies provider - reads from config
|
|
1352
1345
|
{
|
|
1353
1346
|
provide: "ALLOWED_COOKIES",
|
|
1354
1347
|
useFactory: /* @__PURE__ */ __name((config) => config?.allowedCookies || [], "useFactory"),
|
|
@@ -1367,6 +1360,18 @@ exports.RenderModule = class _RenderModule {
|
|
|
1367
1360
|
]
|
|
1368
1361
|
};
|
|
1369
1362
|
}
|
|
1363
|
+
/**
|
|
1364
|
+
* @deprecated Use forRoot() instead
|
|
1365
|
+
*/
|
|
1366
|
+
static register(config) {
|
|
1367
|
+
return this.forRoot(config);
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* @deprecated Use forRootAsync() instead
|
|
1371
|
+
*/
|
|
1372
|
+
static registerAsync(options) {
|
|
1373
|
+
return this.forRootAsync(options);
|
|
1374
|
+
}
|
|
1370
1375
|
};
|
|
1371
1376
|
exports.RenderModule = _ts_decorate6([
|
|
1372
1377
|
common.Global(),
|
|
@@ -1471,7 +1476,7 @@ function createSSRHooks() {
|
|
|
1471
1476
|
*
|
|
1472
1477
|
* Configure in module registration:
|
|
1473
1478
|
* ```typescript
|
|
1474
|
-
* RenderModule.
|
|
1479
|
+
* RenderModule.forRoot({
|
|
1475
1480
|
* allowedHeaders: ['user-agent', 'x-tenant-id', 'x-api-version']
|
|
1476
1481
|
* })
|
|
1477
1482
|
* ```
|
|
@@ -1533,7 +1538,7 @@ function createSSRHooks() {
|
|
|
1533
1538
|
*
|
|
1534
1539
|
* Configure in module registration:
|
|
1535
1540
|
* ```typescript
|
|
1536
|
-
* RenderModule.
|
|
1541
|
+
* RenderModule.forRoot({
|
|
1537
1542
|
* allowedCookies: ['theme', 'locale', 'consent']
|
|
1538
1543
|
* })
|
|
1539
1544
|
* ```
|
package/dist/index.mjs
CHANGED
|
@@ -1147,39 +1147,32 @@ var RenderModule = class _RenderModule {
|
|
|
1147
1147
|
__name(this, "RenderModule");
|
|
1148
1148
|
}
|
|
1149
1149
|
/**
|
|
1150
|
-
*
|
|
1150
|
+
* Configure the render module
|
|
1151
1151
|
*
|
|
1152
1152
|
* @param config - Optional render configuration
|
|
1153
1153
|
* @returns Dynamic module
|
|
1154
1154
|
*
|
|
1155
1155
|
* @example
|
|
1156
1156
|
* ```ts
|
|
1157
|
-
* // Zero config -
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
1160
|
-
*
|
|
1157
|
+
* // Zero config - uses defaults
|
|
1158
|
+
* RenderModule.forRoot()
|
|
1159
|
+
*
|
|
1160
|
+
* // Enable streaming SSR
|
|
1161
|
+
* RenderModule.forRoot({ mode: 'stream' })
|
|
1161
1162
|
*
|
|
1162
1163
|
* // Enable HMR with proxy mode
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
* RenderModule.register({
|
|
1166
|
-
* vite: { mode: 'proxy', port: 5173 }
|
|
1167
|
-
* })
|
|
1168
|
-
* ],
|
|
1164
|
+
* RenderModule.forRoot({
|
|
1165
|
+
* vite: { mode: 'proxy', port: 5173 }
|
|
1169
1166
|
* })
|
|
1170
1167
|
*
|
|
1171
|
-
* // Enable streaming SSR
|
|
1172
|
-
* RenderModule.register({ mode: 'stream' })
|
|
1173
|
-
*
|
|
1174
1168
|
* // Custom error pages
|
|
1175
|
-
* RenderModule.
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1178
|
-
* errorPageProduction: MyCustomProdErrorPage,
|
|
1169
|
+
* RenderModule.forRoot({
|
|
1170
|
+
* errorPageDevelopment: DevErrorPage,
|
|
1171
|
+
* errorPageProduction: ProdErrorPage,
|
|
1179
1172
|
* })
|
|
1180
1173
|
* ```
|
|
1181
1174
|
*/
|
|
1182
|
-
static
|
|
1175
|
+
static forRoot(config) {
|
|
1183
1176
|
const providers = [
|
|
1184
1177
|
RenderService,
|
|
1185
1178
|
TemplateParserService,
|
|
@@ -1242,35 +1235,42 @@ var RenderModule = class _RenderModule {
|
|
|
1242
1235
|
};
|
|
1243
1236
|
}
|
|
1244
1237
|
/**
|
|
1245
|
-
*
|
|
1238
|
+
* Configure the render module with async factory
|
|
1246
1239
|
*
|
|
1247
|
-
* Use
|
|
1240
|
+
* Use when configuration depends on other services (database, config service, etc.)
|
|
1248
1241
|
*
|
|
1249
1242
|
* @param options - Async configuration options
|
|
1250
1243
|
* @returns Dynamic module
|
|
1251
1244
|
*
|
|
1252
1245
|
* @example
|
|
1253
1246
|
* ```ts
|
|
1254
|
-
* // Load
|
|
1255
|
-
* RenderModule.
|
|
1247
|
+
* // Load config from ConfigService
|
|
1248
|
+
* RenderModule.forRootAsync({
|
|
1249
|
+
* imports: [ConfigModule],
|
|
1250
|
+
* inject: [ConfigService],
|
|
1251
|
+
* useFactory: (config: ConfigService) => ({
|
|
1252
|
+
* mode: config.get('SSR_MODE'),
|
|
1253
|
+
* defaultHead: { title: config.get('APP_NAME') },
|
|
1254
|
+
* }),
|
|
1255
|
+
* })
|
|
1256
|
+
*
|
|
1257
|
+
* // Load from database
|
|
1258
|
+
* RenderModule.forRootAsync({
|
|
1256
1259
|
* imports: [TenantModule],
|
|
1257
|
-
* inject: [
|
|
1258
|
-
* useFactory: async (
|
|
1259
|
-
* const tenant = await
|
|
1260
|
+
* inject: [TenantService],
|
|
1261
|
+
* useFactory: async (tenantService: TenantService) => {
|
|
1262
|
+
* const tenant = await tenantService.getCurrent();
|
|
1260
1263
|
* return {
|
|
1261
1264
|
* defaultHead: {
|
|
1262
|
-
* title: tenant.
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1265
|
-
* { rel: 'icon', href: tenant.favicon }
|
|
1266
|
-
* ]
|
|
1267
|
-
* }
|
|
1265
|
+
* title: tenant.name,
|
|
1266
|
+
* links: [{ rel: 'icon', href: tenant.favicon }],
|
|
1267
|
+
* },
|
|
1268
1268
|
* };
|
|
1269
|
-
* }
|
|
1269
|
+
* },
|
|
1270
1270
|
* })
|
|
1271
1271
|
* ```
|
|
1272
1272
|
*/
|
|
1273
|
-
static
|
|
1273
|
+
static forRootAsync(options) {
|
|
1274
1274
|
const configProvider = {
|
|
1275
1275
|
provide: "RENDER_CONFIG",
|
|
1276
1276
|
useFactory: options.useFactory,
|
|
@@ -1286,7 +1286,6 @@ var RenderModule = class _RenderModule {
|
|
|
1286
1286
|
provide: APP_INTERCEPTOR,
|
|
1287
1287
|
useClass: RenderInterceptor
|
|
1288
1288
|
},
|
|
1289
|
-
// Vite configuration provider - reads from config
|
|
1290
1289
|
{
|
|
1291
1290
|
provide: "VITE_CONFIG",
|
|
1292
1291
|
useFactory: /* @__PURE__ */ __name((config) => config?.vite || {}, "useFactory"),
|
|
@@ -1294,7 +1293,6 @@ var RenderModule = class _RenderModule {
|
|
|
1294
1293
|
"RENDER_CONFIG"
|
|
1295
1294
|
]
|
|
1296
1295
|
},
|
|
1297
|
-
// SSR mode provider - reads from config
|
|
1298
1296
|
{
|
|
1299
1297
|
provide: "SSR_MODE",
|
|
1300
1298
|
useFactory: /* @__PURE__ */ __name((config) => config?.mode, "useFactory"),
|
|
@@ -1302,7 +1300,6 @@ var RenderModule = class _RenderModule {
|
|
|
1302
1300
|
"RENDER_CONFIG"
|
|
1303
1301
|
]
|
|
1304
1302
|
},
|
|
1305
|
-
// Error page providers - read from config
|
|
1306
1303
|
{
|
|
1307
1304
|
provide: "ERROR_PAGE_DEVELOPMENT",
|
|
1308
1305
|
useFactory: /* @__PURE__ */ __name((config) => config?.errorPageDevelopment, "useFactory"),
|
|
@@ -1317,7 +1314,6 @@ var RenderModule = class _RenderModule {
|
|
|
1317
1314
|
"RENDER_CONFIG"
|
|
1318
1315
|
]
|
|
1319
1316
|
},
|
|
1320
|
-
// Default head provider - reads from config
|
|
1321
1317
|
{
|
|
1322
1318
|
provide: "DEFAULT_HEAD",
|
|
1323
1319
|
useFactory: /* @__PURE__ */ __name((config) => config?.defaultHead, "useFactory"),
|
|
@@ -1325,7 +1321,6 @@ var RenderModule = class _RenderModule {
|
|
|
1325
1321
|
"RENDER_CONFIG"
|
|
1326
1322
|
]
|
|
1327
1323
|
},
|
|
1328
|
-
// Custom template provider - reads from config
|
|
1329
1324
|
{
|
|
1330
1325
|
provide: "CUSTOM_TEMPLATE",
|
|
1331
1326
|
useFactory: /* @__PURE__ */ __name((config) => config?.template, "useFactory"),
|
|
@@ -1333,7 +1328,6 @@ var RenderModule = class _RenderModule {
|
|
|
1333
1328
|
"RENDER_CONFIG"
|
|
1334
1329
|
]
|
|
1335
1330
|
},
|
|
1336
|
-
// Allowed headers provider - reads from config
|
|
1337
1331
|
{
|
|
1338
1332
|
provide: "ALLOWED_HEADERS",
|
|
1339
1333
|
useFactory: /* @__PURE__ */ __name((config) => config?.allowedHeaders || [], "useFactory"),
|
|
@@ -1341,7 +1335,6 @@ var RenderModule = class _RenderModule {
|
|
|
1341
1335
|
"RENDER_CONFIG"
|
|
1342
1336
|
]
|
|
1343
1337
|
},
|
|
1344
|
-
// Allowed cookies provider - reads from config
|
|
1345
1338
|
{
|
|
1346
1339
|
provide: "ALLOWED_COOKIES",
|
|
1347
1340
|
useFactory: /* @__PURE__ */ __name((config) => config?.allowedCookies || [], "useFactory"),
|
|
@@ -1360,6 +1353,18 @@ var RenderModule = class _RenderModule {
|
|
|
1360
1353
|
]
|
|
1361
1354
|
};
|
|
1362
1355
|
}
|
|
1356
|
+
/**
|
|
1357
|
+
* @deprecated Use forRoot() instead
|
|
1358
|
+
*/
|
|
1359
|
+
static register(config) {
|
|
1360
|
+
return this.forRoot(config);
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* @deprecated Use forRootAsync() instead
|
|
1364
|
+
*/
|
|
1365
|
+
static registerAsync(options) {
|
|
1366
|
+
return this.forRootAsync(options);
|
|
1367
|
+
}
|
|
1363
1368
|
};
|
|
1364
1369
|
RenderModule = _ts_decorate6([
|
|
1365
1370
|
Global(),
|
|
@@ -1464,7 +1469,7 @@ function createSSRHooks() {
|
|
|
1464
1469
|
*
|
|
1465
1470
|
* Configure in module registration:
|
|
1466
1471
|
* ```typescript
|
|
1467
|
-
* RenderModule.
|
|
1472
|
+
* RenderModule.forRoot({
|
|
1468
1473
|
* allowedHeaders: ['user-agent', 'x-tenant-id', 'x-api-version']
|
|
1469
1474
|
* })
|
|
1470
1475
|
* ```
|
|
@@ -1526,7 +1531,7 @@ function createSSRHooks() {
|
|
|
1526
1531
|
*
|
|
1527
1532
|
* Configure in module registration:
|
|
1528
1533
|
* ```typescript
|
|
1529
|
-
* RenderModule.
|
|
1534
|
+
* RenderModule.forRoot({
|
|
1530
1535
|
* allowedCookies: ['theme', 'locale', 'consent']
|
|
1531
1536
|
* })
|
|
1532
1537
|
* ```
|
package/dist/render/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { E as ErrorPageDevelopment, e as ErrorPageProduction, b as RenderInterceptor, R as RenderModule, a as RenderService, S as StreamingErrorHandler, T as TemplateParserService } from '../index-
|
|
1
|
+
export { E as ErrorPageDevelopment, e as ErrorPageProduction, b as RenderInterceptor, R as RenderModule, a as RenderService, S as StreamingErrorHandler, T as TemplateParserService } from '../index-BMdluY1g.mjs';
|
|
2
2
|
import '@nestjs/common';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '../render-response.interface-Dc-Kwb09.mjs';
|
package/dist/render/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { E as ErrorPageDevelopment, e as ErrorPageProduction, b as RenderInterceptor, R as RenderModule, a as RenderService, S as StreamingErrorHandler, T as TemplateParserService } from '../index-
|
|
1
|
+
export { E as ErrorPageDevelopment, e as ErrorPageProduction, b as RenderInterceptor, R as RenderModule, a as RenderService, S as StreamingErrorHandler, T as TemplateParserService } from '../index-rl0S5kqW.js';
|
|
2
2
|
import '@nestjs/common';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '../render-response.interface-Dc-Kwb09.js';
|
package/dist/render/index.js
CHANGED
|
@@ -1136,39 +1136,32 @@ exports.RenderModule = class _RenderModule {
|
|
|
1136
1136
|
__name(this, "RenderModule");
|
|
1137
1137
|
}
|
|
1138
1138
|
/**
|
|
1139
|
-
*
|
|
1139
|
+
* Configure the render module
|
|
1140
1140
|
*
|
|
1141
1141
|
* @param config - Optional render configuration
|
|
1142
1142
|
* @returns Dynamic module
|
|
1143
1143
|
*
|
|
1144
1144
|
* @example
|
|
1145
1145
|
* ```ts
|
|
1146
|
-
* // Zero config -
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1146
|
+
* // Zero config - uses defaults
|
|
1147
|
+
* RenderModule.forRoot()
|
|
1148
|
+
*
|
|
1149
|
+
* // Enable streaming SSR
|
|
1150
|
+
* RenderModule.forRoot({ mode: 'stream' })
|
|
1150
1151
|
*
|
|
1151
1152
|
* // Enable HMR with proxy mode
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
* RenderModule.register({
|
|
1155
|
-
* vite: { mode: 'proxy', port: 5173 }
|
|
1156
|
-
* })
|
|
1157
|
-
* ],
|
|
1153
|
+
* RenderModule.forRoot({
|
|
1154
|
+
* vite: { mode: 'proxy', port: 5173 }
|
|
1158
1155
|
* })
|
|
1159
1156
|
*
|
|
1160
|
-
* // Enable streaming SSR
|
|
1161
|
-
* RenderModule.register({ mode: 'stream' })
|
|
1162
|
-
*
|
|
1163
1157
|
* // Custom error pages
|
|
1164
|
-
* RenderModule.
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
* errorPageProduction: MyCustomProdErrorPage,
|
|
1158
|
+
* RenderModule.forRoot({
|
|
1159
|
+
* errorPageDevelopment: DevErrorPage,
|
|
1160
|
+
* errorPageProduction: ProdErrorPage,
|
|
1168
1161
|
* })
|
|
1169
1162
|
* ```
|
|
1170
1163
|
*/
|
|
1171
|
-
static
|
|
1164
|
+
static forRoot(config) {
|
|
1172
1165
|
const providers = [
|
|
1173
1166
|
exports.RenderService,
|
|
1174
1167
|
exports.TemplateParserService,
|
|
@@ -1231,35 +1224,42 @@ exports.RenderModule = class _RenderModule {
|
|
|
1231
1224
|
};
|
|
1232
1225
|
}
|
|
1233
1226
|
/**
|
|
1234
|
-
*
|
|
1227
|
+
* Configure the render module with async factory
|
|
1235
1228
|
*
|
|
1236
|
-
* Use
|
|
1229
|
+
* Use when configuration depends on other services (database, config service, etc.)
|
|
1237
1230
|
*
|
|
1238
1231
|
* @param options - Async configuration options
|
|
1239
1232
|
* @returns Dynamic module
|
|
1240
1233
|
*
|
|
1241
1234
|
* @example
|
|
1242
1235
|
* ```ts
|
|
1243
|
-
* // Load
|
|
1244
|
-
* RenderModule.
|
|
1236
|
+
* // Load config from ConfigService
|
|
1237
|
+
* RenderModule.forRootAsync({
|
|
1238
|
+
* imports: [ConfigModule],
|
|
1239
|
+
* inject: [ConfigService],
|
|
1240
|
+
* useFactory: (config: ConfigService) => ({
|
|
1241
|
+
* mode: config.get('SSR_MODE'),
|
|
1242
|
+
* defaultHead: { title: config.get('APP_NAME') },
|
|
1243
|
+
* }),
|
|
1244
|
+
* })
|
|
1245
|
+
*
|
|
1246
|
+
* // Load from database
|
|
1247
|
+
* RenderModule.forRootAsync({
|
|
1245
1248
|
* imports: [TenantModule],
|
|
1246
|
-
* inject: [
|
|
1247
|
-
* useFactory: async (
|
|
1248
|
-
* const tenant = await
|
|
1249
|
+
* inject: [TenantService],
|
|
1250
|
+
* useFactory: async (tenantService: TenantService) => {
|
|
1251
|
+
* const tenant = await tenantService.getCurrent();
|
|
1249
1252
|
* return {
|
|
1250
1253
|
* defaultHead: {
|
|
1251
|
-
* title: tenant.
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1254
|
-
* { rel: 'icon', href: tenant.favicon }
|
|
1255
|
-
* ]
|
|
1256
|
-
* }
|
|
1254
|
+
* title: tenant.name,
|
|
1255
|
+
* links: [{ rel: 'icon', href: tenant.favicon }],
|
|
1256
|
+
* },
|
|
1257
1257
|
* };
|
|
1258
|
-
* }
|
|
1258
|
+
* },
|
|
1259
1259
|
* })
|
|
1260
1260
|
* ```
|
|
1261
1261
|
*/
|
|
1262
|
-
static
|
|
1262
|
+
static forRootAsync(options) {
|
|
1263
1263
|
const configProvider = {
|
|
1264
1264
|
provide: "RENDER_CONFIG",
|
|
1265
1265
|
useFactory: options.useFactory,
|
|
@@ -1275,7 +1275,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1275
1275
|
provide: core.APP_INTERCEPTOR,
|
|
1276
1276
|
useClass: exports.RenderInterceptor
|
|
1277
1277
|
},
|
|
1278
|
-
// Vite configuration provider - reads from config
|
|
1279
1278
|
{
|
|
1280
1279
|
provide: "VITE_CONFIG",
|
|
1281
1280
|
useFactory: /* @__PURE__ */ __name((config) => config?.vite || {}, "useFactory"),
|
|
@@ -1283,7 +1282,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1283
1282
|
"RENDER_CONFIG"
|
|
1284
1283
|
]
|
|
1285
1284
|
},
|
|
1286
|
-
// SSR mode provider - reads from config
|
|
1287
1285
|
{
|
|
1288
1286
|
provide: "SSR_MODE",
|
|
1289
1287
|
useFactory: /* @__PURE__ */ __name((config) => config?.mode, "useFactory"),
|
|
@@ -1291,7 +1289,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1291
1289
|
"RENDER_CONFIG"
|
|
1292
1290
|
]
|
|
1293
1291
|
},
|
|
1294
|
-
// Error page providers - read from config
|
|
1295
1292
|
{
|
|
1296
1293
|
provide: "ERROR_PAGE_DEVELOPMENT",
|
|
1297
1294
|
useFactory: /* @__PURE__ */ __name((config) => config?.errorPageDevelopment, "useFactory"),
|
|
@@ -1306,7 +1303,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1306
1303
|
"RENDER_CONFIG"
|
|
1307
1304
|
]
|
|
1308
1305
|
},
|
|
1309
|
-
// Default head provider - reads from config
|
|
1310
1306
|
{
|
|
1311
1307
|
provide: "DEFAULT_HEAD",
|
|
1312
1308
|
useFactory: /* @__PURE__ */ __name((config) => config?.defaultHead, "useFactory"),
|
|
@@ -1314,7 +1310,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1314
1310
|
"RENDER_CONFIG"
|
|
1315
1311
|
]
|
|
1316
1312
|
},
|
|
1317
|
-
// Custom template provider - reads from config
|
|
1318
1313
|
{
|
|
1319
1314
|
provide: "CUSTOM_TEMPLATE",
|
|
1320
1315
|
useFactory: /* @__PURE__ */ __name((config) => config?.template, "useFactory"),
|
|
@@ -1322,7 +1317,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1322
1317
|
"RENDER_CONFIG"
|
|
1323
1318
|
]
|
|
1324
1319
|
},
|
|
1325
|
-
// Allowed headers provider - reads from config
|
|
1326
1320
|
{
|
|
1327
1321
|
provide: "ALLOWED_HEADERS",
|
|
1328
1322
|
useFactory: /* @__PURE__ */ __name((config) => config?.allowedHeaders || [], "useFactory"),
|
|
@@ -1330,7 +1324,6 @@ exports.RenderModule = class _RenderModule {
|
|
|
1330
1324
|
"RENDER_CONFIG"
|
|
1331
1325
|
]
|
|
1332
1326
|
},
|
|
1333
|
-
// Allowed cookies provider - reads from config
|
|
1334
1327
|
{
|
|
1335
1328
|
provide: "ALLOWED_COOKIES",
|
|
1336
1329
|
useFactory: /* @__PURE__ */ __name((config) => config?.allowedCookies || [], "useFactory"),
|
|
@@ -1349,6 +1342,18 @@ exports.RenderModule = class _RenderModule {
|
|
|
1349
1342
|
]
|
|
1350
1343
|
};
|
|
1351
1344
|
}
|
|
1345
|
+
/**
|
|
1346
|
+
* @deprecated Use forRoot() instead
|
|
1347
|
+
*/
|
|
1348
|
+
static register(config) {
|
|
1349
|
+
return this.forRoot(config);
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* @deprecated Use forRootAsync() instead
|
|
1353
|
+
*/
|
|
1354
|
+
static registerAsync(options) {
|
|
1355
|
+
return this.forRootAsync(options);
|
|
1356
|
+
}
|
|
1352
1357
|
};
|
|
1353
1358
|
exports.RenderModule = _ts_decorate6([
|
|
1354
1359
|
common.Global(),
|