km-card-layout-core 0.1.14 → 0.1.16

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/utils.js CHANGED
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.buildRenderData = exports.DEFAULT_DECOR_COLOR = exports.resolveSpecialStyle = exports.updateElementsStyle = exports.applyBackground = exports.applySpecialStyle = exports.backgroundChange = void 0;
17
+ exports.DEFAULT_DECOR_COLOR = exports.resolveSpecialStyle = exports.updateElementsStyle = exports.applyBackground = exports.applySpecialStyle = exports.backgroundChange = void 0;
18
+ exports.buildRenderData = buildRenderData;
18
19
  const km_card_layout_core_1 = require("km-card-layout-core");
19
20
  const changeBackground_1 = require("./ops/changeBackground");
20
21
  __exportStar(require("./bindings"), exports);
@@ -25,7 +26,7 @@ Object.defineProperty(exports, "applyBackground", { enumerable: true, get: funct
25
26
  Object.defineProperty(exports, "updateElementsStyle", { enumerable: true, get: function () { return changeBackground_2.updateElementsStyle; } });
26
27
  Object.defineProperty(exports, "resolveSpecialStyle", { enumerable: true, get: function () { return changeBackground_2.resolveSpecialStyle; } });
27
28
  Object.defineProperty(exports, "DEFAULT_DECOR_COLOR", { enumerable: true, get: function () { return changeBackground_2.DEFAULT_DECOR_COLOR; } });
28
- const buildRenderData = (layout, items, dataInput, config) => {
29
+ function buildRenderData(layout, items, config) {
29
30
  // 绑定数据
30
31
  let renderLayout = (0, km_card_layout_core_1.applyItemCollectBindings)(layout, items);
31
32
  // 设置显示逻辑
@@ -34,5 +35,4 @@ const buildRenderData = (layout, items, dataInput, config) => {
34
35
  // 设置背景
35
36
  renderLayout = renderLayout.map((la, index) => (0, km_card_layout_core_1.backgroundChange)(config.currentBg[index], la));
36
37
  return renderLayout;
37
- };
38
- exports.buildRenderData = buildRenderData;
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "km-card-layout-core",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Shared render helpers for CardMaster layout JSON (binding resolution, layout normalization).",
5
5
  "main": "dist/index.js",
6
6
  "types": "types.d.ts",
package/types.d.ts CHANGED
@@ -12,8 +12,18 @@ import type {
12
12
  CardLayoutSchema,
13
13
  RenderNode,
14
14
  RenderResult,
15
+ TemplateItem
15
16
  } from './interface';
16
17
 
18
+ export type Config = {
19
+ showAvatar: boolean;
20
+ showLogo: boolean;
21
+ /**
22
+ * 当前背景 (0 为正面背景 1 为背面背景)
23
+ */
24
+ currentBg: TemplateBackground[];
25
+ };
26
+
17
27
  export function addUnit(
18
28
  value: string | number | undefined | null,
19
29
  unit: 'px' | 'rpx'
@@ -149,3 +159,10 @@ export function buildRenderResult(
149
159
  data: Record<string, any>,
150
160
  unit?: 'px' | 'rpx'
151
161
  ): RenderResult;
162
+
163
+
164
+ export function buildRenderData (
165
+ layout: CardLayoutSchema[],
166
+ items: TemplateItem[],
167
+ config: Config
168
+ ): CardLayoutSchema[];
package/utils.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  TemplateItem,
7
7
  } from 'km-card-layout-core';
8
8
  import { setElementVisible } from './ops/changeBackground';
9
+ import { Config } from './types';
9
10
 
10
11
  export * from './bindings';
11
12
  export {
@@ -17,28 +18,20 @@ export {
17
18
  DEFAULT_DECOR_COLOR,
18
19
  } from './ops/changeBackground';
19
20
 
20
- export type Config = {
21
- showAvatar: boolean;
22
- showLogo: boolean;
23
- /**
24
- * 当前背景 (0 为正面背景 1 为背面背景)
25
- */
26
- currentBg: TemplateBackground[];
27
- };
28
21
 
29
-
30
- export const buildRenderData = (
22
+ export function buildRenderData(
31
23
  layout: CardLayoutSchema[],
32
24
  items: TemplateItem[],
33
- dataInput: Record<string, any>,
34
25
  config: Config
35
- ): CardLayoutSchema[] => {
26
+ ): CardLayoutSchema[] {
36
27
  // 绑定数据
37
28
  let renderLayout = applyItemCollectBindings(layout, items);
38
29
  // 设置显示逻辑
39
30
  renderLayout = setElementVisible(renderLayout, 'avatar', config.showAvatar);
40
31
  renderLayout = setElementVisible(renderLayout, 'logo', config.showLogo);
41
32
  // 设置背景
42
- renderLayout = renderLayout.map((la,index) => backgroundChange(config.currentBg[index], la));
33
+ renderLayout = renderLayout.map((la, index) =>
34
+ backgroundChange(config.currentBg[index], la)
35
+ );
43
36
  return renderLayout;
44
- };
37
+ }