expo-asset 9.0.1 → 9.0.2
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/CHANGELOG.md +6 -0
- package/build/AssetUris.d.ts.map +1 -1
- package/build/AssetUris.js +14 -1
- package/build/AssetUris.js.map +1 -1
- package/package.json +2 -2
- package/src/AssetUris.ts +17 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 9.0.2 — 2024-01-05
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fix relative URLs and support for `unstable_path` in development. ([#26084](https://github.com/expo/expo/pull/26084) by [@EvanBacon](https://github.com/EvanBacon))
|
|
18
|
+
|
|
13
19
|
## 9.0.1 — 2023-12-13
|
|
14
20
|
|
|
15
21
|
_This version does not introduce any user-facing changes._
|
package/build/AssetUris.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetUris.d.ts","sourceRoot":"","sources":["../src/AssetUris.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"AssetUris.d.ts","sourceRoot":"","sources":["../src/AssetUris.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAe/C;AAMD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAuB9D"}
|
package/build/AssetUris.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
export function getFilename(url) {
|
|
2
|
-
const { pathname } = new URL(url);
|
|
2
|
+
const { pathname, searchParams } = new URL(url, 'https://e');
|
|
3
|
+
// When attached to a dev server, we use `unstable_path` to represent the file path. This ensures
|
|
4
|
+
// the file name is not canonicalized by the browser.
|
|
5
|
+
// NOTE(EvanBacon): This is technically not tied to `__DEV__` as it's possible to use this while bundling in production
|
|
6
|
+
// mode.
|
|
7
|
+
if (__DEV__) {
|
|
8
|
+
if (searchParams.has('unstable_path')) {
|
|
9
|
+
const encodedFilePath = decodeURIComponent(searchParams.get('unstable_path'));
|
|
10
|
+
return getBasename(encodedFilePath);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return getBasename(pathname);
|
|
14
|
+
}
|
|
15
|
+
function getBasename(pathname) {
|
|
3
16
|
return pathname.substring(pathname.lastIndexOf('/') + 1);
|
|
4
17
|
}
|
|
5
18
|
export function getFileExtension(url) {
|
package/build/AssetUris.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetUris.js","sourceRoot":"","sources":["../src/AssetUris.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"AssetUris.js","sourceRoot":"","sources":["../src/AssetUris.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAE7D,iGAAiG;IACjG,qDAAqD;IACrD,uHAAuH;IACvH,QAAQ;IACR,IAAI,OAAO,EAAE;QACX,IAAI,YAAY,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;YACrC,MAAM,eAAe,GAAG,kBAAkB,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,CAAE,CAAC,CAAC;YAC/E,OAAO,WAAW,CAAC,eAAe,CAAC,CAAC;SACrC;KACF;IAED,OAAO,WAAW,CAAC,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AAC,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC;QAC1D,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC;AACrB,CAAC","sourcesContent":["export function getFilename(url: string): string {\n const { pathname, searchParams } = new URL(url, 'https://e');\n\n // When attached to a dev server, we use `unstable_path` to represent the file path. This ensures\n // the file name is not canonicalized by the browser.\n // NOTE(EvanBacon): This is technically not tied to `__DEV__` as it's possible to use this while bundling in production\n // mode.\n if (__DEV__) {\n if (searchParams.has('unstable_path')) {\n const encodedFilePath = decodeURIComponent(searchParams.get('unstable_path')!);\n return getBasename(encodedFilePath);\n }\n }\n\n return getBasename(pathname);\n}\n\nfunction getBasename(pathname: string): string {\n return pathname.substring(pathname.lastIndexOf('/') + 1);\n}\n\nexport function getFileExtension(url: string): string {\n const filename = getFilename(url);\n const dotIndex = filename.lastIndexOf('.');\n // Ignore leading dots for hidden files\n return dotIndex > 0 ? filename.substring(dotIndex) : '';\n}\n\n/**\n * Returns the base URL from a manifest's URL. For example, given a manifest hosted at\n * https://example.com/app/manifest.json, the base URL would be https://example.com/app/. Query\n * parameters and fragments also are removed.\n *\n * For an Expo-hosted project with a manifest hosted at https://exp.host/@user/project/index.exp, the\n * base URL would be https://exp.host/@user/project.\n *\n * We also normalize the \"exp\" protocol to \"http\" to handle internal URLs with the Expo schemes used\n * to tell the OS to open the URLs in the the Expo client.\n */\nexport function getManifestBaseUrl(manifestUrl: string): string {\n const urlObject = new URL(manifestUrl);\n\n let nextProtocol = urlObject.protocol;\n // Change the scheme to http(s) if it is exp(s)\n if (nextProtocol === 'exp:') {\n nextProtocol = 'http:';\n } else if (nextProtocol === 'exps:') {\n nextProtocol = 'https:';\n }\n urlObject.protocol = nextProtocol;\n\n // Trim filename, query parameters, and fragment, if any\n const directory = urlObject.pathname.substring(0, urlObject.pathname.lastIndexOf('/') + 1);\n urlObject.pathname = directory;\n urlObject.search = '';\n urlObject.hash = '';\n\n // The URL spec doesn't allow for changing the protocol to `http` or `https`\n // without a port set so instead, we'll just swap the protocol manually.\n return urlObject.protocol !== nextProtocol\n ? urlObject.href.replace(urlObject.protocol, nextProtocol)\n : urlObject.href;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-asset",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.2",
|
|
4
4
|
"description": "An Expo universal module to download assets and pass them into other APIs",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@types/react-native__assets": "~1.0.0",
|
|
50
50
|
"expo-module-scripts": "^3.0.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "b5a3db3c8993f3b22e8cba1e2c6005fee57988c2"
|
|
53
53
|
}
|
package/src/AssetUris.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
export function getFilename(url: string): string {
|
|
2
|
-
const { pathname } = new URL(url);
|
|
2
|
+
const { pathname, searchParams } = new URL(url, 'https://e');
|
|
3
|
+
|
|
4
|
+
// When attached to a dev server, we use `unstable_path` to represent the file path. This ensures
|
|
5
|
+
// the file name is not canonicalized by the browser.
|
|
6
|
+
// NOTE(EvanBacon): This is technically not tied to `__DEV__` as it's possible to use this while bundling in production
|
|
7
|
+
// mode.
|
|
8
|
+
if (__DEV__) {
|
|
9
|
+
if (searchParams.has('unstable_path')) {
|
|
10
|
+
const encodedFilePath = decodeURIComponent(searchParams.get('unstable_path')!);
|
|
11
|
+
return getBasename(encodedFilePath);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return getBasename(pathname);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getBasename(pathname: string): string {
|
|
3
19
|
return pathname.substring(pathname.lastIndexOf('/') + 1);
|
|
4
20
|
}
|
|
5
21
|
|