-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/Kraken Bundle #866
Feat/Kraken Bundle #866
Conversation
fromURL 会比 fromHref 好一点 |
href 是 Hypertext Reference 的简写 |
assets 跟 url 放一起了,未来还会有 file(如果有) 等,统一当作 href 处理,内部根据协议再去判断,而不是传入的时候区分好,因为比如 src="xxxxxxx" 的情况是直接new bundle 的。 @wssgcg1213 |
integration_tests/lib/main.dart
Outdated
@@ -82,7 +83,7 @@ void main() async { | |||
var kraken = krakenMap[i] = Kraken( | |||
viewportWidth: 360, | |||
viewportHeight: 640, | |||
bundleContent: 'console.log("Starting integration tests...")', | |||
bundle: KrakenBundle.fromWithContent('console.log("Starting integration tests...")'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fromWithContent 应该是 fromContent
kraken/lib/widget.dart
Outdated
@@ -226,34 +217,66 @@ class Kraken extends StatefulWidget { | |||
defineElement(tagName.toUpperCase(), creator); | |||
} | |||
|
|||
loadHref(KrakenBundle bundle) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不对呀,
void loadBundle(KrakenBundle bundle)
kraken/lib/src/launcher/bundle.dart
Outdated
: super(url) { | ||
this.content = content; | ||
} | ||
|
||
RawBundle.fromByteCode(Uint8List byteCode, Uri url) : super(url) { | ||
RawBundle.fromByteCode(Uint8List byteCode, String url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kraken/lib/src/launcher/bundle.dart
Outdated
@@ -192,6 +207,11 @@ class NetworkAssetBundle extends AssetBundle { | |||
Future<ByteData> load(String key) async { | |||
final HttpClientRequest request = await httpClient.getUrl(_urlFromKey(key)); | |||
request.headers.set('Accept', getAcceptHeader()); | |||
if (additionalHttpHeaders != null) { | |||
additionalHttpHeaders?.forEach((key, value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
additionalHttpHeaders?.forEach(request.headers.set);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 ?.
多余了, 跟前面的判空是一个逻辑
: super(url); | ||
|
||
Map<String, String>? additionalHttpHeaders = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有其他人用, 这个可以私有的
@@ -622,27 +631,45 @@ class KrakenController { | |||
historyModule.href = value; | |||
} | |||
|
|||
set bundleContent(String? value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bundle 已经抽象掉了, 应该 set bundle(KrakenBundle bundle);
bundle = KrakenBundle.fromWithContent(bundleContent, url: bundleURL); | ||
} else { | ||
bundle = KrakenBundle.fromUrl(bundleURL); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你看这里的一堆判断就很恶心了, 抽象成 bundle 的目的就是消灭这些判断的, 直接 load bundle 就行了
kraken/lib/src/module/history.dart
Outdated
|
||
import 'package:kraken/dom.dart'; | ||
import 'package:kraken/kraken.dart'; | ||
import 'package:kraken/module.dart'; | ||
|
||
class HistoryItem { | ||
HistoryItem(this.href, this.state, this.needJump); | ||
HistoryItem(this.href, this.state, this.needJump, { this.bundleContent, this.bundleByteCode }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.bundle
|
||
Uri targetUri = Uri.parse(targetUrl); | ||
Uri? sourceUri = sourceUrl != null ? Uri.parse(sourceUrl) : null; | ||
Uri sourceUri = Uri.parse(sourceUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
@@ -22,6 +23,7 @@ void launch({ | |||
String? bundleURL, | |||
String? bundlePath, | |||
String? bundleContent, | |||
Uint8List? bundleByteCode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
API:
close #861