Skip to content

Commit e0c4f55

Browse files
[path_parsing] Initial import (flutter#7908)
Imports https://github.com/dnfield/dart_path_parsing into this repository, with history, and updates it to follow repository conventions: - Updates minimum SDK support to match our minimum - Switches to repository analysis options, fixing or suppressing all resulting warnings - Standardizes pubspec.yaml to follow our style/conventions - Removes the use of pubspec.lock, per repo conventions
2 parents ca8cb66 + 7f0a596 commit e0c4f55

17 files changed

Lines changed: 1546 additions & 2 deletions

.github/labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@
138138
- any-glob-to-any-file:
139139
- packages/palette_generator/**/*
140140

141+
'p: path_parsing':
142+
- changed-files:
143+
- any-glob-to-any-file:
144+
- third_party/packages/path_parsing/**/*
145+
141146
'p: path_provider':
142147
- changed-files:
143148
- any-glob-to-any-file:

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ packages/webview_flutter/** @bparrishMines
4646
packages/xdg_directories/** @stuartmorgan
4747
third_party/packages/cupertino_icons/** @MitchellGoodwin
4848
third_party/packages/cupertino_icons/test/goldens/** @LongCatIsLooong
49+
third_party/packages/path_parsing/** @domesticmouse
4950

5051
# Plugin platform implementation rules. These should stay last, since the last
5152
# matching entry takes precedence.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ These are the packages hosted in this repository:
6262
| [metrics\_center](./packages/metrics_center/) | [![pub package](https://img.shields.io/pub/v/metrics_center.svg)](https://pub.dev/packages/metrics_center) | [![pub points](https://img.shields.io/pub/points/metrics_center)](https://pub.dev/packages/metrics_center/score) | [![popularity](https://img.shields.io/pub/popularity/metrics_center)](https://pub.dev/packages/metrics_center/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20metrics_center?label=)](https://github.com/flutter/flutter/labels/p%3A%20metrics_center) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20metrics_center?label=)](https://github.com/flutter/packages/labels/p%3A%20metrics_center) |
6363
| [multicast\_dns](./packages/multicast_dns/) | [![pub package](https://img.shields.io/pub/v/multicast_dns.svg)](https://pub.dev/packages/multicast_dns) | [![pub points](https://img.shields.io/pub/points/multicast_dns)](https://pub.dev/packages/multicast_dns/score) | [![popularity](https://img.shields.io/pub/popularity/multicast_dns)](https://pub.dev/packages/multicast_dns/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20multicast_dns?label=)](https://github.com/flutter/flutter/labels/p%3A%20multicast_dns) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20multicast_dns?label=)](https://github.com/flutter/packages/labels/p%3A%20multicast_dns) |
6464
| [palette\_generator](./packages/palette_generator/) | [![pub package](https://img.shields.io/pub/v/palette_generator.svg)](https://pub.dev/packages/palette_generator) | [![pub points](https://img.shields.io/pub/points/palette_generator)](https://pub.dev/packages/palette_generator/score) | [![popularity](https://img.shields.io/pub/popularity/palette_generator)](https://pub.dev/packages/palette_generator/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20palette_generator?label=)](https://github.com/flutter/flutter/labels/p%3A%20palette_generator) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20palette_generator?label=)](https://github.com/flutter/packages/labels/p%3A%20palette_generator) |
65+
| [path\_parsing](./third_party/packages/path_parsing/) | [![pub package](https://img.shields.io/pub/v/path_parsing.svg)](https://pub.dev/packages/path_parsing) | [![pub points](https://img.shields.io/pub/points/path_parsing)](https://pub.dev/packages/path_parsing/score) | [![popularity](https://img.shields.io/pub/popularity/path_parsing)](https://pub.dev/packages/path_parsing/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20path_parsing?label=)](https://github.com/flutter/flutter/labels/p%3A%20path_parsing) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20path_parsing?label=)](https://github.com/flutter/packages/labels/p%3A%20path_parsing) |
6566
| [path\_provider](./packages/path_provider/) | [![pub package](https://img.shields.io/pub/v/path_provider.svg)](https://pub.dev/packages/path_provider) | [![pub points](https://img.shields.io/pub/points/path_provider)](https://pub.dev/packages/path_provider/score) | [![popularity](https://img.shields.io/pub/popularity/path_provider)](https://pub.dev/packages/path_provider/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20path_provider?label=)](https://github.com/flutter/flutter/labels/p%3A%20path_provider) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20path_provider?label=)](https://github.com/flutter/packages/labels/p%3A%20path_provider) |
6667
| [pigeon](./packages/pigeon/) | [![pub package](https://img.shields.io/pub/v/pigeon.svg)](https://pub.dev/packages/pigeon) | [![pub points](https://img.shields.io/pub/points/pigeon)](https://pub.dev/packages/pigeon/score) | [![popularity](https://img.shields.io/pub/popularity/pigeon)](https://pub.dev/packages/pigeon/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20pigeon?label=)](https://github.com/flutter/flutter/labels/p%3A%20pigeon) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20pigeon?label=)](https://github.com/flutter/packages/labels/p%3A%20pigeon) |
6768
| [pointer\_interceptor](./packages/pointer_interceptor/) | [![pub package](https://img.shields.io/pub/v/pointer_interceptor.svg)](https://pub.dev/packages/pointer_interceptor) | [![pub points](https://img.shields.io/pub/points/pointer_interceptor)](https://pub.dev/packages/pointer_interceptor/score) | [![popularity](https://img.shields.io/pub/popularity/pointer_interceptor)](https://pub.dev/packages/pointer_interceptor/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20pointer_interceptor?label=)](https://github.com/flutter/flutter/labels/p%3A%20pointer_interceptor) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20pointer_interceptor?label=)](https://github.com/flutter/packages/labels/p%3A%20pointer_interceptor) |

script/tool/lib/src/license_check_command.dart

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ const Set<String> _ignoredFullBasenameList = <String>{
4242
'resource.h', // Generated by VS.
4343
};
4444

45+
// Third-party packages where the code doesn't have file-level annotation, just
46+
// the package-level LICENSE file. Each entry must be a directory relative to
47+
// third_party/packages, as that is the only directory where this is allowed.
48+
const Set<String> _unannotatedFileThirdPartyDirectories = <String>{
49+
'path_parsing',
50+
};
51+
4552
// Copyright and license regexes for third-party code.
4653
//
4754
// These are intentionally very simple, since there is very little third-party
@@ -69,6 +76,16 @@ final List<RegExp> _thirdPartyLicenseBlockRegexes = <RegExp>[
6976
r'// Use of this source code is governed by a BSD-style license that can be\n'
7077
r'// found in the LICENSE file\.\n',
7178
),
79+
// packages/third_party/path_parsing.
80+
RegExp(
81+
r'Copyright \(c\) 2018 Dan Field\n\n'
82+
r'Permission is hereby granted, free of charge, to any person obtaining a copy\n'
83+
r'of this software and associated documentation files \(the "Software"\), to deal\n'
84+
r'in the Software without restriction, including without limitation the rights\n'
85+
r'to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n'
86+
r'copies of the Software, and to permit persons to whom the Software is\n'
87+
r'furnished to do so, subject to the following conditions:',
88+
),
7289
];
7390

7491
// The exact format of the BSD license that our license files should contain.
@@ -217,10 +234,26 @@ class LicenseCheckCommand extends PackageCommand {
217234

218235
for (final File file in codeFiles) {
219236
print('Checking ${file.path}');
237+
// Some third-party directories have code that doesn't annotate each file,
238+
// so for those check the LICENSE file instead. This is done even though
239+
// it's redundant to re-check it for each file because it ensures that we
240+
// are still validating every file individually, rather than having a
241+
// codepath where whole directories of files are ignored, which would have
242+
// a much worse failure mode.
243+
String content;
244+
if (_unannotatedFileThirdPartyDirectories.any(
245+
(String dir) => file.path.contains('/third_party/packages/$dir/'))) {
246+
Directory packageDir = file.parent;
247+
while (packageDir.parent.basename != 'packages') {
248+
packageDir = packageDir.parent;
249+
}
250+
content = await packageDir.childFile('LICENSE').readAsString();
251+
} else {
252+
content = await file.readAsString();
253+
}
220254
// On Windows, git may auto-convert line endings on checkout; this should
221255
// still pass since they will be converted back on commit.
222-
final String content =
223-
(await file.readAsString()).replaceAll('\r\n', '\n');
256+
content = content.replaceAll('\r\n', '\n');
224257

225258
final String firstParyLicense =
226259
firstPartyLicenseBlockByExtension[p.extension(file.path)] ??
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
.dart_tool/
3+
4+
.packages
5+
.pub/
6+
.idea/
7+
8+
build/
9+
10+
.flutter-plugins
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## 1.0.2
2+
3+
* Transfers the package source from https://github.com/google/process.dart to
4+
https://github.com/dnfield/dart_path_parsing.
5+
6+
## 1.0.1
7+
8+
* Fix [bug in arc decomposition](https://github.com/dnfield/flutter_svg/issues/742).
9+
* Minor code cleanup for analysis warnings.
10+
11+
## 1.0.0
12+
13+
* Stable release.
14+
15+
## 0.2.1
16+
17+
* Performance improvements to parsing.
18+
19+
## 0.2.0
20+
21+
* Stable nullsafe release
22+
23+
## 0.2.0-nullsafety.0
24+
25+
* Nullsafety migration.
26+
27+
## 0.1.4
28+
29+
* Fix implementation of `_PathOffset`'s `==` operator.
30+
31+
## 0.1.3
32+
33+
* Fix a bug in decompose cubic curve - avoid trying to call `toInt()` on `double.infinity`
34+
* Bump test dependency.
35+
36+
## 0.1.2
37+
38+
* Fix bug with smooth curve commands
39+
* Add deep testing
40+
41+
## 0.1.1
42+
43+
* Fix link to homepage in pubspec, add example
44+
45+
## 0.1.0
46+
47+
* Initial release, based on the 0.2.4 release of path_drawing
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018 Dan Field
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "path_parsing"
2+
description:
3+
"A pure Dart parsing library for SVG paths."
4+
5+
third_party {
6+
identifier {
7+
type: "Git"
8+
value: "https://github.com/dnfield/dart_path_parsing/"
9+
primary_source: true
10+
version: "6785396f6c5528c720adb14833b196e529e78998"
11+
}
12+
version: "6785396f6c5528c720adb14833b196e529e78998"
13+
last_upgrade_date { year: 2024 month: 10 day: 24 }
14+
license_type: NOTICE
15+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# path_parsing
2+
3+
Split from the Flutter path drawing library to create a pure Dart parsing
4+
library for SVG paths and code generation (without dependencies on Flutter
5+
runtime).
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// ignore_for_file: avoid_print
2+
3+
import 'package:path_parsing/path_parsing.dart';
4+
5+
/// A [PathProxy] that dumps Flutter `Path` commands to the console.
6+
class PathPrinter extends PathProxy {
7+
@override
8+
void close() {
9+
print('Path.close();');
10+
}
11+
12+
@override
13+
void cubicTo(
14+
double x1,
15+
double y1,
16+
double x2,
17+
double y2,
18+
double x3,
19+
double y3,
20+
) {
21+
print('Path.cubicTo($x1, $y1, $x2, $y2, $x3, $y3);');
22+
}
23+
24+
@override
25+
void lineTo(double x, double y) {
26+
print('Path.lineTo($x, $y);');
27+
}
28+
29+
@override
30+
void moveTo(double x, double y) {
31+
print('Path.moveTo($x, $y);');
32+
}
33+
}
34+
35+
void main() {
36+
const String pathData =
37+
'M22.1595 3.80852C19.6789 1.35254 16.3807 -4.80966e-07 12.8727 '
38+
'-4.80966e-07C9.36452 -4.80966e-07 6.06642 1.35254 3.58579 '
39+
'3.80852C1.77297 5.60333 0.53896 7.8599 0.0171889 10.3343C-0.0738999 '
40+
'10.7666 0.206109 11.1901 0.64265 11.2803C1.07908 11.3706 1.50711 11.0934 '
41+
'1.5982 10.661C2.05552 8.49195 3.13775 6.51338 4.72783 4.9391C9.21893 '
42+
'0.492838 16.5262 0.492728 21.0173 4.9391C25.5082 9.38548 25.5082 16.6202 '
43+
'21.0173 21.0667C16.5265 25.5132 9.21893 25.5133 4.72805 21.0669C3.17644 '
44+
'19.5307 2.10538 17.6035 1.63081 15.4937C1.53386 15.0627 1.10252 14.7908 '
45+
'0.66697 14.887C0.231645 14.983 -0.0427272 15.4103 0.0542205 '
46+
'15.8413C0.595668 18.2481 1.81686 20.4461 3.5859 22.1976C6.14623 '
47+
'24.7325 9.50955 26 12.8727 26C16.236 26 19.5991 24.7326 22.1595 '
48+
'22.1976C27.2802 17.1277 27.2802 8.87841 22.1595 3.80852Z';
49+
50+
writeSvgPathDataToPath(pathData, PathPrinter());
51+
}

0 commit comments

Comments
 (0)