Skip to content

Commit

Permalink
[sync] 2024/07/01 (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmosHuKe authored Jul 1, 2024
2 parents 615d4e6 + 6c72fca commit 0086f73
Show file tree
Hide file tree
Showing 59 changed files with 5,627 additions and 750 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
experimental: false
continue-on-error: ${{ matrix.experimental }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: ${{ matrix.sdk }}
- name: Fetch Dart packages
Expand All @@ -57,10 +57,10 @@ jobs:
name: Check if code excerpts are up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: stable
- name: Fetch Dart packages
Expand All @@ -72,10 +72,10 @@ jobs:
name: Build site and check links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: stable
- name: Fetch Dart packages
Expand All @@ -101,10 +101,10 @@ jobs:
name: Check if text can be replaced with site variables
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: stable
- name: Fetch Dart packages
Expand All @@ -116,10 +116,10 @@ jobs:
name: Validate Firebase configuration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: stable
- name: Fetch Dart packages
Expand All @@ -141,10 +141,10 @@ jobs:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_PROJECT: default
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: stable
- name: Fetch Dart packages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/compile_archive_js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
github.repository == 'cfug/dart.cn' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
token: ${{ secrets.CFUG_DEV_TOKEN }}
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
- name: Build Dart archives downloading JS
run: >
bash tool/get-dart/archive/compile.sh
Expand Down
8 changes: 7 additions & 1 deletion eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function (eleventyConfig) {
// Save in `_site/assets/img` and update links to there.
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
extensions: 'html',
formats: ['avif', 'webp', 'png', 'svg'],
formats: ['webp', 'png', 'svg'],
svgShortCircuit: true,
widths: ['auto'],
defaultAttributes: {
Expand All @@ -136,6 +136,9 @@ export default function (eleventyConfig) {
},
urlPath: '/assets/img/',
outputDir: '_site/assets/img/',
sharpOptions: {
animated: true,
},
});
} else {
// To be more consistent with the production build,
Expand All @@ -151,6 +154,9 @@ export default function (eleventyConfig) {
},
urlPath: '/assets/img/',
outputDir: '_site/assets/img/',
sharpOptions: {
animated: true,
},
});
}

Expand Down
3 changes: 1 addition & 2 deletions examples/language/lib/class_modifiers/ex1/b.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ Vehicle myVehicle = Vehicle();
// Can be extended.
class Car extends Vehicle {
int passengers = 4;
// #enddocregion abstract-usages

@override
void moveForward(int meters) {
// ...
}
// #docregion abstract-usages
}

// Can be implemented.
Expand Down
11 changes: 11 additions & 0 deletions examples/language/lib/patterns/destructuring.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ void main() {
return ('doug', 25);
}

({String name, int age}) getData() {
return (name: 'doug', age: 25);
}

var json = <String, dynamic>{};

{
Expand All @@ -57,6 +61,13 @@ void main() {
var (name, age) = userInfo(json);
// #enddocregion destructure-multiple-returns-2
}

{
// #docregion destructure-multiple-returns-3
final (:name, :age) =
getData(); // For example, return (name: 'doug', age: 25);
// #enddocregion destructure-multiple-returns-3
}
}
{
// #docregion destructure-class-instances
Expand Down
143 changes: 143 additions & 0 deletions examples/non_promotion/lib/non_promotion.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
// ignore_for_file: expected_executable, missing_statement
// ignore_for_file: unused_local_variable, unused_element
// ignore_for_file: prefer_function_declarations_over_variables
// ignore_for_file: prefer_if_null_operators

// #docregion not-field, conflicting-getter
import 'dart:math';
// #enddocregion not-field, conflicting-getter

// #docregion mock
import 'package:mockito/mockito.dart';
// #enddocregion mock

class C1 {
int? i;
Expand Down Expand Up @@ -242,3 +251,137 @@ void miscDeclAnalyzedButNotTested() {
// #enddocregion closure-write-capture
}
}

// #docregion this
extension on int? {
int get valueOrZero {
final self = this;
return self == null ? 0 : self;
}
}
// #enddocregion this

// #docregion private
class PrivateFieldExample {
final int? _val;
PrivateFieldExample(this._val);
}

void test(PrivateFieldExample x) {
if (x._val != null) {
print(x._val + 1);
}
}
// #enddocregion private

// #docregion final
class FinalExample {
final int? _immutablePrivateField;
FinalExample(this._immutablePrivateField);

void f() {
if (_immutablePrivateField != null) {
int i = _immutablePrivateField; // OK
}
}
}
// #enddocregion final

// #docregion not-field
abstract class NotFieldExample {
int? get _value => Random().nextBool() ? 123 : null;
}

void f(NotFieldExample x) {
final value = x._value;
if (value != null) {
print(value.isEven); // OK
}
}
// #enddocregion not-field

// #docregion external
class ExternalExample {
external final int? _externalField;

void f() {
final i = _externalField;
if (i != null) {
print(i.isEven); // OK
}
}
}
// #enddocregion external

// #docregion conflicting-getter
class GetterExample {
final int? _overridden;
GetterExample(this._overridden);
}

class Override implements GetterExample {
@override
int? get _overridden => Random().nextBool() ? 1 : null;
}

void testParity(GetterExample x) {
final i = x._overridden;
if (i != null) {
print(i.isEven); // OK
}
}
// #enddocregion conflicting-getter

// #docregion unrelated
class UnrelatedExample {
final int? _i;
UnrelatedExample(this._i);
}

class Unrelated {
int? get _j => Random().nextBool() ? 1 : null;
}

void f2(UnrelatedExample x) {
if (x._i != null) {
int i = x._i; // OK
}
}
// #enddocregion unrelated

// #docregion conflicting-field
class FieldExample {
final int? _overridden;
FieldExample(this._overridden);
}

class Override2 implements FieldExample {
@override
int? _overridden;
}

void f3(FieldExample x) {
final i = x._overridden;
if (i != null) {
print(i.isEven); // OK
}
}
// #enddocregion conflicting-field

// #docregion mock
class MockingExample {
final int? _i;
MockingExample(this._i);
}

class MockExample extends Mock implements MockingExample {
@override
late final int? _i;
}

void f4(MockingExample x) {
if (x._i != null) {
int i = x._i; // OK
}
}
// #enddocregion mock
3 changes: 3 additions & 0 deletions examples/non_promotion/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ version: 0.0.1
environment:
sdk: ^3.4.0

dependencies:
mockito: ^5.4.4

dev_dependencies:
lints: ^4.0.0
16 changes: 11 additions & 5 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{ "source": "/articles/archive/event-loop", "destination": "https://medium.com/dartlang/dart-asynchronous-programming-isolates-and-event-loops-bffc3e296a6a", "type": 301 },
{ "source": "/articles/archive/numeric-computation", "destination": "/guides/language/numbers", "type": 301 },
{ "source": "/articles/archive/zones", "destination": "/libraries/async/zones", "type": 301 },
{ "source": "/articles/await-async", "destination": "/codelabs/async-await", "type": 301 },
{ "source": "/articles/await-async", "destination": "/libraries/async/async-await", "type": 301 },
{ "source": "/articles/broadcast-streams", "destination": "https://medium.com/dartlang/dart-asynchronous-programming-streams-dab952023ed7", "type": 301 },
{ "source": "/articles/converters-and-codecs", "destination": "/libraries/convert/converters-and-codecs", "type": 301 },
{ "source": "/articles/creating-streams", "destination": "/libraries/async/creating-streams", "type": 301 },
Expand All @@ -64,7 +64,7 @@
{ "source": "/articles/js-dart-interop", "destination": "/web/libraries#js-interop", "type": 301 },
{ "source": "/articles/json-web-service", "destination": "/guides/json", "type": 301 },
{ "source": "/articles/language", "destination": "/language", "type": 301 },
{ "source": "/articles/language/await-async", "destination": "/codelabs/async-await", "type": 301 },
{ "source": "/articles/language/await-async", "destination": "/libraries/async/async-await", "type": 301 },
{ "source": "/articles/language/mixins", "destination": "/language/mixins", "type": 301 },
{ "source": "/articles/language/optional-types", "destination": "/resources/faq#types", "type": 301 },
{ "source": "/articles/libraries", "destination": "/libraries", "type": 301 },
Expand All @@ -84,7 +84,7 @@
{ "source": "/articles/server{,/**}", "destination": "/server", "type": 301 },
{ "source": "/articles/snapshots", "destination": "/tools/dart-compile", "type": 301 },
{ "source": "/articles/style-guide{,/**}", "destination": "/effective-dart/style", "type": 301 },
{ "source": "/articles/using-future-based-apis{,/**}", "destination": "/codelabs/async-await", "type": 301 },
{ "source": "/articles/using-future-based-apis{,/**}", "destination": "/libraries/async/async-await", "type": 301 },
{ "source": "/articles/why-dart-types", "destination": "/resources/faq#types", "type": 301 },
{ "source": "/articles/zones", "destination": "/libraries/async/zones", "type": 301 },
{ "source": "/assets/dart-logo-for-shares*.png", "destination": "/assets/img/logo/dart-logo-for-shares.png", "type": 301 },
Expand All @@ -96,6 +96,9 @@
{ "source": "/cl", "destination": "https://dart-review.googlesource.com/q/status:open+-is:wip", "type": 301 },
{ "source": "/cl/:rest*", "destination": "https://dart-review.googlesource.com/c/sdk/+/:rest*", "type": 301 },
{ "source": "/cloud{,/**}", "destination": "/server/google-cloud", "type": 301 },
{ "source": "/codelabs", "destination": "/tutorials", "type": 301 },
{ "source": "/codelabs/async-await", "destination": "/libraries/async/async-await", "type": 301 },
{ "source": "/codelabs/dart-cheatsheet", "destination": "/resources/dart-cheatsheet", "type": 301 },
{ "source": "/codelabs/null-safety{,/**}", "destination": "/null-safety/understanding-null-safety", "type": 301 },
{ "source": "/codelabs/server{,/**}", "destination": "/tutorials/server/httpserver", "type": 301 },
{ "source": "/code-of-conduct", "destination": "/community/code-of-conduct", "type": 301 },
Expand Down Expand Up @@ -139,7 +142,7 @@
{ "source": "/docs/tutorials/cmdline", "destination": "/tutorials/server/cmdline", "type": 301 },
{ "source": "/docs/tutorials/connect-dart-html", "destination": "/library/dart-html", "type": 301 },
{ "source": "/docs/tutorials/fetchdata", "destination": "/tutorials/server/fetch-data", "type": 301 },
{ "source": "/docs/tutorials/futures", "destination": "/codelabs/async-await", "type": 301 },
{ "source": "/docs/tutorials/futures", "destination": "/libraries/async/async-await", "type": 301 },
{ "source": "/docs/tutorials/get-started", "destination": "/tutorials/server/get-started", "type": 301 },
{ "source": "/docs/tutorials/httpserver", "destination": "/tutorials/server/httpserver", "type": 301 },
{ "source": "/docs/tutorials/indexeddb{,/**}", "destination": "https://api.dart.cn/stable/dart-indexed_db/dart-indexed_db-library.html", "type": 301 },
Expand Down Expand Up @@ -277,6 +280,9 @@
{ "source": "/stable{,/**}", "destination": "https://api.dart.cn/stable", "type": 301 },
{ "source": "/support/faq?(.html)", "destination": "/resources/faq", "type": 301 },
{ "source": "/support{,/**}", "destination": "/community", "type": 301 },

{ "source": "/to/main-function", "destination": "/language/functions#main", "type": 301 },

{ "source": "/tools/**/download{,.html,/**}", "destination": "/get-dart", "type": 301 },
{ "source": "/tools/**/private-files?(.html)", "destination": "/guides/libraries/private-files", "type": 301 },
{ "source": "/tools/analyzer", "destination": "/tools/dart-analyze", "type": 301 },
Expand Down Expand Up @@ -317,7 +323,7 @@
{ "source": "/tutorials/dart-vm", "destination": "/tutorials/server", "type": 301 },
{ "source": "/tutorials/dart-vm/:page*", "destination": "/tutorials/server/:page*", "type": 301 },
{ "source": "/tutorials/language", "destination": "/language", "type": 301 },
{ "source": "/tutorials/language/futures", "destination": "/codelabs/async-await", "type": 301 },
{ "source": "/tutorials/language/futures", "destination": "/libraries/async/async-await", "type": 301 },
{ "source": "/tutorials/language/streams", "destination": "/libraries/async/using-streams", "type": 301 },
{ "source": "/tutorials/libraries", "destination": "/libraries", "type": 301 },
{ "source": "/tutorials/libraries/shared-pkgs", "destination": "/guides/packages", "type": 301 },
Expand Down
Loading

0 comments on commit 0086f73

Please sign in to comment.