Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop requesting mappings over the network and fix shoebox usage #923

Merged
merged 3 commits into from
Jul 24, 2024
Merged
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
9 changes: 2 additions & 7 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ export default class Application extends JSONAPIAdapter {
return false;
}

shouldBackgroundReloadRecord(store, { modelName, id }) {
let key = `${modelName}-${id}`;
let hasId = this.ids[key];
if (!hasId) {
this.ids[key] = true;
}
return !hasId;
shouldBackgroundReloadRecord() {
return false;
}

constructor() {
Expand Down
20 changes: 7 additions & 13 deletions app/routes/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@ export default class ClassRoute extends Route {
legacyModuleMappings;

model(params) {
return this.legacyModuleMappings
.fetch()
.then((response) => response.json())
.then((mappings) => {
let ret = {
mappings: this.legacyModuleMappings.buildMappings(mappings),
className: params['class'].substr(
0,
params['class'].lastIndexOf('.')
),
};
return ret;
});
let ret = {
mappings: this.legacyModuleMappings.buildMappings(
this.legacyModuleMappings.legacyMappings
),
className: params['class'].substr(0, params['class'].lastIndexOf('.')),
};
return ret;
}

redirect(model) {
Expand Down
18 changes: 6 additions & 12 deletions app/routes/data-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ export default class DataClassRoute extends Route {
legacyModuleMappings;

model(params) {
return this.legacyModuleMappings
.fetch()
.then((response) => response.json())
.then((mappings) => {
return {
mappings: this.legacyModuleMappings.buildMappings(mappings),
className: params['class'].substr(
0,
params['class'].lastIndexOf('.')
),
};
});
return {
mappings: this.legacyModuleMappings.buildMappings(
this.legacyModuleMappings.legacyMappings
),
className: params['class'].substr(0, params['class'].lastIndexOf('.')),
};
}

redirect(model) {
Expand Down
15 changes: 6 additions & 9 deletions app/routes/data-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ export default class DataModuleRoute extends Route {
legacyModuleMappings;

model(params) {
return this.legacyModuleMappings
.fetch()
.then((response) => response.json())
.then((mappings) => {
return {
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
mappings: this.legacyModuleMappings.buildMappings(mappings),
};
});
return {
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
mappings: this.legacyModuleMappings.buildMappings(
this.legacyModuleMappings.legacyMappings
),
};
}

redirect(model) {
Expand Down
15 changes: 6 additions & 9 deletions app/routes/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ export default class ModuleRoute extends Route {
legacyModuleMappings;

model(params) {
return this.legacyModuleMappings
.fetch()
.then((response) => response.json())
.then((mappings) => {
return {
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
mappings: this.legacyModuleMappings.buildMappings(mappings),
};
});
return {
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
mappings: this.legacyModuleMappings.buildMappings(
this.legacyModuleMappings.legacyMappings
),
};
}

redirect(model) {
Expand Down
5 changes: 4 additions & 1 deletion app/routes/project-version/classes/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export default class ClassRoute extends Route.extend(ScrollTracker) {
this.metaStore
);
const klass = params['class'];
return this.find('class', `${project}-${projectVersion}-${klass}`);
return this.find(
'class',
`${project}-${projectVersion}-${klass}`.toLowerCase()
);
}

find(typeName, param) {
Expand Down
12 changes: 4 additions & 8 deletions app/services/legacy-module-mappings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import fetch from 'fetch';
import Service from '@ember/service';
import { tracked } from '@glimmer/tracking';

import legacyMappings from 'ember-rfc176-data/mappings.json';

const LOCALNAME_CONVERSIONS = {
Object: 'EmberObject',
Array: 'EmberArray',
Expand All @@ -10,12 +11,11 @@ const LOCALNAME_CONVERSIONS = {

export default class LegacyModuleMappingsService extends Service {
@tracked mappings;
legacyMappings = legacyMappings;

async initMappings() {
try {
let response = await this.fetch();
let mappings = await response.json();
let newMappings = this.buildMappings(mappings);
let newMappings = this.buildMappings(legacyMappings);
this.mappings = newMappings;
} catch (e) {
this.mappings = [];
Expand All @@ -32,10 +32,6 @@ export default class LegacyModuleMappingsService extends Service {
});
}

fetch() {
return fetch('/assets/mappings.json');
}

getModule(name, documentedModule) {
if (!this.mappings) {
return '';
Expand Down
10 changes: 1 addition & 9 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
const envIsProduction = process.env.EMBER_ENV === 'production';
const premberUrls = require('./prember-urls');
const nodeSass = require('node-sass');
Expand Down Expand Up @@ -57,12 +55,6 @@ module.exports = function (defaults) {
},
});

let mappingsTree = new Funnel('node_modules/ember-rfc176-data/', {
srcDir: '/',
include: ['mappings.json'],
destDir: '/assets/',
});

const { Webpack } = require('@embroider/webpack');
const appTree = require('@embroider/compat').compatBuild(app, Webpack, {
staticAddonTrees: true,
Expand All @@ -72,5 +64,5 @@ module.exports = function (defaults) {
staticComponents: true,
});

return mergeTrees([require('prember').prerender(app, appTree), mappingsTree]);
return require('prember').prerender(app, appTree);
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"bourbon-neat": "^1.9.1",
"broccoli-asset-rev": "^3.0.0",
"broccoli-funnel": "^2.0.1",
"broccoli-merge-trees": "^2.0.0",
"ember-a11y-testing": "^5.2.1",
"ember-anchor": "^1.0.3",
"ember-auto-import": "^2.7.2",
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/acceptance/class-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module('Acceptance | Class', function (hooks) {

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

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

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