@stencil/angular-output-target 0.0.1-dev.11730928290.1699ee88 → 0.0.1-dev.11734409046.189fd148

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
@@ -43,10 +43,9 @@ function copyResources(config, resourcesFilesToCopy, directory) {
43
43
  throw new Error('stencil is not properly initialized at this step. Notify the developer');
44
44
  }
45
45
  const copyTasks = resourcesFilesToCopy.map((rf) => {
46
- const dest = path.resolve(directory, rf);
47
46
  return {
48
47
  src: path.join(__dirname, '../resources/control-value-accessors/', rf),
49
- dest: path.extname(dest) ? path.dirname(dest) : dest,
48
+ dest: path.join(directory, rf),
50
49
  keepDirStructure: false,
51
50
  warn: false,
52
51
  ignore: [],
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);
@@ -385,16 +386,15 @@ function copyResources$1(config, resourcesFilesToCopy, directory) {
385
386
  throw new Error('stencil is not properly initialized at this step. Notify the developer');
386
387
  }
387
388
  const copyTasks = resourcesFilesToCopy.map((rf) => {
388
- const dest = path__default["default"].resolve(directory, rf);
389
389
  return {
390
- src: path__default["default"].join(__dirname, '../resources/control-value-accessors/', rf),
391
- dest: path__default["default"].extname(dest) ? path__default["default"].dirname(dest) : dest,
390
+ src: path.join(__dirname, '../resources/control-value-accessors/', rf),
391
+ dest: path.join(directory, rf),
392
392
  keepDirStructure: false,
393
393
  warn: false,
394
394
  ignore: [],
395
395
  };
396
396
  });
397
- return config.sys.copy(copyTasks, path__default["default"].join(directory));
397
+ return config.sys.copy(copyTasks, path.join(directory));
398
398
  }
399
399
  const VALUE_ACCESSOR_SELECTORS = `<VALUE_ACCESSOR_SELECTORS>`;
400
400
  const VALUE_ACCESSOR_EVENT = `<VALUE_ACCESSOR_EVENT>`;
@@ -438,8 +438,8 @@ async function copyResources(config, outputTarget) {
438
438
  if (!config.sys || !config.sys.copy || !config.sys.glob) {
439
439
  throw new Error('stencil is not properly initialized at this step. Notify the developer');
440
440
  }
441
- const srcDirectory = path__default["default"].join(__dirname, '..', 'angular-component-lib');
442
- 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');
443
443
  return config.sys.copy([
444
444
  {
445
445
  src: srcDirectory,
@@ -451,8 +451,8 @@ async function copyResources(config, outputTarget) {
451
451
  ], srcDirectory);
452
452
  }
453
453
  function generateProxies(components, pkgData, outputTarget, rootDir) {
454
- const distTypesDir = path__default["default"].dirname(pkgData.types);
455
- 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);
456
456
  const { outputType } = outputTarget;
457
457
  const componentsTypeFile = relativeImport(outputTarget.directivesProxyFile, dtsFilePath, '.d.ts');
458
458
  const includeSingleComponentAngularModules = outputType === OutputTypes.Scam;
@@ -578,11 +578,11 @@ function normalizeOutputTarget(config, outputTarget) {
578
578
  if (outputTarget.directivesProxyFile == null) {
579
579
  throw new Error('directivesProxyFile is required. Please set it in the Stencil config.');
580
580
  }
581
- if (outputTarget.directivesProxyFile && !path__default["default"].isAbsolute(outputTarget.directivesProxyFile)) {
582
- 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));
583
583
  }
584
- if (outputTarget.directivesArrayFile && !path__default["default"].isAbsolute(outputTarget.directivesArrayFile)) {
585
- 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));
586
586
  }
587
587
  if (outputTarget.includeSingleComponentAngularModules !== undefined) {
588
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
@@ -377,10 +384,9 @@ function copyResources$1(config, resourcesFilesToCopy, directory) {
377
384
  throw new Error('stencil is not properly initialized at this step. Notify the developer');
378
385
  }
379
386
  const copyTasks = resourcesFilesToCopy.map((rf) => {
380
- const dest = path.resolve(directory, rf);
381
387
  return {
382
388
  src: path.join(__dirname, '../resources/control-value-accessors/', rf),
383
- dest: path.extname(dest) ? path.dirname(dest) : dest,
389
+ dest: path.join(directory, rf),
384
390
  keepDirStructure: false,
385
391
  warn: false,
386
392
  ignore: [],
package/package.json CHANGED
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "name": "@stencil/angular-output-target",
3
- "version": "0.0.1-dev.11730928290.1699ee88",
3
+ "version": "0.0.1-dev.11734409046.189fd148",
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.6.0"
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
- "gitHead": "699ee88cb3dc0726b12a985c49a3875b9eb7745a"
63
+ "gitHead": "89fd148dd07aef968f8806f1bc97cf0bffa5844d"
72
64
  }