From 60d1ca65b47be86b838b825dc9b2ff27f158c3e2 Mon Sep 17 00:00:00 2001 From: Arda Satata Date: Sat, 9 Nov 2024 08:58:57 +0900 Subject: [PATCH 1/8] WIP: add expo plugins --- package.json | 2 + yarn.lock | 310 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 311 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 680eef6..9276ae4 100755 --- a/package.json +++ b/package.json @@ -34,10 +34,12 @@ "test:ts": "tsc --noEmit" }, "peerDependencies": { + "@expo/config-plugins": "^8.0.10", "react": "^16.0", "react-native": ">=0.61.1" }, "devDependencies": { + "@expo/config-plugins": "^8.0.10", "@react-native-community/eslint-config": "0.0.5", "@types/react-native": "0.60.25", "@typescript-eslint/eslint-plugin": "2.12.0", diff --git a/yarn.lock b/yarn.lock index 1114d0c..3d2c284 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9,6 +9,13 @@ dependencies: "@babel/highlight" "^7.0.0" +"@babel/code-frame@~7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" + integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== + dependencies: + "@babel/highlight" "^7.10.4" + "@babel/generator@^7.7.4": version "7.7.4" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.7.4.tgz#db651e2840ca9aa66f327dcec1dc5f5fa9611369" @@ -42,6 +49,11 @@ dependencies: "@babel/types" "^7.7.4" +"@babel/helper-validator-identifier@^7.25.9": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz#24b64e2c3ec7cd3b3c547729b8d16871f22cbdc7" + integrity sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ== + "@babel/highlight@^7.0.0": version "7.5.0" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.5.0.tgz#56d11312bd9248fa619591d02472be6e8cb32540" @@ -51,6 +63,16 @@ esutils "^2.0.2" js-tokens "^4.0.0" +"@babel/highlight@^7.10.4": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.25.9.tgz#8141ce68fc73757946f983b343f1231f4691acc6" + integrity sha512-llL88JShoCsth8fF8R4SJnIn+WLvR6ccFxu1H3FlMhDontdcmZWf2HgIZ7AIqV3Xcck1idlohrN4EUBQz6klbw== + dependencies: + "@babel/helper-validator-identifier" "^7.25.9" + chalk "^2.4.2" + js-tokens "^4.0.0" + picocolors "^1.0.0" + "@babel/parser@^7.0.0", "@babel/parser@^7.7.4": version "7.7.5" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.5.tgz#cbf45321619ac12d83363fcf9c94bb67fa646d71" @@ -89,6 +111,55 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" +"@expo/config-plugins@^8.0.10": + version "8.0.10" + resolved "https://registry.yarnpkg.com/@expo/config-plugins/-/config-plugins-8.0.10.tgz#5cda076f38bc04675cb42d8acdd23d6e460a62de" + integrity sha512-KG1fnSKRmsudPU9BWkl59PyE0byrE2HTnqbOrgwr2FAhqh7tfr9nRs6A9oLS/ntpGzmFxccTEcsV0L4apsuxxg== + dependencies: + "@expo/config-types" "^51.0.3" + "@expo/json-file" "~8.3.0" + "@expo/plist" "^0.1.0" + "@expo/sdk-runtime-versions" "^1.0.0" + chalk "^4.1.2" + debug "^4.3.1" + find-up "~5.0.0" + getenv "^1.0.0" + glob "7.1.6" + resolve-from "^5.0.0" + semver "^7.5.4" + slash "^3.0.0" + slugify "^1.6.6" + xcode "^3.0.1" + xml2js "0.6.0" + +"@expo/config-types@^51.0.3": + version "51.0.3" + resolved "https://registry.yarnpkg.com/@expo/config-types/-/config-types-51.0.3.tgz#520bdce5fd75f9d234fd81bd0347443086419450" + integrity sha512-hMfuq++b8VySb+m9uNNrlpbvGxYc8OcFCUX9yTmi9tlx6A4k8SDabWFBgmnr4ao3wEArvWrtUQIfQCVtPRdpKA== + +"@expo/json-file@~8.3.0": + version "8.3.3" + resolved "https://registry.yarnpkg.com/@expo/json-file/-/json-file-8.3.3.tgz#7926e3592f76030ce63d6b1308ac8f5d4d9341f4" + integrity sha512-eZ5dld9AD0PrVRiIWpRkm5aIoWBw3kAyd8VkuWEy92sEthBKDDDHAnK2a0dw0Eil6j7rK7lS/Qaq/Zzngv2h5A== + dependencies: + "@babel/code-frame" "~7.10.4" + json5 "^2.2.2" + write-file-atomic "^2.3.0" + +"@expo/plist@^0.1.0": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@expo/plist/-/plist-0.1.3.tgz#b4fbee2c4f7a88512a4853d85319f4d95713c529" + integrity sha512-GW/7hVlAylYg1tUrEASclw1MMk9FP4ZwyFAY/SUTJIhPDQHtfOlXREyWV3hhrHdX/K+pS73GNgdfT6E/e+kBbg== + dependencies: + "@xmldom/xmldom" "~0.7.7" + base64-js "^1.2.3" + xmlbuilder "^14.0.0" + +"@expo/sdk-runtime-versions@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@expo/sdk-runtime-versions/-/sdk-runtime-versions-1.0.0.tgz#d7ebd21b19f1c6b0395e50d78da4416941c57f7c" + integrity sha512-Doz2bfiPndXYFPMRwPyGa1k5QaKDVpY806UJj570epIiMzWaYyCtobasyfC++qfIXVb5Ocy7r3tP9d62hAQ7IQ== + "@react-native-community/eslint-config@0.0.5": version "0.0.5" resolved "https://registry.yarnpkg.com/@react-native-community/eslint-config/-/eslint-config-0.0.5.tgz#584f6493258202a57efc22e7be66966e43832795" @@ -218,6 +289,16 @@ semver "^6.3.0" tsutils "^3.17.1" +"@xmldom/xmldom@^0.8.8": + version "0.8.10" + resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.8.10.tgz#a1337ca426aa61cef9fe15b5b28e340a72f6fa99" + integrity sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw== + +"@xmldom/xmldom@~0.7.7": + version "0.7.13" + resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.7.13.tgz#ff34942667a4e19a9f4a0996a76814daac364cf3" + integrity sha512-lm2GW5PkosIzccsaZIz7tp8cPADSIlIHWDFTR1N0SzfinhhYgeIQjFMz4rYzanCScr3DqQLeomUDArp6MWKm+g== + acorn-jsx@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.2.0.tgz#4c66069173d6fdd68ed85239fc256226182b2ebe" @@ -260,6 +341,13 @@ ansi-styles@^3.2.0, ansi-styles@^3.2.1: dependencies: color-convert "^1.9.0" +ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -297,6 +385,30 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= +base64-js@^1.2.3, base64-js@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +big-integer@1.6.x: + version "1.6.52" + resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.52.tgz#60a887f3047614a8e1bffe5d7173490a97dc8c85" + integrity sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg== + +bplist-creator@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/bplist-creator/-/bplist-creator-0.1.0.tgz#018a2d1b587f769e379ef5519103730f8963ba1e" + integrity sha512-sXaHZicyEEmY86WyueLTQesbeoH/mquvarJaQNbjuOQO+7gbFcDEWqKmcWA4cOTLzFlfgvkiVxolk1k5bBIpmg== + dependencies: + stream-buffers "2.2.x" + +bplist-parser@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/bplist-parser/-/bplist-parser-0.3.1.tgz#e1c90b2ca2a9f9474cc72f6862bbf3fee8341fd1" + integrity sha512-PyJxiNtA5T2PlLIeBot4lbp7rj4OadzjnMZD/G5zuBNt8ei/yCU7+wW0h2bag9vr8c+/WuRWmSxbqAl9hL1rBA== + dependencies: + big-integer "1.6.x" + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -319,6 +431,14 @@ chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.2: escape-string-regexp "^1.0.5" supports-color "^5.3.0" +chalk@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + chardet@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" @@ -343,11 +463,23 @@ color-convert@^1.9.0: dependencies: color-name "1.1.3" +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + color-name@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" @@ -376,6 +508,13 @@ debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: dependencies: ms "^2.1.1" +debug@^4.3.1: + version "4.3.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52" + integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== + dependencies: + ms "^2.1.3" + deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -682,6 +821,14 @@ file-entry-cache@^5.0.1: dependencies: flat-cache "^2.0.1" +find-up@~5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + flat-cache@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" @@ -716,6 +863,11 @@ get-stdin@^6.0.0: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== +getenv@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/getenv/-/getenv-1.0.0.tgz#874f2e7544fbca53c7a4738f37de8605c3fcfc31" + integrity sha512-7yetJWqbS9sbn0vIfliPsFgoXMKn/YMF+Wuiog97x+urnSRRRZ7xB+uVkwGKzRgq9CDFfMQnE9ruL5DHv9c6Xg== + glob-parent@^5.0.0: version "5.1.0" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.0.tgz#5f4c1d1e748d30cd73ad2944b3577a81b081e8c2" @@ -723,7 +875,7 @@ glob-parent@^5.0.0: dependencies: is-glob "^4.0.1" -glob@^7.1.3, glob@^7.1.6: +glob@7.1.6, glob@^7.1.3, glob@^7.1.6: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== @@ -740,11 +892,21 @@ globals@^11.1.0, globals@^11.7.0: resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== +graceful-fs@^4.1.11: + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + has-symbols@^1.0.0, has-symbols@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" @@ -903,6 +1065,11 @@ json-stable-stringify-without-jsonify@^1.0.1: resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= +json5@^2.2.2: + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== + jsx-ast-utils@^2.0.1: version "2.2.3" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.2.3.tgz#8a9364e402448a3ce7f14d357738310d9248054f" @@ -919,6 +1086,13 @@ levn@^0.3.0, levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + lodash.unescape@4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c" @@ -965,6 +1139,11 @@ ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +ms@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + mute-stream@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" @@ -1046,6 +1225,20 @@ os-tmpdir@~1.0.2: resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -1053,6 +1246,11 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -1068,6 +1266,20 @@ path-parse@^1.0.6: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== +picocolors@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" + integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== + +plist@^3.0.5: + version "3.1.0" + resolved "https://registry.yarnpkg.com/plist/-/plist-3.1.0.tgz#797a516a93e62f5bde55e0b9cc9c967f860893c9" + integrity sha512-uysumyrvkUX0rX/dEVqt8gC3sTBzd4zoWfLeS29nb53imdaXVvLINYXTI2GNqzaMuvacNx4uJQ8+b3zXR0pkgQ== + dependencies: + "@xmldom/xmldom" "^0.8.8" + base64-js "^1.5.1" + xmlbuilder "^15.1.1" + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -1134,6 +1346,11 @@ resolve-from@^4.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== +resolve-from@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" + integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== + resolve@^1.9.0: version "1.14.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.14.0.tgz#6d14c6f9db9f8002071332b600039abf82053f64" @@ -1175,6 +1392,11 @@ rxjs@^6.4.0: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== +sax@>=0.6.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.4.1.tgz#44cc8988377f126304d3b3fc1010c733b929ef0f" + integrity sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg== + semver@5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" @@ -1190,6 +1412,11 @@ semver@^6.1.2, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== +semver@^7.5.4: + version "7.6.3" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" + integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== + shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" @@ -1207,6 +1434,20 @@ signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= +simple-plist@^1.1.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/simple-plist/-/simple-plist-1.3.1.tgz#16e1d8f62c6c9b691b8383127663d834112fb017" + integrity sha512-iMSw5i0XseMnrhtIzRb7XpQEXepa9xhWxGUojHBL43SIpQuDQkh3Wpy67ZbDzZVr6EKxvwVChnVpdl8hEVLDiw== + dependencies: + bplist-creator "0.1.0" + bplist-parser "0.3.1" + plist "^3.0.5" + +slash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" + integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== + slice-ansi@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" @@ -1216,6 +1457,11 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" +slugify@^1.6.6: + version "1.6.6" + resolved "https://registry.yarnpkg.com/slugify/-/slugify-1.6.6.tgz#2d4ac0eacb47add6af9e04d3be79319cbcc7924b" + integrity sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw== + source-map@^0.5.0: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -1226,6 +1472,11 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= +stream-buffers@2.2.x: + version "2.2.0" + resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4" + integrity sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg== + string-width@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -1285,6 +1536,13 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + table@^5.2.3: version "5.4.6" resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" @@ -1353,6 +1611,11 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" +uuid@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b" + integrity sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg== + v8-compile-cache@^2.0.3: version "2.1.0" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e" @@ -1375,9 +1638,54 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= +write-file-atomic@^2.3.0: + version "2.4.3" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.3.tgz#1fd2e9ae1df3e75b8d8c367443c692d4ca81f481" + integrity sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ== + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + signal-exit "^3.0.2" + write@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== dependencies: mkdirp "^0.5.1" + +xcode@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/xcode/-/xcode-3.0.1.tgz#3efb62aac641ab2c702458f9a0302696146aa53c" + integrity sha512-kCz5k7J7XbJtjABOvkc5lJmkiDh8VhjVCGNiqdKCscmVpdVUpEAyXv1xmCLkQJ5dsHqx3IPO4XW+NTDhU/fatA== + dependencies: + simple-plist "^1.1.0" + uuid "^7.0.3" + +xml2js@0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.6.0.tgz#07afc447a97d2bd6507a1f76eeadddb09f7a8282" + integrity sha512-eLTh0kA8uHceqesPqSE+VvO1CDDJWMwlQfB6LuN6T8w6MaDJ8Txm8P7s5cHD0miF0V+GGTZrDQfxPZQVsur33w== + dependencies: + sax ">=0.6.0" + xmlbuilder "~11.0.0" + +xmlbuilder@^14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-14.0.0.tgz#876b5aec4f05ffd5feb97b0a871c855d16fbeb8c" + integrity sha512-ts+B2rSe4fIckR6iquDjsKbQFK2NlUk6iG5nf14mDEyldgoc2nEKZ3jZWMPTxGQwVgToSjt6VGIho1H8/fNFTg== + +xmlbuilder@^15.1.1: + version "15.1.1" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-15.1.1.tgz#9dcdce49eea66d8d10b42cae94a79c3c8d0c2ec5" + integrity sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg== + +xmlbuilder@~11.0.0: + version "11.0.1" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3" + integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA== + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== From de9c34f1aabe010c315cb284da4aa33e121ef133 Mon Sep 17 00:00:00 2001 From: Arda Satata Date: Sat, 9 Nov 2024 08:59:15 +0900 Subject: [PATCH 2/8] remove "kotlin-android-extensions" --- android/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index d55cb58..c6c6bc0 100755 --- a/android/build.gradle +++ b/android/build.gradle @@ -22,7 +22,6 @@ repositories { apply plugin: "com.android.library" apply plugin: "kotlin-android" -apply plugin: "kotlin-android-extensions" def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback From 4ee944358d08961a30e77844a77886b1c37f1f91 Mon Sep 17 00:00:00 2001 From: Arda Satata Date: Sat, 9 Nov 2024 08:59:24 +0900 Subject: [PATCH 3/8] wip add template --- plugins/ios/appDelegate_template.m | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 plugins/ios/appDelegate_template.m diff --git a/plugins/ios/appDelegate_template.m b/plugins/ios/appDelegate_template.m new file mode 100644 index 0000000..c0209cd --- /dev/null +++ b/plugins/ios/appDelegate_template.m @@ -0,0 +1,73 @@ +#import "AppDelegate.h" +// Line-SDK-RN +#import "RNLine-Swift.h" +#import + +#import +#import + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ +// @generated begin @react-native-firebase/app-didFinishLaunchingWithOptions - expo prebuild (DO NOT MODIFY) sync-ecd111c37e49fdd1ed6354203cd6b1e2a38cccda +[FIRApp configure]; +// @generated end @react-native-firebase/app-didFinishLaunchingWithOptions + self.moduleName = @"main"; + + // You can add your custom initial props in the dictionary below. + // They will be passed down to the ViewController used by React Native. + self.initialProps = @{}; + + // Line-SDK-RN YOUR_CHANNEL_ID changed + [LineLogin setupWithChannelID:@"CHANNEL_ID_REPLACE" universalLinkURL:nil]; + + return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} + +- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge +{ + return [self bundleURL]; +} + +- (NSURL *)bundleURL +{ +#if DEBUG + return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@".expo/.virtual-metro-entry"]; +#else + return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; +#endif +} + + +// Linking API +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { + return [LineLogin application:application open:url options:options] || [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options]; +} + +// Universal Links +- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler { + BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; + BOOL handledLine = [LineLogin application:application continue:userActivity restorationHandler:restorationHandler]; + return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || handledLine || result; +} + +// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries +- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken +{ + return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; +} + +// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries +- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error +{ + return [super application:application didFailToRegisterForRemoteNotificationsWithError:error]; +} + +// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries +- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler +{ + return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; +} + +@end From 165efa9ab9747cf0a17daec2bc311d9108facce5 Mon Sep 17 00:00:00 2001 From: Arda Satata Date: Sat, 9 Nov 2024 08:59:36 +0900 Subject: [PATCH 4/8] add android constants --- plugins/android/constants.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 plugins/android/constants.js diff --git a/plugins/android/constants.js b/plugins/android/constants.js new file mode 100644 index 0000000..99cb1d7 --- /dev/null +++ b/plugins/android/constants.js @@ -0,0 +1,8 @@ +let lineImplementation = "implementation 'com.linecorp.linesdk:linesdk:5.8.0'" + +let compileOptions = `compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + }` + +module.exports = { compileOptions, lineImplementation } From fbe971ce7e9f3e406dc22f78c379ab6e32fa2357 Mon Sep 17 00:00:00 2001 From: Arda Satata Date: Sat, 9 Nov 2024 09:00:06 +0900 Subject: [PATCH 5/8] wip add app plugins --- app.plugin.js | 1 + plugins/ios/withLinePluginConfig.js | 84 +++++++++ plugins/withLineSDK.js | 272 ++++++++++++++++++++++++++++ 3 files changed, 357 insertions(+) create mode 100644 app.plugin.js create mode 100644 plugins/ios/withLinePluginConfig.js create mode 100644 plugins/withLineSDK.js diff --git a/app.plugin.js b/app.plugin.js new file mode 100644 index 0000000..e746b05 --- /dev/null +++ b/app.plugin.js @@ -0,0 +1 @@ +module.exports = require('./plugins/withLineSDK'); \ No newline at end of file diff --git a/plugins/ios/withLinePluginConfig.js b/plugins/ios/withLinePluginConfig.js new file mode 100644 index 0000000..accd32b --- /dev/null +++ b/plugins/ios/withLinePluginConfig.js @@ -0,0 +1,84 @@ +const { withAppDelegate, withInfoPlist } = require('@expo/config-plugins'); + +const withAppDelegateMod = (config, { channelId }) => { + return withAppDelegate( + config, + async (config) => { + console.log(config) + const appDelegate = config.modResults; + + const contents = appDelegate.contents; + // this is the code generated by React native inside didFinishLaunchingWithOptions function; it might change in the future, look for your own anchor then + const injectionIndex = contents.indexOf('self.initialProps = @{};'); + + // console.log('withAppDelegateMod') + // console.log(contents) + // console.log(injectionIndex) + + appDelegate.contents = + contents.substring(0, injectionIndex) + + `\n [LineLogin setupWithChannelID:@${channelId} universalLinkURL:nil]; \n` + + contents.substring(injectionIndex); + + return config; + } + ); +}; + + +function addLineLoginCode(appDelegate) { + if (appDelegate.language === 'objc') { + // Ensure the import statement is present + if (!appDelegate.contents.includes('#import "RNLine-Swift.h"')) { + appDelegate.contents = `#import "RNLine-Swift.h"\n` + appDelegate.contents; + } + + // Inject the `didFinishLaunchingWithOptions` method if it doesn't exist or modify it + if (!appDelegate.contents.includes('[LineLogin setupWithChannelID')) { + const didFinishLaunchingCode = ` +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + [LineLogin setupWithChannelID:@"YOUR_CHANNEL_ID" universalLinkURL:nil]; + return YES; +} +`; + appDelegate.contents = appDelegate.contents.replace( + '- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions', + didFinishLaunchingCode + ); + } + + // Inject the URL handling methods + const urlHandlingMethods = ` +- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options +{ + return [LineLogin application:app open:url options:options]; +} + +- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray> * _Nullable))restorationHandler +{ + BOOL handledLine = [LineLogin application:application continue:userActivity restorationHandler:restorationHandler]; + return handledLine; +} +`; + + if (!appDelegate.contents.includes('[LineLogin application:')) { + appDelegate.contents += urlHandlingMethods; + } + } + + return appDelegate; +} + +const withLineLogin = (config, props) => { + config = withAppDelegateMod(config, props) + // config = withAppDelegate(config, (config) => { + // config.modResults = addLineLoginCode(config.modResults); + // return config; + // }); + // + // // Optionally, modify Info.plist if needed + return config; +}; + +module.exports = { withLineLogin }; diff --git a/plugins/withLineSDK.js b/plugins/withLineSDK.js new file mode 100644 index 0000000..3137f2b --- /dev/null +++ b/plugins/withLineSDK.js @@ -0,0 +1,272 @@ +const { + withDangerousMod, + withPlugins, + IOSConfig, + withAppBuildGradle, + WarningAggregator, + withInfoPlist, + withStringsXml, + withAndroidManifest, +} = require('@expo/config-plugins') +const { resolve } = require('path') +const { readFileSync, writeFileSync, promises } = require('fs') +const { withLineLogin } = require('./ios/withLinePluginConfig') + +// Android +const { lineImplementation, compileOptions } = require('./android/constants') + +// iOS +const lineCFBundleURLSchemes = { + CFBundleURLSchemes: ['line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)'], +} + +const lineLSApplicationQueriesSchemes = 'lineauth2' + +const CHANNEL_ID_REPLACE = 'CHANNEL_ID_REPLACE' + +// iOS mods +// Pass `` to specify that this plugin requires a string property. +function withCustomPlist(config, { channelId }) { + return withInfoPlist(config, config => { + config.modResults.CFBundleURLTypes?.push(lineCFBundleURLSchemes) + + let LSScheme = config.modResults.LSApplicationQueriesSchemes + + if (!LSScheme) { + config.modResults.LSApplicationQueriesSchemes = [ + lineLSApplicationQueriesSchemes, + ] + } else { + if ( + config.modResults.LSApplicationQueriesSchemes.find( + value => value === lineLSApplicationQueriesSchemes, + ) + ) { + // Do nothing + } else { + config.modResults.LSApplicationQueriesSchemes = [ + lineLSApplicationQueriesSchemes, + ] + } + } + + config.modResults.LineSDKConfig = { + ChannelID: channelId, + } + + return config + }) +} + +function withForcedAppDelegate(config, { channelId }) { + return withDangerousMod(config, [ + 'ios', + async config => { + const fileInfo = IOSConfig.Paths.getAppDelegate( + config.modRequest.projectRoot, + ) + + // const envProfile = config.extra.env.RELEASE_STAGE ?? 'development' + + let { path } = fileInfo + + const { projectRoot } = config.modRequest + + // V1 + // const newAppDelegateFile = resolve(projectRoot, 'plugins/line-sdk/ios/', envProfile , 'appDelegate.m'); + // V2 + const newAppDelegateFile = resolve( + projectRoot, + 'plugins/line-sdk/ios/', + 'appDelegate_template.m', + ) + + // V1 + const newAppDelegate = readFileSync(newAppDelegateFile, 'utf8') + + // V2 + const replacedAppDelegate = newAppDelegate.replace( + CHANNEL_ID_REPLACE, + channelId, + ) + + const oldAppDelegateFile = resolve(path) + + await promises.writeFile(oldAppDelegateFile, replacedAppDelegate) + + return config + }, + ]) +} + +function withLinePod(config) { + return withDangerousMod(config, [ + 'ios', + cfg => { + const { platformProjectRoot } = cfg.modRequest + const podfile = resolve(platformProjectRoot, 'Podfile') + const contents = readFileSync(podfile, 'utf-8') + const lines = contents.split('\n') + const index = lines.findIndex(line => /\s+use_expo_modules!/.test(line)) + + writeFileSync( + podfile, + [ + ...lines.slice(0, index), + ` pod 'LineSDKSwift', '~> 5.0'`, + ...lines.slice(index), + ].join('\n'), + ) + + return cfg + }, + ]) +} + +// Android mods +// https://developers.line.biz/en/docs/android-sdk/integrate-line-login/#import-library-into-your-project +function applyLineImplementation(appBuildGradle) { + // TODO: Find a more stable solution for this + if (!appBuildGradle.includes(lineImplementation)) { + return appBuildGradle.replace( + /dependencies\s?{/, + `dependencies { + ${lineImplementation}`, + ) + } else { + return appBuildGradle + } +} + +function applyMavenRepositories(appBuildGradle) { + // TODO: Find a more stable solution for this + if ( + appBuildGradle.includes(`repositories { + mavenCentral()`) + ) { + return appBuildGradle + } else { + return appBuildGradle + `\nrepositories {\nmavenCentral()\n}` + } +} + +// https://developers.line.biz/en/docs/android-sdk/integrate-line-login/#add-android-compilation-options +function applyCompileOptions(appBuildGradle) { + // TODO: Find a more stable solution for this + if (!appBuildGradle.includes(compileOptions)) { + return appBuildGradle.replace( + /android\s?{/, + `android { + ${compileOptions}`, + ) + } else { + return appBuildGradle + } +} + +function withApplyLineImplementation(config) { + return withAppBuildGradle(config, config => { + if (config.modResults.language === 'groovy') { + config.modResults.contents = applyLineImplementation( + config.modResults.contents, + ) + } else { + WarningAggregator.addWarningAndroid( + 'react-native-line', + `Cannot automatically configure app build.gradle if it's not groovy`, + ) + } + return config + }) +} + +function withApplyMaven(config) { + return withAppBuildGradle(config, config => { + if (config.modResults.language === 'groovy') { + config.modResults.contents = applyMavenRepositories( + config.modResults.contents, + ) + } else { + WarningAggregator.addWarningAndroid( + 'react-native-line', + `Cannot automatically configure app build.gradle if it's not groovy`, + ) + } + return config + }) +} + +function withApplyAndroidCompileOptions(config) { + return withAppBuildGradle(config, config => { + if (config.modResults.language === 'groovy') { + config.modResults.contents = applyCompileOptions( + config.modResults.contents, + ) + } else { + WarningAggregator.addWarningAndroid( + 'react-native-line', + `Cannot automatically configure app build.gradle if it's not groovy`, + ) + } + return config + }) +} + +function withLineChannelId(config, { channelId }) { + return withStringsXml(config, config => { + let strings = config.modResults.resources.string + + let line_channel_id = strings.findIndex( + value => value.$.name === 'line_channel_id', + ) + + if (line_channel_id !== -1) { + // Dp nothing + return config + } else { + strings.push({ + $: { + name: 'line_channel_id', + translatable: 'false', + }, + _: channelId.toString(), + }) + } + + return config + }) +} + +function withLineManifest(config) { + return withAndroidManifest(config, config => { + let manifest = config.modResults.manifest + let application = manifest.application + + manifest.$['xmlns:tools'] = 'http://schemas.android.com/tools' + application[0].$['tools:replace'] = 'android:allowBackup' + + return config + }) +} + +function withLineSDK(config, props) { + if (!props?.channelId) { + throw Error('Please specify channelId') + } + return withPlugins(config, [ + // iOS + withLinePod, + [withCustomPlist, props], + [withLineLogin, props], + // [withForcedAppDelegate, props], + + // Android + withApplyLineImplementation, + withApplyMaven, + withLineManifest, + withApplyAndroidCompileOptions, + [withLineChannelId, props], + ]) +} + +module.exports = withLineSDK From 86a7d7e677811870aba9f3dc038ca0902764c644 Mon Sep 17 00:00:00 2001 From: Arda Satata Date: Sun, 10 Nov 2024 21:50:23 +0900 Subject: [PATCH 6/8] tidy up android --- .../android/withApplyAndroidCompileOptions.js | 37 +++++ .../android/withApplyLineImplementation.js | 38 +++++ plugins/android/withApplyMaven.js | 34 +++++ plugins/android/withLineChannelId.js | 28 ++++ plugins/android/withLineManifest.js | 15 ++ plugins/withLineSDK.js | 136 +----------------- 6 files changed, 157 insertions(+), 131 deletions(-) create mode 100644 plugins/android/withApplyAndroidCompileOptions.js create mode 100644 plugins/android/withApplyLineImplementation.js create mode 100644 plugins/android/withApplyMaven.js create mode 100644 plugins/android/withLineChannelId.js create mode 100644 plugins/android/withLineManifest.js diff --git a/plugins/android/withApplyAndroidCompileOptions.js b/plugins/android/withApplyAndroidCompileOptions.js new file mode 100644 index 0000000..f5447e9 --- /dev/null +++ b/plugins/android/withApplyAndroidCompileOptions.js @@ -0,0 +1,37 @@ +const { + withAppBuildGradle, + WarningAggregator, +} = require('@expo/config-plugins') +const { compileOptions } = require('./constants') + +// https://developers.line.biz/en/docs/android-sdk/integrate-line-login/#add-android-compilation-options +function applyCompileOptions(appBuildGradle) { + // TODO: Find a more stable solution for this + if (!appBuildGradle.includes(compileOptions)) { + return appBuildGradle.replace( + /android\s?{/, + `android { + ${compileOptions}`, + ) + } else { + return appBuildGradle + } +} + +function withApplyAndroidCompileOptions(config) { + return withAppBuildGradle(config, config => { + if (config.modResults.language === 'groovy') { + config.modResults.contents = applyCompileOptions( + config.modResults.contents, + ) + } else { + WarningAggregator.addWarningAndroid( + 'react-native-line', + `Cannot automatically configure app build.gradle if it's not groovy`, + ) + } + return config + }) +} + +module.exports = withApplyAndroidCompileOptions diff --git a/plugins/android/withApplyLineImplementation.js b/plugins/android/withApplyLineImplementation.js new file mode 100644 index 0000000..cc36de2 --- /dev/null +++ b/plugins/android/withApplyLineImplementation.js @@ -0,0 +1,38 @@ +const { + withAppBuildGradle, + WarningAggregator, +} = require('@expo/config-plugins') +const { lineImplementation } = require('./constants') + +// Android mods +// https://developers.line.biz/en/docs/android-sdk/integrate-line-login/#import-library-into-your-project +function applyLineImplementation(appBuildGradle) { + // TODO: Find a more stable solution for this + if (!appBuildGradle.includes(lineImplementation)) { + return appBuildGradle.replace( + /dependencies\s?{/, + `dependencies { + ${lineImplementation}`, + ) + } else { + return appBuildGradle + } +} + +function withApplyLineImplementation(config) { + return withAppBuildGradle(config, config => { + if (config.modResults.language === 'groovy') { + config.modResults.contents = applyLineImplementation( + config.modResults.contents, + ) + } else { + WarningAggregator.addWarningAndroid( + 'react-native-line', + `Cannot automatically configure app build.gradle if it's not groovy`, + ) + } + return config + }) +} + +module.exports = withApplyLineImplementation diff --git a/plugins/android/withApplyMaven.js b/plugins/android/withApplyMaven.js new file mode 100644 index 0000000..1aeebeb --- /dev/null +++ b/plugins/android/withApplyMaven.js @@ -0,0 +1,34 @@ +const { + withAppBuildGradle, + WarningAggregator, +} = require('@expo/config-plugins') + +function applyMavenRepositories(appBuildGradle) { + // TODO: Find a more stable solution for this + if ( + appBuildGradle.includes(`repositories { + mavenCentral()`) + ) { + return appBuildGradle + } else { + return appBuildGradle + `\nrepositories {\nmavenCentral()\n}` + } +} + +function withApplyMaven(config) { + return withAppBuildGradle(config, config => { + if (config.modResults.language === 'groovy') { + config.modResults.contents = applyMavenRepositories( + config.modResults.contents, + ) + } else { + WarningAggregator.addWarningAndroid( + 'react-native-line', + `Cannot automatically configure app build.gradle if it's not groovy`, + ) + } + return config + }) +} + +module.exports = withApplyMaven diff --git a/plugins/android/withLineChannelId.js b/plugins/android/withLineChannelId.js new file mode 100644 index 0000000..1de7344 --- /dev/null +++ b/plugins/android/withLineChannelId.js @@ -0,0 +1,28 @@ +const { withStringsXml } = require('@expo/config-plugins') + +function withLineChannelId(config, { channelId }) { + return withStringsXml(config, config => { + let strings = config.modResults.resources.string + + let line_channel_id = strings.findIndex( + value => value.$.name === 'line_channel_id', + ) + + if (line_channel_id !== -1) { + // Dp nothing + return config + } else { + strings.push({ + $: { + name: 'line_channel_id', + translatable: 'false', + }, + _: channelId.toString(), + }) + } + + return config + }) +} + +module.exports = withLineChannelId diff --git a/plugins/android/withLineManifest.js b/plugins/android/withLineManifest.js new file mode 100644 index 0000000..41f3077 --- /dev/null +++ b/plugins/android/withLineManifest.js @@ -0,0 +1,15 @@ +const { withAndroidManifest } = require('@expo/config-plugins') + +function withLineManifest(config) { + return withAndroidManifest(config, config => { + let manifest = config.modResults.manifest + let application = manifest.application + + manifest.$['xmlns:tools'] = 'http://schemas.android.com/tools' + application[0].$['tools:replace'] = 'android:allowBackup' + + return config + }) +} + +module.exports = withLineManifest diff --git a/plugins/withLineSDK.js b/plugins/withLineSDK.js index 3137f2b..ea73ce6 100644 --- a/plugins/withLineSDK.js +++ b/plugins/withLineSDK.js @@ -2,18 +2,18 @@ const { withDangerousMod, withPlugins, IOSConfig, - withAppBuildGradle, - WarningAggregator, withInfoPlist, - withStringsXml, - withAndroidManifest, } = require('@expo/config-plugins') const { resolve } = require('path') const { readFileSync, writeFileSync, promises } = require('fs') const { withLineLogin } = require('./ios/withLinePluginConfig') // Android -const { lineImplementation, compileOptions } = require('./android/constants') +const withApplyLineImplementation = require('./android/withApplyLineImplementation') +const withApplyMaven = require('./android/withApplyMaven') +const withLineManifest = require('./android/withLineManifest') +const withApplyAndroidCompileOptions = require('./android/withApplyAndroidCompileOptions') +const withLineChannelId = require('./android/withLineChannelId') // iOS const lineCFBundleURLSchemes = { @@ -123,132 +123,6 @@ function withLinePod(config) { ]) } -// Android mods -// https://developers.line.biz/en/docs/android-sdk/integrate-line-login/#import-library-into-your-project -function applyLineImplementation(appBuildGradle) { - // TODO: Find a more stable solution for this - if (!appBuildGradle.includes(lineImplementation)) { - return appBuildGradle.replace( - /dependencies\s?{/, - `dependencies { - ${lineImplementation}`, - ) - } else { - return appBuildGradle - } -} - -function applyMavenRepositories(appBuildGradle) { - // TODO: Find a more stable solution for this - if ( - appBuildGradle.includes(`repositories { - mavenCentral()`) - ) { - return appBuildGradle - } else { - return appBuildGradle + `\nrepositories {\nmavenCentral()\n}` - } -} - -// https://developers.line.biz/en/docs/android-sdk/integrate-line-login/#add-android-compilation-options -function applyCompileOptions(appBuildGradle) { - // TODO: Find a more stable solution for this - if (!appBuildGradle.includes(compileOptions)) { - return appBuildGradle.replace( - /android\s?{/, - `android { - ${compileOptions}`, - ) - } else { - return appBuildGradle - } -} - -function withApplyLineImplementation(config) { - return withAppBuildGradle(config, config => { - if (config.modResults.language === 'groovy') { - config.modResults.contents = applyLineImplementation( - config.modResults.contents, - ) - } else { - WarningAggregator.addWarningAndroid( - 'react-native-line', - `Cannot automatically configure app build.gradle if it's not groovy`, - ) - } - return config - }) -} - -function withApplyMaven(config) { - return withAppBuildGradle(config, config => { - if (config.modResults.language === 'groovy') { - config.modResults.contents = applyMavenRepositories( - config.modResults.contents, - ) - } else { - WarningAggregator.addWarningAndroid( - 'react-native-line', - `Cannot automatically configure app build.gradle if it's not groovy`, - ) - } - return config - }) -} - -function withApplyAndroidCompileOptions(config) { - return withAppBuildGradle(config, config => { - if (config.modResults.language === 'groovy') { - config.modResults.contents = applyCompileOptions( - config.modResults.contents, - ) - } else { - WarningAggregator.addWarningAndroid( - 'react-native-line', - `Cannot automatically configure app build.gradle if it's not groovy`, - ) - } - return config - }) -} - -function withLineChannelId(config, { channelId }) { - return withStringsXml(config, config => { - let strings = config.modResults.resources.string - - let line_channel_id = strings.findIndex( - value => value.$.name === 'line_channel_id', - ) - - if (line_channel_id !== -1) { - // Dp nothing - return config - } else { - strings.push({ - $: { - name: 'line_channel_id', - translatable: 'false', - }, - _: channelId.toString(), - }) - } - - return config - }) -} - -function withLineManifest(config) { - return withAndroidManifest(config, config => { - let manifest = config.modResults.manifest - let application = manifest.application - - manifest.$['xmlns:tools'] = 'http://schemas.android.com/tools' - application[0].$['tools:replace'] = 'android:allowBackup' - - return config - }) -} - function withLineSDK(config, props) { if (!props?.channelId) { throw Error('Please specify channelId') From f9c4bc319230a4ab9589eb0163840e690f04bab7 Mon Sep 17 00:00:00 2001 From: Arda Satata Date: Mon, 11 Nov 2024 02:38:20 +0900 Subject: [PATCH 7/8] add ios implementation --- plugins/ios/withAppDelegateMod.js | 80 ++++++++++++++++++ plugins/ios/withCustomPlist.js | 44 ++++++++++ plugins/ios/withLinePluginConfig.js | 84 ------------------- plugins/ios/withLinePod.js | 29 +++++++ plugins/withLineSDK.js | 122 ++-------------------------- 5 files changed, 158 insertions(+), 201 deletions(-) create mode 100644 plugins/ios/withAppDelegateMod.js create mode 100644 plugins/ios/withCustomPlist.js delete mode 100644 plugins/ios/withLinePluginConfig.js create mode 100644 plugins/ios/withLinePod.js diff --git a/plugins/ios/withAppDelegateMod.js b/plugins/ios/withAppDelegateMod.js new file mode 100644 index 0000000..960f0e7 --- /dev/null +++ b/plugins/ios/withAppDelegateMod.js @@ -0,0 +1,80 @@ +const { withAppDelegate } = require('@expo/config-plugins'); +const { mergeContents } = require('@expo/config-plugins/build/utils/generateCode') + +/* +* mergeContents doesn't work with offset <1 to put value before anchor, +* hence I made this utility function, probably unstable, use at your own risk +* */ +function injectIntoContents(contents, searchAnchor, injection) { + const openUrlInjectionIndex = contents.indexOf(searchAnchor); + + // Check if the anchor was found; if not, return contents as is + if (openUrlInjectionIndex === -1) { + console.warn('Search anchor not found in contents.'); + return contents; + } + + // Calculate the insertion point + const anchorIndex = openUrlInjectionIndex + searchAnchor.length; + + // Inject the specified code at the appropriate location + return ( + contents.substring(0, anchorIndex) + + injection + + contents.substring(anchorIndex) + ); +} + +const withAppDelegateMod = (config, { channelId }) => { + return withAppDelegate( + config, + async (config) => { + const appDelegate = config.modResults; + + const withHeader = mergeContents({ + anchor: /#import "AppDelegate\.h"/, + comment: "//", + newSrc: '#import "RNLine-Swift.h"', + offset: 1, + src: appDelegate.contents, + tag: "line-header", + }); + + const withChannelIdInjection = mergeContents({ + anchor: "self.initialProps = @{};", + comment: "//", + newSrc: `[LineLogin setupWithChannelID:@"${channelId}" universalLinkURL:nil];`, + offset: 1, + src: withHeader.contents, + tag: "line-channel-id", + }); + + // + // Handle redirection back to the app from Line + // + withChannelIdInjection.contents = injectIntoContents(withChannelIdInjection.contents, `- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { + return`,` [LineLogin application:application open:url options:options] ||`) + + const withContinueUserActivityVariableInjection = mergeContents({ + anchor: "restorationHandler:restorationHandler];", + comment: "//", + newSrc: `BOOL handledLine = [LineLogin application:application continue:userActivity restorationHandler:restorationHandler];`, + offset: 1, + src: withChannelIdInjection.contents, + tag: "line-continue-user-activity-variable-injection", + }); + + withChannelIdInjection.contents = injectIntoContents(withContinueUserActivityVariableInjection.contents,`] || result`, ` || handledLine` ) + + return { + ...config, + modResults: { + ...appDelegate, + contents: withChannelIdInjection.contents + } + }; + } + ); +}; + +module.exports = withAppDelegateMod diff --git a/plugins/ios/withCustomPlist.js b/plugins/ios/withCustomPlist.js new file mode 100644 index 0000000..15e092d --- /dev/null +++ b/plugins/ios/withCustomPlist.js @@ -0,0 +1,44 @@ +// iOS mods +// Pass `` to specify that this plugin requires a string property. +const { withInfoPlist } = require('@expo/config-plugins') + +// iOS +const lineCFBundleURLSchemes = { + CFBundleURLSchemes: ['line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)'], +} + +const lineLSApplicationQueriesSchemes = 'lineauth2' + +function withCustomPlist(config, { channelId }) { + return withInfoPlist(config, config => { + config.modResults.CFBundleURLTypes?.push(lineCFBundleURLSchemes) + + let LSScheme = config.modResults.LSApplicationQueriesSchemes + + if (!LSScheme) { + config.modResults.LSApplicationQueriesSchemes = [ + lineLSApplicationQueriesSchemes, + ] + } else { + if ( + config.modResults.LSApplicationQueriesSchemes.find( + value => value === lineLSApplicationQueriesSchemes, + ) + ) { + // Do nothing + } else { + config.modResults.LSApplicationQueriesSchemes = [ + lineLSApplicationQueriesSchemes, + ] + } + } + + config.modResults.LineSDKConfig = { + ChannelID: channelId, + } + + return config + }) +} + +module.exports = withCustomPlist \ No newline at end of file diff --git a/plugins/ios/withLinePluginConfig.js b/plugins/ios/withLinePluginConfig.js deleted file mode 100644 index accd32b..0000000 --- a/plugins/ios/withLinePluginConfig.js +++ /dev/null @@ -1,84 +0,0 @@ -const { withAppDelegate, withInfoPlist } = require('@expo/config-plugins'); - -const withAppDelegateMod = (config, { channelId }) => { - return withAppDelegate( - config, - async (config) => { - console.log(config) - const appDelegate = config.modResults; - - const contents = appDelegate.contents; - // this is the code generated by React native inside didFinishLaunchingWithOptions function; it might change in the future, look for your own anchor then - const injectionIndex = contents.indexOf('self.initialProps = @{};'); - - // console.log('withAppDelegateMod') - // console.log(contents) - // console.log(injectionIndex) - - appDelegate.contents = - contents.substring(0, injectionIndex) + - `\n [LineLogin setupWithChannelID:@${channelId} universalLinkURL:nil]; \n` + - contents.substring(injectionIndex); - - return config; - } - ); -}; - - -function addLineLoginCode(appDelegate) { - if (appDelegate.language === 'objc') { - // Ensure the import statement is present - if (!appDelegate.contents.includes('#import "RNLine-Swift.h"')) { - appDelegate.contents = `#import "RNLine-Swift.h"\n` + appDelegate.contents; - } - - // Inject the `didFinishLaunchingWithOptions` method if it doesn't exist or modify it - if (!appDelegate.contents.includes('[LineLogin setupWithChannelID')) { - const didFinishLaunchingCode = ` -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - [LineLogin setupWithChannelID:@"YOUR_CHANNEL_ID" universalLinkURL:nil]; - return YES; -} -`; - appDelegate.contents = appDelegate.contents.replace( - '- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions', - didFinishLaunchingCode - ); - } - - // Inject the URL handling methods - const urlHandlingMethods = ` -- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options -{ - return [LineLogin application:app open:url options:options]; -} - -- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray> * _Nullable))restorationHandler -{ - BOOL handledLine = [LineLogin application:application continue:userActivity restorationHandler:restorationHandler]; - return handledLine; -} -`; - - if (!appDelegate.contents.includes('[LineLogin application:')) { - appDelegate.contents += urlHandlingMethods; - } - } - - return appDelegate; -} - -const withLineLogin = (config, props) => { - config = withAppDelegateMod(config, props) - // config = withAppDelegate(config, (config) => { - // config.modResults = addLineLoginCode(config.modResults); - // return config; - // }); - // - // // Optionally, modify Info.plist if needed - return config; -}; - -module.exports = { withLineLogin }; diff --git a/plugins/ios/withLinePod.js b/plugins/ios/withLinePod.js new file mode 100644 index 0000000..58f4f70 --- /dev/null +++ b/plugins/ios/withLinePod.js @@ -0,0 +1,29 @@ +const { withDangerousMod } = require('@expo/config-plugins') +const { readFileSync, writeFileSync } = require('fs') +const { resolve } = require('path') + +function withLinePod(config) { + return withDangerousMod(config, [ + 'ios', + cfg => { + const { platformProjectRoot } = cfg.modRequest + const podfile = resolve(platformProjectRoot, 'Podfile') + const contents = readFileSync(podfile, 'utf-8') + const lines = contents.split('\n') + const index = lines.findIndex(line => /\s+use_expo_modules!/.test(line)) + + writeFileSync( + podfile, + [ + ...lines.slice(0, index), + ` pod 'LineSDKSwift', '~> 5.0'`, + ...lines.slice(index), + ].join('\n'), + ) + + return cfg + }, + ]) +} + +module.exports = withLinePod \ No newline at end of file diff --git a/plugins/withLineSDK.js b/plugins/withLineSDK.js index ea73ce6..c1b0f47 100644 --- a/plugins/withLineSDK.js +++ b/plugins/withLineSDK.js @@ -1,12 +1,4 @@ -const { - withDangerousMod, - withPlugins, - IOSConfig, - withInfoPlist, -} = require('@expo/config-plugins') -const { resolve } = require('path') -const { readFileSync, writeFileSync, promises } = require('fs') -const { withLineLogin } = require('./ios/withLinePluginConfig') +const { withPlugins } = require('@expo/config-plugins') // Android const withApplyLineImplementation = require('./android/withApplyLineImplementation') @@ -16,112 +8,9 @@ const withApplyAndroidCompileOptions = require('./android/withApplyAndroidCompil const withLineChannelId = require('./android/withLineChannelId') // iOS -const lineCFBundleURLSchemes = { - CFBundleURLSchemes: ['line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)'], -} - -const lineLSApplicationQueriesSchemes = 'lineauth2' - -const CHANNEL_ID_REPLACE = 'CHANNEL_ID_REPLACE' - -// iOS mods -// Pass `` to specify that this plugin requires a string property. -function withCustomPlist(config, { channelId }) { - return withInfoPlist(config, config => { - config.modResults.CFBundleURLTypes?.push(lineCFBundleURLSchemes) - - let LSScheme = config.modResults.LSApplicationQueriesSchemes - - if (!LSScheme) { - config.modResults.LSApplicationQueriesSchemes = [ - lineLSApplicationQueriesSchemes, - ] - } else { - if ( - config.modResults.LSApplicationQueriesSchemes.find( - value => value === lineLSApplicationQueriesSchemes, - ) - ) { - // Do nothing - } else { - config.modResults.LSApplicationQueriesSchemes = [ - lineLSApplicationQueriesSchemes, - ] - } - } - - config.modResults.LineSDKConfig = { - ChannelID: channelId, - } - - return config - }) -} - -function withForcedAppDelegate(config, { channelId }) { - return withDangerousMod(config, [ - 'ios', - async config => { - const fileInfo = IOSConfig.Paths.getAppDelegate( - config.modRequest.projectRoot, - ) - - // const envProfile = config.extra.env.RELEASE_STAGE ?? 'development' - - let { path } = fileInfo - - const { projectRoot } = config.modRequest - - // V1 - // const newAppDelegateFile = resolve(projectRoot, 'plugins/line-sdk/ios/', envProfile , 'appDelegate.m'); - // V2 - const newAppDelegateFile = resolve( - projectRoot, - 'plugins/line-sdk/ios/', - 'appDelegate_template.m', - ) - - // V1 - const newAppDelegate = readFileSync(newAppDelegateFile, 'utf8') - - // V2 - const replacedAppDelegate = newAppDelegate.replace( - CHANNEL_ID_REPLACE, - channelId, - ) - - const oldAppDelegateFile = resolve(path) - - await promises.writeFile(oldAppDelegateFile, replacedAppDelegate) - - return config - }, - ]) -} - -function withLinePod(config) { - return withDangerousMod(config, [ - 'ios', - cfg => { - const { platformProjectRoot } = cfg.modRequest - const podfile = resolve(platformProjectRoot, 'Podfile') - const contents = readFileSync(podfile, 'utf-8') - const lines = contents.split('\n') - const index = lines.findIndex(line => /\s+use_expo_modules!/.test(line)) - - writeFileSync( - podfile, - [ - ...lines.slice(0, index), - ` pod 'LineSDKSwift', '~> 5.0'`, - ...lines.slice(index), - ].join('\n'), - ) - - return cfg - }, - ]) -} +const withCustomPlist = require('./ios/withCustomPlist') +const withLinePod = require('./ios/withLinePod') +const withAppDelegateMod = require('./ios/withAppDelegateMod') function withLineSDK(config, props) { if (!props?.channelId) { @@ -131,8 +20,7 @@ function withLineSDK(config, props) { // iOS withLinePod, [withCustomPlist, props], - [withLineLogin, props], - // [withForcedAppDelegate, props], + [withAppDelegateMod, props], // Android withApplyLineImplementation, From fc7373032fd5e9d2c8294c7d25ca3564481b6827 Mon Sep 17 00:00:00 2001 From: Arda Satata Date: Mon, 11 Nov 2024 02:50:19 +0900 Subject: [PATCH 8/8] added readme --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index ade8831..9395c8d 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,33 @@ The following objects are returned on the methods described above: } ``` +## Expo Support + +If you're using expo you can add this plugins + +``` + "plugins": [ + ... + // This is required, please add `expo-build-properties` to your project + [ + "expo-build-properties", + { + "ios": { + "useFrameworks": "static" + } + } + ], + [ + "@xmartlabs/react-native-line", + { + "channelId": "YOUR_CHANNEL_ID" + } + ] + ], +``` + +⚠️ [iOS] if you're using other plugins it might cause conflict on `appDelegate.mm` file, please implement your own appDelegate mod if conflict occur + ## Example If you want to see `@xmartlabs/react-native-line` in action, just move into the [example](/example) folder and run `yarn ios`/`yarn android`. By seeing its source code, you will have a better understanding of the library usage.