Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/ember-cli-fastboot/addon/locations/none.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable ember/no-classic-classes, ember/no-get, ember/require-computed-property-dependencies, prettier/prettier */
import { computed, get } from '@ember/object';
import { bool, readOnly } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;
import { getOwner } from '@ember/application'
import NoneLocation from '@ember/routing/none-location'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable prettier/prettier */
import Ember from 'ember';
import { getOnerror, setOnerror } from '@ember/-internals/error-handling';

/**
* Initializer to attach an `onError` hook to your app running in fastboot. It catches any run loop
Expand All @@ -10,12 +10,12 @@ export default {
name: 'error-handler',

initialize: function() {
if (!Ember.onerror) {
if (!getOnerror()) {
// if no onerror handler is defined, define one for fastboot environments
Ember.onerror = function(err) {
setOnerror(function(err) {
const errorMessage = `There was an error running your app in fastboot. More info about the error: \n ${err.stack || err}`;
console.error(errorMessage);
}
});
}
}
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable ember/no-classic-classes, ember/no-get, prettier/prettier */
import Route from '@ember/routing/route';
import { inject } from '@ember/service';
import * as serviceModule from '@ember/service';
const inject = serviceModule.service || serviceModule.inject;
import { readOnly } from '@ember/object/computed';

export default Route.extend({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,36 @@
if (typeof FastBoot === 'undefined') {
var current = document.getElementById('fastboot-body-start');

var _Ember = require.has('ember') ? require('ember').default : window.Ember;
if (!current) {
return;
}

var isSerializationFirstNode;
var ApplicationInstance;

if (require.has('@ember/-internals/glimmer') && require.has('@ember/application/instance')) {
isSerializationFirstNode = require('@ember/-internals/glimmer').isSerializationFirstNode;
ApplicationInstance = require('@ember/application/instance').default;
} else if (require.has('ember')) {
var _Ember = require('ember').default;
isSerializationFirstNode = _Ember.ViewUtils.isSerializationFirstNode;
ApplicationInstance = _Ember.ApplicationInstance;
} else if (window.Ember) {
isSerializationFirstNode = window.Ember.ViewUtils.isSerializationFirstNode;
ApplicationInstance = window.Ember.ApplicationInstance;
}

if (current && !_Ember) {
if (!isSerializationFirstNode || !ApplicationInstance) {
console.error(`Experimental render mode rehydrate isn't working because it couldn't find Ember via AMD or global.
See https://github.com/ember-fastboot/ember-cli-fastboot/issues/938 for the current state of the fix.`);
return;
}

if (
current &&
typeof _Ember.ViewUtils.isSerializationFirstNode === 'function' &&
_Ember.ViewUtils.isSerializationFirstNode(current.nextSibling)
typeof isSerializationFirstNode === 'function' &&
isSerializationFirstNode(current.nextSibling)
) {
_Ember.ApplicationInstance.reopen({
ApplicationInstance.reopen({
_bootSync: function(options) {
if (options === undefined) {
options = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ appScenarios
routes: {
'redirect-on-transition-to.js': `
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;

export default class MyRoute extends Route {
@service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ appScenarios
app: {
routes: {
'index.js': `import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;

function isEmptyObject(obj) {
return Object.keys(obj).length === 0 && obj.constructor.name === 'Object';
Expand All @@ -46,7 +47,8 @@ appScenarios
}
}`,
'application.js': `import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;

export default class ApplicationRoute extends Route {
@service fastboot;
Expand Down
3 changes: 2 additions & 1 deletion test-packages/test-scenarios/fastboot-shoebox-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ appScenarios
app: {
routes: {
'application.js': `import Route from '@ember/routing/route';
import { inject as service } from '@ember/service'
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;

export default class ApplicationRoute extends Route {
@service fastboot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { defer } from 'rsvp';
import { later } from '@ember/runloop';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;

export default class AsyncContenComponent extends Component {
@service fastboot;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;

export default class ApplicationRoute extends Route {
@service fastboot;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;

export default class EchoRequestHeadersRoute extends Route {
@service fastboot;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { set } from '@ember/object';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;

export default class HeadContentRoute extends Route {
@service headData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;

export default Route.extend({
fastboot: service(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import * as serviceModule from '@ember/service';
const service = serviceModule.service || serviceModule.inject;

export default class ReturnStatusCode418Route extends Route {
@service fastboot;
Expand Down
13 changes: 8 additions & 5 deletions test-packages/test-scenarios/oneerror-per-visit-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ appScenarios
});
});`,
'instance-initializers': {
'setup-onerror.js': `import Ember from 'ember';
'setup-onerror.js': `import { setOnerror } from '@ember/-internals/error-handling';
export function initialize(owner) {
let isFastBoot = typeof 'FastBoot' !== 'undefined';
let fastbootRequestPath;
Expand All @@ -36,12 +36,12 @@ appScenarios

console.log('setting up error handler ' + fastbootRequestPath);

Ember.onerror = function (error) {
setOnerror(function (error) {
if (isFastBoot) {
error.fastbootRequestPath = fastbootRequestPath;
throw error;
}
};
});
}

export default {
Expand All @@ -52,12 +52,15 @@ appScenarios
routes: {
'application.js': `import Route from '@ember/routing/route';
import { action } from '@ember/object';
import Ember from 'ember';
import { getOnerror } from '@ember/-internals/error-handling';

export default class ApplicationRoute extends Route {
@action
error(err) {
Ember.onerror(err);
const onerror = getOnerror();
if (onerror) {
onerror(err);
}
}
}
`,
Expand Down
Loading