@formfeed/engine 0.3.16 → 0.3.18
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 +34 -15
- package/index.cjs +657 -15
- package/index.js +657 -15
- package/package.json +1 -1
- package/types/frame/paged-print.d.cts +66 -0
- package/types/frame/paged-print.d.ts +66 -0
- package/types/frame/paged-print.entry.d.cts +1 -0
- package/types/frame/paged-print.entry.d.ts +1 -0
- package/types/index.d.cts +2 -2
- package/types/index.d.ts +2 -2
- package/types/lib/assemble.d.cts +7 -1
- package/types/lib/assemble.d.ts +7 -1
- package/types/lib/einvoice/check.d.cts +1 -1
- package/types/lib/einvoice/check.d.ts +1 -1
- package/types/lib/einvoice/coverage.d.cts +28 -0
- package/types/lib/einvoice/coverage.d.ts +28 -0
- package/types/lib/einvoice/index.d.cts +1 -0
- package/types/lib/einvoice/index.d.ts +1 -0
- package/types/lib/einvoice/report.d.cts +14 -0
- package/types/lib/einvoice/report.d.ts +14 -0
- package/types/lib/generated/frames.d.cts +2 -0
- package/types/lib/generated/frames.d.ts +2 -0
package/README.md
CHANGED
|
@@ -14,19 +14,38 @@ npm install @formfeed/engine
|
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
getEngine,
|
|
19
|
+
defaultHelpers,
|
|
20
|
+
defaultLimits,
|
|
21
|
+
assembleDocument,
|
|
22
|
+
} from '@formfeed/engine';
|
|
18
23
|
|
|
19
24
|
const engine = getEngine('liquid');
|
|
20
25
|
const compiled = engine.compile('<h1>{{ title | upper }}</h1>', {});
|
|
21
26
|
const analysis = engine.analyze('<h1>{{ title | upper }}</h1>');
|
|
22
27
|
// analysis.variables → [{ path: ['title'], ... }], analysis.diagnostics → []
|
|
23
28
|
|
|
24
|
-
const html = await engine.render(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
const html = await engine.render(
|
|
30
|
+
compiled,
|
|
31
|
+
{ title: 'Hello' },
|
|
32
|
+
{
|
|
33
|
+
locale: 'de-DE',
|
|
34
|
+
timezone: 'Europe/Berlin',
|
|
35
|
+
currency: 'EUR',
|
|
36
|
+
partials: () => undefined,
|
|
37
|
+
helpers: defaultHelpers(),
|
|
38
|
+
limits: defaultLimits,
|
|
39
|
+
},
|
|
40
|
+
);
|
|
28
41
|
|
|
29
|
-
const document = assembleDocument({
|
|
42
|
+
const document = assembleDocument({
|
|
43
|
+
html,
|
|
44
|
+
css: '',
|
|
45
|
+
head: '',
|
|
46
|
+
settings: { paper: { format: 'A4' } },
|
|
47
|
+
kind: 'pdf',
|
|
48
|
+
});
|
|
30
49
|
```
|
|
31
50
|
|
|
32
51
|
The supported surface is the `Engine` interface (`compile`, `analyze`, `render`) returned by
|
|
@@ -35,15 +54,15 @@ The supported surface is the `Engine` interface (`compile`, `analyze`, `render`)
|
|
|
35
54
|
|
|
36
55
|
## What is inside
|
|
37
56
|
|
|
38
|
-
| Module
|
|
39
|
-
|
|
40
|
-
| `engines/`
|
|
41
|
-
| `helpers/`
|
|
42
|
-
| `analysis/`
|
|
43
|
-
| `schema.ts`
|
|
44
|
-
| `assemble.ts` | Template settings, print reset, `assembleDocument()` and `renderVersion()` (body, header, footer, title)
|
|
45
|
-
| `import/`
|
|
46
|
-
| `office/`
|
|
57
|
+
| Module | Contents |
|
|
58
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
59
|
+
| `engines/` | `jinja2` (Nunjucks with a Python compatibility layer), `liquid` (LiquidJS), `handlebars`, each implementing `Engine` |
|
|
60
|
+
| `helpers/` | One helper registry for all three dialects: formatting (`money`, `date`, `number`, `numToWords`, `t`), text, collections, codes (`qrcode`, `barcode`, `epcQr`), document (`asset`, `pageBreak`, `image`, `chart`) |
|
|
61
|
+
| `analysis/` | Block pairing and sample-data checks behind every `analyze()` |
|
|
62
|
+
| `schema.ts` | `inferSchema(sample)` to JSON Schema 2020-12 |
|
|
63
|
+
| `assemble.ts` | Template settings, print reset, `assembleDocument()` and `renderVersion()` (body, header, footer, title) |
|
|
64
|
+
| `import/` | `importApitemplate()` and `importApitemplateFromApi()`, `importPdfmonkey()` and `importJsreport()`: convert templates of apitemplate.io, PDFMonkey and jsreport into Formfeed drafts |
|
|
65
|
+
| `office/` | Word and PowerPoint templates: `renderOffice()` fills a `.docx` or `.pptx` file, `analyzeOffice()` lists its tags, variables and findings per part and paragraph, `OfficeTemplateError` carries the findings of a document that cannot be filled, and `starterDocument()` and `starterPresentation()` return example files with their sample data |
|
|
47
66
|
|
|
48
67
|
## Documentation
|
|
49
68
|
|