Git Product home page Git Product logo

glass-easel's People

Contributors

bytemain avatar fzliang avatar lastleaf avatar maniaciachao avatar mrazauskas avatar sgly avatar tidyzq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glass-easel's Issues

Support typing for extra fields in component instance

When adding a custom field in a component (defined with definition API), its type is hard to specify.

Solution 1

Add a definition field for specifying types for the extra fields, e.g.

componentSpace.defineComponent({
  extraThisFieldsType: undefined as unknown as { /* SOME CUSTOM FIELDS TYPE */ }
})

The data type of extraThisFieldsType can be merged into ThisType of the component.

Solution 2

Add another initiation function, which returns some fields that will be written into this (of the method caller, if any), e.g.

componentSpace.defineComponent({
  extraThisFields: () => { /* SOME CUSTOM FIELDS */ }
})

If some fields cannot be set during initiation, its type should be given manually, e.g.

componentSpace.defineComponent({
  extraThisFields: () => {
    delayedField: undefined as SomeType | undefined
  }
})

Change the Component Name Search Rules

Currently, when creating a component through createComponent , the tag name seach rules are:

  • search in the usingComponents list;
  • search in the generics list;
  • search in the component space with the tag name treated as absolute path.

The last rule does not make sense. The propose of the rule is to make it possible to use global components, but there should be a better way to define the global component list.

Remove `dataDeepCopy` and `propertyPassingDeepCopy` in favor of non-copy-setData

Currently these two component options are used to control whether the data should be copied while templating. It is component-level options, but it is more practical to control the deep copy strategies of each data field.

We want to remove them in faver of some advanced data update methods.

General API design:

  • add an extra argument for replaceDataOnPath and spliceArrayDataOnPath for the DeepCopyStrategy ;
  • add a new method updateAtomicData to set fields with DeepCopyStrategy.None .

Supports getting row offset of inline scripts

Inline scripts in WXML files obtained by TmplGroup#get_inline_script may be processed by an external processor for validation or transformation purpose. In that case, row offset of inline scripts is required for calculating code position during external processing.

Remove `clearClasses` backend calls

The backend would like to know which classes are changed, in other words, addClass and removeClass interfaces are better, but clearClasses is not good.

This also helps the implementation of #60 .

Tag-name and Common Attributes should be Lowercased

For the compatibilities of the legacy framework and XML spec, tag name and common attributes should be lower-cased. For example:

<Div data-myData></diV>

should be treated as the same as

<div data-mydata></div>

Special template directives are excluded:

  • data:myData and mark:myMark should not be lowercased;
  • event bindings like bind:myEvent should not be lowercased.

Variables in the template `trueText` `nullText` raise Template parsing error

If variables in the template start with true/false/null (<text>{{ trueText }}</text>), it will cause a syntax error.

Test:

https://npm.runkit.com/glass-easel-template-compiler

Code:

const glassEaselTemplateCompiler = require("glass-easel-template-compiler")
const g = new glassEaselTemplateCompiler.TmplGroup()
g.addTmpl('/path', '<text>{{ trueText }}</text>')
console.log(g.getTmplGenObjectGroups())

Return:

"Template parsing error (from line 1 column 14 to line 1 column 14) : Unexpected character"

It should be related to the syntax definition of this file:
https://github.com/wechat-miniprogram/glass-easel/blob/1874b8d2099ec62364113be76f3939b81a10a6e7/glass-easel-template-compiler/src/tmpl.pest

Support special directive in templates

Currently the unused directive like <div unused:xxx="xxx" /> will be dropped automatically.

But in some cases we do like some special directives attached to an element.

Support template update (for rapid development)

In WXML editors, it is much more convinient if we support template update, which means, when wxml updates, the template engine gets the new content, and applies it to the component directly without recreate the component and without state loss. This will be helpful for rapid development.

Allow Using `NativeNode`

Currently, in using or usingComponents of behaviors (and components), if the target is not found, the default component in current component space is used.

This behavior should be changed. If the target is not found, then treat it as a native node.

This is helpful when working with placeholders, and maybe helpful to solve #5 .

Support logical/styling tag name separation

Tag name can be aliased with "using" or "usingComponents".

Sometimes we would like the alias contains the same logic behavior as the using target in the backend, but its styling (tag name selector matching) follows the alias itself.

This requires several features.

  • In the backend protocol, the createElement call contains a second argument as the alias.
  • When aliasing native node (introduced in #13 ), the using information contains the logical tag name.
  • While host node creation, the logical tag name always refers to a non-special element (such as "span").

组件路径中的is: 'idPath'也显得有些多余

个人感觉:从API角度,defineComponent时is属性显得很多余,直接将defineComponent的结果赋在using上感觉比较合理,如果是为了兼容老版本,应该也可以用babel来在编译时生成唯一id并派发到实际文件路径来解决

[bug] ios 真机小程序白屏无法加载

版本:iphone12,iOS 16.4.1 ,微信 8.0.36,基础库 2.31.0
使用开发者工具 mac 1.0.6.2304212 运行正常

页面有配置全局组件 usingComponents、只在后面的页单独开启了 "renderer": "skyline", "componentFramework": "glass-easel"

使用工具启动真机预览小程序,进主页就报错了。主页是 webview 模式

IMG_7447

WXS used in template will lose when referenced by other file

test case to reproduce:

const def = glassEasel
  .registerElement({
    template: multiTmpl({
      child: `
        <wxs name="w">module.exports = { fn: function () { return 1 } }</wxs>
        <template name="child">
          <span>{{ w.fn() }}</span>
        </template>
      `,
      '': `
        <import src="./child" />
        <div>
          <template is="child" />
        </div>
      `,
    }),
  })
  .general()
const elem = glassEasel.Component.create('root', def)

Custom Property Value Comparison Function

When passing objects or arrays between components, most of the times the value is treated as updated (without any deep-comparison). It causes some update perf issues between components.

This can be solved by adding a custom property comparison function to decide whether the value is updated.

Allow non-lowercase-letter after dash when doing dash-to-camel conversion

When doing dash-to-camel conversion, e.g. handling template attributes as property names, dash with a lowercase letter followed it will be correctly converted: a-b => aB

However, when a dash is not followed by a lowercase letter, it will not be removed. a-3 => a-3

The expected result should be a-3 => a3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.