Skip to content

Commit

Permalink
Fix Expo plugin issues, dependency issues, and stabilize (#247)
Browse files Browse the repository at this point in the history
- Update Expo config
- Add Prettier config
- Update Node version in NPM release GitHub action
- Rebuild ViroRenderer for iOS
  • Loading branch information
robertjcolley authored Jan 25, 2024
1 parent 50879c8 commit 15d3e1d
Show file tree
Hide file tree
Showing 159 changed files with 10,498 additions and 2,270 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 10
- uses: JS-DevTools/npm-publish@v1
node-version: 16
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false
}
2 changes: 0 additions & 2 deletions .reviewboardrc

This file was deleted.

Empty file added __test__/androidXrMode.ts
Empty file.
161 changes: 161 additions & 0 deletions __test__/infoPlistDefined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import { DEFAULTS } from "../plugins/withViro";

const TEST_TEXT = "This is not the default text.";

export const infoPlistDefinedTestPluginConfigs = [
{
config: [
"@viro-community/react-viro",
{ ios: { photosPermission: TEST_TEXT } },
],
afterInfoPlist: {
NSPhotoLibraryUsageDescription: TEST_TEXT,
NSPhotoLibraryAddUsageDescription: DEFAULTS.ios.savePhotosPermission,
NSCameraUsageDescription: DEFAULTS.ios.cameraUsagePermission,
NSMicrophoneUsageDescription: DEFAULTS.ios.microphoneUsagePermission,
},
},
{
config: [
"@viro-community/react-viro",
{ ios: { savePhotosPermission: TEST_TEXT } },
],
afterInfoPlist: {
NSPhotoLibraryUsageDescription: DEFAULTS.ios.photosPermission,
NSPhotoLibraryAddUsageDescription: TEST_TEXT,
NSCameraUsageDescription: DEFAULTS.ios.cameraUsagePermission,
NSMicrophoneUsageDescription: DEFAULTS.ios.microphoneUsagePermission,
},
},
{
config: [
"@viro-community/react-viro",
{ ios: { cameraUsagePermission: TEST_TEXT } },
],
afterInfoPlist: {
NSPhotoLibraryUsageDescription: DEFAULTS.ios.photosPermission,
NSPhotoLibraryAddUsageDescription: DEFAULTS.ios.savePhotosPermission,
NSCameraUsageDescription: TEST_TEXT,
NSMicrophoneUsageDescription: DEFAULTS.ios.microphoneUsagePermission,
},
},
{
config: [
"@viro-community/react-viro",
{ ios: { microphoneUsagePermission: TEST_TEXT } },
],
afterInfoPlist: {
NSPhotoLibraryUsageDescription: DEFAULTS.ios.photosPermission,
NSPhotoLibraryAddUsageDescription: DEFAULTS.ios.savePhotosPermission,
NSCameraUsageDescription: DEFAULTS.ios.cameraUsagePermission,
NSMicrophoneUsageDescription: TEST_TEXT,
},
},
{
config: [
"@viro-community/react-viro",
{
ios: {
microphoneUsagePermission: TEST_TEXT,
photosPermission: TEST_TEXT,
savePhotosPermission: TEST_TEXT,
cameraUsagePermission: TEST_TEXT,
},
},
],
afterInfoPlist: {
NSPhotoLibraryUsageDescription: TEST_TEXT,
NSPhotoLibraryAddUsageDescription: TEST_TEXT,
NSCameraUsageDescription: TEST_TEXT,
NSMicrophoneUsageDescription: TEST_TEXT,
},
},
];

export const infoPlistDefinedAppConfigBefore: any = {
name: "Example App Config",
slug: "example-app-config",
version: "1.0.0",
orientation: "portrait",
icon: "./assets/images/icon.png",
scheme: "myapp",
userInterfaceStyle: "automatic",
splash: {
image: "./assets/images/splash.png",
resizeMode: "contain",
backgroundColor: "#ffffff",
},
updates: {
fallbackToCacheTimeout: 0,
},
assetBundlePatterns: ["**/*"],
plugins: [],
ios: {
supportsTablet: true,
bundleIdentifier: "com.example.app.config",
buildNumber: `${Math.floor(Number(Date.now() / 1000))}`,
config: {
usesNonExemptEncryption: false,
},
},
android: {
adaptiveIcon: {
foregroundImage: "./assets/images/adaptive-icon.png",
backgroundColor: "#ffffff",
},
package: "com.example.app.config",
versionCode: Math.floor(Number(Date.now() / 1000)),
},
extra: {
eas: {
projectId: "eef69c9f-ddbe-45f2-933a-51ff4f8948b9",
},
},
};

export const infoPlistDefinedAppConfigAfter: any = {
name: "Example App Config",
slug: "example-app-config",
version: "1.0.0",
orientation: "portrait",
icon: "./assets/images/icon.png",
scheme: "myapp",
userInterfaceStyle: "automatic",
splash: {
image: "./assets/images/splash.png",
resizeMode: "contain",
backgroundColor: "#ffffff",
},
updates: {
fallbackToCacheTimeout: 0,
},
assetBundlePatterns: ["**/*"],
plugins: [],
ios: {
supportsTablet: true,
bundleIdentifier: "com.example.app.config",
buildNumber: `${Math.floor(Number(Date.now() / 1000))}`,
config: {
usesNonExemptEncryption: false,
},
infoPlist: {
NSPhotoLibraryUsageDescription: DEFAULTS.ios.photosPermission,
NSPhotoLibraryAddUsageDescription: DEFAULTS.ios.savePhotosPermission,
NSCameraUsageDescription: DEFAULTS.ios.cameraUsagePermission,
NSMicrophoneUsageDescription: DEFAULTS.ios.microphoneUsagePermission,
},
},
android: {
adaptiveIcon: {
foregroundImage: "./assets/images/adaptive-icon.png",
backgroundColor: "#ffffff",
},
package: "com.example.app.config",
versionCode: Math.floor(Number(Date.now() / 1000)),
},
extra: {
eas: {
projectId: "eef69c9f-ddbe-45f2-933a-51ff4f8948b9",
},
},
};
96 changes: 96 additions & 0 deletions __test__/noInfoPlistDefined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { DEFAULTS } from "../plugins/withViro";

export const pluginConfigs = [
"@viro-community/react-viro",
["@viro-community/react-viro", { ios: {} }],
["@viro-community/react-viro", { android: { xRMode: ["GVR"] } }],
["@viro-community/react-viro", { android: { xRMode: ["GVR"] }, ios: {} }],
];

export const noInfoPlistDefinitionsAppConfigBefore: any = {
name: "Example App Config",
slug: "example-app-config",
version: "1.0.0",
orientation: "portrait",
icon: "./assets/images/icon.png",
scheme: "myapp",
userInterfaceStyle: "automatic",
splash: {
image: "./assets/images/splash.png",
resizeMode: "contain",
backgroundColor: "#ffffff",
},
updates: {
fallbackToCacheTimeout: 0,
},
assetBundlePatterns: ["**/*"],
plugins: [],
ios: {
supportsTablet: true,
bundleIdentifier: "com.example.app.config",
buildNumber: `${Math.floor(Number(Date.now() / 1000))}`,
config: {
usesNonExemptEncryption: false,
},
},
android: {
adaptiveIcon: {
foregroundImage: "./assets/images/adaptive-icon.png",
backgroundColor: "#ffffff",
},
package: "com.example.app.config",
versionCode: Math.floor(Number(Date.now() / 1000)),
},
extra: {
eas: {
projectId: "eef69c9f-ddbe-45f2-933a-51ff4f8948b9",
},
},
};

export const noInfoPlistDefinitionsAppConfigAfter: any = {
name: "Example App Config",
slug: "example-app-config",
version: "1.0.0",
orientation: "portrait",
icon: "./assets/images/icon.png",
scheme: "myapp",
userInterfaceStyle: "automatic",
splash: {
image: "./assets/images/splash.png",
resizeMode: "contain",
backgroundColor: "#ffffff",
},
updates: {
fallbackToCacheTimeout: 0,
},
assetBundlePatterns: ["**/*"],
plugins: [],
ios: {
supportsTablet: true,
bundleIdentifier: "com.example.app.config",
buildNumber: `${Math.floor(Number(Date.now() / 1000))}`,
config: {
usesNonExemptEncryption: false,
},
infoPlist: {
NSPhotoLibraryUsageDescription: DEFAULTS.ios.photosPermission,
NSPhotoLibraryAddUsageDescription: DEFAULTS.ios.savePhotosPermission,
NSCameraUsageDescription: DEFAULTS.ios.cameraUsagePermission,
NSMicrophoneUsageDescription: DEFAULTS.ios.microphoneUsagePermission,
},
},
android: {
adaptiveIcon: {
foregroundImage: "./assets/images/adaptive-icon.png",
backgroundColor: "#ffffff",
},
package: "com.example.app.config",
versionCode: Math.floor(Number(Date.now() / 1000)),
},
extra: {
eas: {
projectId: "eef69c9f-ddbe-45f2-933a-51ff4f8948b9",
},
},
};
41 changes: 41 additions & 0 deletions __test__/withViro.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { describe, expect, test } from "@jest/globals";
import { withDefaultInfoPlist } from "../plugins/withViroIos";
import {
noInfoPlistDefinitionsAppConfigAfter,
noInfoPlistDefinitionsAppConfigBefore,
pluginConfigs,
} from "./noInfoPlistDefined";
import {
infoPlistDefinedAppConfigAfter,
infoPlistDefinedAppConfigBefore,
infoPlistDefinedTestPluginConfigs,
} from "./infoPlistDefined";

describe("withViro", () => {
test("should correctly set InfoPlist config if no InfoPlist values are configured", () => {
for (const configuration of pluginConfigs) {
noInfoPlistDefinitionsAppConfigBefore.plugins = [configuration];
noInfoPlistDefinitionsAppConfigAfter.plugins = [configuration];
expect(
withDefaultInfoPlist(
noInfoPlistDefinitionsAppConfigBefore,
undefined as any
)
).toStrictEqual(noInfoPlistDefinitionsAppConfigAfter);
}
});

test("should correctly set InfoPlist config if InfoPlist values are configured", () => {
for (const scenario of infoPlistDefinedTestPluginConfigs) {
infoPlistDefinedAppConfigBefore.ios.infoPlist = undefined;
infoPlistDefinedAppConfigBefore.plugins = [scenario.config];
infoPlistDefinedAppConfigAfter.plugins = [scenario.config];
infoPlistDefinedAppConfigAfter.ios.infoPlist = scenario.afterInfoPlist;
expect(
withDefaultInfoPlist(infoPlistDefinedAppConfigBefore, undefined as any)
).toStrictEqual(infoPlistDefinedAppConfigAfter);
}
});

// TODO: Testing that withViro updates files correctly (Podfile, Android files, etc.)
});
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
};
6 changes: 5 additions & 1 deletion dist/components/AR/ViroARCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down
6 changes: 5 additions & 1 deletion dist/components/AR/ViroARImageMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down
2 changes: 1 addition & 1 deletion dist/components/AR/ViroARObjectMarker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import { ViroBase } from "../ViroBase";
import { NativeSyntheticEvent } from "react-native";
import { ViroARAnchorFoundEvent, ViroARAnchorRemovedEvent, ViroARAnchorUpdatedEvent } from "../Types/ViroEvents";
declare type Props = {};
type Props = {};
/**
* Container for Viro Components anchored to a detected object.
*/
Expand Down
6 changes: 5 additions & 1 deletion dist/components/AR/ViroARObjectMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down
2 changes: 1 addition & 1 deletion dist/components/AR/ViroARPlane.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import { ViroARAnchorFoundEvent, ViroARAnchorRemovedEvent, ViroARAnchorUpdatedEvent } from "../Types/ViroEvents";
import { ViroBase } from "../ViroBase";
import { NativeSyntheticEvent } from "react-native";
declare type Props = {
type Props = {
anchorId?: string;
minHeight?: number;
minWidth?: number;
Expand Down
6 changes: 5 additions & 1 deletion dist/components/AR/ViroARPlane.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down
Loading

0 comments on commit 15d3e1d

Please sign in to comment.