Skip to content

Commit

Permalink
[google_sign_in] Renames generated folder to js_interop. (flutter#6915)
Browse files Browse the repository at this point in the history
* Renames generated to js_interop

* Fix analyze errors

* Fix format

* Fix version check

* Add comment for public_member_api_docs
  • Loading branch information
peixinli committed Jan 10, 2023
1 parent b1797c2 commit 620a059
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 70 deletions.
3 changes: 2 additions & 1 deletion packages/google_sign_in/google_sign_in_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## NEXT
## 0.10.2+1

* Updates code for `no_leading_underscores_for_local_identifiers` lint.
* Updates minimum Flutter version to 2.10.
* Renames generated folder to js_interop.

## 0.10.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';
import 'package:google_sign_in_web/src/generated/gapiauth2.dart' as gapi;
import 'package:google_sign_in_web/src/js_interop/gapiauth2.dart' as gapi;
import 'package:google_sign_in_web/src/utils.dart';
import 'package:integration_test/integration_test.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart';
import 'package:js/js.dart';

import 'src/generated/gapiauth2.dart' as auth2;
import 'src/js_interop/gapiauth2.dart' as auth2;
import 'src/load_gapi.dart' as gapi;
import 'src/utils.dart' show gapiUserToPluginUserData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/gapi

// ignore_for_file: public_member_api_docs, unused_element, sort_constructors_first, prefer_generic_function_type_aliases
// ignore_for_file: public_member_api_docs,
// * public_member_api_docs originally undocumented because the file was
// autogenerated.

@JS()
library gapi;

import 'package:js/js.dart';

// Module gapi
typedef void LoadCallback(
typedef LoadCallback = void Function(
[dynamic args1,
dynamic args2,
dynamic args3,
Expand All @@ -28,6 +30,11 @@ typedef void LoadCallback(
@anonymous
@JS()
abstract class LoadConfig {
external factory LoadConfig(
{LoadCallback callback,
Function? onerror,
num? timeout,
Function? ontimeout});
external LoadCallback get callback;
external set callback(LoadCallback v);
external Function? get onerror;
Expand All @@ -36,11 +43,6 @@ abstract class LoadConfig {
external set timeout(num? v);
external Function? get ontimeout;
external set ontimeout(Function? v);
external factory LoadConfig(
{LoadCallback callback,
Function? onerror,
num? timeout,
Function? ontimeout});
}

/*type CallbackOrConfig = LoadConfig | LoadCallback;*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/gapi.auth2

// ignore_for_file: public_member_api_docs, unused_element, non_constant_identifier_names, sort_constructors_first, always_specify_types, strict_raw_type
// ignore_for_file: public_member_api_docs, non_constant_identifier_names,
// * public_member_api_docs originally undocumented because the file was
// autogenerated.
// * non_constant_identifier_names required to be able to use the same parameter
// names as the underlying library.

@JS()
library gapiauth2;
Expand Down Expand Up @@ -122,6 +126,15 @@ abstract class CurrentUser {
@anonymous
@JS()
abstract class SigninOptions {
external factory SigninOptions(
{String app_package_name,
bool fetch_basic_profile,
String prompt,
String scope,
String /*'popup'|'redirect'*/ ux_mode,
String redirect_uri,
String login_hint});

/// The package name of the Android app to install over the air.
/// See Android app installs from your web site:
/// https://developers.google.com/identity/sign-in/web/android-app-installs
Expand Down Expand Up @@ -162,15 +175,6 @@ abstract class SigninOptions {
// https://developers.google.com/identity/protocols/OpenIDConnect?hl=en#authenticationuriparameters
external String? get login_hint;
external set login_hint(String? v);

external factory SigninOptions(
{String app_package_name,
bool fetch_basic_profile,
String prompt,
String scope,
String /*'popup'|'redirect'*/ ux_mode,
String redirect_uri,
String login_hint});
}

/// Definitions by: John <https://github.com/jhcao23>
Expand All @@ -179,23 +183,35 @@ abstract class SigninOptions {
@anonymous
@JS()
abstract class OfflineAccessOptions {
external factory OfflineAccessOptions(
{String scope,
String /*'select_account'|'consent'*/ prompt,
String app_package_name});
external String? get scope;
external set scope(String? v);
external String? /*'select_account'|'consent'*/ get prompt;
external set prompt(String? /*'select_account'|'consent'*/ v);
external String? get app_package_name;
external set app_package_name(String? v);
external factory OfflineAccessOptions(
{String scope,
String /*'select_account'|'consent'*/ prompt,
String app_package_name});
}

/// Interface that represents the different configuration parameters for the gapi.auth2.init method.
/// Reference: https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiauth2clientconfig
@anonymous
@JS()
abstract class ClientConfig {
external factory ClientConfig({
String client_id,
String cookie_policy,
String scope,
bool fetch_basic_profile,
String? hosted_domain,
String openid_realm,
String /*'popup'|'redirect'*/ ux_mode,
String redirect_uri,
String plugin_name,
});

/// The app's client ID, found and created in the Google Developers Console.
external String? get client_id;
external set client_id(String? v);
Expand Down Expand Up @@ -238,18 +254,6 @@ abstract class ClientConfig {
/// See: https://github.com/flutter/flutter/issues/88084
external String? get plugin_name;
external set plugin_name(String? v);

external factory ClientConfig({
String client_id,
String cookie_policy,
String scope,
bool fetch_basic_profile,
String? hosted_domain,
String openid_realm,
String /*'popup'|'redirect'*/ ux_mode,
String redirect_uri,
String plugin_name,
});
}

@JS('gapi.auth2.SigninOptionsBuilder')
Expand Down Expand Up @@ -290,20 +294,23 @@ abstract class AuthResponse {
external set first_issued_at(num? v);
external num? get expires_at;
external set expires_at(num? v);
external factory AuthResponse(
{String? access_token,
String? id_token,
String? login_hint,
String? scope,
num? expires_in,
num? first_issued_at,
num? expires_at});
}

/// Reference: https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiauth2authorizeconfig
@anonymous
@JS()
abstract class AuthorizeConfig {
external factory AuthorizeConfig(
{String client_id,
String scope,
String response_type,
String prompt,
String cookie_policy,
String hosted_domain,
String login_hint,
String app_package_name,
String openid_realm,
bool include_granted_scopes});
external String get client_id;
external set client_id(String v);
external String get scope;
Expand All @@ -324,23 +331,22 @@ abstract class AuthorizeConfig {
external set openid_realm(String? v);
external bool? get include_granted_scopes;
external set include_granted_scopes(bool? v);
external factory AuthorizeConfig(
{String client_id,
String scope,
String response_type,
String prompt,
String cookie_policy,
String hosted_domain,
String login_hint,
String app_package_name,
String openid_realm,
bool include_granted_scopes});
}

/// Reference: https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiauth2authorizeresponse
@anonymous
@JS()
abstract class AuthorizeResponse {
external factory AuthorizeResponse(
{String access_token,
String id_token,
String code,
String scope,
num expires_in,
num first_issued_at,
num expires_at,
String error,
String error_subtype});
external String get access_token;
external set access_token(String v);
external String get id_token;
Expand All @@ -359,16 +365,6 @@ abstract class AuthorizeResponse {
external set error(String v);
external String get error_subtype;
external set error_subtype(String v);
external factory AuthorizeResponse(
{String access_token,
String id_token,
String code,
String scope,
num expires_in,
num first_issued_at,
num expires_at,
String error,
String error_subtype});
}

/// A GoogleUser object represents one user account.
Expand Down Expand Up @@ -498,6 +494,4 @@ external void render(
abstract class Promise<T> {
external factory Promise(
void Function(void Function(T result) resolve, Function reject) executor);
external Promise then(void Function(T result) onFulfilled,
[Function onRejected]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart' show visibleForTesting;
import 'package:js/js.dart';

import 'generated/gapi.dart' as gapi;
import 'js_interop/gapi.dart' as gapi;
import 'utils.dart' show injectJSLibraries;

@JS()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'dart:html' as html;

import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart';

import 'generated/gapiauth2.dart' as auth2;
import 'js_interop/gapiauth2.dart' as auth2;

/// Injects a list of JS [libraries] as `script` tags into a [target] [html.HtmlElement].
///
Expand Down
2 changes: 1 addition & 1 deletion packages/google_sign_in/google_sign_in_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system
for signing in with a Google account on Android, iOS and Web.
repository: https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 0.10.2
version: 0.10.2+1

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit 620a059

Please sign in to comment.