@superfan-app/spotify-auth 0.1.77 → 0.1.79
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.
- package/package.json +1 -1
- package/plugin/build/index.js +21 -0
- package/plugin/src/index.ts +31 -1
package/package.json
CHANGED
package/plugin/build/index.js
CHANGED
|
@@ -135,6 +135,26 @@ const withSpotifyAndroidManifest = (config, props) => {
|
|
|
135
135
|
return config;
|
|
136
136
|
});
|
|
137
137
|
};
|
|
138
|
+
const withSpotifyManifestPlaceholders = (config, props) => {
|
|
139
|
+
return (0, config_plugins_1.withAppBuildGradle)(config, (config) => {
|
|
140
|
+
const { host: callbackHost, path: callbackPath } = parseCallback(props.callback);
|
|
141
|
+
const pathPattern = callbackPath ? callbackPath.replace(/\//g, '\\/') + '.*' : '.*';
|
|
142
|
+
const placeholderBlock = `manifestPlaceholders = [
|
|
143
|
+
redirectSchemeName: "${props.scheme}",
|
|
144
|
+
redirectHostName: "${callbackHost}",
|
|
145
|
+
redirectPathPattern: "${pathPattern}"
|
|
146
|
+
]`;
|
|
147
|
+
if (config.modResults.contents.includes('manifestPlaceholders')) {
|
|
148
|
+
// Replace existing block
|
|
149
|
+
config.modResults.contents = config.modResults.contents.replace(/manifestPlaceholders\s*=\s*\[[\s\S]*?\]/, placeholderBlock);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// Inject into defaultConfig
|
|
153
|
+
config.modResults.contents = config.modResults.contents.replace(/defaultConfig\s*\{/, `defaultConfig {\n ${placeholderBlock}`);
|
|
154
|
+
}
|
|
155
|
+
return config;
|
|
156
|
+
});
|
|
157
|
+
};
|
|
138
158
|
// endregion
|
|
139
159
|
const withSpotifyAuth = (config, props) => {
|
|
140
160
|
// Ensure the config exists
|
|
@@ -147,6 +167,7 @@ const withSpotifyAuth = (config, props) => {
|
|
|
147
167
|
config = withSpotifyURLSchemes(config, props);
|
|
148
168
|
// Apply Android configurations
|
|
149
169
|
config = withSpotifyAndroidManifest(config, props);
|
|
170
|
+
config = withSpotifyManifestPlaceholders(config, props);
|
|
150
171
|
return config;
|
|
151
172
|
};
|
|
152
173
|
exports.default = (0, config_plugins_1.createRunOncePlugin)(withSpotifyAuth, pkg.name, pkg.version);
|
package/plugin/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// plugin/src/index.ts
|
|
2
2
|
|
|
3
|
-
import { type ConfigPlugin, createRunOncePlugin, withInfoPlist, withAndroidManifest, AndroidConfig } from '@expo/config-plugins'
|
|
3
|
+
import { type ConfigPlugin, createRunOncePlugin, withInfoPlist, withAndroidManifest, withAppBuildGradle, AndroidConfig } from '@expo/config-plugins'
|
|
4
4
|
import { SpotifyConfig } from './types.js'
|
|
5
5
|
|
|
6
6
|
const pkg = require('../../package.json');
|
|
@@ -161,6 +161,35 @@ const withSpotifyAndroidManifest: ConfigPlugin<SpotifyConfig> = (config, props)
|
|
|
161
161
|
});
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
const withSpotifyManifestPlaceholders: ConfigPlugin<SpotifyConfig> = (config, props) => {
|
|
165
|
+
return withAppBuildGradle(config, (config) => {
|
|
166
|
+
const { host: callbackHost, path: callbackPath } = parseCallback(props.callback)
|
|
167
|
+
const pathPattern = callbackPath ? callbackPath.replace(/\//g, '\\/') + '.*' : '.*'
|
|
168
|
+
|
|
169
|
+
const placeholderBlock = `manifestPlaceholders = [
|
|
170
|
+
redirectSchemeName: "${props.scheme}",
|
|
171
|
+
redirectHostName: "${callbackHost}",
|
|
172
|
+
redirectPathPattern: "${pathPattern}"
|
|
173
|
+
]`
|
|
174
|
+
|
|
175
|
+
if (config.modResults.contents.includes('manifestPlaceholders')) {
|
|
176
|
+
// Replace existing block
|
|
177
|
+
config.modResults.contents = config.modResults.contents.replace(
|
|
178
|
+
/manifestPlaceholders\s*=\s*\[[\s\S]*?\]/,
|
|
179
|
+
placeholderBlock
|
|
180
|
+
)
|
|
181
|
+
} else {
|
|
182
|
+
// Inject into defaultConfig
|
|
183
|
+
config.modResults.contents = config.modResults.contents.replace(
|
|
184
|
+
/defaultConfig\s*\{/,
|
|
185
|
+
`defaultConfig {\n ${placeholderBlock}`
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return config
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
|
|
164
193
|
// endregion
|
|
165
194
|
|
|
166
195
|
const withSpotifyAuth: ConfigPlugin<SpotifyConfig> = (config, props) => {
|
|
@@ -179,6 +208,7 @@ const withSpotifyAuth: ConfigPlugin<SpotifyConfig> = (config, props) => {
|
|
|
179
208
|
|
|
180
209
|
// Apply Android configurations
|
|
181
210
|
config = withSpotifyAndroidManifest(config, props);
|
|
211
|
+
config = withSpotifyManifestPlaceholders(config, props);
|
|
182
212
|
|
|
183
213
|
return config;
|
|
184
214
|
};
|