create-sitecore-jss 22.8.0 → 22.9.0-canary.10
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/LICENSE.MD +202 -202
- package/README.md +10 -10
- package/dist/InitializerFactory.js +17 -7
- package/dist/bin.js +17 -7
- package/dist/common/processes/transform.js +19 -9
- package/dist/common/utils/helpers.js +17 -7
- package/dist/init-runner.js +17 -7
- package/dist/initializers/angular-sxp/index.js +17 -7
- package/dist/initializers/angular-xmcloud/index.js +17 -7
- package/dist/initializers/nextjs/index.js +17 -7
- package/dist/initializers/nextjs-multisite/index.js +17 -7
- package/dist/initializers/nextjs-styleguide/index.js +17 -7
- package/dist/initializers/nextjs-styleguide-tracking/index.js +17 -7
- package/dist/initializers/nextjs-sxa/index.js +17 -7
- package/dist/initializers/nextjs-xmcloud/index.js +17 -7
- package/dist/initializers/react/index.js +17 -7
- package/dist/templates/angular/package.json +6 -6
- package/dist/templates/angular/src/assets/images/sc_logo.svg +52 -52
- package/dist/templates/angular-sxp/data/component-content/Styleguide/ContentReuse/LoremIpsumContentBlock/en.yml +9 -9
- package/dist/templates/angular-sxp/data/content/Styleguide/ContentListField/Item1/en.yml +6 -6
- package/dist/templates/angular-sxp/data/content/Styleguide/ContentListField/Item2/en.yml +6 -6
- package/dist/templates/angular-sxp/data/content/Styleguide/EditFrameDemo/Item1/en.yml +6 -6
- package/dist/templates/angular-sxp/data/content/Styleguide/EditFrameDemo/Item2/en.yml +6 -6
- package/dist/templates/angular-sxp/data/content/Styleguide/ItemLinkField/Item1/en.yml +6 -6
- package/dist/templates/angular-sxp/data/content/Styleguide/ItemLinkField/Item2/en.yml +6 -6
- package/dist/templates/angular-sxp/data/dictionary/en.yml +4 -4
- package/dist/templates/angular-sxp/data/dictionary/{{language}}.yml +4 -4
- package/dist/templates/angular-sxp/data/routes/en.yml +61 -61
- package/dist/templates/angular-sxp/data/routes/graphql/en.yml +27 -27
- package/dist/templates/angular-sxp/data/routes/graphql/sample-1/en.yml +9 -9
- package/dist/templates/angular-sxp/data/routes/graphql/sample-2/en.yml +9 -9
- package/dist/templates/angular-sxp/data/routes/styleguide/custom-route-type/en.yml +12 -12
- package/dist/templates/angular-sxp/data/routes/styleguide/en.yml +271 -271
- package/dist/templates/angular-sxp/data/routes/styleguide/{{language}}.yml +25 -25
- package/dist/templates/angular-sxp/data/routes/{{language}}.yml +4 -4
- package/dist/templates/angular-sxp/sitecore/config/{{appName}}.config +90 -90
- package/dist/templates/angular-sxp/sitecore/definitions/components/graph-ql-integrated-demo.sitecore.graphql +71 -71
- package/dist/templates/angular-sxp/sitecore/gitignore +2 -2
- package/dist/templates/angular-xmcloud/package.json +2 -2
- package/dist/templates/nextjs/package.json +6 -6
- package/dist/templates/nextjs/public/sc_logo.svg +52 -52
- package/dist/templates/nextjs-styleguide/data/component-content/Styleguide/ContentReuse/LoremIpsumContentBlock/en.yml +9 -9
- package/dist/templates/nextjs-styleguide/data/content/Styleguide/ContentListField/Item1/en.yml +6 -6
- package/dist/templates/nextjs-styleguide/data/content/Styleguide/ContentListField/Item2/en.yml +6 -6
- package/dist/templates/nextjs-styleguide/data/content/Styleguide/EditFrameDemo/Item1/en.yml +6 -6
- package/dist/templates/nextjs-styleguide/data/content/Styleguide/EditFrameDemo/Item2/en.yml +6 -6
- package/dist/templates/nextjs-styleguide/data/content/Styleguide/ItemLinkField/Item1/en.yml +6 -6
- package/dist/templates/nextjs-styleguide/data/content/Styleguide/ItemLinkField/Item2/en.yml +6 -6
- package/dist/templates/nextjs-styleguide/data/dictionary/en.yml +4 -4
- package/dist/templates/nextjs-styleguide/data/dictionary/{{language}}.yml +4 -4
- package/dist/templates/nextjs-styleguide/data/routes/en.yml +63 -63
- package/dist/templates/nextjs-styleguide/data/routes/graphql/en.yml +27 -27
- package/dist/templates/nextjs-styleguide/data/routes/graphql/sample-1/en.yml +9 -9
- package/dist/templates/nextjs-styleguide/data/routes/graphql/sample-2/en.yml +9 -9
- package/dist/templates/nextjs-styleguide/data/routes/styleguide/custom-route-type/en.yml +12 -12
- package/dist/templates/nextjs-styleguide/data/routes/styleguide/en.yml +259 -259
- package/dist/templates/nextjs-styleguide/data/routes/styleguide/{{language}}.yml +25 -25
- package/dist/templates/nextjs-styleguide/data/routes/{{language}}.yml +4 -4
- package/dist/templates/nextjs-styleguide-tracking/data/dictionary/en.yml +5 -5
- package/dist/templates/nextjs-styleguide-tracking/data/routes/tracking/en.yml +8 -8
- package/dist/templates/nextjs-sxa/src/assets/sass/components/_component-column-splitter.scss +14 -14
- package/dist/templates/nextjs-sxa/src/assets/sass/components/promo/_promo-shadow.scss +42 -42
- package/dist/templates/nextjs-xmcloud/package.json +3 -3
- package/dist/templates/node-headless-ssr-experience-edge/package.json +4 -4
- package/dist/templates/node-headless-ssr-proxy/package.json +6 -6
- package/dist/templates/node-xmcloud-proxy/package.json +7 -7
- package/dist/templates/node-xmcloud-proxy/src/index.ts +1 -1
- package/dist/templates/react/data/component-content/Styleguide/ContentReuse/LoremIpsumContentBlock/en.yml +9 -9
- package/dist/templates/react/data/content/Styleguide/ContentListField/Item1/en.yml +6 -6
- package/dist/templates/react/data/content/Styleguide/ContentListField/Item2/en.yml +6 -6
- package/dist/templates/react/data/content/Styleguide/EditFrameDemo/Item1/en.yml +6 -6
- package/dist/templates/react/data/content/Styleguide/EditFrameDemo/Item2/en.yml +6 -6
- package/dist/templates/react/data/content/Styleguide/ItemLinkField/Item1/en.yml +6 -6
- package/dist/templates/react/data/content/Styleguide/ItemLinkField/Item2/en.yml +6 -6
- package/dist/templates/react/data/dictionary/en.yml +4 -4
- package/dist/templates/react/data/dictionary/{{language}}.yml +4 -4
- package/dist/templates/react/data/routes/en.yml +61 -61
- package/dist/templates/react/data/routes/graphql/en.yml +27 -27
- package/dist/templates/react/data/routes/graphql/sample-1/en.yml +9 -9
- package/dist/templates/react/data/routes/graphql/sample-2/en.yml +9 -9
- package/dist/templates/react/data/routes/styleguide/custom-route-type/en.yml +12 -12
- package/dist/templates/react/data/routes/styleguide/en.yml +263 -263
- package/dist/templates/react/data/routes/styleguide/{{language}}.yml +26 -26
- package/dist/templates/react/data/routes/{{language}}.yml +4 -4
- package/dist/templates/react/package.json +24 -24
- package/dist/templates/react/server/server.webpack.config.js +3 -3
- package/dist/templates/react/src/setupProxy.js +6 -6
- package/dist/templates/react-native/.buckconfig +6 -6
- package/dist/templates/react-native/.eslintrc +74 -74
- package/dist/templates/react-native/.gitattributes +1 -1
- package/dist/templates/react-native/.prettierrc +9 -9
- package/dist/templates/react-native/.vscode/launch.json +42 -42
- package/dist/templates/react-native/.vscode/settings.json +1 -1
- package/dist/templates/react-native/LICENSE.txt +202 -202
- package/dist/templates/react-native/README.MD +115 -115
- package/dist/templates/react-native/android/app/BUCK +55 -55
- package/dist/templates/react-native/android/app/build.gradle +201 -201
- package/dist/templates/react-native/android/app/build_defs.bzl +19 -19
- package/dist/templates/react-native/android/app/proguard-rules.pro +10 -10
- package/dist/templates/react-native/android/app/src/debug/AndroidManifest.xml +8 -8
- package/dist/templates/react-native/android/app/src/main/AndroidManifest.xml +26 -26
- package/dist/templates/react-native/android/app/src/main/java/com/{{appName}}/MainActivity.java +15 -15
- package/dist/templates/react-native/android/app/src/main/java/com/{{appName}}/MainApplication.java +74 -74
- package/dist/templates/react-native/android/app/src/main/res/values/strings.xml +3 -3
- package/dist/templates/react-native/android/app/src/main/res/values/styles.xml +9 -9
- package/dist/templates/react-native/android/build.gradle +38 -38
- package/dist/templates/react-native/android/gradle/wrapper/gradle-wrapper.properties +5 -5
- package/dist/templates/react-native/android/gradle.properties +21 -21
- package/dist/templates/react-native/android/gradlew +188 -188
- package/dist/templates/react-native/android/gradlew.bat +100 -100
- package/dist/templates/react-native/android/settings.gradle +3 -3
- package/dist/templates/react-native/app.json +3 -3
- package/dist/templates/react-native/assets/img/sc_logo.svg +52 -52
- package/dist/templates/react-native/data/content/Styleguide/ItemLinkField/Item1/en.json +10 -10
- package/dist/templates/react-native/data/routes/en.json +22 -22
- package/dist/templates/react-native/data/routes/styleguide/en.json +227 -227
- package/dist/templates/react-native/data/routes/styleguide/{{language}}.json +31 -31
- package/dist/templates/react-native/data/routes/{{language}}.json +7 -7
- package/dist/templates/react-native/gitignore +60 -60
- package/dist/templates/react-native/ios/Podfile +53 -53
- package/dist/templates/react-native/ios/{{appName}}/AppDelegate.h +15 -15
- package/dist/templates/react-native/ios/{{appName}}/AppDelegate.m +42 -42
- package/dist/templates/react-native/ios/{{appName}}/Base.lproj/LaunchScreen.xib +42 -42
- package/dist/templates/react-native/ios/{{appName}}/Images.xcassets/AppIcon.appiconset/Contents.json +38 -38
- package/dist/templates/react-native/ios/{{appName}}/Images.xcassets/Contents.json +6 -6
- package/dist/templates/react-native/ios/{{appName}}/Info.plist +57 -57
- package/dist/templates/react-native/ios/{{appName}}/main.m +16 -16
- package/dist/templates/react-native/ios/{{appName}}-tvOS/Info.plist +53 -53
- package/dist/templates/react-native/ios/{{appName}}-tvOSTests/Info.plist +24 -24
- package/dist/templates/react-native/ios/{{appName}}.xcodeproj/xcshareddata/xcschemes/BasicSampleReactNative-tvOS.xcscheme +129 -129
- package/dist/templates/react-native/ios/{{appName}}.xcodeproj/xcshareddata/xcschemes/BasicSampleReactNative.xcscheme +129 -129
- package/dist/templates/react-native/ios/{{appName}}Tests/BasicSampleReactNativeTests.m +72 -72
- package/dist/templates/react-native/ios/{{appName}}Tests/Info.plist +24 -24
- package/dist/templates/react-native/package.json +78 -78
- package/dist/templates/react-native/sitecore/config/{{appName}}.config +47 -47
- package/dist/templates/react-native/sitecore/gitignore +2 -2
- package/dist/templates/vue/data/component-content/Styleguide/ContentReuse/LoremIpsumContentBlock/en.yml +9 -9
- package/dist/templates/vue/data/content/Styleguide/ContentListField/Item1/en.yml +6 -6
- package/dist/templates/vue/data/content/Styleguide/ContentListField/Item2/en.yml +6 -6
- package/dist/templates/vue/data/content/Styleguide/EditFrameDemo/Item1/en.yml +6 -6
- package/dist/templates/vue/data/content/Styleguide/EditFrameDemo/Item2/en.yml +6 -6
- package/dist/templates/vue/data/content/Styleguide/ItemLinkField/Item1/en.yml +6 -6
- package/dist/templates/vue/data/content/Styleguide/ItemLinkField/Item2/en.yml +6 -6
- package/dist/templates/vue/data/dictionary/en.yml +7 -7
- package/dist/templates/vue/data/dictionary/{{language}}.yml +7 -7
- package/dist/templates/vue/data/routes/en.yml +63 -63
- package/dist/templates/vue/data/routes/graphql/en.yml +34 -34
- package/dist/templates/vue/data/routes/graphql/sample-1/en.yml +9 -9
- package/dist/templates/vue/data/routes/graphql/sample-2/en.yml +9 -9
- package/dist/templates/vue/data/routes/styleguide/custom-route-type/en.yml +12 -12
- package/dist/templates/vue/data/routes/styleguide/en.yml +264 -264
- package/dist/templates/vue/data/routes/styleguide/{{language}}.yml +26 -26
- package/dist/templates/vue/data/routes/{{language}}.yml +4 -4
- package/dist/templates/vue/package.json +13 -13
- package/dist/templates/vue/public/img/icons/safari-pinned-tab.svg +75 -75
- package/dist/templates/vue/src/assets/sc_logo.svg +52 -52
- package/package.json +20 -22
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
# Sitecore JSS React Native Sample Application
|
|
2
|
-
|
|
3
|
-
<!---
|
|
4
|
-
@TODO: Update to next version docs before release
|
|
5
|
-
-->
|
|
6
|
-
[Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/22/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-react-native.html)
|
|
7
|
-
|
|
8
|
-
## Note
|
|
9
|
-
|
|
10
|
-
Sitecore JSS for React Native is considered highly experimental. It is strongly recommended that you have prior experience working with JSS, React Native, the toolchain that React Native requires, and have some exposure to native app development.
|
|
11
|
-
|
|
12
|
-
## Prerequisites
|
|
13
|
-
|
|
14
|
-
The basic sample for React Native is based on a project created via the React Native CLI, e.g. `react-native init`
|
|
15
|
-
Your first step will be to follow the instructions on this page: https://reactnative.dev/docs/environment-setup
|
|
16
|
-
|
|
17
|
-
Choose the `React Native CLI Quickstart` tab, then choose your Development OS and app Target OS. We have tested the basic sample app on the following configurations:
|
|
18
|
-
|
|
19
|
-
- Windows / Android
|
|
20
|
-
- In this configuration, testing was done using a physical device connected via USB to the development machine, not the Android emulator.
|
|
21
|
-
- macOS / iOS
|
|
22
|
-
- In this configuration, testing was done using the Xcode simulator.
|
|
23
|
-
|
|
24
|
-
The installation process for all the necessary Android/iOS dependencies and tools can take a significant amount of time - plan accordingly.
|
|
25
|
-
|
|
26
|
-
## Getting Started
|
|
27
|
-
|
|
28
|
-
1. Ensure you have completed the Prerequisites section and have confirmed you're able to run the `AwesomeProject` sample that the instructions direct you to create.
|
|
29
|
-
|
|
30
|
-
1. At this point, you can follow steps 1 and 2 from the JSS Quick Start guide: https://jss.sitecore.com/docs/getting-started/quick-start, or the following abbreviated version:
|
|
31
|
-
|
|
32
|
-
1. In a new folder, clone or download the basic sample app repo: https://github.com/Sitecore/jss/tree/master/samples/react-native
|
|
33
|
-
|
|
34
|
-
1. If you don't have Sitecore installed or aren't planning to immediately develop against a Sitecore instance, skip to the next step.
|
|
35
|
-
|
|
36
|
-
- Otherwise, if you have Sitecore installed: from a terminal, run `npm run setup`
|
|
37
|
-
|
|
38
|
-
1. Choose your target platform:
|
|
39
|
-
|
|
40
|
-
- Android: run `npm run start-android`
|
|
41
|
-
|
|
42
|
-
- iOS: run `npm run start-ios`
|
|
43
|
-
|
|
44
|
-
At this point, the React Native build process should start, opening 1 or 2 separate terminal window(s)/tab(s) containing the output from the React Native `Metro` bundler and the output from the React Native platform-specific compiler (e.g. Xcode, Android SDK).
|
|
45
|
-
|
|
46
|
-
Once the build process completes, you should see the basic sample app in the simulator or physical device (whichever you're choosing to use). _Note: the initial build can take several minutes. Subsequent builds are typically much faster. This is not something specific to JSS, but rather normal behavior for React Native._
|
|
47
|
-
|
|
48
|
-
The app will be running in `disconnected` application mode. This means data and assets are embedded statically within the app.
|
|
49
|
-
|
|
50
|
-
## Build customizations
|
|
51
|
-
|
|
52
|
-
Although the build process is largely the same as "normal" React Native, we've customized the invocation of the process a bit. In particular:
|
|
53
|
-
|
|
54
|
-
- We've added a custom `babel` preset that encapsulates other `babel` plugins that allow us to swap module dependencies at build-time based on the application mode in which you're developing. The basic sample currently uses `disconnected` and `connected` modes along with a new, native-specific, `disconnected-tunnel` mode. More info on that further on in this document.
|
|
55
|
-
|
|
56
|
-
- For more information about JSS application modes, please refer to the official Sitecore JSS documentation: https://jss.sitecore.com/#/application-modes?id=jss-application-modes
|
|
57
|
-
|
|
58
|
-
- One other customization to build invocation is the addition of the `--reset-cache` argument to the metro bundler `start` script. This argument instructs the bundler to ignore its dependency cache during the build process, which ensures that the `babel` customizations mentioned earlier are invoked and allows you to easily switch between application modes at build time.
|
|
59
|
-
|
|
60
|
-
## Deployment to Sitecore
|
|
61
|
-
|
|
62
|
-
All of the standard Sitecore JSS manifest generation and deployment processes are available for this project. You can follow the official guides for [setting up the Sitecore server](https://jss.sitecore.com/docs/getting-started/jss-server-install) and subsequently [deploying your app](https://jss.sitecore.com/docs/getting-started/app-deployment). Once setup and deployment are complete, you will be able to run your JSS app in `connected` or `connected-tunnel` modes.
|
|
63
|
-
|
|
64
|
-
## Connecting to Sitecore
|
|
65
|
-
|
|
66
|
-
When you're ready to connect to Sitecore for data, you have two application mode options: `connected` and `connected-tunnel`.
|
|
67
|
-
|
|
68
|
-
### Connected Mode
|
|
69
|
-
|
|
70
|
-
Connected mode essentially means that all route data and network images for your app are retrieved from a remote Sitecore instance. Each target app OS has a npm script for starting connected mode:
|
|
71
|
-
|
|
72
|
-
`start-android:connected`
|
|
73
|
-
|
|
74
|
-
`start-ios:connected`
|
|
75
|
-
|
|
76
|
-
For more information on Connected mode, please refer to the official Sitecore JSS documentation: https://jss.sitecore.com/#/application-modes?id=connected-developer-mode
|
|
77
|
-
|
|
78
|
-
### Connected Tunnel Mode
|
|
79
|
-
|
|
80
|
-
Connected tunnel mode is similar to connected mode in that you are connecting to a Sitecore instance for route data and network images, but the Sitecore instance is on your local machine or otherwise unavailable via public DNS.
|
|
81
|
-
|
|
82
|
-
For example:
|
|
83
|
-
You have a Sitecore instance installed on your dev machine and a Sitecore site that is configured to use `jssbasicapp` for a hostname, and you have host bindings set to `jssbasicapp` for an IIS site, and `jssbasicapp` is configured in your hosts file. This a very common scenario for local Sitecore development.
|
|
84
|
-
|
|
85
|
-
Now imagine testing a native app in either a simulator or on a physical device. The app may try to make requests to `http://jssbasicapp`, but that host can't be resolved because the simulator/device does not use your local machine for DNS resolution.
|
|
86
|
-
|
|
87
|
-
This is where Connected Tunnel mode will provide benefit. When you use Connected Tunnel mode, we use an instance of [`ngrok`](https://ngrok.com/) to create a tunnel between your simulator / device and your local dev machine. We then modify Layout Service and media requests from your app to use the ngrok tunnel, which will tunnel response data from Sitecore back to your app. This means you don't have to change any host bindings on your dev machine.
|
|
88
|
-
|
|
89
|
-
Each target app OS has a npm script for starting connected tunnel mode:
|
|
90
|
-
|
|
91
|
-
`start-android:connected-tunnel`
|
|
92
|
-
|
|
93
|
-
`start-ios:connected-tunnel`
|
|
94
|
-
|
|
95
|
-
## Assets
|
|
96
|
-
|
|
97
|
-
Your app may have two types of assets: `static` and `network`. Static assets are those that are embedded as resources in your app. Network assets are those that are retrieved from a remote URL.
|
|
98
|
-
|
|
99
|
-
When developing in disconnected mode, it may be desirable to treat "future" network assets as static assets. For instance, if you're following a code-first approach, you'll likely have assets in your code base that will eventually be imported into Sitecore. At that point, the asset becomes a network asset. Prior to that, however, you may want to test your app with all assets handled as static.
|
|
100
|
-
|
|
101
|
-
In React Native, static assets must be referenced in your code with a `require()` statement so that the React Native packager can resolve references to assets at build time and include them in your app bundle. Unfortunately, the asset path must be static as well, meaning we can't use dynamic values for `require()` paths.
|
|
102
|
-
|
|
103
|
-
To help illustrate the issue, let's look at our disconnected data (in `/data/routes/en.json`). You'll notice it contains an image field referencing `/data/media/img/sc_logo.png`. When our React native Image component needs to reference that image statically, we need to `require` it, e.g. `require('/data/media/img/sc_logo.png')`, but that require can't happen at runtime.
|
|
104
|
-
|
|
105
|
-
In order to work around this limitation, we map our static assets in disconnected mode and then swap out references to those assets at runtime. For example, look at the `/assets/images.disconnected.js` file. You can see it exports an object with keys corresponding to an image location and the corresponding static `require()` statement.
|
|
106
|
-
|
|
107
|
-
Then, in the `/src/dataService/dataService.disconnected.js` file, when the disconnected route data is being retrieved, we process the data and replace any static image paths we encounter with the corresponding value from the image object map mentioned earlier.
|
|
108
|
-
|
|
109
|
-
When working in `connected` or `connected-tunnel` mode, we can use the `/assets/images.connected.js` map, which removes references to images that are retrieved via http.
|
|
110
|
-
|
|
111
|
-
## Known limitations
|
|
112
|
-
|
|
113
|
-
- For MacOS, `ttab` dependency doesn't work in VS Code Powershell terminal.
|
|
114
|
-
|
|
115
|
-
- For MacOS, the `glob` pattern used by all other demo apps does not work for finding `.sitecore.js` files for Sitecore manifest generation: `./sitecore/**/*.sitecore.j`
|
|
1
|
+
# Sitecore JSS React Native Sample Application
|
|
2
|
+
|
|
3
|
+
<!---
|
|
4
|
+
@TODO: Update to next version docs before release
|
|
5
|
+
-->
|
|
6
|
+
[Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/22/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-react-native.html)
|
|
7
|
+
|
|
8
|
+
## Note
|
|
9
|
+
|
|
10
|
+
Sitecore JSS for React Native is considered highly experimental. It is strongly recommended that you have prior experience working with JSS, React Native, the toolchain that React Native requires, and have some exposure to native app development.
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
The basic sample for React Native is based on a project created via the React Native CLI, e.g. `react-native init`
|
|
15
|
+
Your first step will be to follow the instructions on this page: https://reactnative.dev/docs/environment-setup
|
|
16
|
+
|
|
17
|
+
Choose the `React Native CLI Quickstart` tab, then choose your Development OS and app Target OS. We have tested the basic sample app on the following configurations:
|
|
18
|
+
|
|
19
|
+
- Windows / Android
|
|
20
|
+
- In this configuration, testing was done using a physical device connected via USB to the development machine, not the Android emulator.
|
|
21
|
+
- macOS / iOS
|
|
22
|
+
- In this configuration, testing was done using the Xcode simulator.
|
|
23
|
+
|
|
24
|
+
The installation process for all the necessary Android/iOS dependencies and tools can take a significant amount of time - plan accordingly.
|
|
25
|
+
|
|
26
|
+
## Getting Started
|
|
27
|
+
|
|
28
|
+
1. Ensure you have completed the Prerequisites section and have confirmed you're able to run the `AwesomeProject` sample that the instructions direct you to create.
|
|
29
|
+
|
|
30
|
+
1. At this point, you can follow steps 1 and 2 from the JSS Quick Start guide: https://jss.sitecore.com/docs/getting-started/quick-start, or the following abbreviated version:
|
|
31
|
+
|
|
32
|
+
1. In a new folder, clone or download the basic sample app repo: https://github.com/Sitecore/jss/tree/master/samples/react-native
|
|
33
|
+
|
|
34
|
+
1. If you don't have Sitecore installed or aren't planning to immediately develop against a Sitecore instance, skip to the next step.
|
|
35
|
+
|
|
36
|
+
- Otherwise, if you have Sitecore installed: from a terminal, run `npm run setup`
|
|
37
|
+
|
|
38
|
+
1. Choose your target platform:
|
|
39
|
+
|
|
40
|
+
- Android: run `npm run start-android`
|
|
41
|
+
|
|
42
|
+
- iOS: run `npm run start-ios`
|
|
43
|
+
|
|
44
|
+
At this point, the React Native build process should start, opening 1 or 2 separate terminal window(s)/tab(s) containing the output from the React Native `Metro` bundler and the output from the React Native platform-specific compiler (e.g. Xcode, Android SDK).
|
|
45
|
+
|
|
46
|
+
Once the build process completes, you should see the basic sample app in the simulator or physical device (whichever you're choosing to use). _Note: the initial build can take several minutes. Subsequent builds are typically much faster. This is not something specific to JSS, but rather normal behavior for React Native._
|
|
47
|
+
|
|
48
|
+
The app will be running in `disconnected` application mode. This means data and assets are embedded statically within the app.
|
|
49
|
+
|
|
50
|
+
## Build customizations
|
|
51
|
+
|
|
52
|
+
Although the build process is largely the same as "normal" React Native, we've customized the invocation of the process a bit. In particular:
|
|
53
|
+
|
|
54
|
+
- We've added a custom `babel` preset that encapsulates other `babel` plugins that allow us to swap module dependencies at build-time based on the application mode in which you're developing. The basic sample currently uses `disconnected` and `connected` modes along with a new, native-specific, `disconnected-tunnel` mode. More info on that further on in this document.
|
|
55
|
+
|
|
56
|
+
- For more information about JSS application modes, please refer to the official Sitecore JSS documentation: https://jss.sitecore.com/#/application-modes?id=jss-application-modes
|
|
57
|
+
|
|
58
|
+
- One other customization to build invocation is the addition of the `--reset-cache` argument to the metro bundler `start` script. This argument instructs the bundler to ignore its dependency cache during the build process, which ensures that the `babel` customizations mentioned earlier are invoked and allows you to easily switch between application modes at build time.
|
|
59
|
+
|
|
60
|
+
## Deployment to Sitecore
|
|
61
|
+
|
|
62
|
+
All of the standard Sitecore JSS manifest generation and deployment processes are available for this project. You can follow the official guides for [setting up the Sitecore server](https://jss.sitecore.com/docs/getting-started/jss-server-install) and subsequently [deploying your app](https://jss.sitecore.com/docs/getting-started/app-deployment). Once setup and deployment are complete, you will be able to run your JSS app in `connected` or `connected-tunnel` modes.
|
|
63
|
+
|
|
64
|
+
## Connecting to Sitecore
|
|
65
|
+
|
|
66
|
+
When you're ready to connect to Sitecore for data, you have two application mode options: `connected` and `connected-tunnel`.
|
|
67
|
+
|
|
68
|
+
### Connected Mode
|
|
69
|
+
|
|
70
|
+
Connected mode essentially means that all route data and network images for your app are retrieved from a remote Sitecore instance. Each target app OS has a npm script for starting connected mode:
|
|
71
|
+
|
|
72
|
+
`start-android:connected`
|
|
73
|
+
|
|
74
|
+
`start-ios:connected`
|
|
75
|
+
|
|
76
|
+
For more information on Connected mode, please refer to the official Sitecore JSS documentation: https://jss.sitecore.com/#/application-modes?id=connected-developer-mode
|
|
77
|
+
|
|
78
|
+
### Connected Tunnel Mode
|
|
79
|
+
|
|
80
|
+
Connected tunnel mode is similar to connected mode in that you are connecting to a Sitecore instance for route data and network images, but the Sitecore instance is on your local machine or otherwise unavailable via public DNS.
|
|
81
|
+
|
|
82
|
+
For example:
|
|
83
|
+
You have a Sitecore instance installed on your dev machine and a Sitecore site that is configured to use `jssbasicapp` for a hostname, and you have host bindings set to `jssbasicapp` for an IIS site, and `jssbasicapp` is configured in your hosts file. This a very common scenario for local Sitecore development.
|
|
84
|
+
|
|
85
|
+
Now imagine testing a native app in either a simulator or on a physical device. The app may try to make requests to `http://jssbasicapp`, but that host can't be resolved because the simulator/device does not use your local machine for DNS resolution.
|
|
86
|
+
|
|
87
|
+
This is where Connected Tunnel mode will provide benefit. When you use Connected Tunnel mode, we use an instance of [`ngrok`](https://ngrok.com/) to create a tunnel between your simulator / device and your local dev machine. We then modify Layout Service and media requests from your app to use the ngrok tunnel, which will tunnel response data from Sitecore back to your app. This means you don't have to change any host bindings on your dev machine.
|
|
88
|
+
|
|
89
|
+
Each target app OS has a npm script for starting connected tunnel mode:
|
|
90
|
+
|
|
91
|
+
`start-android:connected-tunnel`
|
|
92
|
+
|
|
93
|
+
`start-ios:connected-tunnel`
|
|
94
|
+
|
|
95
|
+
## Assets
|
|
96
|
+
|
|
97
|
+
Your app may have two types of assets: `static` and `network`. Static assets are those that are embedded as resources in your app. Network assets are those that are retrieved from a remote URL.
|
|
98
|
+
|
|
99
|
+
When developing in disconnected mode, it may be desirable to treat "future" network assets as static assets. For instance, if you're following a code-first approach, you'll likely have assets in your code base that will eventually be imported into Sitecore. At that point, the asset becomes a network asset. Prior to that, however, you may want to test your app with all assets handled as static.
|
|
100
|
+
|
|
101
|
+
In React Native, static assets must be referenced in your code with a `require()` statement so that the React Native packager can resolve references to assets at build time and include them in your app bundle. Unfortunately, the asset path must be static as well, meaning we can't use dynamic values for `require()` paths.
|
|
102
|
+
|
|
103
|
+
To help illustrate the issue, let's look at our disconnected data (in `/data/routes/en.json`). You'll notice it contains an image field referencing `/data/media/img/sc_logo.png`. When our React native Image component needs to reference that image statically, we need to `require` it, e.g. `require('/data/media/img/sc_logo.png')`, but that require can't happen at runtime.
|
|
104
|
+
|
|
105
|
+
In order to work around this limitation, we map our static assets in disconnected mode and then swap out references to those assets at runtime. For example, look at the `/assets/images.disconnected.js` file. You can see it exports an object with keys corresponding to an image location and the corresponding static `require()` statement.
|
|
106
|
+
|
|
107
|
+
Then, in the `/src/dataService/dataService.disconnected.js` file, when the disconnected route data is being retrieved, we process the data and replace any static image paths we encounter with the corresponding value from the image object map mentioned earlier.
|
|
108
|
+
|
|
109
|
+
When working in `connected` or `connected-tunnel` mode, we can use the `/assets/images.connected.js` map, which removes references to images that are retrieved via http.
|
|
110
|
+
|
|
111
|
+
## Known limitations
|
|
112
|
+
|
|
113
|
+
- For MacOS, `ttab` dependency doesn't work in VS Code Powershell terminal.
|
|
114
|
+
|
|
115
|
+
- For MacOS, the `glob` pattern used by all other demo apps does not work for finding `.sitecore.js` files for Sitecore manifest generation: `./sitecore/**/*.sitecore.j`
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
# To learn about Buck see [Docs](https://buckbuild.com/).
|
|
2
|
-
# To run your application with Buck:
|
|
3
|
-
# - install Buck
|
|
4
|
-
# - `npm start` - to start the packager
|
|
5
|
-
# - `cd android`
|
|
6
|
-
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
|
|
7
|
-
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
|
|
8
|
-
# - `buck install -r android/app` - compile, install and run application
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
|
|
12
|
-
|
|
13
|
-
lib_deps = []
|
|
14
|
-
|
|
15
|
-
create_aar_targets(glob(["libs/*.aar"]))
|
|
16
|
-
|
|
17
|
-
create_jar_targets(glob(["libs/*.jar"]))
|
|
18
|
-
|
|
19
|
-
android_library(
|
|
20
|
-
name = "all-libs",
|
|
21
|
-
exported_deps = lib_deps,
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
android_library(
|
|
25
|
-
name = "app-code",
|
|
26
|
-
srcs = glob([
|
|
27
|
-
"src/main/java/**/*.java",
|
|
28
|
-
]),
|
|
29
|
-
deps = [
|
|
30
|
-
":all-libs",
|
|
31
|
-
":build_config",
|
|
32
|
-
":res",
|
|
33
|
-
],
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
android_build_config(
|
|
37
|
-
name = "build_config",
|
|
38
|
-
package = "com.<%- appName %>",
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
android_resource(
|
|
42
|
-
name = "res",
|
|
43
|
-
package = "com.<%- appName %>",
|
|
44
|
-
res = "src/main/res",
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
android_binary(
|
|
48
|
-
name = "app",
|
|
49
|
-
keystore = "//android/keystores:debug",
|
|
50
|
-
manifest = "src/main/AndroidManifest.xml",
|
|
51
|
-
package_type = "debug",
|
|
52
|
-
deps = [
|
|
53
|
-
":app-code",
|
|
54
|
-
],
|
|
55
|
-
)
|
|
1
|
+
# To learn about Buck see [Docs](https://buckbuild.com/).
|
|
2
|
+
# To run your application with Buck:
|
|
3
|
+
# - install Buck
|
|
4
|
+
# - `npm start` - to start the packager
|
|
5
|
+
# - `cd android`
|
|
6
|
+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
|
|
7
|
+
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
|
|
8
|
+
# - `buck install -r android/app` - compile, install and run application
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
|
|
12
|
+
|
|
13
|
+
lib_deps = []
|
|
14
|
+
|
|
15
|
+
create_aar_targets(glob(["libs/*.aar"]))
|
|
16
|
+
|
|
17
|
+
create_jar_targets(glob(["libs/*.jar"]))
|
|
18
|
+
|
|
19
|
+
android_library(
|
|
20
|
+
name = "all-libs",
|
|
21
|
+
exported_deps = lib_deps,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
android_library(
|
|
25
|
+
name = "app-code",
|
|
26
|
+
srcs = glob([
|
|
27
|
+
"src/main/java/**/*.java",
|
|
28
|
+
]),
|
|
29
|
+
deps = [
|
|
30
|
+
":all-libs",
|
|
31
|
+
":build_config",
|
|
32
|
+
":res",
|
|
33
|
+
],
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
android_build_config(
|
|
37
|
+
name = "build_config",
|
|
38
|
+
package = "com.<%- appName %>",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
android_resource(
|
|
42
|
+
name = "res",
|
|
43
|
+
package = "com.<%- appName %>",
|
|
44
|
+
res = "src/main/res",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
android_binary(
|
|
48
|
+
name = "app",
|
|
49
|
+
keystore = "//android/keystores:debug",
|
|
50
|
+
manifest = "src/main/AndroidManifest.xml",
|
|
51
|
+
package_type = "debug",
|
|
52
|
+
deps = [
|
|
53
|
+
":app-code",
|
|
54
|
+
],
|
|
55
|
+
)
|