hyperapp-is 0.1.49 → 0.2.0

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.
Files changed (44) hide show
  1. package/README.md +220 -1557
  2. package/dist/{hyperapp-is/animation → animation}/easing.d.ts +4 -0
  3. package/dist/{hyperapp-is/animation → animation}/easing.js +4 -4
  4. package/dist/{hyperapp-is/animation → animation}/properties.d.ts +9 -16
  5. package/dist/{hyperapp-is/animation → animation}/properties.js +13 -12
  6. package/dist/{hyperapp-is/animation → animation}/raf.d.ts +11 -12
  7. package/dist/animation/raf.js +192 -0
  8. package/dist/core/component.d.ts +23 -0
  9. package/dist/core/component.js +52 -0
  10. package/dist/core/effects.d.ts +10 -0
  11. package/dist/core/effects.js +34 -0
  12. package/dist/core/state.d.ts +21 -0
  13. package/dist/{hyperapp-is/core → core}/state.js +15 -20
  14. package/dist/dom/dialog.d.ts +6 -0
  15. package/dist/dom/dialog.js +85 -0
  16. package/dist/dom/utils.d.ts +15 -0
  17. package/dist/dom/utils.js +19 -0
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.js +1 -0
  20. package/dist/services/google.d.ts +69 -0
  21. package/dist/services/google.js +170 -0
  22. package/package.json +14 -40
  23. package/dist/hyperapp-is/animation/index.d.ts +0 -5
  24. package/dist/hyperapp-is/animation/index.js +0 -4
  25. package/dist/hyperapp-is/animation/raf.js +0 -209
  26. package/dist/hyperapp-is/animationView/carousel.d.ts +0 -48
  27. package/dist/hyperapp-is/animationView/carousel.js +0 -461
  28. package/dist/hyperapp-is/animationView/index.d.ts +0 -2
  29. package/dist/hyperapp-is/animationView/index.js +0 -2
  30. package/dist/hyperapp-is/core/component.d.ts +0 -65
  31. package/dist/hyperapp-is/core/component.js +0 -242
  32. package/dist/hyperapp-is/core/index.d.ts +0 -6
  33. package/dist/hyperapp-is/core/index.js +0 -4
  34. package/dist/hyperapp-is/core/navigator.d.ts +0 -115
  35. package/dist/hyperapp-is/core/navigator.js +0 -615
  36. package/dist/hyperapp-is/core/state.d.ts +0 -27
  37. package/dist/hyperapp-is/dom/index.d.ts +0 -2
  38. package/dist/hyperapp-is/dom/index.js +0 -2
  39. package/dist/hyperapp-is/dom/utils.d.ts +0 -37
  40. package/dist/hyperapp-is/dom/utils.js +0 -69
  41. package/dist/hyperapp-is/index.d.ts +0 -16
  42. package/dist/hyperapp-is/index.js +0 -10
  43. package/dist/hyperapp-is/services/google.d.ts +0 -89
  44. package/dist/hyperapp-is/services/google.js +0 -178
@@ -1,69 +0,0 @@
1
- // hyperapp-is / dom / utils.ts
2
- // ---------- ---------- ---------- ---------- ----------
3
- // getScrollMargin
4
- // ---------- ---------- ---------- ---------- ----------
5
- /**
6
- * スクロールの余白を取得する
7
- */
8
- export const getScrollMargin = function (e) {
9
- const el = e.currentTarget;
10
- if (!el)
11
- return { top: 0, left: 0, right: 0, bottom: 0 };
12
- return {
13
- top: el.scrollTop,
14
- left: el.scrollLeft,
15
- right: el.scrollWidth - (el.clientWidth + el.scrollLeft),
16
- bottom: el.scrollHeight - (el.clientHeight + el.scrollTop)
17
- };
18
- };
19
- // ---------- ---------- ---------- ---------- ----------
20
- // getMatrixState
21
- // ---------- ---------- ---------- ---------- ----------
22
- /**
23
- * DOM から transfrom 情報を取得する
24
- */
25
- export const getMatrixState = (dom) => {
26
- const style = getComputedStyle(dom);
27
- const transform = style.transform;
28
- if (!transform || transform === 'none')
29
- return null;
30
- let m;
31
- try {
32
- m = new DOMMatrix(transform);
33
- }
34
- catch {
35
- return null;
36
- }
37
- const scaleX = Math.hypot(m.m11, m.m12, m.m13);
38
- const scaleY = Math.hypot(m.m21, m.m22, m.m23);
39
- const scaleZ = Math.hypot(m.m31, m.m32, m.m33);
40
- let rotateX = 0;
41
- let rotateY = 0;
42
- let rotateZ = 0;
43
- if (scaleX && scaleY && scaleZ) {
44
- rotateY = Math.asin(-m.m13 / scaleZ);
45
- const EPS = 1e-8;
46
- if (Math.cos(rotateY) > EPS) {
47
- rotateX = Math.atan2(m.m23 / scaleZ, m.m33 / scaleZ);
48
- rotateZ = Math.atan2(m.m12 / scaleY, m.m11 / scaleX);
49
- }
50
- }
51
- return {
52
- translate: {
53
- x: m.m41,
54
- y: m.m42,
55
- z: m.m43
56
- },
57
- scale: {
58
- x: scaleX,
59
- y: scaleY,
60
- z: scaleZ
61
- },
62
- // radian
63
- rotate: {
64
- x: rotateX,
65
- y: rotateY,
66
- z: rotateZ
67
- }
68
- };
69
- };
@@ -1,16 +0,0 @@
1
- export type { Keys, Keys_String, Keys_ArrayString, Keys_Number, Keys_ArrayNumber, Keys_ArrayRAFTask, Keys_NavigatorItem, } from "./core/state";
2
- export type { NavigatorItem, JsonEntry, NavigatorColumn, SearchResult } from "./core/navigator";
3
- export { getValue, setValue, getLocalState, setLocalState, createLocalKey } from "./core/state";
4
- export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton, HistoryInput } from "./core/component";
5
- export { convertJsonToNavigatorItem, getParentItems, NavigatorFinder, NavigatorSearch, icon_depth, icon_name, icon_directory, icon_file, icon_trashBox, icon_filter, icon_copy } from "./core/navigator";
6
- export type { InternalEffect, RAFEvent } from "./animation/raf";
7
- export type { CSSProperty } from "./animation/properties";
8
- export { RAFTask, subscription_RAFManager } from "./animation/raf";
9
- export { progress_easing } from "./animation/easing";
10
- export { createUnits, createRAFProperties, effect_RAFProperties } from "./animation/properties";
11
- export type { CarouselState, CarouselController } from "./animationView/carousel";
12
- export { Carousel, effect_InitCarousel } from "./animationView/carousel";
13
- export type { ScrollMargin, MatrixState } from "./dom/utils";
14
- export { getScrollMargin, getMatrixState } from "./dom/utils";
15
- export type { GoogleAccountsId, GoogleTokenClient, GoogleAccountsOAuth2, GoogleAccounts, Google, GoogleAuthConfig, GoogleUser, GoogleAuthResult, GoogleScope, GetAccessTokenConfig, GoogleButtonOptions } from "./services/google";
16
- export { getGoogle, getGoogleAuthResult, getAccessToken, GoogleAuth } from "./services/google";
@@ -1,10 +0,0 @@
1
- // hyperapp-is / index.ts
2
- export { getValue, setValue, getLocalState, setLocalState, createLocalKey } from "./core/state";
3
- export { el, concatAction, getClassList, deleteKeys, Route, SelectButton, OptionButton, HistoryInput } from "./core/component";
4
- export { convertJsonToNavigatorItem, getParentItems, NavigatorFinder, NavigatorSearch, icon_depth, icon_name, icon_directory, icon_file, icon_trashBox, icon_filter, icon_copy } from "./core/navigator";
5
- export { RAFTask, subscription_RAFManager } from "./animation/raf";
6
- export { progress_easing } from "./animation/easing";
7
- export { createUnits, createRAFProperties, effect_RAFProperties } from "./animation/properties";
8
- export { Carousel, effect_InitCarousel } from "./animationView/carousel";
9
- export { getScrollMargin, getMatrixState } from "./dom/utils";
10
- export { getGoogle, getGoogleAuthResult, getAccessToken, GoogleAuth } from "./services/google";
@@ -1,89 +0,0 @@
1
- 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 & {});
2
- export interface GoogleAccountsId {
3
- initialize(config: {
4
- client_id: string;
5
- auto_select?: boolean;
6
- ux_mode?: "popup" | "redirect";
7
- callback: (response: {
8
- credential: string;
9
- }) => void;
10
- }): void;
11
- disableAutoSelect(): void;
12
- cancel(): void;
13
- prompt(callback?: (notification: any) => void): void;
14
- renderButton(parent: HTMLElement, options?: {
15
- theme?: "outline" | "filled_blue" | "filled_black";
16
- size?: "large" | "medium" | "small";
17
- text?: "signin_with" | "signup_with" | "continue_with";
18
- shape?: "rectangular" | "pill" | "circle" | "square";
19
- }): void;
20
- revoke(hint: string, // email or sub
21
- callback: () => void): void;
22
- }
23
- export interface GoogleTokenClient {
24
- requestAccessToken(options?: {
25
- prompt?: "none" | "consent" | "select_account";
26
- }): void;
27
- }
28
- export interface GoogleAccountsOAuth2 {
29
- initTokenClient(config: {
30
- client_id: string;
31
- scope: string;
32
- callback: (response: {
33
- access_token?: string;
34
- error?: string;
35
- }) => void;
36
- }): GoogleTokenClient;
37
- }
38
- export interface GoogleAccounts {
39
- id: GoogleAccountsId;
40
- oauth2: GoogleAccountsOAuth2;
41
- }
42
- export interface Google {
43
- accounts: GoogleAccounts;
44
- }
45
- export interface GoogleAuthConfig {
46
- clientId: string;
47
- autoSelect?: boolean;
48
- uxMode?: "popup" | "redirect";
49
- }
50
- export interface GoogleUser {
51
- name: string;
52
- email: string;
53
- picture: string;
54
- sub: string;
55
- }
56
- export interface GoogleAuthResult {
57
- idToken: string;
58
- user: GoogleUser;
59
- }
60
- export interface GetAccessTokenConfig {
61
- clientId: string;
62
- scope: GoogleScope[];
63
- prompt?: "none" | "select_account" | "consent";
64
- }
65
- /**
66
- * Google 変数を取得する
67
- */
68
- export declare const getGoogle: () => Promise<Google>;
69
- /**
70
- * idToken から ユーザー情報を取得
71
- *
72
- * @param {string} idToken - ユーザートークン
73
- * @returns {GoogleAuthResult}
74
- */
75
- export declare const getGoogleAuthResult: (idToken: string) => GoogleAuthResult;
76
- export declare const getAccessToken: (config: GetAccessTokenConfig) => Promise<string>;
77
- export interface GoogleButtonOptions {
78
- renderButton?: HTMLElement;
79
- theme?: "outline" | "filled_blue" | "filled_black";
80
- size?: "large" | "medium" | "small";
81
- text?: "signin_with" | "signup_with" | "continue_with";
82
- shape?: "rectangular" | "pill" | "circle" | "square";
83
- }
84
- export declare class GoogleAuth {
85
- #private;
86
- constructor(config: GoogleAuthConfig, options?: GoogleButtonOptions);
87
- initialize(): Promise<GoogleAuthResult>;
88
- logout(hint: string): void;
89
- }
@@ -1,178 +0,0 @@
1
- // ========== ========== ========== ========== ==========
2
- // import
3
- // ========== ========== ========== ========== ==========
4
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
5
- if (kind === "m") throw new TypeError("Private method is not writable");
6
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
7
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
8
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9
- };
10
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
13
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
14
- };
15
- var _GoogleAuth_config, _GoogleAuth_options, _GoogleAuth_google, _GoogleAuth_initialized;
16
- // ========== ========== ========== ========== ==========
17
- // procedure
18
- // ========== ========== ========== ========== ==========
19
- // ---------- ---------- ---------- ---------- ----------
20
- // getGoogle
21
- // ---------- ---------- ---------- ---------- ----------
22
- // 2重読み込み防止用の変数
23
- let googlePromise = null;
24
- /**
25
- * Google 変数を取得する
26
- */
27
- export const getGoogle = async () => {
28
- if (window.google)
29
- return window.google;
30
- if (googlePromise)
31
- return googlePromise;
32
- googlePromise = new Promise((resolve, reject) => {
33
- const script = document.createElement("script");
34
- script.src = "https://accounts.google.com/gsi/client";
35
- // success
36
- script.addEventListener("load", () => {
37
- const result = window.google;
38
- if (result) {
39
- resolve(result);
40
- }
41
- else {
42
- reject(new Error("error: loadGoogle: 001"));
43
- }
44
- });
45
- // error
46
- script.addEventListener("error", () => {
47
- reject(new Error("error: loadGoogle: 002"));
48
- });
49
- // append child
50
- document.body.appendChild(script);
51
- });
52
- return googlePromise;
53
- };
54
- // ---------- ---------- ---------- ---------- ----------
55
- // getGoogleAuthResult
56
- // ---------- ---------- ---------- ---------- ----------
57
- /**
58
- * idToken から ユーザー情報を取得
59
- *
60
- * @param {string} idToken - ユーザートークン
61
- * @returns {GoogleAuthResult}
62
- */
63
- export const getGoogleAuthResult = (idToken) => {
64
- const base64 = idToken.split(".")[1]
65
- .replace(/-/g, "+")
66
- .replace(/_/g, "/");
67
- const decode = (str) => decodeURIComponent(atob(str)
68
- .split("")
69
- .map(c => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2))
70
- .join(""));
71
- const payload = JSON.parse(decode(base64));
72
- const user = {
73
- name: payload.name,
74
- email: payload.email,
75
- picture: payload.picture,
76
- sub: payload.sub
77
- };
78
- return {
79
- idToken,
80
- user
81
- };
82
- };
83
- // ---------- ---------- ---------- ---------- ----------
84
- // getAccessToken
85
- // ---------- ---------- ---------- ---------- ----------
86
- export const getAccessToken = async (config) => {
87
- const google = await getGoogle();
88
- return new Promise((resolve, reject) => {
89
- var _a;
90
- // variable
91
- const prompt = (_a = config.prompt) !== null && _a !== void 0 ? _a : "select_account";
92
- // initialize
93
- const tokenClient = google.accounts.oauth2.initTokenClient({
94
- client_id: config.clientId,
95
- scope: config.scope.join(" "),
96
- callback: (response) => {
97
- if (response.error) {
98
- reject(response);
99
- }
100
- else {
101
- if (response.access_token) {
102
- resolve(response.access_token);
103
- }
104
- else {
105
- reject(new Error("No access_token"));
106
- }
107
- }
108
- }
109
- }); // end initialize
110
- // request AccessToken
111
- tokenClient.requestAccessToken({ prompt }); // prompt == "none" のときには、事前にログインが必要
112
- });
113
- };
114
- export class GoogleAuth {
115
- // constructor
116
- constructor(config, options) {
117
- // field
118
- _GoogleAuth_config.set(this, void 0);
119
- _GoogleAuth_options.set(this, void 0);
120
- _GoogleAuth_google.set(this, void 0);
121
- _GoogleAuth_initialized.set(this, void 0);
122
- __classPrivateFieldSet(this, _GoogleAuth_config, config, "f");
123
- __classPrivateFieldSet(this, _GoogleAuth_options, options !== null && options !== void 0 ? options : {}, "f");
124
- __classPrivateFieldSet(this, _GoogleAuth_initialized, false, "f");
125
- }
126
- // method: initialize
127
- async initialize() {
128
- if (__classPrivateFieldGet(this, _GoogleAuth_initialized, "f")) {
129
- throw new Error("Already initialized");
130
- }
131
- __classPrivateFieldSet(this, _GoogleAuth_google, await getGoogle(), "f");
132
- __classPrivateFieldSet(this, _GoogleAuth_initialized, true, "f");
133
- const client = __classPrivateFieldGet(this, _GoogleAuth_google, "f").accounts.id;
134
- return new Promise(resolve => {
135
- var _a, _b, _c, _d, _e, _f, _g;
136
- let resolved = false;
137
- const callback = (response) => {
138
- if (resolved)
139
- return;
140
- resolved = true;
141
- resolve(getGoogleAuthResult(response.credential));
142
- };
143
- client.initialize({
144
- client_id: __classPrivateFieldGet(this, _GoogleAuth_config, "f").clientId,
145
- auto_select: (_a = __classPrivateFieldGet(this, _GoogleAuth_config, "f").autoSelect) !== null && _a !== void 0 ? _a : true,
146
- ux_mode: (_b = __classPrivateFieldGet(this, _GoogleAuth_config, "f").uxMode) !== null && _b !== void 0 ? _b : "popup",
147
- callback
148
- });
149
- if ((_c = __classPrivateFieldGet(this, _GoogleAuth_options, "f")) === null || _c === void 0 ? void 0 : _c.renderButton) {
150
- client.renderButton(__classPrivateFieldGet(this, _GoogleAuth_options, "f").renderButton, {
151
- theme: (_d = __classPrivateFieldGet(this, _GoogleAuth_options, "f").theme) !== null && _d !== void 0 ? _d : "outline",
152
- size: (_e = __classPrivateFieldGet(this, _GoogleAuth_options, "f").size) !== null && _e !== void 0 ? _e : "medium",
153
- text: (_f = __classPrivateFieldGet(this, _GoogleAuth_options, "f").text) !== null && _f !== void 0 ? _f : "signin_with",
154
- shape: (_g = __classPrivateFieldGet(this, _GoogleAuth_options, "f").shape) !== null && _g !== void 0 ? _g : "rectangular",
155
- });
156
- }
157
- client.prompt((notification) => {
158
- if (!resolved && notification.isNotDisplayed()) {
159
- console.log("isNotDisplayed");
160
- }
161
- if (!resolved && notification.isSkippedMoment()) {
162
- console.log("isSkippedMoment");
163
- }
164
- });
165
- });
166
- }
167
- // method: logout
168
- logout(hint) {
169
- if (!__classPrivateFieldGet(this, _GoogleAuth_google, "f"))
170
- return;
171
- const client = __classPrivateFieldGet(this, _GoogleAuth_google, "f").accounts.id;
172
- client.disableAutoSelect();
173
- client.cancel();
174
- client.revoke(hint, () => { });
175
- __classPrivateFieldSet(this, _GoogleAuth_initialized, false, "f");
176
- }
177
- }
178
- _GoogleAuth_config = new WeakMap(), _GoogleAuth_options = new WeakMap(), _GoogleAuth_google = new WeakMap(), _GoogleAuth_initialized = new WeakMap();