@blackbaud/skyux-branding-builder 0.0.2
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/CHANGELOG.md +5 -0
- package/README.md +3 -0
- package/index.d.ts +8 -0
- package/index.js +4 -0
- package/index.js.map +1 -0
- package/package.json +45 -0
- package/src/plugins/build-assets-manifest-plugin.d.mts +2 -0
- package/src/plugins/build-assets-manifest-plugin.mjs +64 -0
- package/src/plugins/build-assets-manifest-plugin.mjs.map +1 -0
- package/src/plugins/build-style-dictionary-plugin.d.mts +3 -0
- package/src/plugins/build-style-dictionary-plugin.mjs +240 -0
- package/src/plugins/build-style-dictionary-plugin.mjs.map +1 -0
- package/src/plugins/prepare-package-plugin.d.mts +2 -0
- package/src/plugins/prepare-package-plugin.mjs +28 -0
- package/src/plugins/prepare-package-plugin.mjs.map +1 -0
- package/src/plugins/shared/assets-config.d.ts +8 -0
- package/src/plugins/shared/assets-config.js +2 -0
- package/src/plugins/shared/assets-config.js.map +1 -0
- package/src/plugins/shared/assets-font-config.d.ts +6 -0
- package/src/plugins/shared/assets-font-config.js +2 -0
- package/src/plugins/shared/assets-font-config.js.map +1 -0
- package/src/plugins/shared/assets-image-config.d.ts +3 -0
- package/src/plugins/shared/assets-image-config.js +2 -0
- package/src/plugins/shared/assets-image-config.js.map +1 -0
- package/src/plugins/shared/assets-images-config.d.ts +4 -0
- package/src/plugins/shared/assets-images-config.js +2 -0
- package/src/plugins/shared/assets-images-config.js.map +1 -0
- package/src/plugins/shared/assets-strings-config.d.ts +3 -0
- package/src/plugins/shared/assets-strings-config.js +2 -0
- package/src/plugins/shared/assets-strings-config.js.map +1 -0
- package/src/plugins/shared/assets-utils.d.mts +3 -0
- package/src/plugins/shared/assets-utils.mjs +63 -0
- package/src/plugins/shared/assets-utils.mjs.map +1 -0
- package/src/types/breakpoint.d.ts +1 -0
- package/src/types/breakpoint.js +2 -0
- package/src/types/breakpoint.js.map +1 -0
- package/src/types/reference-token-set.d.ts +7 -0
- package/src/types/reference-token-set.js +2 -0
- package/src/types/reference-token-set.js.map +1 -0
- package/src/types/responsive.d.ts +4 -0
- package/src/types/responsive.js +2 -0
- package/src/types/responsive.js.map +1 -0
- package/src/types/token-config.d.ts +9 -0
- package/src/types/token-config.js +2 -0
- package/src/types/token-config.js.map +1 -0
- package/src/types/token-set.d.ts +8 -0
- package/src/types/token-set.js +2 -0
- package/src/types/token-set.js.map +1 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { Breakpoint } from './src/types/breakpoint.ts';
|
|
2
|
+
export type { Responsive } from './src/types/responsive.ts';
|
|
3
|
+
export type { ReferenceTokenSet } from './src/types/reference-token-set.ts';
|
|
4
|
+
export type { TokenConfig } from './src/types/token-config.ts';
|
|
5
|
+
export type { TokenSet } from './src/types/token-set.ts';
|
|
6
|
+
export { buildStyleDictionaryPlugin } from './src/plugins/build-style-dictionary-plugin.mjs';
|
|
7
|
+
export { buildAssetsManifestPlugin } from './src/plugins/build-assets-manifest-plugin.mjs';
|
|
8
|
+
export { preparePackagePlugin } from './src/plugins/prepare-package-plugin.mjs';
|
package/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildStyleDictionaryPlugin } from './src/plugins/build-style-dictionary-plugin.mjs';
|
|
2
|
+
export { buildAssetsManifestPlugin } from './src/plugins/build-assets-manifest-plugin.mjs';
|
|
3
|
+
export { preparePackagePlugin } from './src/plugins/prepare-package-plugin.mjs';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAC7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blackbaud/skyux-branding-builder",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "style dictionary builder for design tokens",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"pipelineSettings": {
|
|
8
|
+
"publishToNPM": true
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "vitest run",
|
|
12
|
+
"dev": "vite",
|
|
13
|
+
"build": "npm run clean && tsc --project tsconfig.build.json",
|
|
14
|
+
"build:vite": "vite build",
|
|
15
|
+
"postbuild": "node ./scripts/prepare-package.js",
|
|
16
|
+
"clean": "rm -rf dist",
|
|
17
|
+
"preview": "vite preview"
|
|
18
|
+
},
|
|
19
|
+
"author": "",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@eslint/js": "9.32.0",
|
|
23
|
+
"@tokens-studio/sd-transforms": "1.2.12",
|
|
24
|
+
"@trivago/prettier-plugin-sort-imports": "5.2.2",
|
|
25
|
+
"@types/fs-extra": "^11.0.4",
|
|
26
|
+
"@types/node": "22.15.3",
|
|
27
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
28
|
+
"eslint": "9.32.0",
|
|
29
|
+
"eslint-config-prettier": "10.1.8",
|
|
30
|
+
"fs-extra": "11.3.0",
|
|
31
|
+
"glob": "11.0.1",
|
|
32
|
+
"inquirer": "12.4.3",
|
|
33
|
+
"minimist": "1.2.8",
|
|
34
|
+
"prettier": "3.6.2",
|
|
35
|
+
"style-dictionary": "4.3.3",
|
|
36
|
+
"typescript": "5.8.2",
|
|
37
|
+
"typescript-eslint": "8.38.0",
|
|
38
|
+
"vite": "7.0.6",
|
|
39
|
+
"vitest": "3.2.4"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">= 4.2.1",
|
|
43
|
+
"npm": ">= 3"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { fixAssetsUrl } from './shared/assets-utils.mjs';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
function transformSrc(src, projectName) {
|
|
6
|
+
return src.startsWith('~/assets')
|
|
7
|
+
? fixAssetsUrl('./', src, projectName)
|
|
8
|
+
: src;
|
|
9
|
+
}
|
|
10
|
+
function transformAssetsJson(code, projectName) {
|
|
11
|
+
try {
|
|
12
|
+
const assetsConfig = JSON.parse(code);
|
|
13
|
+
// Resolve asset paths in fonts
|
|
14
|
+
if (assetsConfig.fonts) {
|
|
15
|
+
for (const fontConfig of assetsConfig.fonts) {
|
|
16
|
+
fontConfig.src = transformSrc(fontConfig.src, projectName);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// Resolve asset paths in images
|
|
20
|
+
if (assetsConfig.images) {
|
|
21
|
+
for (const imageConfig of Object.values(assetsConfig.images)) {
|
|
22
|
+
imageConfig.src = transformSrc(imageConfig.src, projectName);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return JSON.stringify(assetsConfig, null, 2);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error('Error transforming assets.json:', error);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function buildAssetsManifestPlugin(projectName) {
|
|
33
|
+
return {
|
|
34
|
+
name: 'build-assets-manifest',
|
|
35
|
+
async generateBundle() {
|
|
36
|
+
const assetsJsonPath = join('public', 'assets', 'assets.json');
|
|
37
|
+
if (!existsSync(assetsJsonPath)) {
|
|
38
|
+
console.warn('assets.json not found in public/assets folder');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const assetsContent = await readFile(assetsJsonPath, 'utf-8');
|
|
43
|
+
if (!assetsContent) {
|
|
44
|
+
console.warn('assets.json is empty');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const transformedContent = transformAssetsJson(assetsContent, projectName);
|
|
48
|
+
if (!transformedContent) {
|
|
49
|
+
console.warn('Failed to transform assets.json');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.emitFile({
|
|
53
|
+
type: 'asset',
|
|
54
|
+
fileName: 'assets/assets.json',
|
|
55
|
+
source: transformedContent,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error('Error processing assets.json:', error);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=build-assets-manifest-plugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-assets-manifest-plugin.mjs","sourceRoot":"","sources":["../../../src/plugins/build-assets-manifest-plugin.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,SAAS,YAAY,CAAC,GAAW,EAAE,WAAmB;IACpD,OAAO,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC;QAC/B,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,CAAC;QACtC,CAAC,CAAC,GAAG,CAAC;AACV,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY,EAAE,WAAmB;IAC5D,IAAI,CAAC;QACH,MAAM,YAAY,GAAiB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEpD,+BAA+B;QAC/B,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;YACvB,KAAK,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C;gBAEF,IAAI,CAAC,kBAAkB,EAAE,CAAC;oBACxB,OAAO,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;oBAChD,OAAO;gBACT,CAAC;gBAED,IAAI,CAAC,QAAQ,CAAC;oBACZ,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,oBAAoB;oBAC9B,MAAM,EAAE,kBAAkB;iBAC3B,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { sync } from 'glob';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import StyleDictionary from 'style-dictionary';
|
|
4
|
+
import { formattedVariables, sortByName } from 'style-dictionary/utils';
|
|
5
|
+
import { getTransforms, register } from '@tokens-studio/sd-transforms';
|
|
6
|
+
import { generateAssetsCss, fixAssetsUrlValue, } from './shared/assets-utils.mjs';
|
|
7
|
+
const DEFAULT_SD_CONFIG = {
|
|
8
|
+
preprocessors: ['tokens-studio'],
|
|
9
|
+
platforms: {
|
|
10
|
+
css: {
|
|
11
|
+
transformGroup: 'custom/tokens-studio',
|
|
12
|
+
options: {
|
|
13
|
+
outputReferences: true,
|
|
14
|
+
showFileHeader: false,
|
|
15
|
+
},
|
|
16
|
+
buildPath: `dist/`,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
function isUrlToken(token) {
|
|
21
|
+
return (token.$extensions?.['com.blackbaud.developer.sky-token-format'] === 'url');
|
|
22
|
+
}
|
|
23
|
+
function getMediaQueryMinWidth(breakpoint) {
|
|
24
|
+
switch (breakpoint) {
|
|
25
|
+
case 'xs':
|
|
26
|
+
default:
|
|
27
|
+
return '0px';
|
|
28
|
+
case 's':
|
|
29
|
+
return '768px';
|
|
30
|
+
case 'm':
|
|
31
|
+
return '992px';
|
|
32
|
+
case 'l':
|
|
33
|
+
return '1200px';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function generateDictionaryFiles(tokenConfig, skyOptions) {
|
|
37
|
+
const sd = new StyleDictionary(undefined);
|
|
38
|
+
let allFiles = [];
|
|
39
|
+
await Promise.all(tokenConfig.tokenSets.map(async (tokenSet) => {
|
|
40
|
+
const tokenDictionary = await sd.extend(getBaseDictionaryConfig(tokenConfig, tokenSet, {
|
|
41
|
+
...skyOptions,
|
|
42
|
+
generateUrlAtProperties: true,
|
|
43
|
+
}));
|
|
44
|
+
const files = await tokenDictionary.formatPlatform('css');
|
|
45
|
+
allFiles = allFiles.concat(files);
|
|
46
|
+
await Promise.all(tokenSet.referenceTokens.map(async (referenceTokenSet) => {
|
|
47
|
+
const referenceTokenDictionary = await sd.extend(getReferenceDictionaryConfig(tokenConfig, tokenSet, referenceTokenSet, skyOptions));
|
|
48
|
+
const files = await referenceTokenDictionary.formatPlatform('css');
|
|
49
|
+
files.forEach((file) => {
|
|
50
|
+
if (referenceTokenSet.responsive) {
|
|
51
|
+
const originalOutput = file.output;
|
|
52
|
+
// NOTE: No return character after original output as we have already added one there when we alphabetize
|
|
53
|
+
file.output =
|
|
54
|
+
referenceTokenSet.responsive.breakpoint === 'xs'
|
|
55
|
+
? originalOutput
|
|
56
|
+
: `@media (min-width: ${getMediaQueryMinWidth(referenceTokenSet.responsive.breakpoint)}) {\n${originalOutput}}\n`;
|
|
57
|
+
file.breakpoint = referenceTokenSet.responsive.breakpoint;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
allFiles = allFiles.concat(files);
|
|
61
|
+
}));
|
|
62
|
+
}));
|
|
63
|
+
// We need to order the files by breakpoint so that the media queries are seen by the browser in the correct order.
|
|
64
|
+
// Media queries do not count towards css specificity, so the order in which they are defined matters.
|
|
65
|
+
const breakpointOrder = [undefined, 'xs', 's', 'm', 'l'];
|
|
66
|
+
allFiles.sort((a, b) => {
|
|
67
|
+
const aIndex = breakpointOrder.indexOf(a.breakpoint);
|
|
68
|
+
const bIndex = breakpointOrder.indexOf(b.breakpoint);
|
|
69
|
+
return aIndex - bIndex;
|
|
70
|
+
});
|
|
71
|
+
return allFiles;
|
|
72
|
+
}
|
|
73
|
+
function getBaseDictionaryConfig(tokenConfig, tokenSet, skyOptions) {
|
|
74
|
+
const config = {
|
|
75
|
+
...DEFAULT_SD_CONFIG,
|
|
76
|
+
};
|
|
77
|
+
const rootPath = tokenConfig.rootPath || 'src/tokens/';
|
|
78
|
+
config.source = [`${rootPath}${tokenSet.path}`];
|
|
79
|
+
const cssOptions = (config.platforms.css.options ??= {});
|
|
80
|
+
Object.assign(cssOptions, {
|
|
81
|
+
skyOptions,
|
|
82
|
+
selector: tokenSet.selector,
|
|
83
|
+
});
|
|
84
|
+
config.platforms.css.files = [
|
|
85
|
+
{
|
|
86
|
+
destination: `${tokenSet.name}/${tokenSet.name}.css`,
|
|
87
|
+
format: 'css/alphabetize-variables',
|
|
88
|
+
filter: (token) => token.filePath.includes(tokenSet.path),
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
return config;
|
|
92
|
+
}
|
|
93
|
+
function getReferenceDictionaryConfig(tokenConfig, tokenSet, referenceTokenSet, skyOptions) {
|
|
94
|
+
const config = {
|
|
95
|
+
...DEFAULT_SD_CONFIG,
|
|
96
|
+
};
|
|
97
|
+
const rootPath = tokenConfig.rootPath || 'src/tokens/';
|
|
98
|
+
config.source = [`${rootPath}${tokenSet.path}`];
|
|
99
|
+
config.include = [`${rootPath}${referenceTokenSet.path}`];
|
|
100
|
+
const cssOptions = (config.platforms.css.options ??= {});
|
|
101
|
+
Object.assign(cssOptions, {
|
|
102
|
+
skyOptions,
|
|
103
|
+
selector: `${tokenSet.selector}${referenceTokenSet.selector || ''}`,
|
|
104
|
+
});
|
|
105
|
+
config.platforms.css.files = [
|
|
106
|
+
{
|
|
107
|
+
destination: `${tokenSet.name}/${referenceTokenSet.name}.css`,
|
|
108
|
+
format: 'css/alphabetize-variables',
|
|
109
|
+
filter: (token) => token.filePath.includes(referenceTokenSet.path),
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
return config;
|
|
113
|
+
}
|
|
114
|
+
async function addAssetsCss(tokenConfig, basePath, fileContents) {
|
|
115
|
+
const assetsCss = await generateAssetsCss(basePath, tokenConfig.projectName);
|
|
116
|
+
if (assetsCss) {
|
|
117
|
+
fileContents = `${assetsCss}\n\n${fileContents}`;
|
|
118
|
+
}
|
|
119
|
+
return fileContents;
|
|
120
|
+
}
|
|
121
|
+
export function buildStyleDictionaryPlugin(tokenConfig) {
|
|
122
|
+
register(StyleDictionary);
|
|
123
|
+
StyleDictionary.registerTransform({
|
|
124
|
+
name: 'name/prefixed-kebab',
|
|
125
|
+
transitive: true,
|
|
126
|
+
type: 'name',
|
|
127
|
+
transform: (token) => {
|
|
128
|
+
return `${token.isSource ? '' : 'sky-'}${token.path.join('-')}`;
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
StyleDictionary.registerTransform({
|
|
132
|
+
name: 'size/zero-rem',
|
|
133
|
+
type: 'value',
|
|
134
|
+
filter: (token) => (token.$type === 'dimension' || token.$type === 'fontSize') &&
|
|
135
|
+
token.$value === '0',
|
|
136
|
+
transform: () => '0rem',
|
|
137
|
+
});
|
|
138
|
+
StyleDictionary.registerTransform({
|
|
139
|
+
name: 'assets-path',
|
|
140
|
+
type: 'value',
|
|
141
|
+
filter: isUrlToken,
|
|
142
|
+
transform: (token, _, options) => fixAssetsUrlValue(options.platforms?.css?.options?.skyOptions?.assetsBasePath, token.$value, tokenConfig.projectName),
|
|
143
|
+
});
|
|
144
|
+
// Register custom tokens-studio transform group without the resolveMath transform to allow browsers to do the `calc`.
|
|
145
|
+
// Include the standard css transforms and the custom name transform.
|
|
146
|
+
StyleDictionary.registerTransformGroup({
|
|
147
|
+
name: 'custom/tokens-studio',
|
|
148
|
+
transforms: [
|
|
149
|
+
...getTransforms({
|
|
150
|
+
platform: 'css',
|
|
151
|
+
}).filter((transform) => transform !== 'ts/resolveMath'),
|
|
152
|
+
...StyleDictionary.hooks.transformGroups['css'],
|
|
153
|
+
'name/prefixed-kebab',
|
|
154
|
+
'size/zero-rem',
|
|
155
|
+
'assets-path',
|
|
156
|
+
],
|
|
157
|
+
});
|
|
158
|
+
StyleDictionary.registerFormat({
|
|
159
|
+
name: 'css/alphabetize-variables',
|
|
160
|
+
format: function ({ dictionary, options }) {
|
|
161
|
+
const { outputReferences, outputReferenceFallbacks, skyOptions } = options;
|
|
162
|
+
let properties = '';
|
|
163
|
+
if (skyOptions.generateUrlAtProperties) {
|
|
164
|
+
properties = dictionary.allTokens
|
|
165
|
+
.filter(isUrlToken)
|
|
166
|
+
.sort(sortByName)
|
|
167
|
+
.map((token) => `@property --${token.name} {
|
|
168
|
+
syntax: '<url>';
|
|
169
|
+
inherits: true;
|
|
170
|
+
initial-value: url('data:,');
|
|
171
|
+
}`)
|
|
172
|
+
.join('\n\n');
|
|
173
|
+
}
|
|
174
|
+
dictionary.allTokens = dictionary.allTokens.sort(sortByName);
|
|
175
|
+
const variables = formattedVariables({
|
|
176
|
+
format: 'css',
|
|
177
|
+
dictionary,
|
|
178
|
+
outputReferences,
|
|
179
|
+
outputReferenceFallbacks,
|
|
180
|
+
usesDtcg: true,
|
|
181
|
+
});
|
|
182
|
+
return `${properties ? properties + '\n\n' : ''}${skyOptions?.selectorPrefix ?? ''}${options.selector} {
|
|
183
|
+
${variables}
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
name: 'transform-style-dictionary',
|
|
190
|
+
async transform(_code, id) {
|
|
191
|
+
const rootPath = tokenConfig.rootPath || 'src/tokens/';
|
|
192
|
+
const files = sync(`${rootPath}**/*.json`);
|
|
193
|
+
for (const file of files) {
|
|
194
|
+
this.addWatchFile(path.join(process.cwd(), file));
|
|
195
|
+
}
|
|
196
|
+
if (id.includes('src/dev/tokens.css')) {
|
|
197
|
+
const assetsBasePath = '/assets/';
|
|
198
|
+
const allFiles = await generateDictionaryFiles(tokenConfig, {
|
|
199
|
+
assetsBasePath,
|
|
200
|
+
selectorPrefix: '.local-dev-tokens',
|
|
201
|
+
});
|
|
202
|
+
let localTokens = allFiles.reduce((acc, file) => acc + file.output, '');
|
|
203
|
+
localTokens = await addAssetsCss(tokenConfig, assetsBasePath, localTokens);
|
|
204
|
+
return localTokens;
|
|
205
|
+
}
|
|
206
|
+
return undefined;
|
|
207
|
+
},
|
|
208
|
+
async generateBundle() {
|
|
209
|
+
const assetsBasePath = '../';
|
|
210
|
+
const allFiles = await generateDictionaryFiles(tokenConfig, {
|
|
211
|
+
assetsBasePath,
|
|
212
|
+
selectorPrefix: '',
|
|
213
|
+
});
|
|
214
|
+
const compositeFiles = {};
|
|
215
|
+
for (const file of allFiles) {
|
|
216
|
+
if (file.destination) {
|
|
217
|
+
const fileParts = file.destination.split('/');
|
|
218
|
+
const tokenSetType = fileParts[1];
|
|
219
|
+
const fileName = `bundles/${tokenSetType}.css`;
|
|
220
|
+
// For backwards compatibility with older versions of SKY UX; remove this in a future
|
|
221
|
+
// breaking change.
|
|
222
|
+
const compatFileName = `assets/scss/${tokenSetType}.css`;
|
|
223
|
+
let fileContents = compositeFiles[fileName] || '';
|
|
224
|
+
fileContents = fileContents.concat(file.output ?? '');
|
|
225
|
+
compositeFiles[fileName] = fileContents;
|
|
226
|
+
compositeFiles[compatFileName] = fileContents;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
for (const fileName of Object.keys(compositeFiles)) {
|
|
230
|
+
const fileContents = await addAssetsCss(tokenConfig, assetsBasePath, compositeFiles[fileName]);
|
|
231
|
+
this.emitFile({
|
|
232
|
+
type: 'asset',
|
|
233
|
+
fileName: fileName.replace('dist/', ''),
|
|
234
|
+
source: fileContents,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=build-style-dictionary-plugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-style-dictionary-plugin.mjs","sourceRoot":"","sources":["../../../src/plugins/build-style-dictionary-plugin.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,eAIN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAKvE,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AAoBnC,MAAM,iBAAiB,GAA6B;IAClD,aAAa,EAAE,CAAC,eAAe,CAAC;IAChC,SAAS,EAAE;QACT,GAAG,EAAE;YACH,cAAc,EAAE,sBAAsB;YACtC,OAAO,EAAE;gBACP,gBAAgB,EAAE,IAAI;gBACtB,cAAc,EAAE,KAAK;aACtB;YACD,SAAS,EAAE,OAAO;SACnB;KACF;CACF,CAAC;AAEF,SAAS,UAAU,CAAC,KAAY;IAC9B,OAAO,CACL,KAAK,CAAC,WAAW,EAAE,CAAC,0CAA0C,CAAC,KAAK,KAAK,CAC1E,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,UAAsB;IACnD,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,IAAI,CAAC;QACV;YACE,OAAO,KAAK,CAAC;QACf,KAAK,GAAG;YACN,OAAO,OAAO,CAAC;QACjB,KAAK,GAAG;YACN,OAAO,OAAO,CAAC;QACjB,KAAK,GAAG;YACN,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,uBAAuB,CACpC,WAAwB,EACxB,UAA2B;IAE3B,MAAM,EAAE,GAAG,IAAI,eAAe,CAAC,S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C5B,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;oBACrB,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC9C,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;oBAClC,MAAM,QAAQ,GAAG,WAAW,YAAY,MAAM,CAAC;oBAC/C,qFAAqF;oBACrF,mBAAmB;oBACnB,MAAM,cAAc,GAAG,eAAe,YAAY,MAAM,CAAC;oBAEzD,IAAI,YAAY,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;oBAClD,YAAY,GAAG,YAAY,CAAC,MAAM,CAAE,IAAI,CAAC,MAAiB,IAAI,EAAE,CAAC,CAAC;oBAElE,cAAc,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC;oBACxC,cAAc,CAAC,cAAc,CAAC,GAAG,YAAY,CAAC;gBAChD,CAAC;YACH,CAAC;YAED,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;gBACnD,MAAM,YAAY,GAAG,MAAM,YAAY,CACrC,WAAW,EACX,cAAc,EACd,cAAc,CAAC,QAAQ,CAAC,CACzB,CAAC;gBAEF,IAAI,CAAC,QAAQ,CAAC;oBACZ,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;oBACvC,MAAM,EAAE,YAAY;iBACrB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export function preparePackagePlugin(rootPath) {
|
|
4
|
+
return {
|
|
5
|
+
name: 'transform-package',
|
|
6
|
+
async generateBundle() {
|
|
7
|
+
const packageJson = fs.readFileSync(path.join(rootPath, 'package.json'));
|
|
8
|
+
const readMe = fs.readFileSync(path.join(rootPath, 'README.md'));
|
|
9
|
+
const changelog = fs.readFileSync(path.join(rootPath, 'CHANGELOG.md'));
|
|
10
|
+
this.emitFile({
|
|
11
|
+
type: 'asset',
|
|
12
|
+
fileName: 'package.json',
|
|
13
|
+
source: packageJson,
|
|
14
|
+
});
|
|
15
|
+
this.emitFile({
|
|
16
|
+
type: 'asset',
|
|
17
|
+
fileName: 'README.md',
|
|
18
|
+
source: readMe,
|
|
19
|
+
});
|
|
20
|
+
this.emitFile({
|
|
21
|
+
type: 'asset',
|
|
22
|
+
fileName: 'CHANGELOG.md',
|
|
23
|
+
source: changelog,
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=prepare-package-plugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-package-plugin.mjs","sourceRoot":"","sources":["../../../src/plugins/prepare-package-plugin.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,OAAO;QACL,IAAI,EAAE,mBAAmB;QACzB,KAAK,CAAC,cAAc;YAClB,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;YACzE,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;YACjE,MAAM,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;YAEvE,IAAI,CAAC,QAAQ,CAAC;gBACZ,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,cAAc;gBACxB,MAAM,EAAE,WAAW;aACpB,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC;gBACZ,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,WAAW;gBACrB,MAAM,EAAE,MAAM;aACf,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC;gBACZ,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,cAAc;gBACxB,MAAM,EAAE,SAAS;aAClB,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AssetsFontConfig } from './assets-font-config.js';
|
|
2
|
+
import { AssetsImagesConfig } from './assets-images-config.js';
|
|
3
|
+
import { AssetsStringsConfig } from './assets-strings-config.js';
|
|
4
|
+
export interface AssetsConfig {
|
|
5
|
+
fonts?: AssetsFontConfig[];
|
|
6
|
+
images?: AssetsImagesConfig;
|
|
7
|
+
strings?: AssetsStringsConfig;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-config.js","sourceRoot":"","sources":["../../../../src/plugins/shared/assets-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-font-config.js","sourceRoot":"","sources":["../../../../src/plugins/shared/assets-font-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-image-config.js","sourceRoot":"","sources":["../../../../src/plugins/shared/assets-image-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-images-config.js","sourceRoot":"","sources":["../../../../src/plugins/shared/assets-images-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-strings-config.js","sourceRoot":"","sources":["../../../../src/plugins/shared/assets-strings-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function fixAssetsUrl(basePath: string | undefined, value: string, projectName: string): string;
|
|
2
|
+
export declare function fixAssetsUrlValue(basePath: string | undefined, value: string, projectName: string): string;
|
|
3
|
+
export declare function generateAssetsCss(basePath: string, projectName: string): Promise<string>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
export function fixAssetsUrl(basePath, value, projectName) {
|
|
5
|
+
const effectiveBasePath = getBasePath(basePath, projectName);
|
|
6
|
+
if (effectiveBasePath !== undefined) {
|
|
7
|
+
if (effectiveBasePath === basePath) {
|
|
8
|
+
// Local path - replace ~/assets/ with the base path
|
|
9
|
+
value = value.replace(/~\/assets\//g, effectiveBasePath);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
// CDN path - replace ~/ with the CDN base path
|
|
13
|
+
value = value.replace(/~\//g, effectiveBasePath);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
export function fixAssetsUrlValue(basePath, value, projectName) {
|
|
19
|
+
const rawUrl = fixAssetsUrl(basePath, value, projectName);
|
|
20
|
+
return `url('${rawUrl}')`;
|
|
21
|
+
}
|
|
22
|
+
export async function generateAssetsCss(basePath, projectName) {
|
|
23
|
+
const assetsJsonPath = join('public', 'assets', 'assets.json');
|
|
24
|
+
try {
|
|
25
|
+
// Check if assets.json exists
|
|
26
|
+
if (!existsSync(assetsJsonPath)) {
|
|
27
|
+
console.warn('assets.json not found in public/assets folder');
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
// Read and parse assets.json
|
|
31
|
+
const assetsContent = await readFile(assetsJsonPath, 'utf-8');
|
|
32
|
+
const assetsConfig = JSON.parse(assetsContent);
|
|
33
|
+
if (!assetsConfig.fonts || assetsConfig.fonts.length === 0) {
|
|
34
|
+
console.warn('No fonts found in assets.json');
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
// Generate CSS font declarations
|
|
38
|
+
const fontFaceDeclarations = assetsConfig.fonts
|
|
39
|
+
.map((font) => {
|
|
40
|
+
return `@font-face {
|
|
41
|
+
font-family: '${font.family}';
|
|
42
|
+
src: ${fixAssetsUrlValue(basePath, font.src, projectName)};
|
|
43
|
+
font-weight: ${font.weight};
|
|
44
|
+
font-style: ${font.style};
|
|
45
|
+
font-display: swap;
|
|
46
|
+
}`;
|
|
47
|
+
})
|
|
48
|
+
.join('\n\n');
|
|
49
|
+
return fontFaceDeclarations;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error('Error generating font CSS:', error);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function getBasePath(basePath, projectName) {
|
|
57
|
+
const packageVersion = process.env.PACKAGEJSON_VERSION;
|
|
58
|
+
if (packageVersion) {
|
|
59
|
+
return `https://sky.blackbaudcdn.net/static/${projectName}/${packageVersion}/`;
|
|
60
|
+
}
|
|
61
|
+
return basePath;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=assets-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-utils.mjs","sourceRoot":"","sources":["../../../../src/plugins/shared/assets-utils.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,MAAM,UAAU,YAAY,CAC1B,QAA4B,EAC5B,KAAa,EACb,WAAmB;IAEnB,MAAM,iBAAiB,GAAG,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAE7D,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACpC,IAAI,iBAAiB,KAAK,QAAQ,EAAE,CAAC;YACnC,oDAAoD;YACpD,KAAK,GAAG,KAAK,CA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CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC;iBAC1C,IAAI,CAAC,MAAM;gBACZ,IAAI,CAAC,KAAK;;EAExB,CAAC;QACG,CAAC,CAAC;aACD,IAAI,CAAC,MAAM,CAAC,CAAC;QAEhB,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACnD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAClB,QAA4B,EAC5B,WAAmB;IAEnB,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAEvD,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,uCAAuC,WAAW,IAAI,cAAc,GAAG,CAAC;IACjF,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Breakpoint = 'xs' | 's' | 'm' | 'l';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breakpoint.js","sourceRoot":"","sources":["../../../src/types/breakpoint.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference-token-set.js","sourceRoot":"","sources":["../../../src/types/reference-token-set.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsive.js","sourceRoot":"","sources":["../../../src/types/responsive.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-config.js","sourceRoot":"","sources":["../../../src/types/token-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-set.js","sourceRoot":"","sources":["../../../src/types/token-set.ts"],"names":[],"mappings":""}
|