Skip to content

Commit

Permalink
[path_parsing] Initial import (#7908)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stuartmorgan authored Oct 25, 2024
2 parents ca8cb66 + 7f0a596 commit e0c4f55
Show file tree
Hide file tree
Showing 17 changed files with 1,546 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@
- any-glob-to-any-file:
- packages/palette_generator/**/*

'p: path_parsing':
- changed-files:
- any-glob-to-any-file:
- third_party/packages/path_parsing/**/*

'p: path_provider':
- changed-files:
- any-glob-to-any-file:
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ packages/webview_flutter/** @bparrishMines
packages/xdg_directories/** @stuartmorgan
third_party/packages/cupertino_icons/** @MitchellGoodwin
third_party/packages/cupertino_icons/test/goldens/** @LongCatIsLooong
third_party/packages/path_parsing/** @domesticmouse

# Plugin platform implementation rules. These should stay last, since the last
# matching entry takes precedence.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ These are the packages hosted in this repository:
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
Expand Down
37 changes: 35 additions & 2 deletions script/tool/lib/src/license_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ const Set<String> _ignoredFullBasenameList = <String>{
'resource.h', // Generated by VS.
};

// Third-party packages where the code doesn't have file-level annotation, just
// the package-level LICENSE file. Each entry must be a directory relative to
// third_party/packages, as that is the only directory where this is allowed.
const Set<String> _unannotatedFileThirdPartyDirectories = <String>{
'path_parsing',
};

// Copyright and license regexes for third-party code.
//
// These are intentionally very simple, since there is very little third-party
Expand Down Expand Up @@ -69,6 +76,16 @@ final List<RegExp> _thirdPartyLicenseBlockRegexes = <RegExp>[
r'// Use of this source code is governed by a BSD-style license that can be\n'
r'// found in the LICENSE file\.\n',
),
// packages/third_party/path_parsing.
RegExp(
r'Copyright \(c\) 2018 Dan Field\n\n'
r'Permission is hereby granted, free of charge, to any person obtaining a copy\n'
r'of this software and associated documentation files \(the "Software"\), to deal\n'
r'in the Software without restriction, including without limitation the rights\n'
r'to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n'
r'copies of the Software, and to permit persons to whom the Software is\n'
r'furnished to do so, subject to the following conditions:',
),
];

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

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

final String firstParyLicense =
firstPartyLicenseBlockByExtension[p.extension(file.path)] ??
Expand Down
10 changes: 10 additions & 0 deletions third_party/packages/path_parsing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
.dart_tool/

.packages
.pub/
.idea/

build/

.flutter-plugins
47 changes: 47 additions & 0 deletions third_party/packages/path_parsing/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## 1.0.2

* Transfers the package source from https://github.com/google/process.dart to
https://github.com/dnfield/dart_path_parsing.

## 1.0.1

* Fix [bug in arc decomposition](https://github.com/dnfield/flutter_svg/issues/742).
* Minor code cleanup for analysis warnings.

## 1.0.0

* Stable release.

## 0.2.1

* Performance improvements to parsing.

## 0.2.0

* Stable nullsafe release

## 0.2.0-nullsafety.0

* Nullsafety migration.

## 0.1.4

* Fix implementation of `_PathOffset`'s `==` operator.

## 0.1.3

* Fix a bug in decompose cubic curve - avoid trying to call `toInt()` on `double.infinity`
* Bump test dependency.

## 0.1.2

* Fix bug with smooth curve commands
* Add deep testing

## 0.1.1

* Fix link to homepage in pubspec, add example

## 0.1.0

* Initial release, based on the 0.2.4 release of path_drawing
19 changes: 19 additions & 0 deletions third_party/packages/path_parsing/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2018 Dan Field

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions third_party/packages/path_parsing/METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "path_parsing"
description:
"A pure Dart parsing library for SVG paths."

third_party {
identifier {
type: "Git"
value: "https://github.com/dnfield/dart_path_parsing/"
primary_source: true
version: "6785396f6c5528c720adb14833b196e529e78998"
}
version: "6785396f6c5528c720adb14833b196e529e78998"
last_upgrade_date { year: 2024 month: 10 day: 24 }
license_type: NOTICE
}
5 changes: 5 additions & 0 deletions third_party/packages/path_parsing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# path_parsing

Split from the Flutter path drawing library to create a pure Dart parsing
library for SVG paths and code generation (without dependencies on Flutter
runtime).
51 changes: 51 additions & 0 deletions third_party/packages/path_parsing/example/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ignore_for_file: avoid_print

import 'package:path_parsing/path_parsing.dart';

/// A [PathProxy] that dumps Flutter `Path` commands to the console.
class PathPrinter extends PathProxy {
@override
void close() {
print('Path.close();');
}

@override
void cubicTo(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
) {
print('Path.cubicTo($x1, $y1, $x2, $y2, $x3, $y3);');
}

@override
void lineTo(double x, double y) {
print('Path.lineTo($x, $y);');
}

@override
void moveTo(double x, double y) {
print('Path.moveTo($x, $y);');
}
}

void main() {
const String pathData =
'M22.1595 3.80852C19.6789 1.35254 16.3807 -4.80966e-07 12.8727 '
'-4.80966e-07C9.36452 -4.80966e-07 6.06642 1.35254 3.58579 '
'3.80852C1.77297 5.60333 0.53896 7.8599 0.0171889 10.3343C-0.0738999 '
'10.7666 0.206109 11.1901 0.64265 11.2803C1.07908 11.3706 1.50711 11.0934 '
'1.5982 10.661C2.05552 8.49195 3.13775 6.51338 4.72783 4.9391C9.21893 '
'0.492838 16.5262 0.492728 21.0173 4.9391C25.5082 9.38548 25.5082 16.6202 '
'21.0173 21.0667C16.5265 25.5132 9.21893 25.5133 4.72805 21.0669C3.17644 '
'19.5307 2.10538 17.6035 1.63081 15.4937C1.53386 15.0627 1.10252 14.7908 '
'0.66697 14.887C0.231645 14.983 -0.0427272 15.4103 0.0542205 '
'15.8413C0.595668 18.2481 1.81686 20.4461 3.5859 22.1976C6.14623 '
'24.7325 9.50955 26 12.8727 26C16.236 26 19.5991 24.7326 22.1595 '
'22.1976C27.2802 17.1277 27.2802 8.87841 22.1595 3.80852Z';

writeSvgPathDataToPath(pathData, PathPrinter());
}
9 changes: 9 additions & 0 deletions third_party/packages/path_parsing/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: path_parsing_example
publish_to: none

environment:
sdk: ^3.3.0

dependencies:
path_parsing:
path: ../
1 change: 1 addition & 0 deletions third_party/packages/path_parsing/lib/path_parsing.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'src/path_parsing.dart';
Loading

0 comments on commit e0c4f55

Please sign in to comment.