@stencil/templates 5.0.0-alpha.7 → 5.0.0-alpha.8

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/dist/index.d.mts CHANGED
@@ -41,4 +41,35 @@ type ProjectTemplateId = (typeof PROJECT_TEMPLATES)[number];
41
41
  */
42
42
  declare function getTemplatePath(templateId: ProjectTemplateId): string;
43
43
  //#endregion
44
- export { PROJECT_TEMPLATES, type ProjectTemplateId, type StyleExtension, getComponentBoilerplate, getStyleBoilerplate, getTemplatePath, toPascalCase };
44
+ //#region src/project/config.d.ts
45
+ type OutputKey = 'loader' | 'standalone' | 'ssr' | 'ssr-wasm' | 'www';
46
+ type DocKey = 'cem' | 'json' | 'vscode';
47
+ interface PackageJsonFields {
48
+ type?: 'module';
49
+ module?: string;
50
+ types?: string;
51
+ }
52
+ interface ConfigSelections {
53
+ namespace: string;
54
+ outputs: ReadonlyArray<OutputKey>;
55
+ signals: boolean;
56
+ docs: ReadonlyArray<DocKey>;
57
+ }
58
+ /**
59
+ * Returns stencil.config.ts source for the given selections, or null if zero-config
60
+ * covers everything (outputs = [] | ['loader'], no signals, no docs).
61
+ *
62
+ * @param sel - Wizard selections to encode into the config file.
63
+ * @returns TypeScript source string, or null if no config file is needed.
64
+ */
65
+ declare function generateStencilConfig(sel: ConfigSelections): string | null;
66
+ /**
67
+ * Returns the package.json distributable fields for the given output selections.
68
+ * Returns an empty object for www-only (non-publishable app mode).
69
+ * Priority: loader > standalone > ssr > ssr-wasm.
70
+ * @param outputs - Wizard output selections to encode into package.json.
71
+ * @returns An object with the fields to write into package.json.
72
+ */
73
+ declare function generatePackageJsonFields(outputs: ReadonlyArray<OutputKey>): PackageJsonFields;
74
+ //#endregion
75
+ export { type ConfigSelections, type DocKey, type OutputKey, PROJECT_TEMPLATES, type PackageJsonFields, type ProjectTemplateId, type StyleExtension, generatePackageJsonFields, generateStencilConfig, getComponentBoilerplate, getStyleBoilerplate, getTemplatePath, toPascalCase };
package/dist/index.mjs CHANGED
@@ -65,4 +65,72 @@ function getTemplatePath(templateId) {
65
65
  return join(__dirname, "..", "templates", "project", templateId);
66
66
  }
67
67
  //#endregion
68
- export { PROJECT_TEMPLATES, getComponentBoilerplate, getStyleBoilerplate, getTemplatePath, toPascalCase };
68
+ //#region src/project/config.ts
69
+ /**
70
+ * Returns stencil.config.ts source for the given selections, or null if zero-config
71
+ * covers everything (outputs = [] | ['loader'], no signals, no docs).
72
+ *
73
+ * @param sel - Wizard selections to encode into the config file.
74
+ * @returns TypeScript source string, or null if no config file is needed.
75
+ */
76
+ function generateStencilConfig(sel) {
77
+ if ((sel.outputs.length === 0 || sel.outputs.length === 1 && sel.outputs[0] === "loader") && !sel.signals && sel.docs.length === 0) return null;
78
+ const outputLines = [];
79
+ if (sel.outputs.includes("loader") || sel.outputs.length === 0) outputLines.push(` { type: 'loader-bundle' },`);
80
+ if (sel.outputs.includes("standalone")) outputLines.push(` { type: 'standalone' },`);
81
+ if (sel.outputs.includes("ssr")) outputLines.push(` { type: 'ssr' },`);
82
+ if (sel.outputs.includes("ssr-wasm")) outputLines.push(` { type: 'ssr-wasm' },`);
83
+ if (sel.outputs.includes("www")) outputLines.push(` { type: 'www' },`);
84
+ if (sel.docs.includes("cem")) outputLines.push(` { type: 'docs-custom-elements-manifest', file: 'custom-elements.json' },`);
85
+ if (sel.docs.includes("json")) outputLines.push(` { type: 'docs-json', file: 'docs/api.json' },`);
86
+ if (sel.docs.includes("vscode")) outputLines.push(` { type: 'docs-vscode', file: 'vscode-data.json' },`);
87
+ const parts = [
88
+ `import type { Config } from '@stencil/core';`,
89
+ ``,
90
+ `export const config: Config = {`,
91
+ ` namespace: '${sel.namespace}',`
92
+ ];
93
+ if (outputLines.length > 0) {
94
+ parts.push(` outputTargets: [`);
95
+ parts.push(...outputLines);
96
+ parts.push(` ],`);
97
+ }
98
+ if (sel.signals) parts.push(` signalBacking: true,`);
99
+ parts.push(`};`);
100
+ parts.push(``);
101
+ return parts.join("\n");
102
+ }
103
+ /**
104
+ * Returns the package.json distributable fields for the given output selections.
105
+ * Returns an empty object for www-only (non-publishable app mode).
106
+ * Priority: loader > standalone > ssr > ssr-wasm.
107
+ * @param outputs - Wizard output selections to encode into package.json.
108
+ * @returns An object with the fields to write into package.json.
109
+ */
110
+ function generatePackageJsonFields(outputs) {
111
+ const isDefault = outputs.length === 0;
112
+ const has = (key) => outputs.includes(key);
113
+ if (isDefault || has("loader")) return {
114
+ type: "module",
115
+ module: "./dist/loader-bundle/index.js",
116
+ types: "./dist/types/loader.d.ts"
117
+ };
118
+ if (has("standalone")) return {
119
+ type: "module",
120
+ module: "./dist/standalone/index.js",
121
+ types: "./dist/types/standalone.d.ts"
122
+ };
123
+ if (has("ssr")) return {
124
+ type: "module",
125
+ module: "./dist/ssr/index.js",
126
+ types: "./dist/ssr/index.d.ts"
127
+ };
128
+ if (has("ssr-wasm")) return {
129
+ type: "module",
130
+ module: "./dist/ssr-wasm/index.js",
131
+ types: "./dist/ssr-wasm/plugin.d.ts"
132
+ };
133
+ return {};
134
+ }
135
+ //#endregion
136
+ export { PROJECT_TEMPLATES, generatePackageJsonFields, generateStencilConfig, getComponentBoilerplate, getStyleBoilerplate, getTemplatePath, toPascalCase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/templates",
3
- "version": "5.0.0-alpha.7",
3
+ "version": "5.0.0-alpha.8",
4
4
  "description": "Project and generate templates for Stencil",
5
5
  "keywords": [
6
6
  "scaffolding",
@@ -6,16 +6,13 @@
6
6
  "files": [
7
7
  "dist/"
8
8
  ],
9
- "main": "dist/loader-bundle/index.cjs",
10
- "module": "dist/loader-bundle/index.js",
11
- "types": "dist/types/index.d.ts",
12
9
  "scripts": {
13
10
  "build": "stencil build",
14
11
  "dev": "stencil build --dev --watch --serve",
15
12
  "generate": "stencil generate"
16
13
  },
17
14
  "devDependencies": {
18
- "@stencil/core": "^5.0.0"
15
+ "@stencil/core": "{{STENCIL_VERSION}}"
19
16
  },
20
- "collection": "dist/collection/collection-manifest.json"
17
+ "collection": "./dist/collection/collection-manifest.json"
21
18
  }
@@ -1,4 +1,6 @@
1
- import { Component, Host } from '@stencil/core';
1
+ import { Component, Prop } from '@stencil/core';
2
+
3
+ import { format } from '../../utils/utils';
2
4
 
3
5
  @Component({
4
6
  tag: 'my-component',
@@ -6,11 +8,20 @@ import { Component, Host } from '@stencil/core';
6
8
  encapsulation: { type: 'shadow' },
7
9
  })
8
10
  export class MyComponent {
11
+ /** The first name */
12
+ @Prop() first?: string;
13
+
14
+ /** The middle name */
15
+ @Prop() middle?: string;
16
+
17
+ /** The last name */
18
+ @Prop() last?: string;
19
+
20
+ private getText(): string {
21
+ return format(this.first, this.middle, this.last);
22
+ }
23
+
9
24
  render() {
10
- return (
11
- <Host>
12
- <slot></slot>
13
- </Host>
14
- );
25
+ return <div>Hello, World! I'm {this.getText()}</div>;
15
26
  }
16
27
  }
@@ -0,0 +1,3 @@
1
+ export function format(first?: string, middle?: string, last?: string): string {
2
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
3
+ }