@stencil/angular-output-target 0.10.0 → 0.10.1

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
package/dist/index.cjs.js CHANGED
@@ -1,14 +1,8 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var path = require('path');
6
4
  var os = require('os');
7
5
 
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
11
-
12
6
  const OutputTypes = {
13
7
  Component: 'component',
14
8
  Scam: 'scam',
@@ -58,18 +52,18 @@ function normalizePath(str) {
58
52
  return str;
59
53
  }
60
54
  function relativeImport(pathFrom, pathTo, ext) {
61
- let relativePath = path__default["default"].relative(path__default["default"].dirname(pathFrom), path__default["default"].dirname(pathTo));
55
+ let relativePath = path.relative(path.dirname(pathFrom), path.dirname(pathTo));
62
56
  if (relativePath === '') {
63
57
  relativePath = '.';
64
58
  }
65
59
  else if (relativePath[0] !== '.') {
66
60
  relativePath = './' + relativePath;
67
61
  }
68
- return normalizePath(`${relativePath}/${path__default["default"].basename(pathTo, ext)}`);
62
+ return normalizePath(`${relativePath}/${path.basename(pathTo, ext)}`);
69
63
  }
70
64
  async function readPackageJson(config, rootDir) {
71
65
  var _a;
72
- const pkgJsonPath = path__default["default"].join(rootDir, 'package.json');
66
+ const pkgJsonPath = path.join(rootDir, 'package.json');
73
67
  let pkgJson;
74
68
  try {
75
69
  pkgJson = (await ((_a = config.sys) === null || _a === void 0 ? void 0 : _a.readFile(pkgJsonPath, 'utf8')));
@@ -149,9 +143,10 @@ const SLASH_REGEX = /\\/g;
149
143
  *
150
144
  * @param prop A ComponentCompilerEvent or ComponentCompilerProperty to turn into a property declaration.
151
145
  * @param type The name of the type (e.g. 'string')
146
+ * @param inlinePropertyAsSetter Inlines the entire property as an empty Setter, to aid Angulars Compilerp
152
147
  * @returns The property declaration as a string.
153
148
  */
154
- function createPropertyDeclaration(prop, type) {
149
+ function createPropertyDeclaration(prop, type, inlinePropertyAsSetter = false) {
155
150
  const comment = createDocComment(prop.docs);
156
151
  let eventName = prop.name;
157
152
  if (/[-/]/.test(prop.name)) {
@@ -159,8 +154,14 @@ function createPropertyDeclaration(prop, type) {
159
154
  // https://github.com/ionic-team/stencil-ds-output-targets/issues/212
160
155
  eventName = `'${prop.name}'`;
161
156
  }
162
- return `${comment.length > 0 ? ` ${comment}` : ''}
157
+ if (inlinePropertyAsSetter) {
158
+ return `${comment.length > 0 ? ` ${comment}` : ''}
159
+ set ${eventName}(_: ${type}) {};`;
160
+ }
161
+ else {
162
+ return `${comment.length > 0 ? ` ${comment}` : ''}
163
163
  ${eventName}: ${type};`;
164
+ }
164
165
  }
165
166
  /**
166
167
  * Creates an Angular component declaration from formatted Stencil compiler metadata.
@@ -200,8 +201,8 @@ const createAngularComponentDefinition = (tagName, inputs, outputs, methods, inc
200
201
  if (standalone && includeImportCustomElements) {
201
202
  standaloneOption = `\n standalone: true`;
202
203
  }
203
- const propertyDeclarations = inlineComponentProps.map((m) => createPropertyDeclaration(m, `Components.${tagNameAsPascal}['${m.name}']`));
204
- const propertiesDeclarationText = ['protected el: HTMLElement;', ...propertyDeclarations].join('\n ');
204
+ const propertyDeclarations = inlineComponentProps.map((m) => createPropertyDeclaration(m, `Components.${tagNameAsPascal}['${m.name}']`, true));
205
+ const propertiesDeclarationText = [`protected el: HTML${tagNameAsPascal}Element;`, ...propertyDeclarations].join('\n ');
205
206
  /**
206
207
  * Notes on the generated output:
207
208
  * - We disable @angular-eslint/no-inputs-metadata-property, so that
@@ -347,7 +348,7 @@ async function generateValueAccessors(compilerCtx, components, outputTarget, con
347
348
  if (!Array.isArray(outputTarget.valueAccessorConfigs) || outputTarget.valueAccessorConfigs.length === 0) {
348
349
  return;
349
350
  }
350
- const targetDir = path__default["default"].dirname(outputTarget.directivesProxyFile);
351
+ const targetDir = path.dirname(outputTarget.directivesProxyFile);
351
352
  const normalizedValueAccessors = outputTarget.valueAccessorConfigs.reduce((allAccessors, va) => {
352
353
  const elementSelectors = Array.isArray(va.elementSelectors) ? va.elementSelectors : [va.elementSelectors];
353
354
  const type = va.type;
@@ -365,8 +366,8 @@ async function generateValueAccessors(compilerCtx, components, outputTarget, con
365
366
  await Promise.all(Object.keys(normalizedValueAccessors).map(async (type) => {
366
367
  const valueAccessorType = type; // Object.keys converts to string
367
368
  const targetFileName = `${type}-value-accessor.ts`;
368
- const targetFilePath = path__default["default"].join(targetDir, targetFileName);
369
- const srcFilePath = path__default["default"].join(__dirname, '../resources/control-value-accessors/', targetFileName);
369
+ const targetFilePath = path.join(targetDir, targetFileName);
370
+ const srcFilePath = path.join(__dirname, '../resources/control-value-accessors/', targetFileName);
370
371
  const srcFileContents = await compilerCtx.fs.readFile(srcFilePath);
371
372
  const finalText = createValueAccessor(srcFileContents, normalizedValueAccessors[valueAccessorType], outputTarget.outputType);
372
373
  await compilerCtx.fs.writeFile(targetFilePath, finalText);
@@ -386,14 +387,14 @@ function copyResources$1(config, resourcesFilesToCopy, directory) {
386
387
  }
387
388
  const copyTasks = resourcesFilesToCopy.map((rf) => {
388
389
  return {
389
- src: path__default["default"].join(__dirname, '../resources/control-value-accessors/', rf),
390
- dest: path__default["default"].join(directory, rf),
390
+ src: path.join(__dirname, '../resources/control-value-accessors/', rf),
391
+ dest: path.join(directory, rf),
391
392
  keepDirStructure: false,
392
393
  warn: false,
393
394
  ignore: [],
394
395
  };
395
396
  });
396
- return config.sys.copy(copyTasks, path__default["default"].join(directory));
397
+ return config.sys.copy(copyTasks, path.join(directory));
397
398
  }
398
399
  const VALUE_ACCESSOR_SELECTORS = `<VALUE_ACCESSOR_SELECTORS>`;
399
400
  const VALUE_ACCESSOR_EVENT = `<VALUE_ACCESSOR_EVENT>`;
@@ -437,8 +438,8 @@ async function copyResources(config, outputTarget) {
437
438
  if (!config.sys || !config.sys.copy || !config.sys.glob) {
438
439
  throw new Error('stencil is not properly initialized at this step. Notify the developer');
439
440
  }
440
- const srcDirectory = path__default["default"].join(__dirname, '..', 'angular-component-lib');
441
- const destDirectory = path__default["default"].join(path__default["default"].dirname(outputTarget.directivesProxyFile), 'angular-component-lib');
441
+ const srcDirectory = path.join(__dirname, '..', 'angular-component-lib');
442
+ const destDirectory = path.join(path.dirname(outputTarget.directivesProxyFile), 'angular-component-lib');
442
443
  return config.sys.copy([
443
444
  {
444
445
  src: srcDirectory,
@@ -450,8 +451,8 @@ async function copyResources(config, outputTarget) {
450
451
  ], srcDirectory);
451
452
  }
452
453
  function generateProxies(components, pkgData, outputTarget, rootDir) {
453
- const distTypesDir = path__default["default"].dirname(pkgData.types);
454
- const dtsFilePath = path__default["default"].join(rootDir, distTypesDir, GENERATED_DTS);
454
+ const distTypesDir = path.dirname(pkgData.types);
455
+ const dtsFilePath = path.join(rootDir, distTypesDir, GENERATED_DTS);
455
456
  const { outputType } = outputTarget;
456
457
  const componentsTypeFile = relativeImport(outputTarget.directivesProxyFile, dtsFilePath, '.d.ts');
457
458
  const includeSingleComponentAngularModules = outputType === OutputTypes.Scam;
@@ -577,11 +578,11 @@ function normalizeOutputTarget(config, outputTarget) {
577
578
  if (outputTarget.directivesProxyFile == null) {
578
579
  throw new Error('directivesProxyFile is required. Please set it in the Stencil config.');
579
580
  }
580
- if (outputTarget.directivesProxyFile && !path__default["default"].isAbsolute(outputTarget.directivesProxyFile)) {
581
- results.directivesProxyFile = normalizePath(path__default["default"].join(config.rootDir, outputTarget.directivesProxyFile));
581
+ if (outputTarget.directivesProxyFile && !path.isAbsolute(outputTarget.directivesProxyFile)) {
582
+ results.directivesProxyFile = normalizePath(path.join(config.rootDir, outputTarget.directivesProxyFile));
582
583
  }
583
- if (outputTarget.directivesArrayFile && !path__default["default"].isAbsolute(outputTarget.directivesArrayFile)) {
584
- results.directivesArrayFile = normalizePath(path__default["default"].join(config.rootDir, outputTarget.directivesArrayFile));
584
+ if (outputTarget.directivesArrayFile && !path.isAbsolute(outputTarget.directivesArrayFile)) {
585
+ results.directivesArrayFile = normalizePath(path.join(config.rootDir, outputTarget.directivesArrayFile));
585
586
  }
586
587
  if (outputTarget.includeSingleComponentAngularModules !== undefined) {
587
588
  throw new Error("The 'includeSingleComponentAngularModules' option has been removed. Please use 'outputType' instead.");
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
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.1",
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/",
@@ -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
  }