hyperapp-is 0.1.35 → 0.1.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,4 +13,4 @@ export { Carousel, effect_InitCarousel } from "./animationView/carousel";
13
13
  export type { ScrollMargin, MatrixState } from "./dom/utils";
14
14
  export { getScrollMargin, getMatrixState } from "./dom/utils";
15
15
  export type { GoogleAccountsId, GoogleTokenClient, GoogleAccountsOAuth2, GoogleAccounts, Google, GoogleAuthConfig, GoogleUser, GoogleAuthResult, GoogleScope, GetAccessTokenConfig } from "./services/google";
16
- export { getGoogle, googleAuth, googleLogout, getAccessToken } from "./services/google";
16
+ export { getGoogle, googleAuth, getAccessToken } from "./services/google";
@@ -7,4 +7,4 @@ export { progress_easing } from "./animation/easing";
7
7
  export { createUnits, createRAFProperties, effect_RAFProperties } from "./animation/properties";
8
8
  export { Carousel, effect_InitCarousel } from "./animationView/carousel";
9
9
  export { getScrollMargin, getMatrixState } from "./dom/utils";
10
- export { getGoogle, googleAuth, googleLogout, getAccessToken } from "./services/google";
10
+ export { getGoogle, googleAuth, getAccessToken } from "./services/google";
@@ -10,6 +10,12 @@ export interface GoogleAccountsId {
10
10
  disableAutoSelect(): void;
11
11
  cancel(): void;
12
12
  prompt(callback?: (notification: any) => void): void;
13
+ renderButton(parent: HTMLElement, options?: {
14
+ theme?: "outline" | "filled_blue" | "filled_black";
15
+ size?: "large" | "medium" | "small";
16
+ text?: "signin_with" | "signup_with" | "continue_with";
17
+ shape?: "rectangular" | "pill" | "circle" | "square";
18
+ }): void;
13
19
  }
14
20
  export interface GoogleTokenClient {
15
21
  requestAccessToken(options?: {
@@ -49,8 +55,7 @@ export interface GoogleAuthResult {
49
55
  idToken: string;
50
56
  user: GoogleUser;
51
57
  }
52
- export declare const googleAuth: (config: GoogleAuthConfig) => Promise<GoogleAuthResult>;
53
- export declare const googleLogout: () => Promise<void>;
58
+ export declare const googleAuth: (config: GoogleAuthConfig) => Promise<GoogleAuthResult | null>;
54
59
  export type GoogleScope = "openid" | "email" | "profile" | "https://www.googleapis.com/auth/drive" | "https://www.googleapis.com/auth/drive.readonly" | "https://www.googleapis.com/auth/drive.file" | "https://www.googleapis.com/auth/drive.metadata.readonly" | "https://www.googleapis.com/auth/drive.appdata" | "https://www.googleapis.com/auth/calendar" | "https://www.googleapis.com/auth/calendar.readonly" | "https://www.googleapis.com/auth/calendar.events" | "https://www.googleapis.com/auth/calendar.events.readonly" | "https://www.googleapis.com/auth/gmail.readonly" | "https://www.googleapis.com/auth/gmail.modify" | "https://www.googleapis.com/auth/gmail.send" | "https://www.googleapis.com/auth/gmail.compose" | "https://www.googleapis.com/auth/gmail.labels" | "https://www.googleapis.com/auth/spreadsheets" | "https://www.googleapis.com/auth/spreadsheets.readonly" | "https://www.googleapis.com/auth/documents" | "https://www.googleapis.com/auth/documents.readonly" | "https://www.googleapis.com/auth/presentations" | "https://www.googleapis.com/auth/presentations.readonly" | "https://www.googleapis.com/auth/forms" | "https://www.googleapis.com/auth/forms.responses.readonly" | "https://www.googleapis.com/auth/youtube.readonly" | "https://www.googleapis.com/auth/youtube" | "https://www.googleapis.com/auth/youtube.upload" | "https://www.googleapis.com/auth/youtube.force-ssl" | "https://www.googleapis.com/auth/userinfo.email" | "https://www.googleapis.com/auth/userinfo.profile" | (string & {});
55
60
  export interface GetAccessTokenConfig {
56
61
  clientId: string;
@@ -80,52 +80,39 @@ export const googleAuth = async (config) => {
80
80
  // show prompt
81
81
  client.prompt((notification) => {
82
82
  if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
83
- reject(new Error("Prompt skipped or not displayed"));
83
+ resolve(null);
84
84
  }
85
85
  });
86
86
  }); // end result
87
87
  };
88
88
  // ---------- ---------- ---------- ---------- ----------
89
- // googleLogout
90
- // ---------- ---------- ---------- ---------- ----------
91
- export const googleLogout = async () => {
92
- const google = await getGoogle();
93
- // 自動ログインを無効化
94
- google.accounts.id.disableAutoSelect();
95
- // セッション的なものをクリア(念のため)
96
- google.accounts.id.cancel();
97
- };
98
- // ---------- ---------- ---------- ---------- ----------
99
89
  // getAccessToken
100
90
  // ---------- ---------- ---------- ---------- ----------
101
- export const getAccessToken = (config) => new Promise((resolve, reject) => {
102
- var _a;
103
- // get google
104
- const google = window.google;
105
- if (!google) {
106
- reject(new Error("error: Google SDK not loaded. Call getGoogle() before getAccessToken()."));
107
- return;
108
- }
109
- // variable
110
- const prompt = (_a = config.prompt) !== null && _a !== void 0 ? _a : "select_account";
111
- // initialize
112
- const tokenClient = google.accounts.oauth2.initTokenClient({
113
- client_id: config.clientId,
114
- scope: config.scope.join(" "),
115
- callback: (response) => {
116
- if (response.error) {
117
- reject(response);
118
- }
119
- else {
120
- if (response.access_token) {
121
- resolve(response.access_token);
91
+ export const getAccessToken = async (config) => {
92
+ const google = await getGoogle();
93
+ return new Promise((resolve, reject) => {
94
+ var _a;
95
+ // variable
96
+ const prompt = (_a = config.prompt) !== null && _a !== void 0 ? _a : "select_account";
97
+ // initialize
98
+ const tokenClient = google.accounts.oauth2.initTokenClient({
99
+ client_id: config.clientId,
100
+ scope: config.scope.join(" "),
101
+ callback: (response) => {
102
+ if (response.error) {
103
+ reject(response);
122
104
  }
123
105
  else {
124
- reject(new Error("No access_token"));
106
+ if (response.access_token) {
107
+ resolve(response.access_token);
108
+ }
109
+ else {
110
+ reject(new Error("No access_token"));
111
+ }
125
112
  }
126
113
  }
127
- }
128
- }); // end initialize
129
- // request AccessToken
130
- tokenClient.requestAccessToken({ prompt }); // prompt == "none" のときには、事前にログインが必要
131
- });
114
+ }); // end initialize
115
+ // request AccessToken
116
+ tokenClient.requestAccessToken({ prompt }); // prompt == "none" のときには、事前にログインが必要
117
+ });
118
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperapp-is",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "UI foundation library for Hyperapp by is4416",
5
5
  "license": "MIT",
6
6
  "type": "module",