@lpdfio/lpdf 0.21.0 → 0.23.0

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/LICENSE CHANGED
@@ -14,7 +14,7 @@ Lpdf is available under three license tiers: a free Community License for indivi
14
14
 
15
15
  "Production environment" means any environment in which the Software processes real user data or supports live business operations, including staging environments accessible by end users.
16
16
 
17
- "Production System" means a distinct, independently operated system, application, or automated workflow that uses the Software in a production environment, where "independently operated" means it serves a separate and identifiable purpose, user base, or business function. For the avoidance of doubt: multiple delivery channels (web, mobile, desktop, API) of the same system serving the same purpose and user base constitute a single Production System; all internal business operations of an organization where the organization's own personnel are the sole end users constitute a single Production System regardless of the number of internal systems or services involved; a service or component that operates exclusively as part of a larger system and has no independent production deployment is not a separate Production System.
17
+ "Production System" means a distinct, independently operated system, application, or automated workflow that uses the Software in a production environment, where "independently operated" means it serves a separate and identifiable purpose, user base, or business function. For the avoidance of doubt: multiple delivery channels (web, mobile, desktop, API) of the same system serving the same purpose and user base constitute a single Production System; all internal business operations of an organization where the organization's own personnel are the sole end users constitute a single Production System regardless of the number of internal systems or services involved; a service or component that operates exclusively as part of a larger system and has no independent production deployment is not a separate Production System; and a shared internal service or gateway that provides functionality to multiple otherwise-independent Production Systems does not itself constitute a single Production System encompassing them — each Production System it serves is counted and licensed individually.
18
18
 
19
19
  ### Equal Features Across All Tiers
20
20
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # @lpdfio/lpdf
4
4
 
5
- **Node.js SDK for [Lpdf](https://lpdf.io) — PDF as Code on every platform**
5
+ **Node.js SDK for [Lpdf](https://lpdf.io?utm_campaign=sdk-node&utm_medium=referral&utm_source=readme) — PDF as Code on every platform**
6
6
 
7
7
  You describe a document as code or XML. Lpdf renders a compact, pixel-perfect PDF — identical across platforms.
8
8
 
@@ -14,8 +14,8 @@ npm install @lpdfio/lpdf
14
14
 
15
15
  ## Usage — Node.js
16
16
 
17
- ```ts
18
- import { L, NoAttr } from 'lpdf'
17
+ ```js
18
+ const { L, NoAttr } = require('@lpdfio/lpdf')
19
19
 
20
20
  const engine = L.engine()
21
21
 
@@ -38,23 +38,17 @@ const doc = L.document({ size: 'letter', margin: '48pt' }, [
38
38
  ]),
39
39
  ])
40
40
 
41
- const pdf = await engine.render(doc)
41
+ engine.render(doc).then((pdf) => require('node:fs').writeFileSync('proposal.pdf', pdf))
42
42
  ```
43
43
 
44
44
  ## Requirements
45
45
 
46
- - Node.js 16+
46
+ - Node.js 20+
47
47
  - No external runtime dependencies — the WASM engine is embedded in the package.
48
48
 
49
- ## Versioning
50
-
51
- The first two numbers are the Lpdf engine, and the last number counts changes to this package only. `0.22.3` runs engine `0.22`, with three JS-only changes since that engine shipped. Every engine release publishes all SDKs at `X.Y.0`, so the same `X.Y` means the same engine in every language.
52
-
53
- To stay on one engine and still get this package's fixes, use a tilde range in `package.json`: `"@lpdfio/lpdf": "~0.22.0"`.
54
-
55
49
  ## Docs
56
50
 
57
- [lpdf.io/docs/js](https://lpdf.io/docs/js)
51
+ [lpdf.io/docs](https://lpdf.io/docs/install/?sdk=js&utm_campaign=sdk-node&utm_medium=referral&utm_source=readme)
58
52
 
59
53
  ## Issues
60
54
 
package/dist/L.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { LpdfTokens, PdfDocument } from './kit';
1
+ import type { DocumentAssets, DocumentTokens, PdfDocument } from './kit';
2
2
  import { PdfEngine } from './engine';
3
3
  /** Pass as `attrs` when a node has no attributes. Equivalent to `null`. */
4
4
  export declare const NoAttr: null;
@@ -11,7 +11,7 @@ export declare const NoAttr: null;
11
11
  *
12
12
  * @example
13
13
  * ```ts
14
- * import { L, NoAttr } from 'lpdf';
14
+ * const { L, NoAttr } = require('@lpdfio/lpdf');
15
15
  *
16
16
  * const engine = L.engine().setLicenseKey(process.env.LPDF_KEY);
17
17
  *
@@ -29,35 +29,36 @@ export declare const L: Readonly<{
29
29
  engine: () => PdfEngine;
30
30
  /** Convert a `PdfDocument` tree to an lpdf XML string. */
31
31
  toXml: (doc: PdfDocument) => string;
32
- document: (attrs: import("./kit").DocumentAttr | null, nodes: import("./kit").LpdfSectionNode[]) => PdfDocument;
33
- section: (attrs: import("./kit").SectionAttr | null, nodes: (import("./kit").LpdfLayoutBlock | import("./kit").LpdfCanvasBlock)[]) => import("./kit").LpdfSectionNode;
34
- layout: (_attrs: null, nodes: import("./layout").LpdfNode[]) => import("./kit").LpdfLayoutBlock;
35
- canvas: (_attrs: null, layers: import("./canvas").LpdfCanvasLayerNode[]) => import("./kit").LpdfCanvasBlock;
36
- tokens: (attrs: LpdfTokens) => LpdfTokens;
37
- stack: (attrs: import("./layout").StackAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
38
- flank: (attrs: import("./layout").FlankAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
39
- split: (attrs: import("./layout").SplitAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
40
- cluster: (attrs: import("./layout").ClusterAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
41
- grid: (attrs: import("./layout").GridAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
42
- frame: (attrs: import("./layout").FrameAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
43
- link: (attrs: import("./layout").LinkAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
44
- table: (attrs: import("./layout").TableAttr, nodes: (import("./layout").LpdfTheadNode | import("./layout").LpdfTrNode)[]) => import("./layout").LpdfTableNode;
45
- thead: (attrs: import("./layout").TheadAttr | null, nodes: import("./layout").LpdfTdNode[]) => import("./layout").LpdfTheadNode;
46
- tr: (attrs: import("./layout").TrAttr | null, nodes: import("./layout").LpdfTdNode[]) => import("./layout").LpdfTrNode;
47
- td: (attrs: import("./layout").TdAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfTdNode;
48
- text: (attrs: import("./layout").TextAttr | null, nodes: (string | import("./layout").LpdfSpanNode)[]) => import("./layout").LpdfTextNode;
49
- span: (attrs: import("./layout").SpanAttr | null, nodes: string[]) => import("./layout").LpdfSpanNode;
50
- divider: (attrs: import("./layout").DividerAttr | null) => import("./layout").LpdfDividerNode;
51
- img: (attrs: import("./layout").ImgAttr) => import("./layout").LpdfImgNode;
52
- barcode: (attrs: import("./layout").BarcodeAttr) => import("./layout").LpdfBarcodeNode;
53
- region: (attrs: import("./layout").RegionAttr, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfRegionNode;
54
- field: (type: string, name: string, attrs?: import("./layout").FieldAttr | null) => import("./layout").LpdfFieldNode;
55
- layer: (attrs: import("./canvas").LayerAttr | null, nodes: import("./canvas").LpdfCanvasPrimitiveNode[]) => import("./canvas").LpdfCanvasLayerNode;
56
- rect: (x: number, y: number, w: number, h: number, style?: import("./canvas").CanvasRectStyle) => import("./canvas").LpdfCanvasRectNode;
57
- line: (x1: number, y1: number, x2: number, y2: number, style?: import("./canvas").CanvasLineStyle) => import("./canvas").LpdfCanvasLineNode;
58
- ellipse: (cx: number, cy: number, rx: number, ry: number, style?: import("./canvas").CanvasEllipseStyle) => import("./canvas").LpdfCanvasEllipseNode;
59
- circle: (cx: number, cy: number, r: number, style?: import("./canvas").CanvasEllipseStyle) => import("./canvas").LpdfCanvasCircleNode;
60
- path: (d: string, style?: import("./canvas").CanvasPathStyle) => import("./canvas").LpdfCanvasPathNode;
61
- textAt: (x: number, y: number, content: string, style?: import("./canvas").CanvasTextStyle, runs?: import("./canvas").CanvasRun[]) => import("./canvas").LpdfCanvasTextNode;
62
- imgAt: (x: number, y: number, w: number, h: number, name: string, anchor?: string) => import("./canvas").LpdfCanvasImgNode;
32
+ document: (attrs: import("./kit").DocumentAttr | null, nodes?: import("./kit").LpdfSectionNode[]) => PdfDocument;
33
+ section: (attrs: import("./kit").SectionAttr | null, nodes?: (import("./kit").LpdfLayoutBlock | import("./kit").LpdfCanvasBlock)[]) => import("./kit").LpdfSectionNode;
34
+ layout: (_attrs: null, nodes?: import("./layout").LpdfNode[]) => import("./kit").LpdfLayoutBlock;
35
+ canvas: (_attrs: null, layers?: import("./canvas").LpdfCanvasLayerNode[]) => import("./kit").LpdfCanvasBlock;
36
+ assets: (attrs: DocumentAssets) => DocumentAssets;
37
+ tokens: (attrs: DocumentTokens) => DocumentTokens;
38
+ stack: (attrs: import("./attrs").StackAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
39
+ flank: (attrs: import("./attrs").FlankAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
40
+ split: (attrs: import("./attrs").SplitAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
41
+ cluster: (attrs: import("./attrs").ClusterAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
42
+ grid: (attrs: import("./attrs").GridAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
43
+ frame: (attrs: import("./attrs").FrameAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
44
+ link: (attrs: import("./attrs").LinkAttr, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
45
+ table: (attrs: import("./attrs").TableAttr, nodes?: (import("./layout").LpdfTheadNode | import("./layout").LpdfTrNode)[]) => import("./layout").LpdfTableNode;
46
+ thead: (attrs: import("./attrs").TheadAttr | null, nodes?: import("./layout").LpdfTdNode[]) => import("./layout").LpdfTheadNode;
47
+ tr: (attrs: import("./attrs").TrAttr | null, nodes?: import("./layout").LpdfTdNode[]) => import("./layout").LpdfTrNode;
48
+ td: (attrs: import("./attrs").TdAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfTdNode;
49
+ text: (attrs: import("./attrs").TextAttr | null, nodes?: (string | import("./layout").LpdfSpanNode)[]) => import("./layout").LpdfTextNode;
50
+ span: (attrs: import("./attrs").SpanAttr | null, nodes?: string[]) => import("./layout").LpdfSpanNode;
51
+ divider: (attrs?: import("./attrs").DividerAttr | null) => import("./layout").LpdfDividerNode;
52
+ img: (attrs: import("./attrs").ImgAttr) => import("./layout").LpdfImgNode;
53
+ barcode: (attrs: import("./attrs").BarcodeAttr) => import("./layout").LpdfBarcodeNode;
54
+ region: (attrs: import("./attrs").RegionAttr, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfRegionNode;
55
+ field: (attrs: import("./attrs").FieldAttr) => import("./layout").LpdfFieldNode;
56
+ layer: (attrs: import("./attrs").LayerAttr | null, nodes?: import("./canvas").LpdfCanvasPrimitiveNode[]) => import("./canvas").LpdfCanvasLayerNode;
57
+ rect: (attrs: import("./attrs").RectAttr) => import("./canvas").LpdfCanvasRectNode;
58
+ line: (attrs: import("./attrs").LineAttr) => import("./canvas").LpdfCanvasLineNode;
59
+ ellipse: (attrs: import("./attrs").EllipseAttr) => import("./canvas").LpdfCanvasEllipseNode;
60
+ circle: (attrs: import("./attrs").CircleAttr) => import("./canvas").LpdfCanvasCircleNode;
61
+ path: (attrs: import("./attrs").PathAttr) => import("./canvas").LpdfCanvasPathNode;
62
+ textAt: (attrs: import("./attrs").CanvasTextAttr, nodes?: (string | import("./layout").LpdfSpanNode)[]) => import("./canvas").LpdfCanvasTextNode;
63
+ imgAt: (attrs: import("./attrs").CanvasImgAttr) => import("./canvas").LpdfCanvasImgNode;
63
64
  }>;
package/dist/L.js CHANGED
@@ -17,7 +17,7 @@ exports.NoAttr = null;
17
17
  *
18
18
  * @example
19
19
  * ```ts
20
- * import { L, NoAttr } from 'lpdf';
20
+ * const { L, NoAttr } = require('@lpdfio/lpdf');
21
21
  *
22
22
  * const engine = L.engine().setLicenseKey(process.env.LPDF_KEY);
23
23
  *
@@ -40,6 +40,7 @@ exports.L = Object.freeze({
40
40
  section: kit_1.LpdfKit.section,
41
41
  layout: kit_1.LpdfKit.layout,
42
42
  canvas: kit_1.LpdfKit.canvas,
43
+ assets: (attrs) => attrs,
43
44
  tokens: (attrs) => attrs,
44
45
  // ── Layout ────────────────────────────────────────────────────────────────
45
46
  stack: layout_1.LpdfLayout.stack,
package/dist/_shared.d.ts CHANGED
@@ -19,7 +19,8 @@ export interface RenderOptions {
19
19
  data?: Record<string, unknown> | null;
20
20
  }
21
21
  /**
22
- * Page scope for canvas layers and layout regions.
23
- * Numeric ranges (e.g. '2-4', '1,3-5', '2-last') remain as plain strings.
22
+ * The attributes of an element: an attribute object's own properties, with each camelCase name
23
+ * written as the schema's kebab-case one (`fontSize` as `font-size`) and each value as a string.
24
+ * Properties that are `undefined` are left out.
24
25
  */
25
- export type PageScope = 'each' | 'first' | 'last' | 'odd' | 'even';
26
+ export declare function buildAttrs(options: object | null | undefined): Record<string, string>;
package/dist/_shared.js CHANGED
@@ -3,3 +3,18 @@
3
3
  * Shared types used by both the Node.js and browser entry points.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildAttrs = buildAttrs;
7
+ /**
8
+ * The attributes of an element: an attribute object's own properties, with each camelCase name
9
+ * written as the schema's kebab-case one (`fontSize` as `font-size`) and each value as a string.
10
+ * Properties that are `undefined` are left out.
11
+ */
12
+ function buildAttrs(options) {
13
+ const result = {};
14
+ for (const [key, value] of Object.entries(options ?? {})) {
15
+ if (value !== undefined && value !== null) {
16
+ result[key.replace(/[A-Z]/g, c => '-' + c.toLowerCase())] = String(value);
17
+ }
18
+ }
19
+ return result;
20
+ }