xpict 0.3.2 → 0.3.4

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/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { GroupLayer, RepeatLayer, GroupLayerOptions, ImageLayer, ImageLayerOptions, LineLayer, LineLayerOptions, RectangleLayer, RectangleLayerOptions, RepeatLayerOptions, TextLayer, TextLayerOptions, CircleLayerOptions, CircleLayer } from "./layers";
2
2
  import { negativeEffect, blurEffect, grayscaleEffect } from "./effects";
3
3
  import { Template, InputTemplateOptions } from "./template";
4
- import { wrapText, fontConfig } from "./utils";
5
4
  export * from "./layers";
6
5
  export * from "./effects";
7
6
  export * from "./template";
@@ -20,9 +19,5 @@ declare const xpict: {
20
19
  blur: typeof blurEffect;
21
20
  grayscale: typeof grayscaleEffect;
22
21
  };
23
- utils: {
24
- fontConfig: typeof fontConfig;
25
- wrapText: typeof wrapText;
26
- };
27
22
  };
28
23
  export default xpict;
package/dist/index.js CHANGED
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const layers_1 = require("./layers");
18
18
  const effects_1 = require("./effects");
19
19
  const template_1 = require("./template");
20
- const utils_1 = require("./utils");
21
20
  __exportStar(require("./layers"), exports);
22
21
  __exportStar(require("./effects"), exports);
23
22
  __exportStar(require("./template"), exports);
@@ -52,9 +51,5 @@ const xpict = {
52
51
  blur: effects_1.blurEffect,
53
52
  grayscale: effects_1.grayscaleEffect,
54
53
  },
55
- utils: {
56
- fontConfig: utils_1.fontConfig,
57
- wrapText: utils_1.wrapText,
58
- },
59
54
  };
60
55
  exports.default = xpict;
@@ -5,9 +5,14 @@ export type EachOptions<Data> = {
5
5
  index: number;
6
6
  };
7
7
  export type EachFunction<Data, Item> = (options: EachOptions<Data>) => Item[];
8
+ export type LayerFunctionOptions = {
9
+ index: number;
10
+ length: number;
11
+ };
12
+ export type LayerFunction<Data, Item> = (item: Item, options: LayerFunctionOptions) => Layer<Data>;
8
13
  export type RepeatLayerOptions<Data, Item> = {
9
14
  each: EachFunction<Data, Item>;
10
- layer: (item: Item, index: number) => Layer<Data>;
15
+ layer: LayerFunction<Data, Item>;
11
16
  when?: WhenFunction<Data>;
12
17
  x: Axis<Data>;
13
18
  y: Axis<Data>;
@@ -31,7 +31,7 @@ class RepeatLayer extends layer_1.Layer {
31
31
  const prevY = ctx.offsetY;
32
32
  ctx.offsetX += dx;
33
33
  ctx.offsetY += dy;
34
- const layer = this.options.layer(item, index);
34
+ const layer = this.options.layer(item, { index: index, length: items.length });
35
35
  await layer.render({
36
36
  context: ctx,
37
37
  data: data,
@@ -1 +1 @@
1
- export declare function wrapText(text: string, maxWidth: number): string;
1
+ export declare function wrapText(text: string, maxWidth: number): string[];
@@ -16,5 +16,5 @@ function wrapText(text, maxWidth) {
16
16
  }
17
17
  }
18
18
  lines.push(line);
19
- return lines.join("\n");
19
+ return lines;
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xpict",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Xpict é uma biblioteca para a geração de imagens padronizadas a partir de modelos declarativos.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",