@stencil/templates 5.0.0-alpha.22 → 5.0.0-alpha.24

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
@@ -72,4 +72,42 @@ declare function generateStencilConfig(sel: ConfigSelections): string | null;
72
72
  */
73
73
  declare function generatePackageJsonFields(outputs: ReadonlyArray<OutputKey>): PackageJsonFields;
74
74
  //#endregion
75
- export { type ConfigSelections, type DocKey, type OutputKey, PROJECT_TEMPLATES, type PackageJsonFields, type ProjectTemplateId, type StyleExtension, generatePackageJsonFields, generateStencilConfig, getComponentBoilerplate, getStyleBoilerplate, getTemplatePath, toPascalCase };
75
+ //#region src/project/index-html.d.ts
76
+ interface IndexHtmlSelections {
77
+ projectName: string;
78
+ namespace: string;
79
+ globalStyle: boolean;
80
+ }
81
+ /**
82
+ * Returns src/index.html source for a `www`-output project: entry <script> tag pointing
83
+ * at the compiled bundle, and a <link> to the global stylesheet if one was selected.
84
+ *
85
+ * @param sel - Wizard selections to encode into the HTML file.
86
+ * @returns HTML source string.
87
+ */
88
+ declare function generateIndexHtml(sel: IndexHtmlSelections): string;
89
+ //#endregion
90
+ //#region src/generate/preview.d.ts
91
+ /**
92
+ * Returns the `usage/example.md` boilerplate for `stencil generate`. Read by the docs
93
+ * pipeline (readme / docs-json / custom-elements-manifest demos) and by the dev server's
94
+ * live component preview.
95
+ *
96
+ * @param tagName - Dash-case custom element tag name.
97
+ * @returns Markdown source string.
98
+ */
99
+ declare function getUsageExampleBoilerplate(tagName: string): string;
100
+ /**
101
+ * Returns a standalone index.html boilerplate for `stencil generate`, scoped to a single
102
+ * component's own directory. Its presence opts that directory out of the dev server's
103
+ * auto-generated preview, trading it for a hand-authored demo page.
104
+ *
105
+ * @param tagName - Dash-case custom element tag name.
106
+ * @param entryScriptSrc - Resolved src for the project's browser entry bundle (see
107
+ * `resolveEntryScriptSrc` in the CLI package), or `null` if the project has no browser-loadable
108
+ * output target (e.g. an SSR-only project) - the script tag is omitted in that case.
109
+ * @returns HTML source string.
110
+ */
111
+ declare function getPreviewHtmlBoilerplate(tagName: string, entryScriptSrc: string | null): string;
112
+ //#endregion
113
+ export { type ConfigSelections, type DocKey, type IndexHtmlSelections, type OutputKey, PROJECT_TEMPLATES, type PackageJsonFields, type ProjectTemplateId, type StyleExtension, generateIndexHtml, generatePackageJsonFields, generateStencilConfig, getComponentBoilerplate, getPreviewHtmlBoilerplate, getStyleBoilerplate, getTemplatePath, getUsageExampleBoilerplate, toPascalCase };
package/dist/index.mjs CHANGED
@@ -133,4 +133,78 @@ function generatePackageJsonFields(outputs) {
133
133
  return {};
134
134
  }
135
135
  //#endregion
136
- export { PROJECT_TEMPLATES, generatePackageJsonFields, generateStencilConfig, getComponentBoilerplate, getStyleBoilerplate, getTemplatePath, toPascalCase };
136
+ //#region src/project/index-html.ts
137
+ /**
138
+ * Returns src/index.html source for a `www`-output project: entry <script> tag pointing
139
+ * at the compiled bundle, and a <link> to the global stylesheet if one was selected.
140
+ *
141
+ * @param sel - Wizard selections to encode into the HTML file.
142
+ * @returns HTML source string.
143
+ */
144
+ function generateIndexHtml(sel) {
145
+ const fsNamespace = sel.namespace.toLowerCase();
146
+ const headLines = [
147
+ ` <meta charset="UTF-8" />`,
148
+ ` <title>${sel.projectName}</title>`,
149
+ ` <meta name="viewport" content="width=device-width, initial-scale=1" />`
150
+ ];
151
+ if (sel.globalStyle) headLines.push(` <link rel="stylesheet" href="/build/${fsNamespace}.css" />`);
152
+ headLines.push(` <script type="module" src="/build/${fsNamespace}.js"><\/script>`);
153
+ return [
154
+ `<!doctype html>`,
155
+ `<html lang="en">`,
156
+ ` <head>`,
157
+ ...headLines,
158
+ ` </head>`,
159
+ ` <body>`,
160
+ ` <my-component first="Stencil" last="'Don't call me a framework' JS"></my-component>`,
161
+ ` </body>`,
162
+ `</html>`,
163
+ ``
164
+ ].join("\n");
165
+ }
166
+ //#endregion
167
+ //#region src/generate/preview.ts
168
+ /**
169
+ * Returns the `usage/example.md` boilerplate for `stencil generate`. Read by the docs
170
+ * pipeline (readme / docs-json / custom-elements-manifest demos) and by the dev server's
171
+ * live component preview.
172
+ *
173
+ * @param tagName - Dash-case custom element tag name.
174
+ * @returns Markdown source string.
175
+ */
176
+ function getUsageExampleBoilerplate(tagName) {
177
+ return `# Example
178
+
179
+ \`\`\`html
180
+ <${tagName}></${tagName}>
181
+ \`\`\`
182
+ `;
183
+ }
184
+ /**
185
+ * Returns a standalone index.html boilerplate for `stencil generate`, scoped to a single
186
+ * component's own directory. Its presence opts that directory out of the dev server's
187
+ * auto-generated preview, trading it for a hand-authored demo page.
188
+ *
189
+ * @param tagName - Dash-case custom element tag name.
190
+ * @param entryScriptSrc - Resolved src for the project's browser entry bundle (see
191
+ * `resolveEntryScriptSrc` in the CLI package), or `null` if the project has no browser-loadable
192
+ * output target (e.g. an SSR-only project) - the script tag is omitted in that case.
193
+ * @returns HTML source string.
194
+ */
195
+ function getPreviewHtmlBoilerplate(tagName, entryScriptSrc) {
196
+ return `<!doctype html>
197
+ <html lang="en">
198
+ <head>
199
+ <meta charset="UTF-8" />
200
+ <title>${tagName}</title>
201
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
202
+ ${entryScriptSrc ? ` <script type="module" src="${entryScriptSrc}"><\/script>\n` : ` <!-- no browser-loadable output target configured - add your own entry script -->\n`} </head>
203
+ <body>
204
+ <${tagName}></${tagName}>
205
+ </body>
206
+ </html>
207
+ `;
208
+ }
209
+ //#endregion
210
+ export { PROJECT_TEMPLATES, generateIndexHtml, generatePackageJsonFields, generateStencilConfig, getComponentBoilerplate, getPreviewHtmlBoilerplate, getStyleBoilerplate, getTemplatePath, getUsageExampleBoilerplate, toPascalCase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/templates",
3
- "version": "5.0.0-alpha.22",
3
+ "version": "5.0.0-alpha.24",
4
4
  "description": "Project and generate templates for Stencil",
5
5
  "keywords": [
6
6
  "scaffolding",
@@ -33,7 +33,7 @@
33
33
  "vitest": "^4.1.7"
34
34
  },
35
35
  "peerDependencies": {
36
- "@stencil/core": "^5.0.0 || 5.0.0-alpha.22"
36
+ "@stencil/core": "^5.0.0 || 5.0.0-alpha.24"
37
37
  },
38
38
  "volta": {
39
39
  "extends": "../../package.json"