@adobe/generator-aio-app
Advanced tools
Comparing version 0.7.2 to 0.7.3
@@ -52,2 +52,3 @@ /* | ||
'regenerator-runtime': '^0.13.5', | ||
'@adobe/exc-app': '^0.2.14', | ||
'@react-spectrum/button': '^3.0.0-rc.2', | ||
@@ -71,3 +72,3 @@ '@react-spectrum/form': '^3.0.0-rc.2', | ||
utils.appendOrWrite(this, this.destinationPath(dotenvFilename), | ||
'AIO_LAUNCH_URL_PREFIX="https://experience.adobe.com/?devMode=true#/myapps/?localDevUrl="') | ||
'AIO_LAUNCH_URL_PREFIX="https://experience.adobe.com/?devMode=true#/apps/?localDevUrl="') | ||
} | ||
@@ -74,0 +75,0 @@ |
@@ -68,2 +68,12 @@ /*<% if (false) { %> | ||
console.log('ims object:', this.props.ims) | ||
// use exc runtime event handlers | ||
// respond to configuration change events (e.g. user switches org) | ||
this.props.runtime.on('configuration', ({ imsOrg, imsToken, locale }) => { | ||
console.log('configuration change', { imsOrg, imsToken, locale }) | ||
}) | ||
// respond to history change events | ||
this.props.runtime.on('history', ({ type, path }) => { | ||
console.log('history change', { type, path }) | ||
}) | ||
} | ||
@@ -70,0 +80,0 @@ |
@@ -14,3 +14,11 @@ /*<% if (false) { %> | ||
/** | ||
* | ||
* Script to load the Adobe Experience Cloud Runtime. | ||
* | ||
* @throws {Error} error in case of failure, most likely when the app is not running in | ||
* the Experience Cloud Shell. | ||
* | ||
*/ | ||
/* eslint-disable-next-line */ | ||
module.exports = function(e,t){if(t.location===t.parent.location)throw new Error("Module Runtime: Needs to be within an iframe!");var o=function(e){var t=new URL(e.location.href).searchParams.get("_mr");return t||!e.EXC_US_HMR?t:e.sessionStorage.getItem("unifiedShellMRScript")}(t);if(!o)throw new Error("Module Runtime: Missing script!");if("https:"!==(o=new URL(decodeURIComponent(o))).protocol)throw new Error("Module Runtime: Must be HTTPS!");if(!/experience(-qa|-stage)?\.adobe\.com$/.test(o.hostname)&&!/localhost\.corp\.adobe\.com$/.test(o.hostname))throw new Error("Module Runtime: Invalid domain!");if(!/\.js$/.test(o.pathname))throw new Error("Module Runtime: Must be a JavaScript file!");t.EXC_US_HMR&&t.sessionStorage.setItem("unifiedShellMRScript",o.toString());var n=e.createElement("script");n.async=1,n.src=o.toString(),n.onload=n.onreadystatechange=function(){n.readyState&&!/loaded|complete/.test(n.readyState)||(n.onload=n.onreadystatechange=null,n=void 0,"EXC_MR_READY"in t&&t.EXC_MR_READY())},e.head.appendChild(n)}; | ||
(function(e,t){if(t.location===t.parent.location)throw new Error("Module Runtime: Needs to be within an iframe!");var o=function(e){var t=new URL(e.location.href).searchParams.get("_mr");return t||!e.EXC_US_HMR?t:e.sessionStorage.getItem("unifiedShellMRScript")}(t);if(!o)throw new Error("Module Runtime: Missing script!");if("https:"!==(o=new URL(decodeURIComponent(o))).protocol)throw new Error("Module Runtime: Must be HTTPS!");if(!/^(exc-unifiedcontent\.)?experience(-qa|-stage|-cdn|-cdn-stage)?\.adobe\.(com|net)$/.test(o.hostname)&&!/localhost\.corp\.adobe\.com$/.test(o.hostname))throw new Error("Module Runtime: Invalid domain!");if(!/\.js$/.test(o.pathname))throw new Error("Module Runtime: Must be a JavaScript file!");t.EXC_US_HMR&&t.sessionStorage.setItem("unifiedShellMRScript",o.toString());var n=e.createElement("script");n.async=1,n.src=o.toString(),n.onload=n.onreadystatechange=function(){n.readyState&&!/loaded|complete/.test(n.readyState)||(n.onload=n.onreadystatechange=null,n=void 0,"EXC_MR_READY"in t&&t.EXC_MR_READY())},e.head.appendChild(n)})(document,window); |
@@ -20,44 +20,30 @@ /*<% if (false) { %> | ||
import Runtime, { init } from '@adobe/exc-app' | ||
import App from './App' | ||
import loadExcRuntime from './exc-runtime' | ||
/* Here you can bootstrap your application and configure the integration with the Adobe Experience Cloud Shell */ | ||
let inExc = false | ||
try { | ||
// throws if not running in exc | ||
loadExcRuntime(document, window) | ||
inExc = true | ||
// attempt to load the Experience Cloud Runtime | ||
require('./exc-runtime') | ||
// if there are no errors, bootstrap the app in the Experience Cloud Shell | ||
init(bootstrapInExcShell) | ||
} catch (e) { | ||
console.log('application not running in Adobe Experience Cloud Shell') | ||
// fallback, not in exc run the UI without the shell | ||
// fallback mode, run the application without the Experience Cloud Runtime | ||
bootstrapRaw() | ||
} | ||
if (inExc) { | ||
// this piece of code is needed in case the Adobe Experience Cloud shell runtime is not yet loaded. | ||
// if it is ready we bootstrap the app, otherwise we defer the bootstrapping to the exc runtime when it is ready. | ||
if ('exc-module-runtime' in window) { | ||
bootstrapInExcShell() | ||
} else { | ||
// callback for the exc shell runtime, if not ready yet | ||
window.EXC_MR_READY = () => bootstrapInExcShell() | ||
} | ||
} | ||
function bootstrapRaw () { | ||
/* **here you can mock the exc runtime and ims objects** */ | ||
const runtime = {} | ||
const ims = {} | ||
const mockRuntime = { on: () => {} } | ||
const mockIms = {} | ||
// render the actual react application and pass along the runtime object to make it available to the App | ||
ReactDOM.render(<App runtime={ runtime } ims={ ims }/>, document.getElementById('root')) | ||
ReactDOM.render(<App runtime={ mockRuntime } ims={ mockIms }/>, document.getElementById('root')) | ||
} | ||
function bootstrapInExcShell () { | ||
// initializes the runtime object | ||
const Runtime = window['exc-module-runtime'].default | ||
const runtime = new Runtime({ | ||
// this options allows the app to takeover 100% of the browser's viewport | ||
canTakeover: true | ||
}) | ||
// get the Experience Cloud Runtime object | ||
const runtime = Runtime() | ||
@@ -75,2 +61,4 @@ // set the app name to the Shell header | ||
runtime.on('ready', ({ imsOrg, imsToken, imsProfile, locale }) => { | ||
// tell the exc-runtime object we are done | ||
runtime.done() | ||
console.log('Ready! received imsProfile:', imsProfile) | ||
@@ -86,9 +74,2 @@ const ims = { | ||
// respond to history change events | ||
runtime.historyChange = path => { | ||
console.log('history changed :: ', path) | ||
// this.history.replace(path) | ||
// this.setState({currentPath: `/${path}`}) | ||
} | ||
// set solution info, shortTitle is used when window is too small to display full title | ||
@@ -101,5 +82,2 @@ runtime.solution = { | ||
runtime.title = '<%= projectName %>' | ||
// tell the exc-runtime object we are done | ||
runtime.done() | ||
} |
{ | ||
"name": "@adobe/generator-aio-app", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"description": "Adobe I/O application yeoman code generator", | ||
@@ -5,0 +5,0 @@ "main": "generators/app/index.js", |
@@ -41,3 +41,3 @@ /* | ||
function assertEnvContent (prevContent) { | ||
assert.fileContent('.env', 'AIO_LAUNCH_URL_PREFIX="https://experience.adobe.com/?devMode=true#/myapps/?localDevUrl="') | ||
assert.fileContent('.env', 'AIO_LAUNCH_URL_PREFIX="https://experience.adobe.com/?devMode=true#/apps/?localDevUrl="') | ||
assert.fileContent('.env', prevContent) | ||
@@ -54,2 +54,3 @@ } | ||
'regenerator-runtime': expect.any(String), | ||
'@adobe/exc-app': expect.any(String), | ||
'@react-spectrum/button': expect.any(String), | ||
@@ -77,2 +78,3 @@ '@react-spectrum/form': expect.any(String), | ||
assert.file('web-src/404.html') | ||
assert.file('web-src/src/exc-runtime.js') | ||
assert.file('web-src/src/index.js') | ||
@@ -82,3 +84,2 @@ assert.file('web-src/src/App.js') | ||
assert.file('web-src/src/utils.js') | ||
assert.file('web-src/src/exc-runtime.js') | ||
} | ||
@@ -85,0 +86,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
223119