Skip to content

Commit f50f4fe

Browse files
authored
Merge pull request #923 from ember-learn/mappings-request
stop requesting mappings over the network and fix shoebox usage
2 parents 4677173 + fc64a22 commit f50f4fe

File tree

11 files changed

+39
-75
lines changed

11 files changed

+39
-75
lines changed

app/adapters/application.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,8 @@ export default class Application extends JSONAPIAdapter {
2929
return false;
3030
}
3131

32-
shouldBackgroundReloadRecord(store, { modelName, id }) {
33-
let key = `${modelName}-${id}`;
34-
let hasId = this.ids[key];
35-
if (!hasId) {
36-
this.ids[key] = true;
37-
}
38-
return !hasId;
32+
shouldBackgroundReloadRecord() {
33+
return false;
3934
}
4035

4136
constructor() {

app/routes/class.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,13 @@ export default class ClassRoute extends Route {
1010
legacyModuleMappings;
1111

1212
model(params) {
13-
return this.legacyModuleMappings
14-
.fetch()
15-
.then((response) => response.json())
16-
.then((mappings) => {
17-
let ret = {
18-
mappings: this.legacyModuleMappings.buildMappings(mappings),
19-
className: params['class'].substr(
20-
0,
21-
params['class'].lastIndexOf('.')
22-
),
23-
};
24-
return ret;
25-
});
13+
let ret = {
14+
mappings: this.legacyModuleMappings.buildMappings(
15+
this.legacyModuleMappings.legacyMappings
16+
),
17+
className: params['class'].substr(0, params['class'].lastIndexOf('.')),
18+
};
19+
return ret;
2620
}
2721

2822
redirect(model) {

app/routes/data-class.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@ export default class DataClassRoute extends Route {
1010
legacyModuleMappings;
1111

1212
model(params) {
13-
return this.legacyModuleMappings
14-
.fetch()
15-
.then((response) => response.json())
16-
.then((mappings) => {
17-
return {
18-
mappings: this.legacyModuleMappings.buildMappings(mappings),
19-
className: params['class'].substr(
20-
0,
21-
params['class'].lastIndexOf('.')
22-
),
23-
};
24-
});
13+
return {
14+
mappings: this.legacyModuleMappings.buildMappings(
15+
this.legacyModuleMappings.legacyMappings
16+
),
17+
className: params['class'].substr(0, params['class'].lastIndexOf('.')),
18+
};
2519
}
2620

2721
redirect(model) {

app/routes/data-module.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ export default class DataModuleRoute extends Route {
1010
legacyModuleMappings;
1111

1212
model(params) {
13-
return this.legacyModuleMappings
14-
.fetch()
15-
.then((response) => response.json())
16-
.then((mappings) => {
17-
return {
18-
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
19-
mappings: this.legacyModuleMappings.buildMappings(mappings),
20-
};
21-
});
13+
return {
14+
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
15+
mappings: this.legacyModuleMappings.buildMappings(
16+
this.legacyModuleMappings.legacyMappings
17+
),
18+
};
2219
}
2320

2421
redirect(model) {

app/routes/module.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ export default class ModuleRoute extends Route {
1010
legacyModuleMappings;
1111

1212
model(params) {
13-
return this.legacyModuleMappings
14-
.fetch()
15-
.then((response) => response.json())
16-
.then((mappings) => {
17-
return {
18-
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
19-
mappings: this.legacyModuleMappings.buildMappings(mappings),
20-
};
21-
});
13+
return {
14+
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
15+
mappings: this.legacyModuleMappings.buildMappings(
16+
this.legacyModuleMappings.legacyMappings
17+
),
18+
};
2219
}
2320

2421
redirect(model) {

app/routes/project-version/classes/class.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export default class ClassRoute extends Route.extend(ScrollTracker) {
3333
this.metaStore
3434
);
3535
const klass = params['class'];
36-
return this.find('class', `${project}-${projectVersion}-${klass}`);
36+
return this.find(
37+
'class',
38+
`${project}-${projectVersion}-${klass}`.toLowerCase()
39+
);
3740
}
3841

3942
find(typeName, param) {

app/services/legacy-module-mappings.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import fetch from 'fetch';
21
import Service from '@ember/service';
32
import { tracked } from '@glimmer/tracking';
43

4+
import legacyMappings from 'ember-rfc176-data/mappings.json';
5+
56
const LOCALNAME_CONVERSIONS = {
67
Object: 'EmberObject',
78
Array: 'EmberArray',
@@ -10,12 +11,11 @@ const LOCALNAME_CONVERSIONS = {
1011

1112
export default class LegacyModuleMappingsService extends Service {
1213
@tracked mappings;
14+
legacyMappings = legacyMappings;
1315

1416
async initMappings() {
1517
try {
16-
let response = await this.fetch();
17-
let mappings = await response.json();
18-
let newMappings = this.buildMappings(mappings);
18+
let newMappings = this.buildMappings(legacyMappings);
1919
this.mappings = newMappings;
2020
} catch (e) {
2121
this.mappings = [];
@@ -32,10 +32,6 @@ export default class LegacyModuleMappingsService extends Service {
3232
});
3333
}
3434

35-
fetch() {
36-
return fetch('/assets/mappings.json');
37-
}
38-
3935
getModule(name, documentedModule) {
4036
if (!this.mappings) {
4137
return '';

ember-cli-build.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict';
22

33
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
4-
const Funnel = require('broccoli-funnel');
5-
const mergeTrees = require('broccoli-merge-trees');
64
const envIsProduction = process.env.EMBER_ENV === 'production';
75
const premberUrls = require('./prember-urls');
86
const nodeSass = require('node-sass');
@@ -57,12 +55,6 @@ module.exports = function (defaults) {
5755
},
5856
});
5957

60-
let mappingsTree = new Funnel('node_modules/ember-rfc176-data/', {
61-
srcDir: '/',
62-
include: ['mappings.json'],
63-
destDir: '/assets/',
64-
});
65-
6658
const { Webpack } = require('@embroider/webpack');
6759
const appTree = require('@embroider/compat').compatBuild(app, Webpack, {
6860
staticAddonTrees: true,
@@ -72,5 +64,5 @@ module.exports = function (defaults) {
7264
staticComponents: true,
7365
});
7466

75-
return mergeTrees([require('prember').prerender(app, appTree), mappingsTree]);
67+
return require('prember').prerender(app, appTree);
7668
};

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"bourbon-neat": "^1.9.1",
6262
"broccoli-asset-rev": "^3.0.0",
6363
"broccoli-funnel": "^2.0.1",
64-
"broccoli-merge-trees": "^2.0.0",
6564
"ember-a11y-testing": "^5.2.1",
6665
"ember-anchor": "^1.0.3",
6766
"ember-auto-import": "^2.7.2",

pnpm-lock.yaml

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/acceptance/class-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module('Acceptance | Class', function (hooks) {
1515

1616
test('lists all the methods on the class page', async function (assert) {
1717
const store = this.owner.lookup('service:store');
18-
const container = store.peekRecord('class', 'ember-1.0.0-Container');
18+
const container = store.peekRecord('class', 'ember-1.0.0-container');
1919
assert.equal(
2020
findAll('.spec-method-list li').length,
2121
container.get('methods.length')
@@ -32,7 +32,7 @@ module('Acceptance | Class', function (hooks) {
3232

3333
test('lists all the properties on the class page', function (assert) {
3434
const store = this.owner.lookup('service:store');
35-
const container = store.peekRecord('class', 'ember-1.0.0-Container');
35+
const container = store.peekRecord('class', 'ember-1.0.0-container');
3636
assert.equal(
3737
findAll('.spec-property-list li').length,
3838
container.get('properties.length')
@@ -41,7 +41,7 @@ module('Acceptance | Class', function (hooks) {
4141

4242
test('lists all the events on the class page', function (assert) {
4343
const store = this.owner.lookup('service:store');
44-
const container = store.peekRecord('class', 'ember-1.0.0-Container');
44+
const container = store.peekRecord('class', 'ember-1.0.0-container');
4545
assert.equal(
4646
findAll('.spec-event-list li').length,
4747
container.get('events.length')

0 commit comments

Comments
 (0)