@stencil/angular-output-target 0.10.0 → 0.10.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.
@@ -4,9 +4,10 @@ import { createComponentEventTypeImports, dashToPascalCase, formatToQuotedList }
4
4
  *
5
5
  * @param prop A ComponentCompilerEvent or ComponentCompilerProperty to turn into a property declaration.
6
6
  * @param type The name of the type (e.g. 'string')
7
+ * @param inlinePropertyAsSetter Inlines the entire property as an empty Setter, to aid Angulars Compilerp
7
8
  * @returns The property declaration as a string.
8
9
  */
9
- function createPropertyDeclaration(prop, type) {
10
+ function createPropertyDeclaration(prop, type, inlinePropertyAsSetter = false) {
10
11
  const comment = createDocComment(prop.docs);
11
12
  let eventName = prop.name;
12
13
  if (/[-/]/.test(prop.name)) {
@@ -14,8 +15,14 @@ function createPropertyDeclaration(prop, type) {
14
15
  // https://github.com/ionic-team/stencil-ds-output-targets/issues/212
15
16
  eventName = `'${prop.name}'`;
16
17
  }
17
- return `${comment.length > 0 ? ` ${comment}` : ''}
18
+ if (inlinePropertyAsSetter) {
19
+ return `${comment.length > 0 ? ` ${comment}` : ''}
20
+ set ${eventName}(_: ${type}) {};`;
21
+ }
22
+ else {
23
+ return `${comment.length > 0 ? ` ${comment}` : ''}
18
24
  ${eventName}: ${type};`;
25
+ }
19
26
  }
20
27
  /**
21
28
  * Creates an Angular component declaration from formatted Stencil compiler metadata.
@@ -55,8 +62,8 @@ export const createAngularComponentDefinition = (tagName, inputs, outputs, metho
55
62
  if (standalone && includeImportCustomElements) {
56
63
  standaloneOption = `\n standalone: true`;
57
64
  }
58
- const propertyDeclarations = inlineComponentProps.map((m) => createPropertyDeclaration(m, `Components.${tagNameAsPascal}['${m.name}']`));
59
- const propertiesDeclarationText = ['protected el: HTMLElement;', ...propertyDeclarations].join('\n ');
65
+ const propertyDeclarations = inlineComponentProps.map((m) => createPropertyDeclaration(m, `Components.${tagNameAsPascal}['${m.name}']`, true));
66
+ const propertiesDeclarationText = [`protected el: HTML${tagNameAsPascal}Element;`, ...propertyDeclarations].join('\n ');
60
67
  /**
61
68
  * Notes on the generated output:
62
69
  * - We disable @angular-eslint/no-inputs-metadata-property, so that
@@ -132,6 +139,10 @@ const formatOutputType = (componentClassName, event) => {
132
139
  return [p1, `I${componentClassName}${v.substring(1, v.length - 1)}`, p2].join('');
133
140
  }
134
141
  return [p1, dst, p2].join('');
142
+ })
143
+ // Capture all instances that contain sub types, e.g. `IMyComponent.SomeMoreComplexType.SubType`.
144
+ .replace(new RegExp(`^${src}(\.\\w+)+$`, 'g'), (type) => {
145
+ return `I${componentClassName}${src}.${type.split('.').slice(1).join('.')}`;
135
146
  }));
136
147
  }, event.complexType.original
137
148
  .replace(/\n/g, ' ')
package/dist/index.cjs.js CHANGED
@@ -149,9 +149,10 @@ const SLASH_REGEX = /\\/g;
149
149
  *
150
150
  * @param prop A ComponentCompilerEvent or ComponentCompilerProperty to turn into a property declaration.
151
151
  * @param type The name of the type (e.g. 'string')
152
+ * @param inlinePropertyAsSetter Inlines the entire property as an empty Setter, to aid Angulars Compilerp
152
153
  * @returns The property declaration as a string.
153
154
  */
154
- function createPropertyDeclaration(prop, type) {
155
+ function createPropertyDeclaration(prop, type, inlinePropertyAsSetter = false) {
155
156
  const comment = createDocComment(prop.docs);
156
157
  let eventName = prop.name;
157
158
  if (/[-/]/.test(prop.name)) {
@@ -159,8 +160,14 @@ function createPropertyDeclaration(prop, type) {
159
160
  // https://github.com/ionic-team/stencil-ds-output-targets/issues/212
160
161
  eventName = `'${prop.name}'`;
161
162
  }
162
- return `${comment.length > 0 ? ` ${comment}` : ''}
163
+ if (inlinePropertyAsSetter) {
164
+ return `${comment.length > 0 ? ` ${comment}` : ''}
165
+ set ${eventName}(_: ${type}) {};`;
166
+ }
167
+ else {
168
+ return `${comment.length > 0 ? ` ${comment}` : ''}
163
169
  ${eventName}: ${type};`;
170
+ }
164
171
  }
165
172
  /**
166
173
  * Creates an Angular component declaration from formatted Stencil compiler metadata.
@@ -200,8 +207,8 @@ const createAngularComponentDefinition = (tagName, inputs, outputs, methods, inc
200
207
  if (standalone && includeImportCustomElements) {
201
208
  standaloneOption = `\n standalone: true`;
202
209
  }
203
- const propertyDeclarations = inlineComponentProps.map((m) => createPropertyDeclaration(m, `Components.${tagNameAsPascal}['${m.name}']`));
204
- const propertiesDeclarationText = ['protected el: HTMLElement;', ...propertyDeclarations].join('\n ');
210
+ const propertyDeclarations = inlineComponentProps.map((m) => createPropertyDeclaration(m, `Components.${tagNameAsPascal}['${m.name}']`, true));
211
+ const propertiesDeclarationText = [`protected el: HTML${tagNameAsPascal}Element;`, ...propertyDeclarations].join('\n ');
205
212
  /**
206
213
  * Notes on the generated output:
207
214
  * - We disable @angular-eslint/no-inputs-metadata-property, so that
@@ -277,6 +284,10 @@ const formatOutputType = (componentClassName, event) => {
277
284
  return [p1, `I${componentClassName}${v.substring(1, v.length - 1)}`, p2].join('');
278
285
  }
279
286
  return [p1, dst, p2].join('');
287
+ })
288
+ // Capture all instances that contain sub types, e.g. `IMyComponent.SomeMoreComplexType.SubType`.
289
+ .replace(new RegExp(`^${src}(\.\\w+)+$`, 'g'), (type) => {
290
+ return `I${componentClassName}${src}.${type.split('.').slice(1).join('.')}`;
280
291
  }));
281
292
  }, event.complexType.original
282
293
  .replace(/\n/g, ' ')
package/dist/index.js CHANGED
@@ -141,9 +141,10 @@ const SLASH_REGEX = /\\/g;
141
141
  *
142
142
  * @param prop A ComponentCompilerEvent or ComponentCompilerProperty to turn into a property declaration.
143
143
  * @param type The name of the type (e.g. 'string')
144
+ * @param inlinePropertyAsSetter Inlines the entire property as an empty Setter, to aid Angulars Compilerp
144
145
  * @returns The property declaration as a string.
145
146
  */
146
- function createPropertyDeclaration(prop, type) {
147
+ function createPropertyDeclaration(prop, type, inlinePropertyAsSetter = false) {
147
148
  const comment = createDocComment(prop.docs);
148
149
  let eventName = prop.name;
149
150
  if (/[-/]/.test(prop.name)) {
@@ -151,8 +152,14 @@ function createPropertyDeclaration(prop, type) {
151
152
  // https://github.com/ionic-team/stencil-ds-output-targets/issues/212
152
153
  eventName = `'${prop.name}'`;
153
154
  }
154
- return `${comment.length > 0 ? ` ${comment}` : ''}
155
+ if (inlinePropertyAsSetter) {
156
+ return `${comment.length > 0 ? ` ${comment}` : ''}
157
+ set ${eventName}(_: ${type}) {};`;
158
+ }
159
+ else {
160
+ return `${comment.length > 0 ? ` ${comment}` : ''}
155
161
  ${eventName}: ${type};`;
162
+ }
156
163
  }
157
164
  /**
158
165
  * Creates an Angular component declaration from formatted Stencil compiler metadata.
@@ -192,8 +199,8 @@ const createAngularComponentDefinition = (tagName, inputs, outputs, methods, inc
192
199
  if (standalone && includeImportCustomElements) {
193
200
  standaloneOption = `\n standalone: true`;
194
201
  }
195
- const propertyDeclarations = inlineComponentProps.map((m) => createPropertyDeclaration(m, `Components.${tagNameAsPascal}['${m.name}']`));
196
- const propertiesDeclarationText = ['protected el: HTMLElement;', ...propertyDeclarations].join('\n ');
202
+ const propertyDeclarations = inlineComponentProps.map((m) => createPropertyDeclaration(m, `Components.${tagNameAsPascal}['${m.name}']`, true));
203
+ const propertiesDeclarationText = [`protected el: HTML${tagNameAsPascal}Element;`, ...propertyDeclarations].join('\n ');
197
204
  /**
198
205
  * Notes on the generated output:
199
206
  * - We disable @angular-eslint/no-inputs-metadata-property, so that
@@ -269,6 +276,10 @@ const formatOutputType = (componentClassName, event) => {
269
276
  return [p1, `I${componentClassName}${v.substring(1, v.length - 1)}`, p2].join('');
270
277
  }
271
278
  return [p1, dst, p2].join('');
279
+ })
280
+ // Capture all instances that contain sub types, e.g. `IMyComponent.SomeMoreComplexType.SubType`.
281
+ .replace(new RegExp(`^${src}(\.\\w+)+$`, 'g'), (type) => {
282
+ return `I${componentClassName}${src}.${type.split('.').slice(1).join('.')}`;
272
283
  }));
273
284
  }, event.complexType.original
274
285
  .replace(/\n/g, ' ')
package/package.json CHANGED
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "name": "@stencil/angular-output-target",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Angular output target for @stencil/core components.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs.js"
12
+ }
13
+ },
7
14
  "types": "dist/index.d.ts",
8
15
  "files": [
9
16
  "dist/",
@@ -15,7 +22,7 @@
15
22
  },
16
23
  "scripts": {
17
24
  "prepublishOnly": "pnpm run build",
18
- "prebuild": "rimraf ./dist && pnpm run test",
25
+ "prebuild": "rimraf ./dist",
19
26
  "build": "tsc && pnpm run rollup",
20
27
  "dev": "run-p dev:*",
21
28
  "dev:build": "tsc --watch --preserveWatchOutput",
@@ -27,8 +34,8 @@
27
34
  "prettier.base": "prettier \"./({angular-component-lib,src,test,__tests__}/**/*.{ts,tsx,js,jsx})|*.{ts,tsx,js,jsx}\"",
28
35
  "prettier.dry-run": "pnpm run prettier.base --list-different",
29
36
  "release": "np",
30
- "test": "jest --passWithNoTests",
31
- "test.watch": "jest --watch"
37
+ "test": "vitest --run",
38
+ "test.watch": "vitest"
32
39
  },
33
40
  "repository": {
34
41
  "type": "git",
@@ -44,29 +51,14 @@
44
51
  "@angular/core": "8.2.14",
45
52
  "@angular/forms": "8.2.14",
46
53
  "@types/node": "^18.0.0",
47
- "jest": "^27.0.0",
48
- "jest-environment-jsdom": "^27.0.0",
49
54
  "npm-run-all2": "^6.2.4",
50
55
  "rimraf": "^5.0.0",
51
56
  "rollup": "^2.23.1",
52
- "typescript": "~5.0.4"
57
+ "typescript": "~5.7.0",
58
+ "vitest": "^2.1.4"
53
59
  },
54
60
  "peerDependencies": {
55
61
  "@stencil/core": ">=2.0.0 || >=3 || >= 4.0.0-beta.0 || >= 4.0.0"
56
62
  },
57
- "jest": {
58
- "transform": {
59
- "^.+\\.(js|ts|tsx)$": "<rootDir>/test/jest.preprocessor.js"
60
- },
61
- "testRegex": "(\\.(test|spec))\\.(ts?|tsx?|jsx?)$",
62
- "moduleFileExtensions": [
63
- "ts",
64
- "tsx",
65
- "js",
66
- "json",
67
- "jsx"
68
- ],
69
- "testURL": "http://localhost"
70
- },
71
63
  "gitHead": "a3588e905186a0e86e7f88418fd5b2f9531b55e0"
72
64
  }