ember-source 5.8.0-alpha.4 → 5.8.0-alpha.6

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.
@@ -1,9 +1,33 @@
1
1
  const { dasherize } = require('ember-cli-string-utils');
2
+ const { EOL } = require('os');
3
+
4
+ function generateComponentSignature(componentName) {
5
+ let args = ` // The arguments accepted by the component${EOL} Args: {};`;
6
+
7
+ let blocks =
8
+ ` // Any blocks yielded by the component${EOL}` +
9
+ ` Blocks: {${EOL}` +
10
+ ` default: []${EOL}` +
11
+ ` };`;
12
+
13
+ let element =
14
+ ` // The element to which \`...attributes\` is applied in the component template${EOL}` +
15
+ ` Element: null;`;
16
+
17
+ return (
18
+ `export interface ${componentName}Signature {${EOL}` +
19
+ `${args}${EOL}` +
20
+ `${blocks}${EOL}` +
21
+ `${element}${EOL}` +
22
+ `}${EOL}`
23
+ );
24
+ }
2
25
 
3
26
  function modulePrefixForProject(project) {
4
27
  return dasherize(project.config().modulePrefix);
5
28
  }
6
29
 
7
30
  module.exports = {
31
+ generateComponentSignature,
8
32
  modulePrefixForProject,
9
33
  };
@@ -9,6 +9,7 @@ const getPathOption = require('ember-cli-get-component-path-option');
9
9
  const normalizeEntityName = require('ember-cli-normalize-entity-name');
10
10
  const { EOL } = require('os');
11
11
  const { has } = require('@ember/edition-utils');
12
+ const { generateComponentSignature } = require('../-utils');
12
13
 
13
14
  const maybePolyfillTypeScriptBlueprints = require('../-maybe-polyfill-typescript-blueprints');
14
15
 
@@ -273,7 +274,7 @@ module.exports = {
273
274
  case '@glimmer/component':
274
275
  importComponent = `import Component from '@glimmer/component';`;
275
276
  if (this._isUsingTS) {
276
- componentSignature = signatureFor(classifiedModuleName);
277
+ componentSignature = generateComponentSignature(classifiedModuleName);
277
278
  defaultExport = `class ${classifiedModuleName}Component extends Component<${classifiedModuleName}Signature> {}`;
278
279
  } else {
279
280
  defaultExport = `class ${classifiedModuleName}Component extends Component {}`;
@@ -282,7 +283,7 @@ module.exports = {
282
283
  case '@ember/component/template-only':
283
284
  importComponent = `import templateOnly from '@ember/component/template-only';`;
284
285
  if (this._isUsingTS) {
285
- componentSignature = signatureFor(classifiedModuleName);
286
+ componentSignature = generateComponentSignature(classifiedModuleName);
286
287
  defaultExport = `templateOnly<${classifiedModuleName}Signature>();`;
287
288
  } else {
288
289
  defaultExport = `templateOnly();`;
@@ -300,25 +301,3 @@ module.exports = {
300
301
  };
301
302
  },
302
303
  };
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,4 @@
1
1
  <%= importComponent %>
2
2
  <%= importTemplate %>
3
+ <%= componentSignature %>
3
4
  export default <%= defaultExport %>
@@ -8,6 +8,7 @@ const getPathOption = require('ember-cli-get-component-path-option');
8
8
  const normalizeEntityName = require('ember-cli-normalize-entity-name');
9
9
  const { EOL } = require('os');
10
10
  const { has } = require('@ember/edition-utils');
11
+ const { generateComponentSignature } = require('../-utils');
11
12
 
12
13
  const maybePolyfillTypeScriptBlueprints = require('../-maybe-polyfill-typescript-blueprints');
13
14
 
@@ -49,9 +50,17 @@ module.exports = {
49
50
  },
50
51
  ],
51
52
 
53
+ /**
54
+ Flag to let us correctly handle the case where we are running against a
55
+ version of Ember CLI which does not support TS-based emit, and where we
56
+ therefore *must* not emit a `defaultExport` local which includes a type
57
+ parameter in the exported function call or class definition.
58
+ */
59
+ _isUsingTS: false,
60
+
52
61
  init() {
53
62
  this._super && this._super.init.apply(this, arguments);
54
- maybePolyfillTypeScriptBlueprints(this);
63
+ this._isUsingTS = maybePolyfillTypeScriptBlueprints(this);
55
64
  let isOctane = has('octane');
56
65
 
57
66
  this.availableOptions.forEach((option) => {
@@ -134,6 +143,7 @@ module.exports = {
134
143
  let importComponent = '';
135
144
  let importTemplate = '';
136
145
  let defaultExport = '';
146
+ let componentSignature = '';
137
147
 
138
148
  // if we're in an addon, build import statement
139
149
  if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy)) {
@@ -161,17 +171,28 @@ module.exports = {
161
171
  break;
162
172
  case '@glimmer/component':
163
173
  importComponent = `import Component from '@glimmer/component';`;
164
- defaultExport = `class ${classifiedModuleName}Component extends Component {}`;
174
+ if (this._isUsingTS) {
175
+ componentSignature = generateComponentSignature(classifiedModuleName);
176
+ defaultExport = `class ${classifiedModuleName}Component extends Component<${classifiedModuleName}Signature> {}`;
177
+ } else {
178
+ defaultExport = `class ${classifiedModuleName}Component extends Component {}`;
179
+ }
165
180
  break;
166
181
  case '@ember/component/template-only':
167
182
  importComponent = `import templateOnly from '@ember/component/template-only';`;
168
- defaultExport = `templateOnly();`;
183
+ if (this._isUsingTS) {
184
+ componentSignature = generateComponentSignature(classifiedModuleName);
185
+ defaultExport = `templateOnly<${classifiedModuleName}Signature>();`;
186
+ } else {
187
+ defaultExport = `templateOnly();`;
188
+ }
169
189
  break;
170
190
  }
171
191
 
172
192
  return {
173
193
  importTemplate,
174
194
  importComponent,
195
+ componentSignature,
175
196
  defaultExport,
176
197
  path: getPathOption(options),
177
198
  componentClass,
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "5.8.0-alpha.4",
2
+ "version": "5.8.0-alpha.6",
3
3
  "buildType": "tag",
4
- "SHA": "310fc0fdd681d3fe2bedc3ea45d7b2d7d2547b7e",
5
- "assetPath": "/tag/shas/310fc0fdd681d3fe2bedc3ea45d7b2d7d2547b7e.tgz"
4
+ "SHA": "ab2dd5b45820ddfadbf0e62200019d013f9f1d5a",
5
+ "assetPath": "/tag/shas/ab2dd5b45820ddfadbf0e62200019d013f9f1d5a.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 5.8.0-alpha.4
9
+ * @version 5.8.0-alpha.6
10
10
  */
11
11
 
12
12
  /* eslint-disable no-var */
@@ -16577,7 +16577,7 @@ define("ember/version", ["exports"], function (_exports) {
16577
16577
  value: true
16578
16578
  });
16579
16579
  _exports.default = void 0;
16580
- var _default = _exports.default = "5.8.0-alpha.4";
16580
+ var _default = _exports.default = "5.8.0-alpha.6";
16581
16581
  });
16582
16582
  define("simple-html-tokenizer", ["exports"], function (_exports) {
16583
16583
  "use strict";