Skip to content

Commit

Permalink
feat(runtime-web): 移除测试使用的 runtime-web 改动
Browse files Browse the repository at this point in the history
  • Loading branch information
hwaphon committed Mar 13, 2024
1 parent 3c50979 commit 58a7865
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 83 deletions.
11 changes: 0 additions & 11 deletions packages/runtime-web/src/runtime/dsl/config.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/runtime-web/src/runtime/dsl/slot.ts

This file was deleted.

19 changes: 0 additions & 19 deletions packages/runtime-web/src/runtime/dsl/string.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/runtime-web/src/runtime/dsl/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,3 @@ export default class TemplateManager {
return null
}
}

export const createTemplateManager = () => new TemplateManager()
88 changes: 44 additions & 44 deletions packages/runtime-web/src/runtime/index.ts
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
import React from 'react'
// eslint-disable-next-line node/no-missing-import
import { Block } from './components/block'
// eslint-disable-next-line node/no-missing-import
import { Slot } from './components/slot'
import { toJsonString } from './dsl/attribute-value'
import { axmlApi } from './dsl/axml-api'
import { mergeConfig } from './dsl/config'
import createCondition from './dsl/createCondition'
import createList from './dsl/createList'
import { bindThis, getEvent, registEvents } from './dsl/event'
import getForValue from './dsl/for'
import ref from './dsl/ref'
import { autoSyncRootFontSize, setRootFontSizeForRem } from './dsl/rpx'
import { slotScope } from './dsl/slot'
import { getString } from './dsl/string'
import { createStyle } from './dsl/style'
import { createTemplateManager } from './dsl/template'
import TemplateManager from './dsl/template'
// import TwoWayBinding from './dsl/two-way-binding';
import './public/app'
import { Component, Page } from './public/index'

export default {
Component,
$cp: Component,

Page,
$pg: Page,

createTemplateManager,
$ctm: createTemplateManager,

createTemplateManager: function () {
return new TemplateManager()
},
Slot,
$st: Slot,

Block,
$bk: Block,

slotScope,
$stc: slotScope,

slotScope(f, name) {
// 主要是为了防止因为打包的问题,将方法的名称重命名,导致slot匹配不到
if (name) {
f._name = name
}
return f
},
createStyle,
$ct: createStyle,

// 事件绑定
getEvent,
$ge: getEvent,

// 对方法绑定this
bindThis,
$bt: bindThis,

registEvents,
$re: registEvents,
// ref 绑定
ref,
$rf: ref,

// 合并配置
mergeConfig,
$mg: mergeConfig,

mergeConfig(appConfig, config) {
// NOTE: appConfig 为全局配置,config为局部配置,但是config 的优先级大于 appConfig
// 这个版本主要是window。而且目前也不需要区分page 还是 component 。相关的配置基本上随着版本走的。
// 这里也算是预留了一个未来配置扩展扣子
const result = {
...appConfig,
...config,
window: { ...appConfig.window, ...config.window }
}
return result
},
toJsonString,
$tjs: toJsonString,
// 将内容转换成字符串
// TODO: 要改名字,改成 renderContent
getString,
$gt: getString,
getString(content) {
try {
if (content === undefined || content == null) {
return ''
}
// 如果是函数,那么直接返回函数
if (typeof content === 'function') return content

if (React.isValidElement(content)) {
return content
}
return content.toString()
} catch (err) {
console.log(err)
return ''
}
},
// 根据给定的value,获得for指令可用的数组
getForValue,
$gfv: getForValue,
// 创建一个专门提供给axml 的api
axmlApi,
$ap: axmlApi,
// 手动设置根节点fontsize
setRootFontSizeForRem,
$sfr: setRootFontSizeForRem,
// 自动同步根节点的 font-size, 并设置 ROOT_VALUE
autoSyncRootFontSize,
$afz: autoSyncRootFontSize,

$cd: createCondition,
$cl: createList
autoSyncRootFontSize
}

0 comments on commit 58a7865

Please sign in to comment.