@goldstack/template-ssr 0.3.0 → 0.3.1

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,12 +1,12 @@
1
- import React from 'react';
2
- export * from './types/SSRPackage';
3
- import type { APIGatewayProxyEventV2, APIGatewayProxyResultV2, Handler } from 'aws-lambda';
4
- import type { RenderPageProps } from '@goldstack/template-ssr-server';
5
- import type { LambdaApiDeploymentConfiguration } from '@goldstack/utils-aws-lambda';
6
- import type { SSRDeploymentConfiguration } from './types/SSRPackage';
7
- export declare type SSRHandler = Handler<APIGatewayProxyEventV2, APIGatewayProxyResultV2>;
8
- export type { RenderDocumentProps, PartialRenderPageProps, BuildConfiguration, ClientBuildOptionsArgs, ServerBuildOptionsArgs, } from '@goldstack/template-ssr-server';
9
- export declare const renderPage: <PropType>(props: RenderPageProps<PropType>) => Promise<APIGatewayProxyResultV2>;
10
- export declare const createLambdaAPIDeploymentConfiguration: (configuration: SSRDeploymentConfiguration) => LambdaApiDeploymentConfiguration;
11
- export declare const hydrate: (c: React.FunctionComponent<any>) => void;
1
+ import React from 'react';
2
+ export * from './types/SSRPackage';
3
+ import type { APIGatewayProxyEventV2, APIGatewayProxyResultV2, Handler } from 'aws-lambda';
4
+ import type { RenderPageProps } from '@goldstack/template-ssr-server';
5
+ import type { LambdaApiDeploymentConfiguration } from '@goldstack/utils-aws-lambda';
6
+ import type { SSRDeploymentConfiguration } from './types/SSRPackage';
7
+ export declare type SSRHandler = Handler<APIGatewayProxyEventV2, APIGatewayProxyResultV2>;
8
+ export type { RenderDocumentProps, PartialRenderPageProps, BuildConfiguration, ClientBuildOptionsArgs, ServerBuildOptionsArgs, } from '@goldstack/template-ssr-server';
9
+ export declare const renderPage: <PropType>(props: RenderPageProps<PropType>) => Promise<APIGatewayProxyResultV2>;
10
+ export declare const createLambdaAPIDeploymentConfiguration: (configuration: SSRDeploymentConfiguration) => LambdaApiDeploymentConfiguration;
11
+ export declare const hydrate: (c: React.FunctionComponent<any>) => void;
12
12
  //# sourceMappingURL=templateSSR.d.ts.map
@@ -1,56 +1,56 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.hydrate = exports.createLambdaAPIDeploymentConfiguration = exports.renderPage = void 0;
21
- const react_1 = __importDefault(require("react"));
22
- __exportStar(require("./types/SSRPackage"), exports);
23
- const client_1 = __importDefault(require("react-dom/client"));
24
- const renderPage = async (props) => {
25
- // eslint-disable-next-line @typescript-eslint/no-var-requires
26
- return require('@goldstack/template-ssr-server').renderPage(props);
27
- };
28
- exports.renderPage = renderPage;
29
- function isServer() {
30
- return !(typeof window != 'undefined' && window.document);
31
- }
32
- const createLambdaAPIDeploymentConfiguration = (configuration) => {
33
- return {
34
- apiDomain: configuration.domain,
35
- hostedZoneDomain: configuration.hostedZoneDomain,
36
- lambdas: configuration.lambdas,
37
- lambdaNamePrefix: configuration.lambdaNamePrefix,
38
- };
39
- };
40
- exports.createLambdaAPIDeploymentConfiguration = createLambdaAPIDeploymentConfiguration;
41
- const hydrate = (
42
- // element: React.ReactElement<any, string | React.JSXElementConstructor<any>>
43
- c) => {
44
- if (isServer())
45
- return;
46
- const node = document.getElementById('root');
47
- if (node) {
48
- client_1.default.hydrateRoot(node, react_1.default.createElement(c, window.initialProperties));
49
- }
50
- // hydration not required in test environments
51
- if (!node && !process.env.JEST_WORKER_ID) {
52
- throw new Error('Cannot hydrate server-side rendered content and initialise JavaScript on the client. No element with id "root" found on page.');
53
- }
54
- };
55
- exports.hydrate = hydrate;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.hydrate = exports.createLambdaAPIDeploymentConfiguration = exports.renderPage = void 0;
21
+ const react_1 = __importDefault(require("react"));
22
+ __exportStar(require("./types/SSRPackage"), exports);
23
+ const client_1 = __importDefault(require("react-dom/client"));
24
+ const renderPage = async (props) => {
25
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
26
+ return require('@goldstack/template-ssr-server').renderPage(props);
27
+ };
28
+ exports.renderPage = renderPage;
29
+ function isServer() {
30
+ return !(typeof window != 'undefined' && window.document);
31
+ }
32
+ const createLambdaAPIDeploymentConfiguration = (configuration) => {
33
+ return {
34
+ apiDomain: configuration.domain,
35
+ hostedZoneDomain: configuration.hostedZoneDomain,
36
+ lambdas: configuration.lambdas,
37
+ lambdaNamePrefix: configuration.lambdaNamePrefix,
38
+ };
39
+ };
40
+ exports.createLambdaAPIDeploymentConfiguration = createLambdaAPIDeploymentConfiguration;
41
+ const hydrate = (
42
+ // element: React.ReactElement<any, string | React.JSXElementConstructor<any>>
43
+ c) => {
44
+ if (isServer())
45
+ return;
46
+ const node = document.getElementById('root');
47
+ if (node) {
48
+ client_1.default.hydrateRoot(node, react_1.default.createElement(c, window.initialProperties));
49
+ }
50
+ // hydration not required in test environments
51
+ if (!node && !process.env.JEST_WORKER_ID) {
52
+ throw new Error('Cannot hydrate server-side rendered content and initialise JavaScript on the client. No element with id "root" found on page.');
53
+ }
54
+ };
55
+ exports.hydrate = hydrate;
56
56
  //# sourceMappingURL=templateSSR.js.map
@@ -1,30 +1,30 @@
1
- import { LambdaRoutesConfig } from '@goldstack/utils-aws-lambda';
2
- /**
3
- * The prefix to be used for names of the generated lambdas for the dynamic endpoints.
4
- *
5
- * @title Lambda Name Prefix
6
- * @pattern ^[A-Za-z0-9-_]*$
7
- */
8
- declare type LambdaNamePrefix = string;
9
- /**
10
- * The domain name that the service should be deployed to (e.g. mysite.com)
11
- *
12
- * @title Domain
13
- * @pattern ^[^\s]*
14
- */
15
- export declare type Domain = string;
16
- /**
17
- * The domain name of the Route 53 hosted zone that the domain for this service should be added to.
18
- *
19
- * @title Hosted Zone Domain
20
- * @pattern ^[^\s]*
21
- */
22
- export declare type HostedZoneDomain = string;
23
- export interface SSRDeploymentConfiguration {
24
- lambdaNamePrefix?: LambdaNamePrefix;
25
- domain: Domain;
26
- hostedZoneDomain: HostedZoneDomain;
27
- lambdas: LambdaRoutesConfig;
28
- }
29
- export {};
1
+ import { LambdaRoutesConfig } from '@goldstack/utils-aws-lambda';
2
+ /**
3
+ * The prefix to be used for names of the generated lambdas for the dynamic endpoints.
4
+ *
5
+ * @title Lambda Name Prefix
6
+ * @pattern ^[A-Za-z0-9-_]*$
7
+ */
8
+ declare type LambdaNamePrefix = string;
9
+ /**
10
+ * The domain name that the service should be deployed to (e.g. mysite.com)
11
+ *
12
+ * @title Domain
13
+ * @pattern ^[^\s]*
14
+ */
15
+ export declare type Domain = string;
16
+ /**
17
+ * The domain name of the Route 53 hosted zone that the domain for this service should be added to.
18
+ *
19
+ * @title Hosted Zone Domain
20
+ * @pattern ^[^\s]*
21
+ */
22
+ export declare type HostedZoneDomain = string;
23
+ export interface SSRDeploymentConfiguration {
24
+ lambdaNamePrefix?: LambdaNamePrefix;
25
+ domain: Domain;
26
+ hostedZoneDomain: HostedZoneDomain;
27
+ lambdas: LambdaRoutesConfig;
28
+ }
29
+ export {};
30
30
  //# sourceMappingURL=SSRDeploymentConfiguration.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=SSRDeploymentConfiguration.js.map
@@ -1,37 +1,37 @@
1
- import type { AWSDeployment } from '@goldstack/infra-aws';
2
- import type { TerraformDeployment } from '@goldstack/utils-terraform';
3
- import type { Deployment, DeploymentConfiguration } from '@goldstack/infra';
4
- import type { SSRDeploymentConfiguration } from './SSRDeploymentConfiguration';
5
- import type { Package, Configuration } from '@goldstack/utils-package';
6
- export interface ThisDeploymentConfiguration extends SSRDeploymentConfiguration, DeploymentConfiguration {
7
- }
8
- export interface ThisDeployment extends Deployment, AWSDeployment, TerraformDeployment {
9
- configuration: ThisDeploymentConfiguration;
10
- }
11
- /**
12
- * Places where the service should be deployed to.
13
- *
14
- * @title Deployments
15
- */
16
- export declare type SSRDeployments = ThisDeployment[];
17
- /**
18
- * Configures this service.
19
- *
20
- * @title Service Configuration
21
- *
22
- */
23
- export declare type ThisPackageConfiguration = Configuration;
24
- /**
25
- * A deployment for a server-side rendering package.
26
- *
27
- * @title Server-side Rendering Package
28
- */
29
- export interface ThisPackage extends Package {
30
- configuration: ThisPackageConfiguration;
31
- deployments: SSRDeployments;
32
- }
33
- export { ThisDeploymentConfiguration as SSRDeploymentConfiguration };
34
- export { ThisDeployment as SSRDeployment };
35
- export { ThisPackageConfiguration as SSRConfiguration };
36
- export { ThisPackage as SSRPackage };
1
+ import type { AWSDeployment } from '@goldstack/infra-aws';
2
+ import type { TerraformDeployment } from '@goldstack/utils-terraform';
3
+ import type { Deployment, DeploymentConfiguration } from '@goldstack/infra';
4
+ import type { SSRDeploymentConfiguration } from './SSRDeploymentConfiguration';
5
+ import type { Package, Configuration } from '@goldstack/utils-package';
6
+ export interface ThisDeploymentConfiguration extends SSRDeploymentConfiguration, DeploymentConfiguration {
7
+ }
8
+ export interface ThisDeployment extends Deployment, AWSDeployment, TerraformDeployment {
9
+ configuration: ThisDeploymentConfiguration;
10
+ }
11
+ /**
12
+ * Places where the service should be deployed to.
13
+ *
14
+ * @title Deployments
15
+ */
16
+ export declare type SSRDeployments = ThisDeployment[];
17
+ /**
18
+ * Configures this service.
19
+ *
20
+ * @title Service Configuration
21
+ *
22
+ */
23
+ export declare type ThisPackageConfiguration = Configuration;
24
+ /**
25
+ * A deployment for a server-side rendering package.
26
+ *
27
+ * @title Server-side Rendering Package
28
+ */
29
+ export interface ThisPackage extends Package {
30
+ configuration: ThisPackageConfiguration;
31
+ deployments: SSRDeployments;
32
+ }
33
+ export { ThisDeploymentConfiguration as SSRDeploymentConfiguration };
34
+ export { ThisDeployment as SSRDeployment };
35
+ export { ThisPackageConfiguration as SSRConfiguration };
36
+ export { ThisPackage as SSRPackage };
37
37
  //# sourceMappingURL=SSRPackage.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=SSRPackage.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goldstack/template-ssr",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Building blocks for implementing server-side rendered pages.",
5
5
  "keywords": [
6
6
  "goldstack",
@@ -39,23 +39,23 @@
39
39
  "version:apply:force": "yarn version $@ && yarn version apply"
40
40
  },
41
41
  "dependencies": {
42
- "@goldstack/infra": "0.4.0",
43
- "@goldstack/infra-aws": "0.4.0",
44
- "@goldstack/template-ssr-server": "0.3.0",
45
- "@goldstack/utils-aws-lambda": "0.3.0",
46
- "@goldstack/utils-esbuild": "0.5.0",
47
- "@goldstack/utils-package": "0.4.0",
48
- "@goldstack/utils-package-config-embedded": "0.5.0",
49
- "@goldstack/utils-template": "0.4.0",
50
- "@goldstack/utils-terraform": "0.4.0",
42
+ "@goldstack/infra": "0.4.1",
43
+ "@goldstack/infra-aws": "0.4.1",
44
+ "@goldstack/template-ssr-server": "0.3.1",
45
+ "@goldstack/utils-aws-lambda": "0.3.1",
46
+ "@goldstack/utils-esbuild": "0.5.1",
47
+ "@goldstack/utils-package": "0.4.1",
48
+ "@goldstack/utils-package-config-embedded": "0.5.1",
49
+ "@goldstack/utils-template": "0.4.1",
50
+ "@goldstack/utils-terraform": "0.4.1",
51
51
  "react": "^18.2.0",
52
52
  "react-dom": "^18.2.0",
53
53
  "source-map-support": "^0.5.21"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@goldstack/utils-docs-cli": "0.3.11",
57
- "@goldstack/utils-git": "0.2.0",
58
- "@goldstack/utils-package-config-generate": "0.3.0",
57
+ "@goldstack/utils-git": "0.2.1",
58
+ "@goldstack/utils-package-config-generate": "0.3.1",
59
59
  "@types/aws-lambda": "^8.10.88",
60
60
  "@types/jest": "^28.1.8",
61
61
  "@types/node": "^18.7.13",