ember-source 4.12.0-alpha.1 → 4.12.0-alpha.2
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/blueprints/-maybe-polyfill-typescript-blueprints.js +5 -3
- package/blueprints/component/files/__root__/__path__/__name__.ts +1 -0
- package/blueprints/component/index.js +53 -11
- package/blueprints/service/files/__root__/__path__/__name__.ts +10 -0
- package/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +2 -2
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +1 -1
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +3 -9
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/runtime/index.js +0 -1
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +2 -2
- package/package.json +9 -9
- package/types/stable/@ember/-internals/runtime/index.d.ts +0 -1
- package/types/stable/@ember/routing/route.d.ts +1 -1
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
const typescriptBlueprintPolyfill = require('ember-cli-typescript-blueprint-polyfill');
|
|
2
|
-
const EMBER_TYPESCRIPT_BLUEPRINTS =
|
|
2
|
+
const EMBER_TYPESCRIPT_BLUEPRINTS = true;
|
|
3
3
|
|
|
4
4
|
function canEmitTypeScript() {
|
|
5
5
|
return 'EMBER_TYPESCRIPT_BLUEPRINTS' in process.env
|
|
6
|
-
? process.env.EMBER_TYPESCRIPT_BLUEPRINTS
|
|
6
|
+
? process.env.EMBER_TYPESCRIPT_BLUEPRINTS === 'true'
|
|
7
7
|
: EMBER_TYPESCRIPT_BLUEPRINTS;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
module.exports = function (context) {
|
|
11
|
-
|
|
11
|
+
let canUseTypeScript = canEmitTypeScript();
|
|
12
|
+
if (canUseTypeScript) {
|
|
12
13
|
typescriptBlueprintPolyfill(context);
|
|
13
14
|
} else {
|
|
14
15
|
// Use the plain old JS templates from before
|
|
15
16
|
context.path = context.path.replace('blueprints', 'blueprints-js');
|
|
16
17
|
}
|
|
18
|
+
return canUseTypeScript;
|
|
17
19
|
};
|
|
@@ -53,9 +53,17 @@ module.exports = {
|
|
|
53
53
|
},
|
|
54
54
|
],
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
Flag to let us correctly handle the case where we are running against a
|
|
58
|
+
version of Ember CLI which does not support TS-based emit, and where we
|
|
59
|
+
therefore *must* not emit a `defaultExport` local which includes a type
|
|
60
|
+
parameter in the exported function call or class definition.
|
|
61
|
+
*/
|
|
62
|
+
_isUsingTS: false,
|
|
63
|
+
|
|
56
64
|
init() {
|
|
57
65
|
this._super && this._super.init.apply(this, arguments);
|
|
58
|
-
maybePolyfillTypeScriptBlueprints(this);
|
|
66
|
+
this._isUsingTS = maybePolyfillTypeScriptBlueprints(this);
|
|
59
67
|
let isOctane = has('octane');
|
|
60
68
|
|
|
61
69
|
this.availableOptions.forEach((option) => {
|
|
@@ -227,15 +235,8 @@ module.exports = {
|
|
|
227
235
|
},
|
|
228
236
|
|
|
229
237
|
locals(options) {
|
|
230
|
-
let sanitizedModuleName = options.entity.name.replace(/\//g, '-');
|
|
231
|
-
let classifiedModuleName = stringUtil.classify(sanitizedModuleName);
|
|
232
|
-
|
|
233
|
-
let templatePath = '';
|
|
234
|
-
let importComponent = '';
|
|
235
|
-
let importTemplate = '';
|
|
236
|
-
let defaultExport = '';
|
|
237
|
-
|
|
238
238
|
// if we're in an addon, build import statement
|
|
239
|
+
let templatePath = '';
|
|
239
240
|
if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy)) {
|
|
240
241
|
if (options.pod) {
|
|
241
242
|
templatePath = './template';
|
|
@@ -251,6 +252,14 @@ module.exports = {
|
|
|
251
252
|
? options.componentClass
|
|
252
253
|
: '@ember/component';
|
|
253
254
|
|
|
255
|
+
let sanitizedModuleName = options.entity.name.replace(/\//g, '-');
|
|
256
|
+
let classifiedModuleName = stringUtil.classify(sanitizedModuleName);
|
|
257
|
+
|
|
258
|
+
let importComponent = '';
|
|
259
|
+
let importTemplate = '';
|
|
260
|
+
let defaultExport = '';
|
|
261
|
+
let componentSignature = '';
|
|
262
|
+
|
|
254
263
|
switch (componentClass) {
|
|
255
264
|
case '@ember/component':
|
|
256
265
|
importComponent = `import Component from '@ember/component';`;
|
|
@@ -263,20 +272,53 @@ module.exports = {
|
|
|
263
272
|
break;
|
|
264
273
|
case '@glimmer/component':
|
|
265
274
|
importComponent = `import Component from '@glimmer/component';`;
|
|
266
|
-
|
|
275
|
+
if (this._isUsingTS) {
|
|
276
|
+
componentSignature = signatureFor(classifiedModuleName);
|
|
277
|
+
defaultExport = `class ${classifiedModuleName}Component extends Component<${classifiedModuleName}Signature> {}`;
|
|
278
|
+
} else {
|
|
279
|
+
defaultExport = `class ${classifiedModuleName}Component extends Component {}`;
|
|
280
|
+
}
|
|
267
281
|
break;
|
|
268
282
|
case '@ember/component/template-only':
|
|
269
283
|
importComponent = `import templateOnly from '@ember/component/template-only';`;
|
|
270
|
-
|
|
284
|
+
if (this._isUsingTS) {
|
|
285
|
+
componentSignature = signatureFor(classifiedModuleName);
|
|
286
|
+
defaultExport = `templateOnly<${classifiedModuleName}Signature>();`;
|
|
287
|
+
} else {
|
|
288
|
+
defaultExport = `templateOnly();`;
|
|
289
|
+
}
|
|
271
290
|
break;
|
|
272
291
|
}
|
|
273
292
|
|
|
274
293
|
return {
|
|
275
294
|
importTemplate,
|
|
276
295
|
importComponent,
|
|
296
|
+
componentSignature,
|
|
277
297
|
defaultExport,
|
|
278
298
|
path: getPathOption(options),
|
|
279
299
|
componentClass: options.componentClass,
|
|
280
300
|
};
|
|
281
301
|
},
|
|
282
302
|
};
|
|
303
|
+
|
|
304
|
+
function signatureFor(classifiedModuleName) {
|
|
305
|
+
let args = ` // The arguments accepted by the component${EOL} Args: {};`;
|
|
306
|
+
|
|
307
|
+
let blocks =
|
|
308
|
+
` // Any blocks yielded by the component${EOL}` +
|
|
309
|
+
` Blocks: {${EOL}` +
|
|
310
|
+
` default: []${EOL}` +
|
|
311
|
+
` };`;
|
|
312
|
+
|
|
313
|
+
let element =
|
|
314
|
+
` // The element to which \`...attributes\` is applied in the component template${EOL}` +
|
|
315
|
+
` Element: null;`;
|
|
316
|
+
|
|
317
|
+
return (
|
|
318
|
+
`interface ${classifiedModuleName}Signature {${EOL}` +
|
|
319
|
+
`${args}${EOL}` +
|
|
320
|
+
`${blocks}${EOL}` +
|
|
321
|
+
`${element}${EOL}` +
|
|
322
|
+
`}${EOL}`
|
|
323
|
+
);
|
|
324
|
+
}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import Service from '@ember/service';
|
|
2
2
|
|
|
3
3
|
export default class <%= classifiedModuleName %>Service extends Service {}
|
|
4
|
+
|
|
5
|
+
// Don't remove this declaration: this is what enables TypeScript to resolve
|
|
6
|
+
// this service using `Owner.lookup('service:<%= dasherizedModuleName %>')`, as well
|
|
7
|
+
// as to check when you pass the service name as an argument to the decorator,
|
|
8
|
+
// like `@service('<%= dasherizedModuleName %>') declare altName: <%= classifiedModuleName %>Service;`.
|
|
9
|
+
declare module '@ember/service' {
|
|
10
|
+
interface Registry {
|
|
11
|
+
'<%= dasherizedModuleName %>': <%= classifiedModuleName %>Service;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/build-metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.12.0-alpha.
|
|
2
|
+
"version": "4.12.0-alpha.2",
|
|
3
3
|
"buildType": "tag",
|
|
4
|
-
"SHA": "
|
|
5
|
-
"assetPath": "/tag/shas/
|
|
4
|
+
"SHA": "5877d3e3214bcf679a3ec3961bc7d6d26e3c41e1",
|
|
5
|
+
"assetPath": "/tag/shas/5877d3e3214bcf679a3ec3961bc7d6d26e3c41e1.tgz"
|
|
6
6
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
|
|
7
7
|
* @license Licensed under MIT license
|
|
8
8
|
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
|
|
9
|
-
* @version 4.12.0-alpha.
|
|
9
|
+
* @version 4.12.0-alpha.2
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/* eslint-disable no-var */
|
|
@@ -16465,7 +16465,7 @@ define("ember/version", ["exports"], function (_exports) {
|
|
|
16465
16465
|
value: true
|
|
16466
16466
|
});
|
|
16467
16467
|
_exports.default = void 0;
|
|
16468
|
-
var _default = "4.12.0-alpha.
|
|
16468
|
+
var _default = "4.12.0-alpha.2";
|
|
16469
16469
|
_exports.default = _default;
|
|
16470
16470
|
});
|
|
16471
16471
|
define("simple-html-tokenizer", ["exports"], function (_exports) {
|