@pantoken/scaffold-base 0.2.0 → 0.3.0
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 +7 -7
- package/dist/index.mjs +13 -4
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ declare const options: {
|
|
|
5
5
|
name: z.ZodDefault<z.ZodString>;
|
|
6
6
|
};
|
|
7
7
|
/** Shared options every pantoken scaffold platform Preset takes in. */
|
|
8
|
-
declare const base: Base<typeof options>;
|
|
8
|
+
export declare const base: Base<typeof options>;
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/preset.d.ts
|
|
11
11
|
interface PresetInput {
|
|
@@ -19,11 +19,11 @@ interface PresetInput {
|
|
|
19
19
|
* @param input - Preset configuration with name, base, and optional blocks
|
|
20
20
|
* @returns Properly typed Bingo Preset
|
|
21
21
|
*/
|
|
22
|
-
declare function createPreset(input: PresetInput): Preset$1;
|
|
22
|
+
export declare function createPreset(input: PresetInput): Preset$1;
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/blocks/cssdoc.d.ts
|
|
25
25
|
/** Writes the shared `cssdoc.json` schema file, unmodified by platform or options. */
|
|
26
|
-
declare const blockCssdoc: BlockWithoutAddons<{
|
|
26
|
+
export declare const blockCssdoc: BlockWithoutAddons<{
|
|
27
27
|
name: string;
|
|
28
28
|
}>;
|
|
29
29
|
//#endregion
|
|
@@ -33,18 +33,18 @@ declare const blockCssdoc: BlockWithoutAddons<{
|
|
|
33
33
|
* `format: "html"` covers plain HTML/Angular templates (`class="..."`); `"jsx"` covers React/Next
|
|
34
34
|
* (`className="..."`).
|
|
35
35
|
*/
|
|
36
|
-
declare function renderWrapperContainer(format: "html" | "jsx", depth?: number): string;
|
|
36
|
+
export declare function renderWrapperContainer(format: "html" | "jsx", depth?: number): string;
|
|
37
37
|
/** The wrapper layout's root class name (applied to the real document `<body>` or component root). */
|
|
38
|
-
declare function wrapperRootClassName(): string;
|
|
38
|
+
export declare function wrapperRootClassName(): string;
|
|
39
39
|
/**
|
|
40
40
|
* The wrapper layout markup/tokens every platform Preset feeds into its own Handlebars context —
|
|
41
41
|
* `{{projectName}}` inside the rendered markup is left as-is, for the platform's own template to
|
|
42
42
|
* resolve.
|
|
43
43
|
*/
|
|
44
|
-
declare function getWrapperContext(): {
|
|
44
|
+
export declare function getWrapperContext(): {
|
|
45
45
|
wrapperRootClass: string;
|
|
46
46
|
wrapperContainerHtml: (depth?: number) => string;
|
|
47
47
|
wrapperContainerJsx: (depth?: number) => string;
|
|
48
48
|
};
|
|
49
49
|
//#endregion
|
|
50
|
-
export {
|
|
50
|
+
export type { Preset };
|
package/dist/index.mjs
CHANGED
|
@@ -79,10 +79,16 @@ function parseSelector(selector) {
|
|
|
79
79
|
};
|
|
80
80
|
if (selector.startsWith("&")) return null;
|
|
81
81
|
const optional = selector.includes(":optional");
|
|
82
|
-
const attrMatch = /^([a-z]*)\[([\w-]+)(?:~|)=(?:"([^"]*)"|'([^']*)')\]
|
|
82
|
+
const attrMatch = /^([a-z]*)\[([\w-]+)(?:~|)=(?:"([^"]*)"|'([^']*)')\](?:\.([\w-]+))?/i.exec(selector);
|
|
83
83
|
if (attrMatch) {
|
|
84
|
-
const [, tag, attrName, dq, sq] = attrMatch;
|
|
84
|
+
const [, tag, attrName, dq, sq, trailingClass] = attrMatch;
|
|
85
85
|
const value = dq ?? sq ?? "";
|
|
86
|
+
if (tag === "slot") return {
|
|
87
|
+
tag: "div",
|
|
88
|
+
attrs: { "data-slot": value },
|
|
89
|
+
className: trailingClass,
|
|
90
|
+
optional
|
|
91
|
+
};
|
|
86
92
|
if (attrName === "class") return {
|
|
87
93
|
tag: tag || "div",
|
|
88
94
|
className: value,
|
|
@@ -91,6 +97,7 @@ function parseSelector(selector) {
|
|
|
91
97
|
return {
|
|
92
98
|
tag: tag || "div",
|
|
93
99
|
attrs: { [attrName]: value },
|
|
100
|
+
className: trailingClass,
|
|
94
101
|
optional
|
|
95
102
|
};
|
|
96
103
|
}
|
|
@@ -102,6 +109,7 @@ function parseSelector(selector) {
|
|
|
102
109
|
optional
|
|
103
110
|
};
|
|
104
111
|
}
|
|
112
|
+
/** Recursively parse CSS rule bodies into a tree of {@link WrapperNode}s. */
|
|
105
113
|
function parseNodes(css) {
|
|
106
114
|
const nodes = [];
|
|
107
115
|
for (const { selector, body } of splitRules(css)) for (const single of selector.split(",")) {
|
|
@@ -133,7 +141,7 @@ function parseWrapperLayout() {
|
|
|
133
141
|
/** Placeholder text injected at specific parts, keyed by class name. */
|
|
134
142
|
const PART_TEXT = {
|
|
135
143
|
title: "{{projectName}}",
|
|
136
|
-
description: "Styled with <code>@pantoken/components</code
|
|
144
|
+
description: "Styled with <code>@pantoken/components</code>."
|
|
137
145
|
};
|
|
138
146
|
/** The `slot[name="content"]` part gets the platform's actual getting-started content, per format. */
|
|
139
147
|
const MAIN_CONTENT = {
|
|
@@ -146,6 +154,7 @@ function attrName(format) {
|
|
|
146
154
|
function comment(format, text) {
|
|
147
155
|
return format === "jsx" ? `{/* ${text} */}` : `<!-- ${text} -->`;
|
|
148
156
|
}
|
|
157
|
+
/** Render a {@link WrapperNode} (and its children) as indented HTML or JSX markup. */
|
|
149
158
|
function renderNode(node, format, depth) {
|
|
150
159
|
const pad = " ".repeat(depth);
|
|
151
160
|
if (node.comment) return `${pad}${comment(format, node.comment)}`;
|
|
@@ -155,7 +164,7 @@ function renderNode(node, format, depth) {
|
|
|
155
164
|
const openTag = `<${node.tag}${attrs.length ? ` ${attrs.join(" ")}` : ""}>`;
|
|
156
165
|
const closeTag = `</${node.tag}>`;
|
|
157
166
|
const optionalNote = node.optional ? ` ${comment(format, "optional")}` : "";
|
|
158
|
-
const isMainSlot = node.
|
|
167
|
+
const isMainSlot = node.attrs?.["data-slot"] === "content";
|
|
159
168
|
const text = PART_TEXT[node.className ?? ""] ?? (isMainSlot ? MAIN_CONTENT[format] : void 0);
|
|
160
169
|
const childLines = node.children.map((child) => renderNode(child, format, depth + 1));
|
|
161
170
|
const bodyPad = " ".repeat(depth + 1);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pantoken/scaffold-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Shared bingo-stratum Base for pantoken's scaffold presets: common options, the cssdoc.json block, and wrapper-layout markup context.",
|
|
5
|
-
"homepage": "https://pantoken.
|
|
5
|
+
"homepage": "https://pantoken.app",
|
|
6
6
|
"bugs": "https://github.com/thedannywahl/pantoken/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"provenance": true
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@pantoken/plugin-layouts": "0.
|
|
27
|
+
"@pantoken/plugin-layouts": "0.3.0",
|
|
28
28
|
"bingo-stratum": "^0.5.13",
|
|
29
|
-
"zod": "^3.
|
|
29
|
+
"zod": "^3.25.76"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^26.
|
|
32
|
+
"@types/node": "^26.5.0",
|
|
33
33
|
"typescript": "^7.0.2",
|
|
34
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.
|
|
35
|
-
"vite-plus": "0.3.
|
|
34
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.1",
|
|
35
|
+
"vite-plus": "0.3.1"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=22.18.0"
|