@pure-ds/core 0.6.10 → 0.6.11
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/custom-elements.json +803 -16
- package/dist/types/pds.d.ts +1 -0
- package/dist/types/public/assets/js/pds-manager.d.ts +98 -1
- package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-live-converter.d.ts +8 -0
- package/dist/types/public/assets/pds/components/pds-live-converter.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-live-importer.d.ts +2 -0
- package/dist/types/public/assets/pds/components/pds-live-importer.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-live-template-canvas.d.ts +2 -0
- package/dist/types/public/assets/pds/components/pds-live-template-canvas.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-omnibox.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-scrollrow.d.ts +20 -0
- package/dist/types/public/assets/pds/components/pds-scrollrow.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-toaster.d.ts +1 -1
- package/dist/types/public/assets/pds/components/pds-toaster.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-treeview.d.ts +37 -0
- package/dist/types/public/assets/pds/components/pds-treeview.d.ts.map +1 -0
- package/dist/types/src/js/common/toast.d.ts +8 -0
- package/dist/types/src/js/common/toast.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-enhancers.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-generator.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-live.d.ts +2 -1
- package/dist/types/src/js/pds-core/pds-live.d.ts.map +1 -1
- package/dist/types/src/js/pds-live-manager/conversion-service.d.ts +66 -0
- package/dist/types/src/js/pds-live-manager/conversion-service.d.ts.map +1 -0
- package/dist/types/src/js/pds-live-manager/import-contract.d.ts +15 -0
- package/dist/types/src/js/pds-live-manager/import-contract.d.ts.map +1 -0
- package/dist/types/src/js/pds-live-manager/import-history-service.d.ts +32 -0
- package/dist/types/src/js/pds-live-manager/import-history-service.d.ts.map +1 -0
- package/dist/types/src/js/pds-live-manager/import-service.d.ts +21 -0
- package/dist/types/src/js/pds-live-manager/import-service.d.ts.map +1 -0
- package/dist/types/src/js/pds-live-manager/template-service.d.ts +17 -0
- package/dist/types/src/js/pds-live-manager/template-service.d.ts.map +1 -0
- package/dist/types/src/js/pds-manager.d.ts +4 -0
- package/dist/types/src/js/pds.d.ts.map +1 -1
- package/package.json +6 -2
- package/packages/pds-cli/README.md +51 -0
- package/packages/pds-cli/bin/pds-import.js +176 -0
- package/packages/pds-cli/bin/pds-static.js +15 -0
- package/packages/pds-cli/bin/postinstall.mjs +17 -8
- package/public/assets/js/app.js +15 -139
- package/public/assets/js/pds-manager.js +358 -255
- package/public/assets/js/pds.js +7 -7
- package/public/assets/pds/components/pds-live-converter.js +47 -0
- package/public/assets/pds/components/pds-live-edit.js +760 -43
- package/public/assets/pds/components/pds-live-importer.js +772 -0
- package/public/assets/pds/components/pds-live-template-canvas.js +171 -0
- package/public/assets/pds/components/pds-omnibox.js +136 -2
- package/public/assets/pds/components/pds-scrollrow.js +56 -1
- package/public/assets/pds/components/pds-toaster.js +50 -5
- package/public/assets/pds/components/pds-treeview.js +972 -0
- package/public/assets/pds/custom-elements.json +803 -16
- package/public/assets/pds/pds-css-complete.json +7 -2
- package/public/assets/pds/templates/commerce-scroll-explorer.html +115 -0
- package/public/assets/pds/templates/content-brand-showcase.html +110 -0
- package/public/assets/pds/templates/feedback-ops-dashboard.html +91 -0
- package/public/assets/pds/templates/release-readiness-radar.html +69 -0
- package/public/assets/pds/templates/support-command-center.html +92 -0
- package/public/assets/pds/templates/templates.json +53 -0
- package/public/assets/pds/templates/workspace-settings-lab.html +131 -0
- package/public/assets/pds/vscode-custom-data.json +54 -4
- package/readme.md +34 -0
- package/src/js/pds-core/pds-config.js +9 -9
- package/src/js/pds-core/pds-enhancers.js +146 -0
- package/src/js/pds-core/pds-generator.js +170 -29
- package/src/js/pds-core/pds-live.js +453 -13
- package/src/js/pds-live-manager/conversion-service.js +3136 -0
- package/src/js/pds-live-manager/import-contract.js +57 -0
- package/src/js/pds-live-manager/import-history-service.js +145 -0
- package/src/js/pds-live-manager/import-service.js +255 -0
- package/src/js/pds-live-manager/tailwind-conversion-rules.json +383 -0
- package/src/js/pds-live-manager/template-service.js +170 -0
- package/src/js/pds.d.ts +1 -0
- package/src/js/pds.js +35 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { mkdir, readFile, writeFile } from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
6
|
+
import { runLiveImport, listLiveTemplates, getLiveImportSources } from '../../../src/js/pds-live-manager/import-service.js';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
function help() {
|
|
12
|
+
console.log(`pds-import — Import and convert external design inputs for PDS
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
pds-import --type tailwind-html --mode convert-only --source ./input.html --out ./pds-import.json
|
|
16
|
+
pds-import --type tailwind-html --mode adopt-design-and-convert --source ./input.html --out ./pds-import.json
|
|
17
|
+
pds-import --type brand-guidelines --mode adopt-design-and-convert --source ./brand.txt --out ./brand-import.json
|
|
18
|
+
pds-import --type template --template marketing-hero --out ./template-import.json
|
|
19
|
+
|
|
20
|
+
Options:
|
|
21
|
+
--type <value> Import type: tailwind-html | brand-guidelines | template
|
|
22
|
+
--mode <value> Import mode: convert-only | adopt-design-and-convert
|
|
23
|
+
--source <path> Source file path for tailwind-html or brand-guidelines
|
|
24
|
+
--text <value> Inline input text instead of source file
|
|
25
|
+
--template <id> Template id when --type=template
|
|
26
|
+
--config <path> Optional PDS config file (.json/.js/.mjs) to govern conversion rules
|
|
27
|
+
--describe-rules Print Tailwind→PDS conversion rulebook and exit
|
|
28
|
+
--out <path> Output JSON file path (required)
|
|
29
|
+
--html-out <path> Optional output path for converted template HTML (if present)
|
|
30
|
+
--design-out <path> Optional output path for design patch JSON (if present)
|
|
31
|
+
--list List available sources and templates
|
|
32
|
+
--help Show this help message
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function normalizeImportMode(value) {
|
|
37
|
+
const raw = String(value || '').trim().toLowerCase();
|
|
38
|
+
if (raw === 'adopt-design-and-convert') return raw;
|
|
39
|
+
return 'convert-only';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function writeTextOutput(absPath, contents) {
|
|
43
|
+
await mkdir(path.dirname(absPath), { recursive: true });
|
|
44
|
+
await writeFile(absPath, contents, 'utf8');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function parseArgs(argv) {
|
|
48
|
+
const args = { _: [] };
|
|
49
|
+
for (let i = 2; i < argv.length; i += 1) {
|
|
50
|
+
const current = argv[i];
|
|
51
|
+
if (current.startsWith('--')) {
|
|
52
|
+
const key = current.slice(2);
|
|
53
|
+
const next = argv[i + 1];
|
|
54
|
+
if (!next || next.startsWith('--')) {
|
|
55
|
+
args[key] = true;
|
|
56
|
+
} else {
|
|
57
|
+
args[key] = next;
|
|
58
|
+
i += 1;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
args._.push(current);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return args;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function loadInput(args) {
|
|
68
|
+
if (typeof args.text === 'string') return args.text;
|
|
69
|
+
if (typeof args.source === 'string') {
|
|
70
|
+
const sourcePath = path.resolve(process.cwd(), args.source);
|
|
71
|
+
return readFile(sourcePath, 'utf8');
|
|
72
|
+
}
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function loadConfig(args) {
|
|
77
|
+
if (typeof args.config !== 'string' || !args.config.trim()) return null;
|
|
78
|
+
|
|
79
|
+
const configPath = path.resolve(process.cwd(), args.config);
|
|
80
|
+
const ext = path.extname(configPath).toLowerCase();
|
|
81
|
+
|
|
82
|
+
if (ext === '.json') {
|
|
83
|
+
const raw = await readFile(configPath, 'utf8');
|
|
84
|
+
return JSON.parse(raw);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (ext === '.js' || ext === '.mjs' || ext === '.cjs') {
|
|
88
|
+
const mod = await import(pathToFileURL(configPath).href);
|
|
89
|
+
return mod?.config || mod?.default || null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
throw new Error('Unsupported --config format. Use .json, .js, .mjs, or .cjs');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function main() {
|
|
96
|
+
const args = parseArgs(process.argv);
|
|
97
|
+
|
|
98
|
+
if (args.help) {
|
|
99
|
+
help();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (args.list) {
|
|
104
|
+
console.log('Sources:');
|
|
105
|
+
getLiveImportSources().forEach((source) => {
|
|
106
|
+
console.log(`- ${source.id}: ${source.name}`);
|
|
107
|
+
});
|
|
108
|
+
console.log('Templates:');
|
|
109
|
+
(await listLiveTemplates()).forEach((template) => {
|
|
110
|
+
console.log(`- ${template.id}: ${template.name} [${template.icon || 'layout'}]`);
|
|
111
|
+
if (template.description) {
|
|
112
|
+
console.log(` ${template.description}`);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (args['describe-rules']) {
|
|
119
|
+
const rulesPath = path.resolve(__dirname, '../../../src/js/pds-live-manager/tailwind-conversion-rules.json');
|
|
120
|
+
const rulesJson = await readFile(rulesPath, 'utf8');
|
|
121
|
+
console.log(rulesJson);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const type = String(args.type || '').trim();
|
|
126
|
+
const outPath = String(args.out || '').trim();
|
|
127
|
+
const mode = normalizeImportMode(args.mode);
|
|
128
|
+
|
|
129
|
+
if (!type || !outPath) {
|
|
130
|
+
console.error('❌ Missing required arguments --type and --out');
|
|
131
|
+
help();
|
|
132
|
+
process.exitCode = 2;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const request = {
|
|
137
|
+
sourceType: type,
|
|
138
|
+
importMode: mode,
|
|
139
|
+
templateId: args.template,
|
|
140
|
+
input: await loadInput(args),
|
|
141
|
+
config: await loadConfig(args),
|
|
142
|
+
cwd: process.cwd(),
|
|
143
|
+
caller: path.relative(process.cwd(), __dirname),
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const result = await runLiveImport(request);
|
|
147
|
+
const absOutPath = path.resolve(process.cwd(), outPath);
|
|
148
|
+
|
|
149
|
+
await writeTextOutput(absOutPath, JSON.stringify(result, null, 2) + '\n');
|
|
150
|
+
console.log(`✅ Wrote import result to ${absOutPath}`);
|
|
151
|
+
|
|
152
|
+
if (typeof args['html-out'] === 'string' && String(args['html-out']).trim()) {
|
|
153
|
+
const html = String(result?.template?.html || '');
|
|
154
|
+
const absHtmlOutPath = path.resolve(process.cwd(), String(args['html-out']).trim());
|
|
155
|
+
await writeTextOutput(absHtmlOutPath, html);
|
|
156
|
+
console.log(`✅ Wrote converted HTML to ${absHtmlOutPath}`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (typeof args['design-out'] === 'string' && String(args['design-out']).trim()) {
|
|
160
|
+
const designPatch = result?.designPatch && typeof result.designPatch === 'object'
|
|
161
|
+
? result.designPatch
|
|
162
|
+
: {};
|
|
163
|
+
const absDesignOutPath = path.resolve(process.cwd(), String(args['design-out']).trim());
|
|
164
|
+
await writeTextOutput(absDesignOutPath, JSON.stringify(designPatch, null, 2) + '\n');
|
|
165
|
+
console.log(`✅ Wrote design patch to ${absDesignOutPath}`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const issueCount = Array.isArray(result?.issues) ? result.issues.length : 0;
|
|
169
|
+
const validationBlocked = Boolean(result?.meta?.validationBlocked || result?.meta?.validation?.ok === false);
|
|
170
|
+
console.log(`ℹ️ mode=${mode} confidence=${Math.round((result?.confidence || 0) * 100)}% issues=${issueCount} blocked=${validationBlocked}`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
main().catch((error) => {
|
|
174
|
+
console.error('❌ pds-import failed:', error?.message || error);
|
|
175
|
+
process.exit(1);
|
|
176
|
+
});
|
|
@@ -466,6 +466,21 @@ async function main(options = {}) {
|
|
|
466
466
|
log(`⚠️ Failed to copy lit.js: ${e?.message || e}`, 'yellow');
|
|
467
467
|
}
|
|
468
468
|
|
|
469
|
+
// 4d) Copy template catalog and HTML files into target/templates
|
|
470
|
+
try {
|
|
471
|
+
const templateSource = path.join(repoRoot, 'public', 'assets', 'pds', 'templates');
|
|
472
|
+
if (!existsSync(templateSource)) {
|
|
473
|
+
log('⚠️ No templates source found; skipping templates copy', 'yellow');
|
|
474
|
+
} else {
|
|
475
|
+
const templatesDir = path.join(targetDir, 'templates');
|
|
476
|
+
await mkdir(templatesDir, { recursive: true });
|
|
477
|
+
await copyDirectory(templateSource, templatesDir);
|
|
478
|
+
log(`✅ Copied templates → ${path.relative(process.cwd(), templatesDir)}`, 'green');
|
|
479
|
+
}
|
|
480
|
+
} catch (e) {
|
|
481
|
+
log(`⚠️ Failed to copy templates: ${e?.message || e}`, 'yellow');
|
|
482
|
+
}
|
|
483
|
+
|
|
469
484
|
// 5) Generate CSS layers into target/styles
|
|
470
485
|
log('🧬 Generating styles...', 'bold');
|
|
471
486
|
const { Generator } = await loadGenerator();
|
|
@@ -121,18 +121,27 @@ async function ensureBuildScript(consumerRoot) {
|
|
|
121
121
|
|
|
122
122
|
consumerPkg.scripts = consumerPkg.scripts || {};
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
const requiredScripts = {
|
|
125
|
+
'pds:build': 'pds-build',
|
|
126
|
+
'pds:import': 'pds-import',
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
let changed = false;
|
|
130
|
+
for (const [scriptName, scriptCommand] of Object.entries(requiredScripts)) {
|
|
131
|
+
if (!consumerPkg.scripts[scriptName]) {
|
|
132
|
+
consumerPkg.scripts[scriptName] = scriptCommand;
|
|
133
|
+
console.log(`🧩 Added "${scriptName}" script to consumer package.json`);
|
|
134
|
+
changed = true;
|
|
135
|
+
} else {
|
|
136
|
+
console.log(`🔧 Script "${scriptName}" already present in consumer package.json`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
126
139
|
|
|
127
|
-
if (
|
|
128
|
-
consumerPkg.scripts[desiredScriptName] = desiredScriptCmd;
|
|
140
|
+
if (changed) {
|
|
129
141
|
await writeFile(consumerPkgPath, JSON.stringify(consumerPkg, null, 2) + '\n');
|
|
130
|
-
console.log(`🧩 Added "${desiredScriptName}" script to consumer package.json`);
|
|
131
|
-
} else {
|
|
132
|
-
console.log(`🔧 Script "${desiredScriptName}" already present in consumer package.json`);
|
|
133
142
|
}
|
|
134
143
|
} catch (e) {
|
|
135
|
-
console.warn('⚠️ Could not ensure
|
|
144
|
+
console.warn('⚠️ Could not ensure PDS scripts in consumer package.json:', e.message);
|
|
136
145
|
}
|
|
137
146
|
}
|
|
138
147
|
|