@trustme24/flext 1.10.6 → 2.0.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.
Files changed (50) hide show
  1. package/README.md +17 -17
  2. package/bin/flext.mjs +24 -0
  3. package/dist/dialects/index.d.ts +2 -0
  4. package/dist/dialects/latest.d.ts +6 -0
  5. package/dist/dialects/legacy-1-0-beta4.d.ts +11 -0
  6. package/dist/index.cjs +259 -253
  7. package/dist/index.cjs.map +4 -4
  8. package/dist/index.d.ts +10 -7
  9. package/dist/index.js +29 -29
  10. package/dist/index.js.map +4 -4
  11. package/dist/types.d.ts +3 -74
  12. package/package.json +13 -11
  13. package/src/dialects/index.ts +2 -0
  14. package/src/dialects/latest.ts +8 -0
  15. package/src/dialects/legacy-1-0-beta4.ts +75 -0
  16. package/src/index.ts +82 -16
  17. package/src/tsconfig.json +3 -3
  18. package/src/types.ts +2 -102
  19. package/dist/engine.d.ts +0 -66
  20. package/dist/errors.d.ts +0 -25
  21. package/dist/index.css +0 -2
  22. package/dist/lib/index.d.ts +0 -70
  23. package/dist/modules/array/index.d.ts +0 -5
  24. package/dist/modules/cond/index.d.ts +0 -10
  25. package/dist/modules/date/index.d.ts +0 -16
  26. package/dist/modules/index.d.ts +0 -9
  27. package/dist/modules/match/index.d.ts +0 -5
  28. package/dist/modules/math/index.d.ts +0 -17
  29. package/dist/modules/media/index.d.ts +0 -3
  30. package/dist/modules/number/index.d.ts +0 -8
  31. package/dist/modules/put/index.d.ts +0 -7
  32. package/dist/modules/string/index.d.ts +0 -5
  33. package/src/engine.ts +0 -414
  34. package/src/env.d.ts +0 -4
  35. package/src/errors.ts +0 -51
  36. package/src/index.css +0 -1
  37. package/src/lib/index.ts +0 -931
  38. package/src/lib/unocssShadowDomHack.css +0 -133
  39. package/src/modules/array/index.ts +0 -68
  40. package/src/modules/cond/index.ts +0 -123
  41. package/src/modules/date/index.ts +0 -254
  42. package/src/modules/index.ts +0 -9
  43. package/src/modules/match/index.ts +0 -54
  44. package/src/modules/math/index.ts +0 -198
  45. package/src/modules/media/index.ts +0 -27
  46. package/src/modules/number/index.ts +0 -73
  47. package/src/modules/number/localeNames.json +0 -16
  48. package/src/modules/number/locales/kkKz.json +0 -98
  49. package/src/modules/put/index.ts +0 -61
  50. package/src/modules/string/index.ts +0 -45
package/README.md CHANGED
@@ -12,9 +12,9 @@ In many systems, templates start simple and gradually become fragile: fields app
12
12
 
13
13
  A Flext template can contain Markup, Metadata, Modules, and rendering hints in a single artifact. This makes templates easier to reuse, validate, and embed into larger systems such as document pipelines, reporting services, or contract generation platforms.
14
14
 
15
- - [GitHub: TrustMe-kz/flext](https://github.com/TrustMe-kz/flext)
16
- - [NPM: @trustme24/flext](https://www.npmjs.com/package/@trustme24/flext)
17
- - [Demo: Available at CodeSandbox](https://codesandbox.io/p/devbox/trustme24-flext-f5x2hy)
15
+ - [GitHub: TrustMe-kz/flext](https://github.com/TrustMe-kz/flext)
16
+ - [NPM: @trustme24/flext](https://www.npmjs.com/package/@trustme24/flext)
17
+ - [Demo: Available at CodeSandbox](https://codesandbox.io/p/devbox/trustme24-flext-f5x2hy)
18
18
  - [Documentation: Available at TrustMe Wiki](https://trustmekz.atlassian.net/wiki/external/MTUwYzM5NjUzNDE4NDViMGJlMTliOWEzNzM1Y2RiZWE)
19
19
 
20
20
  ---
@@ -46,17 +46,17 @@ Typical issues include: undocumented fields, incompatible template versions, dup
46
46
  ### A few common scenarios illustrate the problem:
47
47
 
48
48
  1. **A template expects a field that is not provided at runtime. The result is either a broken document or silent incorrect output.**
49
- Solution with Flext: The template can explicitly declare required fields using Metadata so missing data is detected early.
49
+ Solution with Flext: The template can explicitly declare required fields using Metadata so missing data is detected early.
50
50
 
51
51
  ————————————
52
52
 
53
53
  2. **Multiple services use the same template but apply different helper logic or formatting rules.**
54
- Solution with Flext: Templates can declare Module dependencies so rendering logic is predictable and consistent.
54
+ Solution with Flext: Templates can declare Module dependencies so rendering logic is predictable and consistent.
55
55
 
56
56
  ————————————
57
57
 
58
58
  3. **Templates evolve but older documents still rely on previous versions.**
59
- Solution with Flext: Templates can carry explicit Version information and compatibility rules.
59
+ Solution with Flext: Templates can carry explicit Version information and compatibility rules.
60
60
 
61
61
  ---
62
62
 
@@ -74,7 +74,7 @@ This approach helps systems understand what a template requires before rendering
74
74
  import Flext from '@trustme24/flext';
75
75
 
76
76
  const template = `
77
- {{!-- @v "1.0.beta4" --}}
77
+ {{!-- @syntax "1.0" --}}
78
78
  {{!-- @use "put" --}}
79
79
  <p>{{ put name 'Unknown user...' }}</p>
80
80
  `;
@@ -88,7 +88,7 @@ document.body.innerHTML = flext.html;
88
88
 
89
89
  ## Core Ideas
90
90
 
91
- A **Flext** template contains three conceptual layers. The first layer is markup: HTML and standard Handlebars expressions. The second layer is Metadata written as directives such as `@v`, `@field`, or `@use`. The third layer is runtime behavior provided through Modules and helpers.
91
+ A **Flext** template contains three conceptual layers. The first layer is markup: HTML and standard Handlebars expressions. The second layer is Metadata written as directives such as `@syntax`, `@field`, or `@use`. The third layer is runtime behavior provided through Modules and helpers.
92
92
 
93
93
  Keeping these elements close together makes templates easier to move between systems and reduces hidden assumptions.
94
94
 
@@ -100,22 +100,22 @@ Metadata directives can describe template Version, language, title, rendering pa
100
100
  import Flext from '@trustme24/flext';
101
101
 
102
102
  const template = `
103
- {{!-- @v "1.0.beta4" --}}
103
+ {{!-- @syntax "1.0" --}}
104
104
  {{!-- @use "put" --}}
105
105
  {{!-- @group "data" --}}
106
- {{!-- @field "data.someField" type="string" label="Message" required --}}
106
+ {{!-- @field "data.helloWorld" type="string" label="Hello World" required --}}
107
107
 
108
- <p class="text-center text-red-500">
109
- {{ put data.someField 'No hello world...' }}
108
+ <p class="text-center">
109
+ {{ put data.helloWorld 'No hello world...' }}
110
110
  </p>
111
111
  `;
112
112
 
113
113
  const flext = new Flext(template, {
114
- data: { someField: 'Hello World!' },
114
+ data: { helloWorld: 'Hello World!' },
115
115
  });
116
116
 
117
117
  console.log(flext.html); // <p class="...">Hello World!</p>
118
- console.log(flext.model); // {"name":"data","$":[{"name":"someField"}]}
118
+ console.log(flext.model); // {"name":"data","$":[{"name":"helloWorld"}]}
119
119
  ```
120
120
 
121
121
  > 💡 **In this example** the template carries additional information: Version, Field definition, and Module usage. This allows runtime tools to build a Data Model, validate input, and render HTML predictably.
@@ -128,7 +128,7 @@ console.log(flext.model); // {"name":"data","$":[{"name":"someField"}]}
128
128
 
129
129
  **Flext** is intended for structured document generation. Common examples include contracts, invoices, reports, certificates, and internal document workflows. It is particularly useful when templates must be versioned, validated, reused across services, or rendered in multiple environments.
130
130
 
131
- Flext can be used on its own, but it is also designed to serve as a core library inside larger systems. Related tools include [vue-flext](https://www.npmjs.com/package/vue-flext) for Vue integration, [flext2pdf](https://www.npmjs.com/package/flext2pdf) for HTML‑to‑PDF rendering, and some **Flext Convert Service** for running document rendering as a microservice.
131
+ Flext can be used on its own, but it is also designed to serve as a core library inside larger systems. Related tools include [Vue Flext](https://www.npmjs.com/package/vue-flext) for Vue integration, [flext2pdf](https://www.npmjs.com/package/flext2pdf) for HTML‑to‑PDF rendering, [Flext File](https://www.npmjs.com/package/flext-file) for portable document packaging and transfer, and some **Flext Service** for running document rendering as a microservice.
132
132
 
133
133
  Together these components allow Flext to power full document pipelines while remaining a lightweight core library.
134
134
 
@@ -141,7 +141,7 @@ Templates should stay declarative and focused on layout. Business logic is usual
141
141
  ### Example:
142
142
 
143
143
  ```handlebars
144
- {{!-- @v "1.0.beta4" --}}
144
+ {{!-- @syntax "1.0" --}}
145
145
  {{!-- @use "put" "date" --}}
146
146
  {{!-- @group "data" --}
147
147
  {{!-- @field "data.city" type="string" label="City" required --}}
@@ -192,7 +192,7 @@ Directives / Modules
192
192
  PDF / Preview / Data Model / Export
193
193
  ```
194
194
 
195
- At runtime Flext parses the template, extracts Metadata, registers Modules, builds a Data Model, and generates preview. The output can then be passed to other tools to display, store, or generating PDF.
195
+ At runtime Flext parses the template, extracts Metadata, registers Modules, builds a Data Model, and generates preview. The output can then be passed to other tools to display, store, or generating PDF. Flext-based documents can also be packaged as `.flext` artifacts with [Flext File](https://www.npmjs.com/package/flext-file) for portable storage or transfer between systems.
196
196
 
197
197
  - [Repo: More information about the repo can be found in ARCHITECTURE.md](https://github.com/TrustMe-kz/flext/blob/main/ARCHITECTURE.md)
198
198
  - [Documentation: More information about the API is available at TrustMe Wiki](https://trustmekz.atlassian.net/wiki/external/MTUwYzM5NjUzNDE4NDViMGJlMTliOWEzNzM1Y2RiZWE)
package/bin/flext.mjs ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+
3
+ async function flext() {
4
+ const [ command = '' ] = process.argv.slice(2);
5
+
6
+
7
+ // Doing some checks
8
+
9
+ if (command !== 'sync') {
10
+ console.log(`Flext: Unknown command: '${command}'\n\nUsage: flext sync`);
11
+ return;
12
+ }
13
+
14
+
15
+ await import('./sync-dialects.mjs');
16
+ }
17
+
18
+ flext().catch((e) => {
19
+ const message = e instanceof Error ? e.message : String(e);
20
+
21
+ console.error('Flext: Unable to execute: ' + message);
22
+
23
+ process.exit(1);
24
+ });
@@ -0,0 +1,2 @@
1
+ export { default as Latest } from './latest';
2
+ export { default as Legacy_1_0_beta4 } from './legacy-1-0-beta4';
@@ -0,0 +1,6 @@
1
+ import { Dialect } from '@flext/core';
2
+ export declare class LatestDialect extends Dialect {
3
+ name: string;
4
+ aliases: string[];
5
+ }
6
+ export default LatestDialect;
@@ -0,0 +1,11 @@
1
+ import { AST } from '@handlebars/parser';
2
+ import { types, Dialect } from '@flext/core';
3
+ export declare const HANDLEBARS_COMMENT_BEGIN = "{{!--";
4
+ export declare const DIALECT_MACRO = "syntax";
5
+ export declare const LEGACY_DIALECT_MACRO = "v";
6
+ export declare class LegacyDialect extends Dialect {
7
+ name: string;
8
+ testAst(val: AST.Program, doWarn?: boolean | null): boolean;
9
+ templateToStandard(template: types.Template): types.StandardTemplate;
10
+ }
11
+ export default LegacyDialect;