5htp-core 0.6.0-75 → 0.6.0-8

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.6.0-75",
4
+ "version": "0.6.0-8",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -94,7 +94,8 @@ export function Route(options: Omit<TControllerDefinition, 'controller'> = {}) {
94
94
  export default abstract class Service<
95
95
  TConfig extends {},
96
96
  THooks extends THooksList,
97
- TApplication extends Application
97
+ TApplication extends Application,
98
+ TParent extends AnyService | Application = Application
98
99
  > {
99
100
 
100
101
  public started?: Promise<void>;
@@ -104,6 +105,7 @@ export default abstract class Service<
104
105
  public metas!: TServiceMetas;
105
106
  public bindings: string[] = []
106
107
 
108
+ public parent: TParent;
107
109
  public app: TApplication;
108
110
  public config: TConfig = {} as TConfig;
109
111
 
@@ -43,6 +43,7 @@ export type LexicalNode = {
43
43
 
44
44
  type TRenderOptions = {
45
45
 
46
+ format?: 'html' | 'text', // Default = html
46
47
  transform?: RteUtils["transformNode"],
47
48
 
48
49
  render?: (
@@ -91,17 +92,9 @@ export class RteUtils {
91
92
  }
92
93
 
93
94
  // Parse content if string
94
- let json: LexicalState;
95
- if (typeof content === 'string' && content.trim().startsWith('{')) {
96
- try {
97
- json = JSON.parse(content) as LexicalState;
98
- } catch (error) {
99
- throw new Anomaly("Invalid JSON format for the given JSON RTE content.");
100
- }
101
- } else if (content && typeof content === 'object' && content.root)
102
- json = content;
103
- else
104
- return { html: '', json: content, ...assets };
95
+ let json = this.parseState(content);
96
+ if (json === false)
97
+ return { html: '', json: content, ...assets }
105
98
 
106
99
  // Parse prev version if string
107
100
  if (typeof options?.attachements?.prevVersion === 'string') {
@@ -128,11 +121,30 @@ export class RteUtils {
128
121
  }
129
122
 
130
123
  // Convert json to HTML
131
- const html = await this.jsonToHtml( json, options );
124
+ let html: string;
125
+ if (options.format === 'text')
126
+ html = await this.jsonToText( json.root );
127
+ else
128
+ html = await this.jsonToHtml( json, options );
132
129
 
133
130
  return { html, json: content, ...assets };
134
131
  }
135
132
 
133
+ private parseState( content: string | LexicalState ): LexicalState | false {
134
+
135
+ if (typeof content === 'string' && content.trim().startsWith('{')) {
136
+ try {
137
+ return JSON.parse(content) as LexicalState;
138
+ } catch (error) {
139
+ throw new Anomaly("Invalid JSON format for the given JSON RTE content.");
140
+ }
141
+ } else if (content && typeof content === 'object' && content.root)
142
+ return content;
143
+ else
144
+ return false;
145
+
146
+ }
147
+
136
148
  private async processContent(
137
149
  node: LexicalNode,
138
150
  parent: LexicalNode | null,
package/types/icons.d.ts CHANGED
@@ -1 +1 @@
1
- export type TIcones = "long-arrow-right"|"times"|"solid/spinner-third"|"sack-dollar"|"bell"|"bullseye"|"project-diagram"|"user-friends"|"eye"|"lock"|"comments"|"phone"|"chalkboard-teacher"|"rocket"|"chart-bar"|"user-circle"|"arrow-right"|"crosshairs"|"at"|"calendar-alt"|"paper-plane"|"plus-circle"|"comments-alt"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"user-plus"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"key"|"user"|"magnet"|"clock"|"cog"|"trash"|"ellipsis-h"|"plus"|"binoculars"|"brands/linkedin"|"search"|"lightbulb"|"times-circle"|"solid/crown"|"brands/discord"|"pen"|"file"|"envelope"|"angle-up"|"angle-down"|"coins"|"angle-right"|"download"|"check"|"info-circle"|"check-circle"|"exclamation-circle"|"meh-rolling-eyes"|"arrow-left"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"power-off"|"bars"|"plane-departure"|"brands/whatsapp"|"wind"|"users"|"bug"|"question-circle"|"external-link"|"play"|"minus-circle"|"broom"|"exclamation-triangle"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"minus"|"comment-alt"|"arrow-to-bottom"|"map-marker-alt"|"briefcase"|"map-marker"|"fire"|"solid/magic"|"magic"|"globe"|"industry"|"calendar"|"building"|"graduation-cap"|"coin"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"unlink"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
1
+ export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"sack-dollar"|"bell"|"bullseye"|"project-diagram"|"user-friends"|"eye"|"lock"|"comments"|"phone"|"chalkboard-teacher"|"rocket"|"user-circle"|"chart-bar"|"crosshairs"|"plus-circle"|"comments-alt"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"arrow-right"|"at"|"calendar-alt"|"paper-plane"|"search"|"lightbulb"|"magnet"|"brands/linkedin"|"user-plus"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"key"|"user"|"solid/crown"|"brands/discord"|"pen"|"plus"|"file"|"envelope"|"angle-up"|"angle-down"|"clock"|"cog"|"trash"|"ellipsis-h"|"binoculars"|"times-circle"|"coins"|"download"|"angle-right"|"info-circle"|"check-circle"|"exclamation-circle"|"check"|"meh-rolling-eyes"|"arrow-left"|"bars"|"users"|"bug"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"power-off"|"play"|"minus-circle"|"external-link"|"question-circle"|"plane-departure"|"brands/whatsapp"|"wind"|"arrow-to-bottom"|"map-marker-alt"|"exclamation-triangle"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"broom"|"minus"|"comment-alt"|"briefcase"|"map-marker"|"fire"|"solid/magic"|"industry"|"calendar"|"globe"|"magic"|"coin"|"building"|"graduation-cap"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"unlink"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"