5htp-core 0.4.9-7 → 0.4.9-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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.4.9-7",
4
+ "version": "0.4.9-9",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -13,7 +13,6 @@
13
13
  "framework"
14
14
  ],
15
15
  "dependencies": {
16
- "@excalidraw/excalidraw": "^0.17.6",
17
16
  "@lexical/file": "^0.19.0",
18
17
  "@lexical/headless": "^0.18.0",
19
18
  "@lexical/html": "^0.18.0",
@@ -39,12 +39,10 @@ export type TRouterContext<
39
39
  page: ClientPage<TRouter>,
40
40
  data: TObjetDonnees
41
41
  }
42
- &
43
42
  // Expose client application services (api, socket, ...)
44
43
  //TRouter["app"]
45
- TApplication
46
- &
47
- ReturnType<TRouter["config"]["context"]>
44
+ & TApplication
45
+ & ReturnType<TRouter["config"]["context"]>
48
46
  )
49
47
 
50
48
  /*----------------------------------
@@ -72,7 +72,9 @@ export type TClientOrServerContext = (
72
72
  // So here, we put the
73
73
  //{[clientContextKey in keyof ClientRouterContext/*Omit<ClientRouterContext, TClientOnlyContextKeys>*/]: undefined}
74
74
  //&
75
- ServerRouterContext
75
+
76
+ // Page is always available in client context
77
+ With<ServerRouterContext, 'page'>
76
78
  )
77
79
  )
78
80
 
@@ -4,11 +4,11 @@
4
4
 
5
5
  // Npm
6
6
  import type { VNode } from 'preact';
7
+ import type { Thing } from 'schema-dts';
7
8
 
8
9
  // Core libs
9
10
  import { ClientOrServerRouter, TClientOrServerContext, TRoute, TErrorRoute } from '@common/router';
10
11
  import { TFetcherList, TDataReturnedByFetchers } from '@common/router/request/api';
11
- import { history } from '@client/services/router/request/history';
12
12
 
13
13
  /*----------------------------------
14
14
  - TYPES
@@ -50,7 +50,9 @@ export type TPageResource = {
50
50
  } | {
51
51
  url: string,
52
52
  preload?: boolean
53
- })
53
+ })
54
+
55
+ type TMetasList = ({ $: string } & { [key: string]: string })[]
54
56
 
55
57
  const debug = false;
56
58
 
@@ -68,6 +70,9 @@ export default abstract class PageResponse<TRouter extends ClientOrServerRouter
68
70
  public url: string;
69
71
 
70
72
  // Resources
73
+ public head: TMetasList = [];
74
+ public metas: { [name: string]: string } = {};
75
+ public jsonld: Thing[] = [];
71
76
  public scripts: TPageResource[] = [];
72
77
  public style: TPageResource[] = [];
73
78
 
@@ -58,7 +58,9 @@ type AppIdentityConfig = {
58
58
  titleSuffix: string,
59
59
  fullTitle: string,
60
60
  description: string,
61
- version: string
61
+ version: string,
62
+ metas?: {[name: string]: string},
63
+ jsonld?: {[name: string]: string},
62
64
  }
63
65
  }
64
66
 
@@ -87,7 +87,7 @@ export default class ServerRequest<
87
87
  this.router = router;
88
88
  this.api = new ApiClient(this);
89
89
 
90
- this.url = this.req.url;
90
+ this.url = this.req.protocol + '://' + this.req.get('host') + this.req.originalUrl;
91
91
  this.host = this.req.get('host') as string;
92
92
  this.method = method;
93
93
  this.headers = headers || {};
@@ -5,7 +5,6 @@
5
5
  // Npm
6
6
  import React from 'react';
7
7
  import renderToString from "preact-render-to-string";
8
- import type { Thing } from 'schema-dts';
9
8
 
10
9
  // Core
11
10
  import { default as Router, TRouterContext } from "@server/services/router";
@@ -27,18 +26,12 @@ const seoLimits = {
27
26
  description: 255
28
27
  }
29
28
 
30
- type TMetasList = ({ $: string } & { [key: string]: string })[]
31
-
32
29
  /*----------------------------------
33
30
  - FONCTION
34
31
  ----------------------------------*/
35
32
 
36
33
  export default class Page<TRouter extends Router = Router> extends PageResponse<TRouter> {
37
34
 
38
- public head: TMetasList = [];
39
- public metas: {[name: string]: string} = {};
40
- public jsonld: Thing[] = [];
41
-
42
35
  public constructor(
43
36
  public route: TRoute | TErrorRoute,
44
37
  public renderer: TFrontRenderer,
@@ -132,17 +125,18 @@ export default class Page<TRouter extends Router = Router> extends PageResponse<
132
125
  'og:type': 'website',
133
126
  'og:locale': this.app.identity.locale,
134
127
  'og:site_name': this.app.identity.web.title,
135
- 'og:url': this.context.request.req.url,
128
+ 'og:url': this.url,
136
129
 
137
130
  'og:title': this.title,
138
131
  'og:description': this.description,
139
132
 
140
- 'twitter:url': this.context.request.req.url,
133
+ 'twitter:url': this.url,
141
134
  'twitter:card': 'summary_large_image',
142
135
  'twitter:title': this.title,
143
- 'twitter:text:title': this.title,
144
136
  'twitter:description': this.description,
145
137
 
138
+ ...(this.app.identity.web.metas || {}),
139
+
146
140
  ...this.metas
147
141
  };
148
142
 
@@ -162,10 +156,10 @@ export default class Page<TRouter extends Router = Router> extends PageResponse<
162
156
  logo: {
163
157
  '@type': 'ImageObject',
164
158
  '@id': this.router.url('/#logo'),
165
- url: this.router.url('/public/app/android-chrome-512x512.png'),
166
- width: "512px",
167
- height: "512px",
168
- caption: this.app.identity.author.name
159
+ url: this.router.url('/public/brand/1024.png'),
160
+ width: "1024px",
161
+ height: "1024px",
162
+ caption: this.app.identity.name
169
163
  },
170
164
  sameAs: []
171
165
  }, {
@@ -178,7 +172,9 @@ export default class Page<TRouter extends Router = Router> extends PageResponse<
178
172
  "@id": this.router.url('/#organization'),
179
173
  },
180
174
  inLanguage: this.app.identity.locale,
181
- potentialAction: [],
175
+ potentialAction: [],
176
+
177
+ ...(this.app.identity.web.jsonld || {}),
182
178
  }, {
183
179
  '@type': "WebPage",
184
180
  '@id': this.url,