kss-modern 1.7.0-beta.6 → 1.7.0-beta.7
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/node/lib/index.d.mts +1 -1
- package/dist/node/lib/index.d.ts +1 -1
- package/dist/node/lib/index.mjs +35 -0
- package/dist/node/lib/pug/worker.d.mts +1 -1
- package/dist/node/lib/pug/worker.d.ts +1 -1
- package/dist/node/shared/{kss-modern.Dxz_7Er0.d.mts → kss-modern.C0c9PPgd.d.mts} +6 -0
- package/dist/node/shared/{kss-modern.Dxz_7Er0.d.ts → kss-modern.C0c9PPgd.d.ts} +6 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BuildAllOptions, L as LogBox, a as Logger, P as PreviewTheme, R as ResolvedStyleguideConfiguration, b as StyleguideBrandColor, c as StyleguideChange, S as StyleguideConfiguration, d as StyleguideContext, e as buildAll, f as buildStyleguide, g as createLogger, l as logger, p as parseStyleguide, r as rebuildSections, h as resolveConfiguration, w as watchStyleguide } from '../shared/kss-modern.
|
|
1
|
+
export { B as BuildAllOptions, L as LogBox, a as Logger, P as PreviewTheme, R as ResolvedStyleguideConfiguration, b as StyleguideBrandColor, c as StyleguideChange, S as StyleguideConfiguration, d as StyleguideContext, e as buildAll, f as buildStyleguide, g as createLogger, l as logger, p as parseStyleguide, r as rebuildSections, h as resolveConfiguration, w as watchStyleguide } from '../shared/kss-modern.C0c9PPgd.mjs';
|
package/dist/node/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BuildAllOptions, L as LogBox, a as Logger, P as PreviewTheme, R as ResolvedStyleguideConfiguration, b as StyleguideBrandColor, c as StyleguideChange, S as StyleguideConfiguration, d as StyleguideContext, e as buildAll, f as buildStyleguide, g as createLogger, l as logger, p as parseStyleguide, r as rebuildSections, h as resolveConfiguration, w as watchStyleguide } from '../shared/kss-modern.
|
|
1
|
+
export { B as BuildAllOptions, L as LogBox, a as Logger, P as PreviewTheme, R as ResolvedStyleguideConfiguration, b as StyleguideBrandColor, c as StyleguideChange, S as StyleguideConfiguration, d as StyleguideContext, e as buildAll, f as buildStyleguide, g as createLogger, l as logger, p as parseStyleguide, r as rebuildSections, h as resolveConfiguration, w as watchStyleguide } from '../shared/kss-modern.C0c9PPgd.js';
|
package/dist/node/lib/index.mjs
CHANGED
|
@@ -586,6 +586,38 @@ async function logicalWriteFile(filepath, content) {
|
|
|
586
586
|
await fs.writeFile(filepath, content);
|
|
587
587
|
}
|
|
588
588
|
|
|
589
|
+
const UNSAFE_SEGMENT_CHARS_RE = /[<>:"\\|?*\u0000-\u001F]/g;
|
|
590
|
+
function toFileSegment(segment) {
|
|
591
|
+
const cleaned = segment.replace(UNSAFE_SEGMENT_CHARS_RE, "-").trim();
|
|
592
|
+
return cleaned === "" || cleaned === "." || cleaned === ".." ? void 0 : cleaned;
|
|
593
|
+
}
|
|
594
|
+
function getJsonSchemaFiles(manifest) {
|
|
595
|
+
const files = /* @__PURE__ */ new Map();
|
|
596
|
+
for (const entry of manifest.mixins) {
|
|
597
|
+
if (!entry.hasSchema || !entry.jsonSchema)
|
|
598
|
+
continue;
|
|
599
|
+
const segments = entry.path.map(toFileSegment).filter((segment) => segment !== void 0);
|
|
600
|
+
const base = (segments.length > 0 ? segments : [entry.id]).join("/");
|
|
601
|
+
let file = `${base}.json`;
|
|
602
|
+
for (let count = 2; files.has(file); count++)
|
|
603
|
+
file = `${base}-${count}.json`;
|
|
604
|
+
if (file !== `${base}.json`)
|
|
605
|
+
logger.warn(`The JSON Schema of mixin "${entry.name}" (${entry.file}:${entry.line}) is written to ${file}, since ${base}.json is taken.`);
|
|
606
|
+
files.set(file, entry.jsonSchema);
|
|
607
|
+
}
|
|
608
|
+
return files;
|
|
609
|
+
}
|
|
610
|
+
async function writeJsonSchemaFiles(directory, manifest, previous = /* @__PURE__ */ new Map()) {
|
|
611
|
+
const root = path.resolve(directory);
|
|
612
|
+
const written = new Map([...getJsonSchemaFiles(manifest)].map(([file, jsonSchema]) => [path.join(root, file), `${JSON.stringify(jsonSchema, null, 2)}
|
|
613
|
+
`]));
|
|
614
|
+
await Promise.all([
|
|
615
|
+
...[...written].filter(([file, content]) => previous.get(file) !== content).map(([file, content]) => logicalWriteFile(file, content)),
|
|
616
|
+
...[...previous.keys()].filter((file) => !written.has(file)).map((file) => fs$1.rm(file, { force: true }))
|
|
617
|
+
]);
|
|
618
|
+
return written;
|
|
619
|
+
}
|
|
620
|
+
|
|
589
621
|
const MIXIN_MANIFEST_PATH = "mixins/manifest.json";
|
|
590
622
|
const MIXIN_OVERVIEW_FILE = "mixins.html";
|
|
591
623
|
function getMixinExplorerHref(id) {
|
|
@@ -694,6 +726,7 @@ function createMixinPipeline(config) {
|
|
|
694
726
|
let lastResult;
|
|
695
727
|
let pugFiles;
|
|
696
728
|
const lastGoodModules = /* @__PURE__ */ new Map();
|
|
729
|
+
let jsonSchemaFiles = /* @__PURE__ */ new Map();
|
|
697
730
|
const build = async (changedFiles) => {
|
|
698
731
|
const startedAt = performance.now();
|
|
699
732
|
const changedPugFiles = changedFiles?.filter((file) => file.endsWith(".pug")).map((file) => path.resolve(file));
|
|
@@ -909,6 +942,8 @@ ${failures.join("\n\n")}`] : []
|
|
|
909
942
|
}
|
|
910
943
|
const manifest = { mixins: entries.filter((entry) => entry.hasSchema || entry.schemaError !== void 0) };
|
|
911
944
|
await writeOutput(config.outDir, manifest, modules);
|
|
945
|
+
if (config.mixinJsonSchemaDir)
|
|
946
|
+
jsonSchemaFiles = await writeJsonSchemaFiles(config.mixinJsonSchemaDir, manifest, jsonSchemaFiles);
|
|
912
947
|
if (isCacheDirty)
|
|
913
948
|
await writeCache(cacheFilePath, data);
|
|
914
949
|
const stats = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as StyleguideConfiguration, M as MixinUsageNode } from '../../shared/kss-modern.
|
|
1
|
+
import { S as StyleguideConfiguration, M as MixinUsageNode } from '../../shared/kss-modern.C0c9PPgd.mjs';
|
|
2
2
|
|
|
3
3
|
type MixinSchemaResult = {
|
|
4
4
|
jsonSchema: Record<string, unknown>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as StyleguideConfiguration, M as MixinUsageNode } from '../../shared/kss-modern.
|
|
1
|
+
import { S as StyleguideConfiguration, M as MixinUsageNode } from '../../shared/kss-modern.C0c9PPgd.js';
|
|
2
2
|
|
|
3
3
|
type MixinSchemaResult = {
|
|
4
4
|
jsonSchema: Record<string, unknown>;
|
|
@@ -262,6 +262,12 @@ interface StyleguideOptions {
|
|
|
262
262
|
* `node_modules/.cache/kss-modern`; `false` keeps the cache in memory only.
|
|
263
263
|
*/
|
|
264
264
|
cacheDir?: string | false;
|
|
265
|
+
/**
|
|
266
|
+
* Write the JSON Schema of every mixin declared with `defineComponent` or `mixinSchema` into this
|
|
267
|
+
* directory, one file per mixin in the folders of its explorer name: `name: 'atoms/Button'` ->
|
|
268
|
+
* `<dir>/atoms/Button.json`. Relative to the working directory. Off unless set.
|
|
269
|
+
*/
|
|
270
|
+
mixinJsonSchemaDir?: string;
|
|
265
271
|
/**
|
|
266
272
|
* Let search engines index the generated styleguide.
|
|
267
273
|
*
|
|
@@ -262,6 +262,12 @@ interface StyleguideOptions {
|
|
|
262
262
|
* `node_modules/.cache/kss-modern`; `false` keeps the cache in memory only.
|
|
263
263
|
*/
|
|
264
264
|
cacheDir?: string | false;
|
|
265
|
+
/**
|
|
266
|
+
* Write the JSON Schema of every mixin declared with `defineComponent` or `mixinSchema` into this
|
|
267
|
+
* directory, one file per mixin in the folders of its explorer name: `name: 'atoms/Button'` ->
|
|
268
|
+
* `<dir>/atoms/Button.json`. Relative to the working directory. Off unless set.
|
|
269
|
+
*/
|
|
270
|
+
mixinJsonSchemaDir?: string;
|
|
265
271
|
/**
|
|
266
272
|
* Let search engines index the generated styleguide.
|
|
267
273
|
*
|