import{ax as s,z as a,A as l,b2 as t}from"./chunks/framework.DkLJC2NO.js";const c=JSON.parse('{"title":"工具函数","description":"","frontmatter":{},"headers":[],"relativePath":"runtime-api/data-source/utils.md","filePath":"runtime-api/data-source/utils.md"}'),e={name:"runtime-api/data-source/utils.md"};function n(p,i,h,o,d,r){return l(),a("div",null,[...i[0]||(i[0]=[t(`

工具函数

@tmagic/data-source 导出的工具函数。

createDataSourceManager

typescript
import { createDataSourceManager } from '@tmagic/data-source';

const dsManager = createDataSourceManager(app, false, initialData);

compiledCondition

typescript
import { compiledCondition } from '@tmagic/data-source';

const result = compiledCondition(
  { field: 'user.age', op: '>', value: 18 },
  { user: { age: 20 } }
);
console.log(result); // true

compliedConditions

compiledNodeField

typescript
import { compiledNodeField } from '@tmagic/data-source';

const compiled = compiledNodeField(
  { isBindDataSource: true, dataSourceId: 'ds_1', template: '\${name}' },
  { ds_1: { name: 'test' } }
);

compliedDataSourceField

template

typescript
import { template } from '@tmagic/data-source';

const result = template(
  '用户名:\${ds_1.user.name},年龄:\${ds_1.user.age}',
  { ds_1: { user: { name: '张三', age: 20 } } }
);
console.log(result); // '用户名:张三,年龄:20'

createIteratorContentData

compliedIteratorItem

updateNode

typescript
import { updateNode } from '@tmagic/data-source';

const newDsl = updateNode(
  { id: 'button_1', type: 'button', text: '新文本' },
  dsl
);

registerDataSourceOnDemand

typescript
import { registerDataSourceOnDemand } from '@tmagic/data-source';

await registerDataSourceOnDemand(dsl, {
  custom: () => import('./CustomDataSource'),
  socket: () => import('./SocketDataSource')
});
`,28)])])}const g=s(e,[["render",n]]);export{c as __pageData,g as default};