@stencil/templates 5.0.0-alpha.6 → 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/LICENSE.md +27 -0
- package/dist/index.d.mts +32 -1
- package/dist/index.mjs +69 -1
- package/package.json +10 -10
- package/templates/project/component-starter/package.json +2 -5
- package/templates/project/component-starter/src/components/my-component/my-component.tsx +17 -6
- package/templates/project/component-starter/src/utils/utils.ts +3 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-present Drifty Co.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
-----------------------------------------
|
|
24
|
+
Third-party components, software, and/or libraries (collectively, "components")
|
|
25
|
+
are included under the licenses specified by their authors. For information
|
|
26
|
+
about these third-party licenses, refer to the separate legal notices governing
|
|
27
|
+
such components at NOTICE file at the top level of the package.
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "5.0.0-alpha.8",
|
|
4
4
|
"description": "Project and generate templates for Stencil",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"scaffolding",
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"import": "./dist/index.mjs"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"build": "tsdown",
|
|
32
|
-
"test": "vitest run --passWithNoTests",
|
|
33
|
-
"typecheck": "tsc --noEmit"
|
|
34
|
-
},
|
|
35
30
|
"devDependencies": {
|
|
36
|
-
"tsdown": "
|
|
37
|
-
"typescript": "
|
|
38
|
-
"vitest": "
|
|
31
|
+
"tsdown": ">=0.21.0 <1.0.0",
|
|
32
|
+
"typescript": ">4.0.0 <7.0.0",
|
|
33
|
+
"vitest": "^4.1.7"
|
|
39
34
|
},
|
|
40
35
|
"volta": {
|
|
41
36
|
"extends": "../../package.json"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsdown",
|
|
40
|
+
"test": "vitest run --passWithNoTests",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|
|
@@ -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": "
|
|
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,
|
|
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
|
}
|