Skip to content

Commit e242d04

Browse files
authored
Add expo as a platform (#384)
1 parent 23527a0 commit e242d04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+17302
-10
lines changed

.circleci/config.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ aliases:
66

77
orbs:
88
node: circleci/[email protected]
9+
browser-tools: circleci/[email protected]
910

1011
executors:
1112
default:
1213
docker:
1314
- image: cimg/node:16.13
1415
working_directory: ~/react-native-url-polyfill
16+
node-browsers:
17+
docker:
18+
- image: cimg/node:16.13-browsers
1519
xcode-11:
1620
macos:
1721
xcode: 11.7.0
@@ -70,6 +74,18 @@ commands:
7074
name: Restoring Detox App Cache
7175
keys:
7276
- detox-app-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock"}}
77+
save-cache-expo-app:
78+
steps:
79+
- save_cache:
80+
key: expo-app-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock"}}
81+
paths:
82+
- node_modules
83+
restore-cache-expo-app:
84+
steps:
85+
- restore_cache:
86+
name: Restoring Detox App Cache
87+
keys:
88+
- expo-app-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock"}}
7389
save-android-build-cache:
7490
steps:
7591
- save_cache:
@@ -231,6 +247,66 @@ jobs:
231247
- run:
232248
name: Run Detox on iOS
233249
command: yarn e2e:ios
250+
test-expo-ios:
251+
parameters:
252+
executor:
253+
default: xcode
254+
type: executor
255+
expo-version:
256+
type: string
257+
executor: << parameters.executor >>
258+
working_directory: ~/react-native-url-polyfill/platforms/expo/<< parameters.expo-version >>
259+
steps:
260+
- attach-workspace
261+
- restore-cache-detox-app
262+
- install-node
263+
- install-yarn-dependencies
264+
- install-detox
265+
- run:
266+
name: Fetch Pods specs
267+
command: curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
268+
- run:
269+
name: Install Pods
270+
command: cd ios && pod install --repo-update
271+
- run: yarn global add expo-cli
272+
- run:
273+
name: Build iOS App w/ Expo
274+
no_output_timeout: 30m
275+
command: npx expo build:ios -t simulator --no-publish --non-interactive
276+
- run:
277+
name: Make Directory tmp
278+
command: mkdir -p tmp
279+
- run:
280+
name: Downloading .ipa from expo
281+
command: curl -o tmp/app.tar.gz "$(npx expo url:ipa --non-interactive)"
282+
- run:
283+
name: Un-tar app.tar.gz
284+
command: tar -xzvf tmp/app.tar.gz -C tmp
285+
- run:
286+
name: Run Detox on iOS
287+
command: yarn test:ios
288+
- save-cache-detox-app
289+
test-expo-web:
290+
parameters:
291+
expo-version:
292+
type: string
293+
executor: node-browsers
294+
working_directory: ~/react-native-url-polyfill/platforms/expo/<< parameters.expo-version >>
295+
steps:
296+
- attach-workspace
297+
- browser-tools/install-chrome
298+
- run: google-chrome --version
299+
- run:
300+
name: Install certutil
301+
command: |
302+
sudo apt update
303+
sudo apt install libnss3-tools
304+
- restore-cache-expo-app
305+
- install-node
306+
- install-yarn-dependencies
307+
- run: yarn global add expo-cli
308+
- run: yarn test:web --runInBand
309+
- save-cache-expo-app
234310

235311
workflows:
236312
tests:
@@ -269,3 +345,17 @@ workflows:
269345
requires:
270346
- lint
271347
- test-js
348+
- test-expo-ios:
349+
matrix:
350+
parameters:
351+
expo-version: ['43']
352+
requires:
353+
- lint
354+
- test-js
355+
- test-expo-web:
356+
matrix:
357+
parameters:
358+
expo-version: ['43']
359+
requires:
360+
- lint
361+
- test-js

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ pids
1515

1616
*.hprof
1717

18-
*.tgz
18+
*.tgz
19+
20+
tmp

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ react-native-url-polyfill is an implementation of the WHATWG [URL Standard](http
3636
- **Trustworthy**. Follows closely the URL Standard spec, and relys on unit tests and Detox e2e tests within [React Native](https://github.com/facebook/react-native).
3737
- **Blob support**. Supports React Native's Blob without additional steps.
3838
- **Hermes support**. Supports [Hermes](https://github.com/facebook/hermes), a JavaScript engine optimized for running React Native.
39+
- **Expo support**. Supports [Expo](https://expo.dev/) and tested against.
3940

4041
## Why do we need this?
4142

platforms/detox/TestPolyfill.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
import React from 'react';
22
import {Text} from 'react-native';
33

4+
function testCreateObjectURL() {
5+
let objectURL;
6+
7+
try {
8+
objectURL = URL.createObjectURL({
9+
data: {
10+
blobId: 1,
11+
offset: 32,
12+
},
13+
size: 64,
14+
});
15+
} catch (e) {
16+
console.error(e);
17+
}
18+
19+
return objectURL;
20+
}
21+
422
const PolyfillTests = () => (
523
<>
624
<Text testID="url-polyfill-version">
@@ -13,15 +31,7 @@ const PolyfillTests = () => (
1331
.href
1432
}
1533
</Text>
16-
<Text testID="url-test-3">
17-
{URL.createObjectURL({
18-
data: {
19-
blobId: 1,
20-
offset: 32,
21-
},
22-
size: 64,
23-
})}
24-
</Text>
34+
<Text testID="url-test-3">{testCreateObjectURL()}</Text>
2535
</>
2636
);
2737

platforms/expo/43/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

platforms/expo/43/.detoxrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"testRunner": "jest",
3+
"runnerConfig": "../../detox/config.json",
4+
"skipLegacyWorkersInjection": true,
5+
"apps": {
6+
"ios": {
7+
"type": "ios.app",
8+
"binaryPath": "tmp/43.app"
9+
}
10+
},
11+
"devices": {
12+
"simulator": {
13+
"type": "ios.simulator",
14+
"device": {
15+
"type": "iPhone 11 Pro"
16+
}
17+
}
18+
},
19+
"configurations": {
20+
"ios": {
21+
"device": "simulator",
22+
"app": "ios"
23+
}
24+
}
25+
}

platforms/expo/43/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

platforms/expo/43/.gitignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
*.hprof
33+
34+
# node.js
35+
#
36+
node_modules/
37+
npm-debug.log
38+
yarn-error.log
39+
40+
# BUCK
41+
buck-out/
42+
\.buckd/
43+
*.keystore
44+
!debug.keystore
45+
46+
# Bundle artifacts
47+
*.jsbundle
48+
49+
# CocoaPods
50+
/ios/Pods/
51+
52+
# Expo
53+
.expo/
54+
web-build/
55+
dist/

platforms/expo/43/App.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {StatusBar} from 'expo-status-bar';
2+
import React from 'react';
3+
import {StyleSheet, Text, View} from 'react-native';
4+
5+
import TestPolyfill from '../../detox/TestPolyfill';
6+
7+
export default function App() {
8+
return (
9+
<View style={styles.container}>
10+
<TestPolyfill />
11+
<StatusBar style="auto" />
12+
</View>
13+
);
14+
}
15+
16+
const styles = StyleSheet.create({
17+
container: {
18+
flex: 1,
19+
backgroundColor: '#fff',
20+
alignItems: 'center',
21+
justifyContent: 'center',
22+
},
23+
});

platforms/expo/43/__tests__/App.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import 'expect-puppeteer';
2+
3+
import config from '../jest-puppeteer.config';
4+
5+
jest.setTimeout(10000);
6+
7+
beforeEach(async () => {
8+
await page.goto(config.url);
9+
await page.waitForSelector('#root');
10+
});
11+
12+
it('should have REACT_NATIVE_URL_POLYFILL', async () => {
13+
const {name, version} = require('../../../../package.json');
14+
15+
await expect(page).toMatchElement('div[data-testid="url-polyfill-version"]', {
16+
text: `${name}@${version}`,
17+
});
18+
});
19+
20+
it('should handle test 1', async () => {
21+
await expect(page).toMatchElement('div[data-testid="url-test-1"]', {
22+
text: 'https://google.dev/dev',
23+
});
24+
});
25+
26+
it('should handle test 2', async () => {
27+
await expect(page).toMatchElement('div[data-testid="url-test-2"]', {
28+
text: 'https://facebook.github.io/react-native/img/header_logo.png',
29+
});
30+
});

0 commit comments

Comments
 (0)