openkraken / kraken Goto Github PK
View Code? Open in Web Editor NEWA web standards-compliant, high-performance rendering engine based on Flutter.
Home Page: https://openkraken.com
License: Apache License 2.0
A web standards-compliant, high-performance rendering engine based on Flutter.
Home Page: https://openkraken.com
License: Apache License 2.0
当前只实现了最基本的输入能力,与 Web 还有不少差距需要补齐
支持有限能力的 querySelector 与 querySelectorAll
需要调查在低性能 CPU 机型上,执行太慢的原因
https://dev.g.alicdn.com/trip/rx-flugy-test/1.0.1/pages/around/index.web.js
通过 WebOPT 能力可以获取短信内容: https://www.chromestatus.com/feature/5873577578463232
目前 border-style 只支持 solid,dotted, dashed 等均不支持
以控制拖动的 bunnce 等默认效果。 https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior
bounce 会增强一些场景下的体验,但也会导致一些场景下带来问题,以及在某些低端机场景下期望关闭该动画来优化性能。参考:https://www.smashingmagazine.com/2018/08/scroll-bouncing-websites/ 由于 safari 不支持该 CSS 属性以及早起某些浏览器不支持,社区有前端层面实现的库来模拟 bounce 效果或者去除 bounce 效果的。比如 https://github.com/lazd/iNoBounce 。实现的方法是判断 touchmove,如果到 scroll 的 top 并且继续向上则 preventDefault(到底部同)。
浏览器设置方式:chrome://flags/#enable-force-dark
Chromium Darkmode 相关代码:
当前测试内容没有覆盖和页面能力相关的测试,比如页面的创建和销毁看内存是否都回收
element.setAttribute("style", "color:red; border: 1px solid blue;")
background-image: radial-gradient(ellipse 50px 10000px at 0px 50px, blue 0% 50px, green 50px);
Report
What did you do?
ℹ example : flutter run
or pod install
What did you expect to happen?
ℹ with no error
What happened instead?
Errno:: ENOENT - No such file or directory @ rb_check_realpath_internal - ../kraken/kraken/example/ios/.symlinks/plugins/kraken/ios/kraken_bridge.framework
CocoaPods Environment
CocoaPods : 1.10.1
Ruby : ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
RubyGems : 3.2.5
Host : macOS 11.2.1 (20D74)
Xcode : 12.4 (12D4e)
Git : git version 2.24.3 (Apple Git-128)
Ruby lib dir : ~/.rvm/rubies/ruby-2.7.2/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/
Flutter Environment
• Flutter version 1.22.6 at ~/flutter
• Framework revision 9b2d32b605 (7 weeks ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
现在只会保存最后一个函数的引用,如果业务中存在多个使用 methodChannel 的模块,那么将会导致只有最后一个模块成功监听到 methodChannel 的回调
kraken.methodChannel.setMethodCallHandler(() => {
// not working
});
kraken.methodChannel.setMethodCallHandler(() => {
// works
});
实现以下与 web 相同的文本效果:
Web
Kraken
测试代码
// test file: /Users/andycall/work/kraken/tests/integration/specs/css/css-position/position-absolute.ts
// it: in-inline-002
let BODY = document.body;
BODY.style.margin = '0px';
let split;
let containerSpan;
let outerSpan;
outerSpan = create(
'span',
{
'box-sizing': 'border-box',
},
[
createText(`outer span`),
(containerSpan = create(
'span',
{
position: 'relative',
border: '1px solid gray',
'box-sizing': 'border-box',
},
[
createText(`container span start`),
(split = create('div', {
width: '10px',
height: '10px',
'box-sizing': 'border-box',
})),
createText(`container span end`),
]
)),
createText(`outer span end`),
]
);
BODY.appendChild(outerSpan);
/**
* Kraken cli compact library. used to preview kraken rendering.
*/
function setStyle(dom, object) {
if (object == null)
return;
for (let key in object) {
if (object.hasOwnProperty(key)) {
dom.style[key] = object[key];
}
}
}
function setAttributes(dom, object) {
for (const key in object) {
if (object.hasOwnProperty(key)) {
dom.setAttribute(key, object[key]);
}
}
}
function sleep(second) {
return new Promise(done => setTimeout(done, second * 1000));
}
function create(tag, style, child) {
const el = document.createElement(tag);
setStyle(el, style);
if (Array.isArray(child)) {
child.forEach(c => el.appendChild(c));
}
else if (child) {
el.appendChild(child);
}
return el;
}
function createText(content) {
return document.createTextNode(content);
}
function append(parent, child) {
parent.appendChild(child);
}
async function matchScreenshot() {
return new Promise((resolve) => {
requestAnimationFrame(() => {
resolve();
});
});
}
async function matchElementImageSnapshot(element) {
return Promise.resolve();
}
async function it(name, fn) {
console.log('starting ' + name);
if (fn.length > 0) {
const timer = setTimeout(() => {
throw new Error('it execute timeout of 5000ms');
}, 5000);
const done = () => {
console.log('done call');
clearTimeout(timer);
};
fn(done);
}
else {
fn();
}
}
function xit(name, fn) {
it(name, fn);
}
MDN:https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
const Something = function(element) {
// |this| is a newly created object
this.name = 'Something Good';
this.handleEvent = function(event) {
console.log(this.name); // 'Something Good', as this is bound to newly created object
switch(event.type) {
case 'click':
// some code here...
break;
case 'dblclick':
// some code here...
break;
}
};
// Note that the listeners in this case are |this|, not this.handleEvent
element.addEventListener('click', this, false);
element.addEventListener('dblclick', this, false);
// You can properly remove the listeners
element.removeEventListener('click', this, false);
element.removeEventListener('dblclick', this, false);
}
const s = new Something(document.body);
<div id="div1"><br />
<span class="bold">DIV #1</span><br />
position: relative;
<div id="div2"><br />
<span class="bold">DIV #2</span><br />
position: absolute;<br />
z-index: 2;
</div>
</div>
<br />
<div id="div3"><br />
<span class="bold">DIV #3</span><br />
position: relative;<br />
z-index: 1;
<div id="div4"><br />
<span class="bold">DIV #4</span><br />
position: absolute;<br />
z-index: 10;
</div>
</div>
如 text-index: 100px;
it('should work with image of no width in flex layout', async (done) => {
let div;
let image;
div = createElement(
'div',
{
style: {
display: 'flex',
},
},
[
image = createElement('div', {
style: {
width: '100px',
height: '100px',
backgroundRepeat: 'no-repeat',
backgroundImage: 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsBAMAAADsqkcyAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAPUExURWp6mWp6mWp6mUdwTGx8mzOT1N8AAAAFdFJOU0lVPgAikM5KZwAAASZJREFUKM9t042NwyAMBWDDdQB81wFcyABNwgBJ6P4znW1+mwRVVfTp6RVTAmtb26M/Q3uKiOGGZ8S/G94Rf28YeV05CqcLz8I/F96Fnxc2wu7MWo0unXgRNSacWKude37zkcMGpsbxQ5ib0QHA9BGOLyyLs/yRNSWYq3I4o7U2wBh24hbIPzrXsKQ97E3BuYJ+gqVle5gSrK9enZHTvO8a1wpe3vog47wyOuhh4UXn41myE4f1TDhelYgkrLzIIWWVjlBP0GD9vRLOPJfdqYbGi3OtmQbuE47pt2nFduA5N+djGlnDntN8eo0308Mj57DgyAT5z6IrU033Kcvg/sROwyl+c9Rd8GVVP1JnsnqF2Q+fhu5ysePYvUF7UeOwwTX11zrq9z/4k3nshwNivwAAAABJRU5ErkJggg==)'
}
}),
]
);
BODY.appendChild(div);
image.onload = async () => {
await matchViewportSnapshot();
done();
};
});
.hero-img {
width: 80%;
}
二次渲染图片有报错,可能与 flutter 图片缓存机制有关:
flutter: NoSuchMethodError: The method '*' was called on null.
Receiver: null
Tried calling: *(827.0)
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1 ImageElement._resize (package:kraken/src/dom/tags/img.dart:296:28)
#2 ImageElement.didAttachRenderer (package:kraken/src/dom/tags/img.dart:107:5)
#3 Element.attachTo (package:kraken/src/dom/element.dart:622:5)
#4 Element.ensureChildAttached (package:kraken/src/dom/element.dart:665:17)
#5 Element.attachTo (package:kraken/src/dom/element.dart:569:5)
#6 Element.ensureChildAttached (package:kraken/src/dom/element.dart:665:17)
#7 Element.attachTo (package:kraken/src/dom/element.dart:569:5)
#8 Element.appendChild (package:kraken/src/dom/element.dart:683:17)
#9 ElementManager.insertAdjacentNode (package:kraken/src/dom/element_manager.dart:314:16)
#10 KrakenViewController.insertAdjacentNode (package:kraken/src/launcher/controller.dart:267:21)
#11 flushUICommand (package:kraken/src/bridge/to_native.dart:393:29)
#12 initBridge.<anonymous closure>.<anonymous closure> (package:kraken/src/bridge/bridge.dart:42:9)
#13 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
#14 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1055:9)
#15 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:971:5)
#16 _rootRun (dart:async/zone.dart:1190:13)
#17 _CustomZone.run (dart:async/zone.dart:1093:19)
#18 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#19 _invoke (dart:ui/hooks.dart:251:10)
#20 _drawFrame (dart:ui/hooks.dart:209:3)
用户可以自定义手势能力,通过插件的机制注册到 element 中。
Flutter 对于多行文本的换行符目前是指定为空格,无法实现 css word-break: break-all 的效果在单词中间换行。
由于文本排版是在 Flutter engine 内部控制,需要 Flutter 官方提供支持 flutter/flutter#61081
Related to openkraken/TSC#5
According TSC Meeting 2021-03-10, Support DDL to Milestone 0.9
现在的构建工具脚本,JSC,包括发布到 pub.dev 的二进制包在桌面平台上现在都仅提供了 macOS 平台的支持。
考虑到有很多用户使用的是 Windows 电脑进行开发,有必要提供可以在 Windows 上运行的工具链
transition: width 2s ease, height 2s ease
按照readme启动example时,执行flutter run 失败。报错如下 :
../lib/src/gesture/scroll_position_with_single_context.dart:37:7: Error: The non-abstract class 'ScrollPositionWithSingleContext' is missing implementations for these members:
class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollActivityDelegate {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../flutter/packages/flutter/lib/src/rendering/viewport_offset.dart:96:12: Context: 'ViewportOffset.hasPixels' is defined here.
bool get hasPixels;
^^^^^^^^^
FAILURE: Build failed with an exception.
Where:
Script '/Users/chenzefeng/Development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 991
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command '/Users/chenzefeng/Development/flutter/bin/flutter'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 14s
如 boxShadow: inset 10px 10px 0 0 rgba(0, 0, 0, 0.5)
Flutter 官方不支持 inset 类型的 box-shadow 见 issue flutter/flutter#18636 , Kraken 需要考虑用自绘方式实现。
在需要判断其他节点当前的样式的场景下,业务中会使用 getComputedStyle。
MDN:https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.