在Dart Chrome应用中使用Polymer [英] Using Polymer in a Dart Chrome App
问题描述
我试图用Dart和Polymer构建一个应用程序。但聚合物脚本似乎在web_components / platform.js中使用eval():32。有人设法这样做吗?
有人有工作实例吗?
感谢
Robert
EDIT
manifest.json: / p>
{
name:Animatr app,
version :1,
author:Robert Hartung,
manifest_version:2,
icons 128:animatr_icon.png},
app:{
background:{
scripts:[background.js]
}
},
content_security_policy:script-src'self'unsafe-inline;
}
main.html:
<!DOCTYPE html>
< html>
< head>
< meta charset =utf-8>
< title> Animatr应用程式< / title>
< link rel =stylesheethref =animatr_chrome_app.css>
< link rel =importhref =packages / polymer / polymer.html>
< / head>
< body>
< script src =packages / chrome / bootstrap.jsdefer>< / script>
< script src =my_chrome_app.darttype =application / dart; component = 1>< / script>
< / body>
< / html>
错误:
拒绝将字符串评估为JavaScript,因为unsafe-eval不是以下Content Security Policy指令中允许的脚本源:default-src'self'chrome-extension -resource:。请注意,'script-src'没有显式设置,因此default-src用作后备。 (chrome-extension://ofkfcbfhgkoglbgldcdokficikimdjji/packages/web_components/platform.js:32)
拒绝执行内联脚本,因为它违反了以下内容安全策略指令:default-src'self'chrome-extension-resource :。要启用内联执行,需要'unsafe-inline'关键字,散列('sha256 -...')或nonce('nonce -...')。还要注意,'script-src'没有显式设置,因此'default-src'用作后备。
pubspec.yaml:
:
chrome:any
聚合物:any
transformers:
- chrome
- polymer:
entry_points:
- app / animatr_chrome_app.html
csp:'true'
应用程序无法正确识别聚合物元素。
解决方案您可以查看 https://github.com/ dart-lang / spark / tree / master / ide 的示例Dart Chrome-Packaged-App。他们也大量使用Polymer。
也许这是相关的 https://github.com/Polymer/polymer/issues/252
看起来这是相关的Dart错误 https://code.google.com/p/dart/issues/detail?id=17409
I am trying to build an app with Dart and Polymer. But polymer scripts seem to be using eval() in web_components/platform.js:32. Has anyone managed to do this? I tried to change CSP but that helped in first place.
Does anyone have a working example?
Regards and Thanks Robert
EDIT
manifest.json:
{ "name": "Animatr app", "version": "1", "author": "Robert Hartung", "manifest_version": 2, "icons": {"128": "animatr_icon.png"}, "app": { "background": { "scripts": ["background.js"] } }, "content_security_policy": "script-src 'self' unsafe-inline;" }
main.html:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Animatr app</title> <link rel="stylesheet" href="animatr_chrome_app.css"> <link rel="import" href="packages/polymer/polymer.html"> </head> <body> <script src="packages/chrome/bootstrap.js" defer></script> <script src="my_chrome_app.dart" type="application/dart;component=1"></script> </body> </html>
ERROR:
Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback. (chrome-extension://ofkfcbfhgkoglbgldcdokficikimdjji/packages/web_components/platform.js:32) Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
pubspec.yaml:
name: animatr_app description: A sample Chrome packaged application dependencies: chrome: any polymer: any transformers: - chrome - polymer: entry_points: - app/animatr_chrome_app.html csp: 'true'
The app does not recognize polymer elements correctly.
解决方案You can take a look at https://github.com/dart-lang/spark/tree/master/ide for an example Dart Chrome-Packaged-App. They also make heavily use of Polymer.
Maybe this is related https://github.com/Polymer/polymer/issues/252
It seems this is the related Dart bug https://code.google.com/p/dart/issues/detail?id=17409
这篇关于在Dart Chrome应用中使用Polymer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文