Skip to content

Commit 2d2f81a

Browse files
authored
Merge pull request code-dot-org#26716 from code-dot-org/export_expo_offline_support
Expo exports: enable offline with assetBundlePatterns
2 parents f590167 + 3d1a038 commit 2d2f81a

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

apps/src/applab/Exporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ export default {
571571
sessionId: `${getEnvironmentPrefix()}-${project.getCurrentId()}`,
572572
files,
573573
name: project.getCurrentName(),
574-
sdkVersion: '32.0.0',
574+
sdkVersion: '31.0.0',
575575
});
576576

577577
// Important that index.html comes first:

apps/src/gamelab/Exporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export default {
293293
sessionId: `${getEnvironmentPrefix()}-${project.getCurrentId()}`,
294294
files,
295295
name: project.getCurrentName(),
296-
sdkVersion: '32.0.0',
296+
sdkVersion: '31.0.0',
297297
});
298298

299299
// Important that index.html comes first:

apps/src/templates/export/expo/CustomAsset.exported_js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,25 @@ export default class CustomAsset {
3333
// Ignore this because it throws if the dir already exists on Android
3434
}
3535
}
36-
({ md5 } = await FileSystem.downloadAsync(this.asset.uri, localUri, {
36+
if (this.asset.localUri) {
37+
await FileSystem.copyAsync({
38+
from: this.asset.localUri,
39+
to: localUri,
40+
});
41+
({ md5 } = await FileSystem.getInfoAsync(localUri, {
3742
cache: true,
3843
md5: true,
39-
}));
44+
}));
45+
} else {
46+
({ md5 } = await FileSystem.downloadAsync(this.asset.uri, localUri, {
47+
cache: true,
48+
md5: true,
49+
}));
50+
}
4051
if (md5 !== this.asset.hash) {
4152
throw new Error(
4253
`Downloaded file for asset '${this.fileName} ` +
43-
`Located at ${this.asset.localUri} ` +
54+
`Located at ${localUri} ` +
4455
`failed MD5 integrity check`
4556
);
4657
}

apps/src/templates/export/expo/app.json.ejs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "<%- appName %> from Code.org Code Studio.",
55
"slug": "<%- appName.replace(/([^a-zA-Z0-9_\-]+)/gi, '-') %>",
66
"privacy": "public",
7-
"sdkVersion": "32.0.0",
7+
"sdkVersion": "31.0.0",
88
"platforms": ["ios", "android"],
99
"version": "1.0.0",
1010
"orientation": "portrait",
@@ -15,8 +15,12 @@
1515
"backgroundColor": "#ffffff"
1616
},
1717
"updates": {
18+
"enabled": false,
1819
"fallbackToCacheTimeout": 0
1920
},
21+
"assetBundlePatterns": [
22+
"**/*"
23+
],
2024
"packagerOpts": {
2125
"assetExts": [
2226
"html",

apps/src/templates/export/expo/package.exported_json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"eject": "expo eject"
99
},
1010
"dependencies": {
11-
"expo": "^32.0.0",
11+
"expo": "^31.0.4",
1212
"expo-cli": "^2.6.14",
1313
"react": "16.5.0",
14-
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz"
14+
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.1.tar.gz"
1515
}
1616
}

apps/src/templates/export/gamelabIndex.html.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
}
2525
</style>
2626
</head>
27-
<body class="<%- exportClass %>" style="margin:0; overflow:hidden; position:absolute; top:0; left:0; width:<%- appWidth %>px; height:<%- appHeight %>px;">
28-
<div id="sketch" class="<%- exportClass %>" style="position: absolute;"></div>
27+
<body class="<%- exportClass %>" style="margin:0; overflow:hidden; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; position:fixed; top:0; left:0; width:<%- appWidth %>px; height:<%- appHeight %>px;">
28+
<div id="sketch" class="<%- exportClass %>" style="position:absolute;"></div>
2929
<div id="soft-buttons" class="soft-buttons-none">
3030
<button id="leftButton" disabled className="arrow">
3131
</button>

0 commit comments

Comments
 (0)