@datatechsolutions/tympan-tokens 0.4.1 → 0.5.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/THIRD_PARTY_NOTICES.md +5 -5
- package/dist/contrast-report.md +95 -95
- package/dist/dtcg/astrlabe.dark-high.tokens.json +99 -43
- package/dist/dtcg/astrlabe.dark.tokens.json +137 -81
- package/dist/dtcg/astrlabe.light-high.tokens.json +146 -33
- package/dist/dtcg/astrlabe.light.tokens.json +211 -98
- package/dist/fonts.css +80 -80
- package/dist/index.d.ts +257 -58
- package/dist/index.js +568 -36
- package/dist/index.js.map +1 -1
- package/dist/print-themes/print-aquarela.css +7 -7
- package/dist/print-themes/print-art-nouveau.css +2 -2
- package/dist/print-themes/print-atlas-oficial.css +7 -7
- package/dist/print-themes/print-azulejo-modernista.css +2 -2
- package/dist/print-themes/print-bauhaus.css +2 -2
- package/dist/print-themes/print-blocos-coloridos.css +5 -5
- package/dist/print-themes/print-brutalista.css +8 -8
- package/dist/print-themes/print-caderno.css +14 -14
- package/dist/print-themes/print-cartao-postal.css +5 -5
- package/dist/print-themes/print-cientifico.css +3 -3
- package/dist/print-themes/print-concretismo.css +8 -8
- package/dist/print-themes/print-construtivismo.css +6 -6
- package/dist/print-themes/print-cordel.css +6 -6
- package/dist/print-themes/print-dados-br.css +12 -12
- package/dist/print-themes/print-dashboard.css +18 -18
- package/dist/print-themes/print-diagrama-modernista.css +3 -3
- package/dist/print-themes/print-divulgacao.css +3 -3
- package/dist/print-themes/print-fluxo-historico.css +3 -3
- package/dist/print-themes/print-grade-holandesa.css +2 -2
- package/dist/print-themes/print-graficos-1900.css +6 -6
- package/dist/print-themes/print-infografico-ilustrado.css +6 -6
- package/dist/print-themes/print-isotype.css +2 -2
- package/dist/print-themes/print-jornal-1959.css +5 -5
- package/dist/print-themes/print-jornal.css +6 -6
- package/dist/print-themes/print-mapa-de-metro.css +1 -1
- package/dist/print-themes/print-memphis.css +5 -5
- package/dist/print-themes/print-minimo-de-tinta.css +4 -4
- package/dist/print-themes/print-papel-recortado.css +2 -2
- package/dist/print-themes/print-papel-salmao.css +6 -6
- package/dist/print-themes/print-pictogramas.css +2 -2
- package/dist/print-themes/print-pop-art.css +2 -2
- package/dist/print-themes/print-prancheta-clara.css +5 -5
- package/dist/print-themes/print-prancheta.css +5 -5
- package/dist/print-themes/print-proporcao-modular.css +2 -2
- package/dist/print-themes/print-riso.css +4 -4
- package/dist/print-themes/print-semanario.css +13 -13
- package/dist/print-themes/print-sinalizacao.css +8 -8
- package/dist/print-themes/print-suico.css +4 -4
- package/dist/print-themes/print-tropicalia.css +3 -3
- package/dist/print-themes.css +133 -133
- package/dist/tokens.css +247 -124
- package/dist/tokens.json +124 -66
- package/dist/values.js +124 -66
- package/fonts/ibmplexsans/ibmplexsans-italic-cyrillic-400_500_600.woff2 +0 -0
- package/fonts/ibmplexsans/ibmplexsans-italic-cyrillic-ext-400_500_600.woff2 +0 -0
- package/fonts/ibmplexsans/ibmplexsans-italic-greek-400_500_600.woff2 +0 -0
- package/fonts/ibmplexsans/ibmplexsans-italic-latin-400_500_600.woff2 +0 -0
- package/fonts/ibmplexsans/ibmplexsans-italic-latin-ext-400_500_600.woff2 +0 -0
- package/fonts/ibmplexsans/ibmplexsans-italic-vietnamese-400_500_600.woff2 +0 -0
- package/fonts/manifest.json +998 -820
- package/fonts/nunitosans/nunitosans-normal-cyrillic-400_600_700_800.woff2 +0 -0
- package/fonts/nunitosans/nunitosans-normal-cyrillic-ext-400_600_700_800.woff2 +0 -0
- package/fonts/nunitosans/nunitosans-normal-latin-400_600_700_800.woff2 +0 -0
- package/fonts/nunitosans/nunitosans-normal-latin-ext-400_600_700_800.woff2 +0 -0
- package/fonts/nunitosans/nunitosans-normal-vietnamese-400_600_700_800.woff2 +0 -0
- package/fonts/sourceserif4/sourceserif4-italic-cyrillic-400_600.woff2 +0 -0
- package/fonts/sourceserif4/sourceserif4-italic-cyrillic-ext-400_600.woff2 +0 -0
- package/fonts/sourceserif4/sourceserif4-italic-greek-400_600.woff2 +0 -0
- package/fonts/sourceserif4/sourceserif4-italic-latin-400_600.woff2 +0 -0
- package/fonts/sourceserif4/sourceserif4-italic-latin-ext-400_600.woff2 +0 -0
- package/fonts/sourceserif4/sourceserif4-italic-vietnamese-400_600.woff2 +0 -0
- package/package.json +1 -1
- package/src/fonts.ts +2 -2
- package/src/index.ts +1 -0
- package/src/presets.ts +115 -16
- package/src/print-book-themes.ts +239 -0
- package/src/print-presets.ts +220 -10
- package/src/stylesheet.ts +5 -0
- package/src/theme.ts +35 -5
- /package/fonts/ibmplexsans/{ibmplexsans-italic-cyrillic.woff2 → ibmplexsans-italic-cyrillic-400.woff2} +0 -0
- /package/fonts/ibmplexsans/{ibmplexsans-italic-cyrillic-ext.woff2 → ibmplexsans-italic-cyrillic-ext-400.woff2} +0 -0
- /package/fonts/ibmplexsans/{ibmplexsans-italic-greek.woff2 → ibmplexsans-italic-greek-400.woff2} +0 -0
- /package/fonts/ibmplexsans/{ibmplexsans-italic-latin.woff2 → ibmplexsans-italic-latin-400.woff2} +0 -0
- /package/fonts/ibmplexsans/{ibmplexsans-italic-latin-ext.woff2 → ibmplexsans-italic-latin-ext-400.woff2} +0 -0
- /package/fonts/ibmplexsans/{ibmplexsans-italic-vietnamese.woff2 → ibmplexsans-italic-vietnamese-400.woff2} +0 -0
- /package/fonts/sourceserif4/{sourceserif4-italic-cyrillic.woff2 → sourceserif4-italic-cyrillic-400.woff2} +0 -0
- /package/fonts/sourceserif4/{sourceserif4-italic-cyrillic-ext.woff2 → sourceserif4-italic-cyrillic-ext-400.woff2} +0 -0
- /package/fonts/sourceserif4/{sourceserif4-italic-greek.woff2 → sourceserif4-italic-greek-400.woff2} +0 -0
- /package/fonts/sourceserif4/{sourceserif4-italic-latin.woff2 → sourceserif4-italic-latin-400.woff2} +0 -0
- /package/fonts/sourceserif4/{sourceserif4-italic-latin-ext.woff2 → sourceserif4-italic-latin-ext-400.woff2} +0 -0
- /package/fonts/sourceserif4/{sourceserif4-italic-vietnamese.woff2 → sourceserif4-italic-vietnamese-400.woff2} +0 -0
package/dist/index.js
CHANGED
|
@@ -929,19 +929,24 @@ function resolveTheme(config, mode, contrastOverride) {
|
|
|
929
929
|
}],
|
|
930
930
|
"sheet-inset": [inset]
|
|
931
931
|
};
|
|
932
|
+
const shadowPins = config.shadowPins?.[mode] ?? {};
|
|
933
|
+
for (const [name, layers] of Object.entries(shadowPins)) shadows[name] = layers.map((l) => ({
|
|
934
|
+
...l,
|
|
935
|
+
color: parseColor(l.color)
|
|
936
|
+
}));
|
|
932
937
|
const R = config.radius;
|
|
933
938
|
const dimensions = {
|
|
934
939
|
radius: R,
|
|
935
940
|
"radius-control": R,
|
|
936
|
-
"radius-card": Math.round(R * 1.6),
|
|
937
|
-
"radius-sheet": Math.round(R * 2.4),
|
|
941
|
+
"radius-card": config.radii?.card ?? Math.round(R * 1.6),
|
|
942
|
+
"radius-sheet": config.radii?.sheet ?? Math.round(R * 2.4),
|
|
938
943
|
"radius-pill": 999,
|
|
939
944
|
"radius-agent": Math.max(2, Math.round(R * .6)),
|
|
940
945
|
"focus-width": contrast === "high" ? 3 : 2,
|
|
941
946
|
"glass-blur-sheet": config.glass ? 20 : 0,
|
|
942
947
|
"glass-blur-floating": config.glass ? 24 : 0
|
|
943
948
|
};
|
|
944
|
-
const numbers = { "glass-saturate": config.glass ? 1.15 : 1 };
|
|
949
|
+
const numbers = { "glass-saturate": config.glass ? config.glassSaturate?.[mode] ?? 1.15 : 1 };
|
|
945
950
|
const fonts = {};
|
|
946
951
|
for (const role of [
|
|
947
952
|
"display",
|
|
@@ -965,7 +970,10 @@ function resolveTheme(config, mode, contrastOverride) {
|
|
|
965
970
|
dimensions,
|
|
966
971
|
numbers,
|
|
967
972
|
fonts,
|
|
968
|
-
strings:
|
|
973
|
+
strings: {
|
|
974
|
+
...config.strings,
|
|
975
|
+
...contrast === config.contrast ? config.modeStrings?.[mode] : void 0
|
|
976
|
+
},
|
|
969
977
|
report
|
|
970
978
|
};
|
|
971
979
|
}
|
|
@@ -1169,8 +1177,10 @@ const fakhirPreset = {
|
|
|
1169
1177
|
/**
|
|
1170
1178
|
* The Astrlabe workflow engine's look (`data-ty-theme="astrlabe"`): slate
|
|
1171
1179
|
* neutrals, an indigo brand (indigo 500 as the accent family, one step darker
|
|
1172
|
-
* where text needs 4.5:1 on light grounds),
|
|
1173
|
-
*
|
|
1180
|
+
* where text needs 4.5:1 on light grounds), liquid-glass surfaces (gradient
|
|
1181
|
+
* fills, specular edges, a strong saturation boost at night), the rounder
|
|
1182
|
+
* corners of that app (12 px controls, 20 px cards, 24 px sheets), its
|
|
1183
|
+
* compact type scale and the sky, indigo and violet mark. The call to
|
|
1174
1184
|
* action is the indigo to purple gradient its primary buttons fill with, and
|
|
1175
1185
|
* text (headings included) uses the platform's own system fonts. The state
|
|
1176
1186
|
* contract holds on every ground: running is a cyan clearly off the indigo
|
|
@@ -1225,20 +1235,23 @@ const astrlabePreset = {
|
|
|
1225
1235
|
"on-brand": "#ffffff",
|
|
1226
1236
|
bg: "#f8fafc",
|
|
1227
1237
|
surface: "rgb(255 255 255 / 0.72)",
|
|
1228
|
-
"surface-raised": "rgb(255 255 255 / 0.
|
|
1238
|
+
"surface-raised": "rgb(255 255 255 / 0.86)",
|
|
1229
1239
|
"surface-solid": "#ffffff",
|
|
1230
1240
|
"surface-raised-solid": "#ffffff",
|
|
1231
|
-
"surface-sunken": "#
|
|
1232
|
-
line: "rgb(148 163 184 / 0.
|
|
1241
|
+
"surface-sunken": "#f2f3fa",
|
|
1242
|
+
line: "rgb(148 163 184 / 0.26)",
|
|
1233
1243
|
"line-strong": "rgb(100 116 139 / 0.45)",
|
|
1234
1244
|
ink: "#0f172a",
|
|
1235
|
-
"ink-2": "#
|
|
1236
|
-
"ink-3": "#
|
|
1245
|
+
"ink-2": "#475569",
|
|
1246
|
+
"ink-3": "#5b6779",
|
|
1237
1247
|
success: "#15803d",
|
|
1238
1248
|
info: "#0e7490",
|
|
1239
1249
|
warning: "#a16207",
|
|
1240
1250
|
danger: "#be123c",
|
|
1241
|
-
neutral: "#
|
|
1251
|
+
neutral: "#5b6779",
|
|
1252
|
+
backdrop: "rgb(15 23 42 / 0.4)",
|
|
1253
|
+
"ambient-1": "rgb(167 139 250 / 0.05)",
|
|
1254
|
+
"ambient-2": "rgb(56 189 248 / 0.03)"
|
|
1242
1255
|
},
|
|
1243
1256
|
dark: {
|
|
1244
1257
|
brand: "#818cf8",
|
|
@@ -1246,22 +1259,25 @@ const astrlabePreset = {
|
|
|
1246
1259
|
"brand-strong": "#a5b4fc",
|
|
1247
1260
|
"brand-soft": "rgb(99 102 241 / 0.2)",
|
|
1248
1261
|
"on-brand": "#1e1b4b",
|
|
1249
|
-
bg: "#
|
|
1250
|
-
surface: "rgb(30 41 59 / 0.
|
|
1251
|
-
"surface-raised": "rgb(30 41 59 / 0.
|
|
1262
|
+
bg: "#020617",
|
|
1263
|
+
surface: "rgb(30 41 59 / 0.7)",
|
|
1264
|
+
"surface-raised": "rgb(30 41 59 / 0.78)",
|
|
1252
1265
|
"surface-solid": "#131c2f",
|
|
1253
1266
|
"surface-raised-solid": "#1b2539",
|
|
1254
1267
|
"surface-sunken": "#0b1222",
|
|
1255
|
-
line: "rgb(148 163 184 / 0.
|
|
1268
|
+
line: "rgb(148 163 184 / 0.24)",
|
|
1256
1269
|
"line-strong": "rgb(148 163 184 / 0.36)",
|
|
1257
|
-
ink: "#
|
|
1270
|
+
ink: "#ffffff",
|
|
1258
1271
|
"ink-2": "#cbd5e1",
|
|
1259
|
-
"ink-3": "#
|
|
1272
|
+
"ink-3": "#94a3b8",
|
|
1260
1273
|
success: "#4ade80",
|
|
1261
1274
|
info: "#22d3ee",
|
|
1262
1275
|
warning: "#fbbf24",
|
|
1263
1276
|
danger: "#fb7185",
|
|
1264
|
-
neutral: "#
|
|
1277
|
+
neutral: "#94a3b8",
|
|
1278
|
+
backdrop: "rgb(0 0 0 / 0.5)",
|
|
1279
|
+
"ambient-1": "rgb(124 58 237 / 0.1)",
|
|
1280
|
+
"ambient-2": "rgb(2 132 199 / 0.08)"
|
|
1265
1281
|
}
|
|
1266
1282
|
},
|
|
1267
1283
|
ctaPins: {
|
|
@@ -1276,6 +1292,174 @@ const astrlabePreset = {
|
|
|
1276
1292
|
"#9333ea"
|
|
1277
1293
|
]
|
|
1278
1294
|
},
|
|
1295
|
+
radii: {
|
|
1296
|
+
card: 20,
|
|
1297
|
+
sheet: 24
|
|
1298
|
+
},
|
|
1299
|
+
glassSaturate: {
|
|
1300
|
+
light: 1.15,
|
|
1301
|
+
dark: 1.5
|
|
1302
|
+
},
|
|
1303
|
+
shadowPins: {
|
|
1304
|
+
light: {
|
|
1305
|
+
sheet: [{
|
|
1306
|
+
x: 0,
|
|
1307
|
+
y: 4,
|
|
1308
|
+
blur: 16,
|
|
1309
|
+
spread: -2,
|
|
1310
|
+
color: "rgb(0 0 0 / 0.1)"
|
|
1311
|
+
}, {
|
|
1312
|
+
x: 0,
|
|
1313
|
+
y: 12,
|
|
1314
|
+
blur: 40,
|
|
1315
|
+
spread: -8,
|
|
1316
|
+
color: "rgb(0 0 0 / 0.06)"
|
|
1317
|
+
}],
|
|
1318
|
+
"sheet-inset": [{
|
|
1319
|
+
x: 0,
|
|
1320
|
+
y: 1,
|
|
1321
|
+
blur: 2,
|
|
1322
|
+
spread: 0,
|
|
1323
|
+
color: "rgb(255 255 255 / 0.7)",
|
|
1324
|
+
inset: true
|
|
1325
|
+
}, {
|
|
1326
|
+
x: 0,
|
|
1327
|
+
y: -1,
|
|
1328
|
+
blur: 2,
|
|
1329
|
+
spread: 0,
|
|
1330
|
+
color: "rgb(0 0 0 / 0.04)",
|
|
1331
|
+
inset: true
|
|
1332
|
+
}],
|
|
1333
|
+
raised: [{
|
|
1334
|
+
x: 0,
|
|
1335
|
+
y: 4,
|
|
1336
|
+
blur: 12,
|
|
1337
|
+
spread: -2,
|
|
1338
|
+
color: "rgb(15 23 42 / 0.08)"
|
|
1339
|
+
}, {
|
|
1340
|
+
x: 0,
|
|
1341
|
+
y: 2,
|
|
1342
|
+
blur: 4,
|
|
1343
|
+
spread: -2,
|
|
1344
|
+
color: "rgb(15 23 42 / 0.04)"
|
|
1345
|
+
}],
|
|
1346
|
+
floating: [{
|
|
1347
|
+
x: 0,
|
|
1348
|
+
y: 12,
|
|
1349
|
+
blur: 24,
|
|
1350
|
+
spread: -8,
|
|
1351
|
+
color: "rgb(15 23 42 / 0.12)"
|
|
1352
|
+
}, {
|
|
1353
|
+
x: 0,
|
|
1354
|
+
y: 4,
|
|
1355
|
+
blur: 8,
|
|
1356
|
+
spread: -4,
|
|
1357
|
+
color: "rgb(15 23 42 / 0.06)"
|
|
1358
|
+
}],
|
|
1359
|
+
modal: [{
|
|
1360
|
+
x: 0,
|
|
1361
|
+
y: 40,
|
|
1362
|
+
blur: 100,
|
|
1363
|
+
spread: -30,
|
|
1364
|
+
color: "rgb(0 0 0 / 0.45)"
|
|
1365
|
+
}, {
|
|
1366
|
+
x: 0,
|
|
1367
|
+
y: 16,
|
|
1368
|
+
blur: 40,
|
|
1369
|
+
spread: -12,
|
|
1370
|
+
color: "rgb(0 0 0 / 0.18)"
|
|
1371
|
+
}]
|
|
1372
|
+
},
|
|
1373
|
+
dark: {
|
|
1374
|
+
sheet: [{
|
|
1375
|
+
x: 0,
|
|
1376
|
+
y: 12,
|
|
1377
|
+
blur: 40,
|
|
1378
|
+
spread: -12,
|
|
1379
|
+
color: "rgb(0 0 0 / 0.5)"
|
|
1380
|
+
}],
|
|
1381
|
+
"sheet-inset": [{
|
|
1382
|
+
x: 0,
|
|
1383
|
+
y: 1,
|
|
1384
|
+
blur: 1,
|
|
1385
|
+
spread: 0,
|
|
1386
|
+
color: "rgb(255 255 255 / 0.12)",
|
|
1387
|
+
inset: true
|
|
1388
|
+
}],
|
|
1389
|
+
raised: [{
|
|
1390
|
+
x: 0,
|
|
1391
|
+
y: 4,
|
|
1392
|
+
blur: 12,
|
|
1393
|
+
spread: -2,
|
|
1394
|
+
color: "rgb(0 0 0 / 0.5)"
|
|
1395
|
+
}, {
|
|
1396
|
+
x: 0,
|
|
1397
|
+
y: 2,
|
|
1398
|
+
blur: 4,
|
|
1399
|
+
spread: -2,
|
|
1400
|
+
color: "rgb(0 0 0 / 0.3)"
|
|
1401
|
+
}],
|
|
1402
|
+
floating: [{
|
|
1403
|
+
x: 0,
|
|
1404
|
+
y: 12,
|
|
1405
|
+
blur: 24,
|
|
1406
|
+
spread: -8,
|
|
1407
|
+
color: "rgb(0 0 0 / 0.6)"
|
|
1408
|
+
}, {
|
|
1409
|
+
x: 0,
|
|
1410
|
+
y: 4,
|
|
1411
|
+
blur: 8,
|
|
1412
|
+
spread: -4,
|
|
1413
|
+
color: "rgb(0 0 0 / 0.4)"
|
|
1414
|
+
}],
|
|
1415
|
+
modal: [{
|
|
1416
|
+
x: 0,
|
|
1417
|
+
y: 40,
|
|
1418
|
+
blur: 100,
|
|
1419
|
+
spread: -30,
|
|
1420
|
+
color: "rgb(0 0 0 / 0.7)"
|
|
1421
|
+
}, {
|
|
1422
|
+
x: 0,
|
|
1423
|
+
y: 16,
|
|
1424
|
+
blur: 40,
|
|
1425
|
+
spread: -12,
|
|
1426
|
+
color: "rgb(0 0 0 / 0.5)"
|
|
1427
|
+
}]
|
|
1428
|
+
}
|
|
1429
|
+
},
|
|
1430
|
+
modeStrings: {
|
|
1431
|
+
light: {
|
|
1432
|
+
"glass-edge": "rgb(255 255 255 / 0.9) rgb(200 200 210 / 0.3) rgb(200 200 210 / 0.25) rgb(255 255 255 / 0.7)",
|
|
1433
|
+
"glass-edge-width": "1.5px",
|
|
1434
|
+
"glass-highlight": "inset 0 1px 2px 0 rgb(255 255 255 / 0.8), inset 0 -1px 2px 0 rgb(0 0 0 / 0.05)",
|
|
1435
|
+
"glass-fill": "linear-gradient(135deg, rgb(255 255 255 / 0.8) 0%, rgb(220 225 240 / 0.62) 40%, rgb(240 245 255 / 0.68) 70%, rgb(255 255 255 / 0.8) 100%)",
|
|
1436
|
+
"glass-fill-raised": "linear-gradient(135deg, rgb(255 255 255 / 0.86) 0%, rgb(215 220 238 / 0.7) 40%, rgb(235 240 255 / 0.76) 70%, rgb(255 255 255 / 0.86) 100%)",
|
|
1437
|
+
"mark-gradient": "linear-gradient(135deg, #38bdf8 0%, #6366f1 40%, #a855f7 100%)",
|
|
1438
|
+
"wordmark-gradient": "linear-gradient(90deg, #0369a1, #4338ca, #7e22ce)"
|
|
1439
|
+
},
|
|
1440
|
+
dark: {
|
|
1441
|
+
"glass-edge": "rgb(255 255 255 / 0.2) rgb(255 255 255 / 0.06) rgb(255 255 255 / 0.04) rgb(255 255 255 / 0.12)",
|
|
1442
|
+
"glass-edge-width": "1.5px",
|
|
1443
|
+
"glass-highlight": "inset 0 1px 1px 0 rgb(255 255 255 / 0.15)",
|
|
1444
|
+
"glass-fill": "linear-gradient(140deg, rgb(30 41 59 / 0.7) 0%, rgb(15 23 42 / 0.6) 45%, rgb(20 30 50 / 0.55) 100%)",
|
|
1445
|
+
"glass-fill-raised": "linear-gradient(140deg, rgb(30 41 59 / 0.78) 0%, rgb(15 23 42 / 0.68) 45%, rgb(20 30 50 / 0.62) 100%)",
|
|
1446
|
+
"mark-gradient": "linear-gradient(135deg, #38bdf8 0%, #6366f1 40%, #a855f7 100%)",
|
|
1447
|
+
"wordmark-gradient": "linear-gradient(90deg, #38bdf8, #818cf8, #a855f7)"
|
|
1448
|
+
}
|
|
1449
|
+
},
|
|
1450
|
+
strings: {
|
|
1451
|
+
"font-size-display": "30px",
|
|
1452
|
+
"font-line-height-display": "36px",
|
|
1453
|
+
"font-size-h1": "24px",
|
|
1454
|
+
"font-line-height-h1": "32px",
|
|
1455
|
+
"font-size-h2": "18px",
|
|
1456
|
+
"font-line-height-h2": "28px",
|
|
1457
|
+
"font-size-h3": "16px",
|
|
1458
|
+
"font-line-height-h3": "24px",
|
|
1459
|
+
"font-size-label": "14px",
|
|
1460
|
+
"font-line-height-label": "20px",
|
|
1461
|
+
"font-tracking-h1": "-0.025em"
|
|
1462
|
+
},
|
|
1279
1463
|
fonts: {
|
|
1280
1464
|
display: [
|
|
1281
1465
|
"-apple-system",
|
|
@@ -1583,7 +1767,16 @@ const ESTADOS_PROVA = [
|
|
|
1583
1767
|
"sem-dado",
|
|
1584
1768
|
"nao-testada"
|
|
1585
1769
|
];
|
|
1586
|
-
/** The word printed for each proof state (
|
|
1770
|
+
/** The word printed for each proof state in English (tympan-print picks by the book's `lang`). */
|
|
1771
|
+
const ROTULOS_PROVA_EN = {
|
|
1772
|
+
sustentada: "Supported",
|
|
1773
|
+
refutada: "Refuted",
|
|
1774
|
+
"nao-da-para-afirmar": "Cannot claim",
|
|
1775
|
+
pendente: "Pending",
|
|
1776
|
+
"sem-dado": "No data",
|
|
1777
|
+
"nao-testada": "Not tested"
|
|
1778
|
+
};
|
|
1779
|
+
/** The word printed for each proof state (always visible, whatever the mark's shape); pt-BR. */
|
|
1587
1780
|
const ROTULOS_PROVA = {
|
|
1588
1781
|
sustentada: "Sustentada",
|
|
1589
1782
|
refutada: "Refutada",
|
|
@@ -1621,8 +1814,8 @@ const dashboard = {
|
|
|
1621
1814
|
tinta2: "#3d3933",
|
|
1622
1815
|
tinta3: "#5f594f",
|
|
1623
1816
|
linha: "#d6cfc2",
|
|
1624
|
-
destaque: "#
|
|
1625
|
-
destaque2: "#
|
|
1817
|
+
destaque: "#9a4f2a",
|
|
1818
|
+
destaque2: "#c4b8a8",
|
|
1626
1819
|
marcaTexto: "#f3e6cf",
|
|
1627
1820
|
contexto: "#8f877a",
|
|
1628
1821
|
prova: {
|
|
@@ -1654,7 +1847,8 @@ const dashboard = {
|
|
|
1654
1847
|
rotuloCaixa: "alta",
|
|
1655
1848
|
notas: "dentro",
|
|
1656
1849
|
figura: "simples",
|
|
1657
|
-
minusculas: false
|
|
1850
|
+
minusculas: false,
|
|
1851
|
+
preencher: true
|
|
1658
1852
|
}
|
|
1659
1853
|
};
|
|
1660
1854
|
const graficos1900 = {
|
|
@@ -4065,15 +4259,56 @@ function mergeCores(base, over) {
|
|
|
4065
4259
|
if (!over) return base;
|
|
4066
4260
|
const { prova, ...rest } = over;
|
|
4067
4261
|
const clean = Object.fromEntries(Object.entries(rest).filter(([, v]) => v !== void 0));
|
|
4262
|
+
const temas = base.temas || clean.temas ? { temas: {
|
|
4263
|
+
...base.temas,
|
|
4264
|
+
...clean.temas
|
|
4265
|
+
} } : {};
|
|
4266
|
+
const categorias = base.categorias || clean.categorias ? { categorias: {
|
|
4267
|
+
...base.categorias,
|
|
4268
|
+
...clean.categorias
|
|
4269
|
+
} } : {};
|
|
4068
4270
|
return {
|
|
4069
4271
|
...base,
|
|
4070
4272
|
...clean,
|
|
4273
|
+
...temas,
|
|
4274
|
+
...categorias,
|
|
4071
4275
|
prova: {
|
|
4072
4276
|
...base.prova,
|
|
4073
4277
|
...prova ?? {}
|
|
4074
4278
|
}
|
|
4075
4279
|
};
|
|
4076
4280
|
}
|
|
4281
|
+
function mergeExtras(base, over) {
|
|
4282
|
+
const out = {};
|
|
4283
|
+
const marcas = {
|
|
4284
|
+
...base.marcas,
|
|
4285
|
+
...over.marcas
|
|
4286
|
+
};
|
|
4287
|
+
if (Object.keys(marcas).length) out.marcas = marcas;
|
|
4288
|
+
const pagina = {
|
|
4289
|
+
...base.pagina,
|
|
4290
|
+
...over.pagina
|
|
4291
|
+
};
|
|
4292
|
+
if (Object.keys(pagina).length) out.pagina = pagina;
|
|
4293
|
+
const folio = {
|
|
4294
|
+
...base.folio,
|
|
4295
|
+
...over.folio
|
|
4296
|
+
};
|
|
4297
|
+
if (Object.keys(folio).length) out.folio = folio;
|
|
4298
|
+
const fl = over.fontesLocais ?? base.fontesLocais;
|
|
4299
|
+
if (fl) out.fontesLocais = fl;
|
|
4300
|
+
const rs = {
|
|
4301
|
+
...base.rastro,
|
|
4302
|
+
...over.rastro
|
|
4303
|
+
};
|
|
4304
|
+
if (Object.keys(rs).length) out.rastro = rs;
|
|
4305
|
+
const tx = {
|
|
4306
|
+
...base.textos,
|
|
4307
|
+
...over.textos
|
|
4308
|
+
};
|
|
4309
|
+
if (Object.keys(tx).length) out.textos = tx;
|
|
4310
|
+
return out;
|
|
4311
|
+
}
|
|
4077
4312
|
/** A style with the editor's overrides applied (nested, partial). */
|
|
4078
4313
|
function mergePrintStyle(style, overrides) {
|
|
4079
4314
|
if (!overrides) return style;
|
|
@@ -4098,19 +4333,24 @@ function mergePrintStyle(style, overrides) {
|
|
|
4098
4333
|
marcaProva: overrides.marcaProva ?? style.marcaProva,
|
|
4099
4334
|
raio: overrides.raio ?? style.raio,
|
|
4100
4335
|
caixaAlta: overrides.caixaAlta ?? style.caixaAlta,
|
|
4101
|
-
pb: overrides.pb ?
|
|
4102
|
-
...style.cor,
|
|
4336
|
+
pb: overrides.pb ? {
|
|
4103
4337
|
...style.pb,
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
...style.pb.prova
|
|
4107
|
-
|
|
4108
|
-
|
|
4338
|
+
...overrides.pb,
|
|
4339
|
+
...style.pb.prova || overrides.pb.prova ? { prova: {
|
|
4340
|
+
...style.pb.prova,
|
|
4341
|
+
...overrides.pb.prova
|
|
4342
|
+
} } : {}
|
|
4343
|
+
} : style.pb,
|
|
4109
4344
|
estrutura: {
|
|
4110
4345
|
...style.estrutura,
|
|
4111
4346
|
...overrides.estrutura
|
|
4112
4347
|
},
|
|
4113
|
-
logo: overrides.logo ?? style.logo
|
|
4348
|
+
logo: overrides.logo ?? style.logo,
|
|
4349
|
+
...overrides.texto || style.texto ? { texto: {
|
|
4350
|
+
...style.texto,
|
|
4351
|
+
...overrides.texto
|
|
4352
|
+
} } : {},
|
|
4353
|
+
...mergeExtras(style, overrides)
|
|
4114
4354
|
};
|
|
4115
4355
|
}
|
|
4116
4356
|
const fromLinear = (c) => c <= .0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - .055;
|
|
@@ -4139,7 +4379,11 @@ function printStyleCoresPb(style) {
|
|
|
4139
4379
|
marcaTexto: toGrey(g.marcaTexto),
|
|
4140
4380
|
contexto: toGrey(g.contexto),
|
|
4141
4381
|
prova: Object.fromEntries(ESTADOS_PROVA.map((e) => [e, toGrey(g.prova[e])])),
|
|
4142
|
-
...g.ornamento ? { ornamento: g.ornamento.map(toGrey) } : {}
|
|
4382
|
+
...g.ornamento ? { ornamento: g.ornamento.map(toGrey) } : {},
|
|
4383
|
+
...g.interesse ? { interesse: toGrey(g.interesse) } : {},
|
|
4384
|
+
...g.temas ? { temas: Object.fromEntries(Object.entries(g.temas).map(([k, v]) => [k, toGrey(v)])) } : {},
|
|
4385
|
+
...g.divergente ? { divergente: g.divergente.map(toGrey) } : {},
|
|
4386
|
+
categorica: categoricaDoEstilo(style).map(toGrey)
|
|
4143
4387
|
}, style.pb);
|
|
4144
4388
|
}
|
|
4145
4389
|
/**
|
|
@@ -4167,6 +4411,62 @@ const kebab = {
|
|
|
4167
4411
|
contexto: "contexto"
|
|
4168
4412
|
};
|
|
4169
4413
|
const num = (n) => String(Math.round(n * 1e3) / 1e3);
|
|
4414
|
+
/**
|
|
4415
|
+
* `cor` moved along OKLCH lightness (hue and chroma kept) until it reaches `min`:1 against `papel`: the
|
|
4416
|
+
* context grey of a theme stays visible on cream paper (areas ≥ 1.5:1, strokes ≥ 3:1).
|
|
4417
|
+
*/
|
|
4418
|
+
function contrasteMinimo(cor, papel, min) {
|
|
4419
|
+
const p = parseColor(papel);
|
|
4420
|
+
if (contrastRatio(parseColor(cor), p) >= min) return toHex(parseColor(cor));
|
|
4421
|
+
const v = rgbToOklch(parseColor(cor));
|
|
4422
|
+
const passo = luminance(p) > .2 ? -.005 : .005;
|
|
4423
|
+
let out = parseColor(cor);
|
|
4424
|
+
for (let i = 0; i < 200 && contrastRatio(out, p) < min; i++) {
|
|
4425
|
+
v.l = Math.min(.995, Math.max(.02, v.l + passo));
|
|
4426
|
+
out = oklchToRgb(v);
|
|
4427
|
+
}
|
|
4428
|
+
return toHex(out);
|
|
4429
|
+
}
|
|
4430
|
+
const SELETORES_PAPEL = {
|
|
4431
|
+
titulo: ":is(h1, h2, h3, h4, .ty-print-title, .ty-print-figure-title, [class*=\"-title\"]:not(.ty-print-panel-title, .ty-print-block-title, .ty-print-margin-title))",
|
|
4432
|
+
numero: ":is(.ty-print-number-value, .ty-print-table td[data-numerica], .ty-print-parliament-total, [class*=\"-numero\"], [class*=\"-number\"])",
|
|
4433
|
+
rotulo: ":is(.ty-print-panel-title, .ty-print-block-title, .ty-print-margin-title, .ty-print-sobretitle, .ty-print-table th, .ty-print-map-legend, .ty-print-running-head, .ty-print-folio, .ty-print-letter)",
|
|
4434
|
+
corpo: "",
|
|
4435
|
+
anotacao: ":is(.ty-print-annotation, .ty-print-margin, .ty-print-callout-text)",
|
|
4436
|
+
mono: ":is(code, pre, .ty-print-mono, .ty-print-table td[data-mono])"
|
|
4437
|
+
};
|
|
4438
|
+
/**
|
|
4439
|
+
* Unlayered rules (they win over `@layer tympan-print`) for a theme's per-role font weights and figures,
|
|
4440
|
+
* scoped to `seletor`; '' when the theme sets neither.
|
|
4441
|
+
*/
|
|
4442
|
+
function printTextoRolesCss(style, seletor) {
|
|
4443
|
+
const out = [];
|
|
4444
|
+
for (const [papel, peso] of Object.entries(style.texto?.pesos ?? {})) {
|
|
4445
|
+
const s = SELETORES_PAPEL[papel];
|
|
4446
|
+
out.push(`${seletor}${s ? ` ${s}` : ""} { font-weight: ${peso}; }`);
|
|
4447
|
+
}
|
|
4448
|
+
for (const [papel, a] of Object.entries(style.texto?.algarismos ?? {})) {
|
|
4449
|
+
const s = SELETORES_PAPEL[papel];
|
|
4450
|
+
out.push(`${seletor}${s ? ` ${s}` : ""} { font-variant-numeric: ${a === "tabular" ? "tabular-nums lining-nums" : "proportional-nums"}; }`);
|
|
4451
|
+
}
|
|
4452
|
+
return out.join("\n");
|
|
4453
|
+
}
|
|
4454
|
+
/** Qualitative palette (Okabe & Ito 2008, colour-blind safe) used when a style defines none. */
|
|
4455
|
+
const CATEGORICA_PADRAO = [
|
|
4456
|
+
"#0072b2",
|
|
4457
|
+
"#e69f00",
|
|
4458
|
+
"#009e73",
|
|
4459
|
+
"#cc79a7",
|
|
4460
|
+
"#56b4e9",
|
|
4461
|
+
"#d55e00",
|
|
4462
|
+
"#f0e442",
|
|
4463
|
+
"#555555"
|
|
4464
|
+
];
|
|
4465
|
+
/** The eight qualitative data colours of a style: its own `categorica`, completed by CATEGORICA_PADRAO. */
|
|
4466
|
+
function categoricaDoEstilo(style) {
|
|
4467
|
+
const own = style.cor.categorica ?? [];
|
|
4468
|
+
return Array.from({ length: 8 }, (_, i) => own[i] ?? CATEGORICA_PADRAO[i]);
|
|
4469
|
+
}
|
|
4170
4470
|
/** Custom properties of a resolved style, in a stable order. */
|
|
4171
4471
|
function printStyleVariables(style) {
|
|
4172
4472
|
const vars = [];
|
|
@@ -4191,6 +4491,21 @@ function printStyleVariables(style) {
|
|
|
4191
4491
|
vars.push(["--ty-print-rotulo-caixa", minusculas ? "lowercase" : rc === "alta" ? "uppercase" : "none"]);
|
|
4192
4492
|
vars.push(["--ty-print-rotulo-variante", rc === "versalete" ? "small-caps" : "normal"]);
|
|
4193
4493
|
vars.push(["--ty-print-rotulo-espaco", rc === "normal" ? "normal" : "0.07em"]);
|
|
4494
|
+
vars.push(["--ty-print-pagina-largura", `${num(style.pagina?.largura ?? 170)}mm`]);
|
|
4495
|
+
vars.push(["--ty-print-pagina-altura", `${num(style.pagina?.altura ?? 240)}mm`]);
|
|
4496
|
+
const preservar = style.texto?.nomesProprios === "preservar";
|
|
4497
|
+
vars.push(["--ty-print-titulo1-caixa", preservar ? "none" : style.caixaAlta ? "uppercase" : minusculas ? "lowercase" : "none"]);
|
|
4498
|
+
vars.push(["--ty-print-sobretitulo-caixa", preservar ? "none" : minusculas ? "lowercase" : rc === "alta" ? "uppercase" : "none"]);
|
|
4499
|
+
vars.push(["--ty-print-celula-caixa", preservar ? "none" : minusculas ? "lowercase" : "none"]);
|
|
4500
|
+
vars.push(["--ty-print-tabela-numeros", style.texto?.numerosTabela === "proporcional" ? "proportional-nums lining-nums" : "tabular-nums lining-nums"]);
|
|
4501
|
+
for (const [k, v] of Object.entries(style.cor.temas ?? {})) vars.push([`--ty-print-tema-${k.replace(/[^a-z0-9-]/gi, "")}`, v]);
|
|
4502
|
+
vars.push(["--ty-print-interesse", style.cor.interesse ?? style.cor.destaque]);
|
|
4503
|
+
vars.push(["--ty-print-contexto-area", contrasteMinimo(style.cor.contexto, style.cor.papel, 1.5)]);
|
|
4504
|
+
vars.push(["--ty-print-contexto-traco", contrasteMinimo(style.cor.contexto, style.cor.papel, 3)]);
|
|
4505
|
+
const dv = style.cor.divergente ?? [style.cor.destaque2, style.cor.destaque];
|
|
4506
|
+
vars.push(["--ty-print-divergente-1", dv[0]]);
|
|
4507
|
+
vars.push(["--ty-print-divergente-2", dv[1]]);
|
|
4508
|
+
categoricaDoEstilo(style).forEach((c, i) => vars.push([`--ty-print-categorica-${i + 1}`, c]));
|
|
4194
4509
|
const orn = style.cor.ornamento ?? [];
|
|
4195
4510
|
const reserva = [
|
|
4196
4511
|
style.cor.destaque,
|
|
@@ -4915,7 +5230,10 @@ const FORCED_COLORS_VARS = [
|
|
|
4915
5230
|
["--ty-shadow-floating", "none"],
|
|
4916
5231
|
["--ty-shadow-modal", "none"],
|
|
4917
5232
|
["--ty-glass-blur-sheet", "0px"],
|
|
4918
|
-
["--ty-glass-blur-floating", "0px"]
|
|
5233
|
+
["--ty-glass-blur-floating", "0px"],
|
|
5234
|
+
["--ty-glass-edge", "CanvasText"],
|
|
5235
|
+
["--ty-glass-fill", "Canvas"],
|
|
5236
|
+
["--ty-glass-fill-raised", "Canvas"]
|
|
4919
5237
|
];
|
|
4920
5238
|
/** Reduced transparency (and no backdrop-filter support): opaque surfaces, no blur, no ambient. */
|
|
4921
5239
|
const OPAQUE_VARS = [
|
|
@@ -4925,6 +5243,8 @@ const OPAQUE_VARS = [
|
|
|
4925
5243
|
["--ty-glass-blur-sheet", "0px !important"],
|
|
4926
5244
|
["--ty-glass-blur-floating", "0px !important"],
|
|
4927
5245
|
["--ty-glass-saturate", "1 !important"],
|
|
5246
|
+
["--ty-glass-fill", "var(--ty-surface-solid) !important"],
|
|
5247
|
+
["--ty-glass-fill-raised", "var(--ty-surface-raised-solid) !important"],
|
|
4928
5248
|
["--ty-ambient-1", "transparent !important"],
|
|
4929
5249
|
["--ty-ambient-2", "transparent !important"]
|
|
4930
5250
|
];
|
|
@@ -5148,8 +5468,8 @@ function flowToneRules() {
|
|
|
5148
5468
|
//#region src/fonts.ts
|
|
5149
5469
|
/** Base stacks of every preset: Source Serif 4, IBM Plex Sans, IBM Plex Mono. */
|
|
5150
5470
|
const BASE_FONT_SPECS = [
|
|
5151
|
-
"Source Serif 4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400",
|
|
5152
|
-
"IBM Plex Sans:ital,wght@0,400;0,500;0,600;0,700;1,400",
|
|
5471
|
+
"Source Serif 4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400;1,8..60,600",
|
|
5472
|
+
"IBM Plex Sans:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600",
|
|
5153
5473
|
"IBM Plex Mono:ital,wght@0,400;0,500;0,600;0,700;1,400"
|
|
5154
5474
|
];
|
|
5155
5475
|
const NOTO_WEIGHTS = "wght@400;500;600;700";
|
|
@@ -5292,9 +5612,221 @@ function fontFaceCss(manifest, specs, base) {
|
|
|
5292
5612
|
}).join("\n");
|
|
5293
5613
|
}
|
|
5294
5614
|
//#endregion
|
|
5615
|
+
//#region src/print-book-themes.ts
|
|
5616
|
+
const REGISTRO = /* @__PURE__ */ new Map();
|
|
5617
|
+
/** A style with overrides and theme extras applied (same as mergePrintStyle, kept for readability). */
|
|
5618
|
+
const mergePrintTheme = mergePrintStyle;
|
|
5619
|
+
/** Resolves a theme id or a preset id to a complete PrintStyle (`name` = the theme id). */
|
|
5620
|
+
function printThemeById(id, visitados = []) {
|
|
5621
|
+
const tema = REGISTRO.get(id);
|
|
5622
|
+
if (!tema) return printPresetById(id);
|
|
5623
|
+
if (visitados.includes(id)) throw new Error(`tympan: book theme cycle ${[...visitados, id].join(" → ")}`);
|
|
5624
|
+
const base = printThemeById(tema.base, [...visitados, id]);
|
|
5625
|
+
const { id: _id, base: _base, referencia, ...over } = tema;
|
|
5626
|
+
return {
|
|
5627
|
+
...mergePrintTheme(base, over),
|
|
5628
|
+
name: tema.id,
|
|
5629
|
+
label: tema.label ?? base.label,
|
|
5630
|
+
referencia: referencia ?? `Tema sobre ${base.name}: ${base.referencia}`
|
|
5631
|
+
};
|
|
5632
|
+
}
|
|
5633
|
+
/** True when `id` names a registered theme or a preset. */
|
|
5634
|
+
function isPrintThemeId(id) {
|
|
5635
|
+
return REGISTRO.has(id) || resolvePrintStyleName(id) !== void 0;
|
|
5636
|
+
}
|
|
5637
|
+
function normalizarCores(c) {
|
|
5638
|
+
if (!c) return void 0;
|
|
5639
|
+
const cor = (v) => typeof v === "string" ? v : toHex(fromDtcgColor(v));
|
|
5640
|
+
const out = {};
|
|
5641
|
+
for (const [k, v] of Object.entries(c)) if ((k === "prova" || k === "temas" || k === "categorias") && v && typeof v === "object") out[k] = Object.fromEntries(Object.entries(v).map(([e, x]) => [e, cor(x)]));
|
|
5642
|
+
else if ((k === "ornamento" || k === "categorica" || k === "divergente") && Array.isArray(v)) out[k] = v.map(cor);
|
|
5643
|
+
else out[k] = cor(v);
|
|
5644
|
+
return out;
|
|
5645
|
+
}
|
|
5646
|
+
/** Validates and normalises a theme read from JSON (colours may be hex or DTCG colour objects). */
|
|
5647
|
+
function printThemeFromJson(json) {
|
|
5648
|
+
const j = typeof json === "string" ? JSON.parse(json) : json;
|
|
5649
|
+
if (!j || typeof j.id !== "string" || !/^[a-z0-9][a-z0-9-]*$/.test(j.id)) throw new Error("tympan: a book theme needs an `id` in kebab case");
|
|
5650
|
+
if (typeof j.base !== "string") throw new Error(`tympan: book theme "${j.id}" needs a \`base\` (a preset or a registered theme)`);
|
|
5651
|
+
const { cor, pb, ...rest } = j;
|
|
5652
|
+
const out = { ...rest };
|
|
5653
|
+
const c = normalizarCores(cor);
|
|
5654
|
+
if (c) out.cor = c;
|
|
5655
|
+
const p = normalizarCores(pb);
|
|
5656
|
+
if (p) out.pb = p;
|
|
5657
|
+
return out;
|
|
5658
|
+
}
|
|
5659
|
+
/** Namespaces read for the theme's meta (id/name, base/extends): tympan's own and the short one brand repos use. */
|
|
5660
|
+
const EXTS = ["br.com.datatechsolutions.tympan", "dev.tympan.print"];
|
|
5661
|
+
/** Unwraps a DTCG group into plain values: `{ $value }` leaves become their value; `$`-keys are dropped. */
|
|
5662
|
+
function desembrulhar(n) {
|
|
5663
|
+
if (!n || typeof n !== "object" || Array.isArray(n)) return n;
|
|
5664
|
+
const o = n;
|
|
5665
|
+
if ("$value" in o) {
|
|
5666
|
+
const v = o.$value;
|
|
5667
|
+
if (o.$type === "fontFamily" && Array.isArray(v)) return pilhaDeFontes(v);
|
|
5668
|
+
if (o.$type === "color" && v && typeof v === "object") return toHex(fromDtcgColor(v));
|
|
5669
|
+
if (o.$type === "dimension" && v && typeof v === "object" && "unit" in v) return emMm(v);
|
|
5670
|
+
return v;
|
|
5671
|
+
}
|
|
5672
|
+
const out = {};
|
|
5673
|
+
for (const [k, v] of Object.entries(o)) if (!k.startsWith("$")) out[k] = desembrulhar(v);
|
|
5674
|
+
return out;
|
|
5675
|
+
}
|
|
5676
|
+
const GENERICAS = /^(serif|sans-serif|monospace|cursive|fantasy|system-ui|ui-[a-z-]+)$/;
|
|
5677
|
+
const pilhaDeFontes = (v) => v.map((x) => GENERICAS.test(x) || /^["']/.test(x) ? x : `"${x}"`).join(", ");
|
|
5678
|
+
const emMm = (v) => v.unit === "px" ? v.value * 25.4 / 96 : v.unit === "pt" ? v.value * 25.4 / 72 : v.unit === "cm" ? v.value * 10 : v.value;
|
|
5679
|
+
/** Figures from the meta: an object by role, or a phrase such as "tabular-nums em numero e rotulo". */
|
|
5680
|
+
function lerAlgarismos(v) {
|
|
5681
|
+
if (v && typeof v === "object") return v;
|
|
5682
|
+
if (typeof v !== "string") return void 0;
|
|
5683
|
+
const tipo = /proporc|proportional/.test(v) ? "proporcional" : /tabular/.test(v) ? "tabular" : void 0;
|
|
5684
|
+
if (!tipo) return void 0;
|
|
5685
|
+
const papeis = [
|
|
5686
|
+
"numero",
|
|
5687
|
+
"rotulo",
|
|
5688
|
+
"corpo"
|
|
5689
|
+
].filter((p) => v.includes(p));
|
|
5690
|
+
return Object.fromEntries((papeis.length ? papeis : ["numero"]).map((p) => [p, tipo]));
|
|
5691
|
+
}
|
|
5692
|
+
/**
|
|
5693
|
+
* A theme from a DTCG (2025.10) tree. The tree mirrors PrintStyleOverrides: each group is a field
|
|
5694
|
+
* (`label`, `fontes.<role>`, `googleFonts`, `cor.<role>`, `cor.prova.<state>`, `cor.categorica.<n>`,
|
|
5695
|
+
* `cor.divergente.<n>`, `traco.largura`, `pb.*`, `estrutura.*`, `texto.*`, `marcas.*`, `pagina.*`, `folio.*`,
|
|
5696
|
+
* `fontesLocais`…) and each `{ "$type", "$value" }` leaf becomes its value (colours as hex or DTCG colour
|
|
5697
|
+
* objects, `fontFamily` arrays become CSS stacks, dimensions become mm). The theme's id and base come from
|
|
5698
|
+
* the root `$extensions["dev.tympan.print"]` (or `["br.com.datatechsolutions.tympan"]`) as `name`/`id` and
|
|
5699
|
+
* `extends`/`base`.
|
|
5700
|
+
*/
|
|
5701
|
+
function printThemeFromDtcg(tree) {
|
|
5702
|
+
const t = typeof tree === "string" ? JSON.parse(tree) : tree;
|
|
5703
|
+
const exts = t.$extensions ?? {};
|
|
5704
|
+
const meta = Object.assign({}, ...EXTS.map((e) => exts[e]).filter(Boolean).map((m) => ({
|
|
5705
|
+
...m.tema,
|
|
5706
|
+
...m
|
|
5707
|
+
})));
|
|
5708
|
+
const id = meta.id ?? meta.name;
|
|
5709
|
+
const base = meta.base ?? meta.extends;
|
|
5710
|
+
if (!id || !base) throw new Error(`tympan: a DTCG book theme needs $extensions["dev.tympan.print"] with name and extends`);
|
|
5711
|
+
const corpo = desembrulhar(t);
|
|
5712
|
+
const cor = corpo.cor;
|
|
5713
|
+
for (const g of [cor, corpo.pb]) if (g) {
|
|
5714
|
+
for (const k of [
|
|
5715
|
+
"categorica",
|
|
5716
|
+
"divergente",
|
|
5717
|
+
"ornamento"
|
|
5718
|
+
]) if (g[k] && typeof g[k] === "object" && !Array.isArray(g[k])) g[k] = Object.entries(g[k]).sort(([a], [b]) => a.localeCompare(b, "en", { numeric: true })).map(([, v]) => v);
|
|
5719
|
+
}
|
|
5720
|
+
const texto = { ...corpo.texto };
|
|
5721
|
+
if (meta.pesos && typeof meta.pesos === "object") texto.pesos = {
|
|
5722
|
+
...meta.pesos,
|
|
5723
|
+
...texto.pesos
|
|
5724
|
+
};
|
|
5725
|
+
const alg = lerAlgarismos(meta.algarismos);
|
|
5726
|
+
if (alg) texto.algarismos = {
|
|
5727
|
+
...alg,
|
|
5728
|
+
...texto.algarismos
|
|
5729
|
+
};
|
|
5730
|
+
if (Object.keys(texto).length) corpo.texto = texto;
|
|
5731
|
+
const dado = meta.dado;
|
|
5732
|
+
if (dado) {
|
|
5733
|
+
const c = { ...corpo.cor };
|
|
5734
|
+
if (dado.interesse && c.interesse === void 0) c.interesse = dado.interesse;
|
|
5735
|
+
if (dado.contexto) c.contexto = dado.contexto;
|
|
5736
|
+
if (dado.perdeu && dado.ganhou && c.divergente === void 0) c.divergente = [dado.perdeu, dado.ganhou];
|
|
5737
|
+
corpo.cor = c;
|
|
5738
|
+
}
|
|
5739
|
+
return printThemeFromJson({
|
|
5740
|
+
...corpo,
|
|
5741
|
+
id,
|
|
5742
|
+
base,
|
|
5743
|
+
...meta.referencia ? { referencia: meta.referencia } : {}
|
|
5744
|
+
});
|
|
5745
|
+
}
|
|
5746
|
+
/** Registers (or replaces) a theme; accepts the theme object, its JSON or a DTCG tree. Returns the theme. */
|
|
5747
|
+
function registerPrintTheme(tema) {
|
|
5748
|
+
const obj = typeof tema === "string" ? JSON.parse(tema) : tema;
|
|
5749
|
+
const t = obj.$extensions ? printThemeFromDtcg(obj) : printThemeFromJson(obj);
|
|
5750
|
+
if (resolvePrintStyleName(t.id)) throw new Error(`tympan: book theme id "${t.id}" collides with a preset`);
|
|
5751
|
+
REGISTRO.set(t.id, t);
|
|
5752
|
+
printThemeById(t.id);
|
|
5753
|
+
return t;
|
|
5754
|
+
}
|
|
5755
|
+
/** Removes a registered theme (tests, hot reload). */
|
|
5756
|
+
function unregisterPrintTheme(id) {
|
|
5757
|
+
return REGISTRO.delete(id);
|
|
5758
|
+
}
|
|
5759
|
+
/** Ids of the registered themes, in registration order. */
|
|
5760
|
+
function registeredPrintThemes() {
|
|
5761
|
+
return [...REGISTRO.keys()];
|
|
5762
|
+
}
|
|
5763
|
+
/** `@font-face` rules for a style's local font files ('' when it has none). */
|
|
5764
|
+
function fontesLocaisCss(style) {
|
|
5765
|
+
return (style.fontesLocais ?? []).map((f) => `@font-face { font-family: "${f.familia.replace(/"/g, "")}"; src: url("${f.src.replace(/"/g, "%22")}") format("woff2"); font-weight: ${f.peso ?? 400}; font-style: ${f.estilo ?? "normal"}; font-display: block; }`).join("\n");
|
|
5766
|
+
}
|
|
5767
|
+
/** Trim and bleed of a style (defaults 170 × 240 mm, 3 mm bleed). */
|
|
5768
|
+
function paginaDoEstilo(style) {
|
|
5769
|
+
const p = style.pagina ?? {};
|
|
5770
|
+
return {
|
|
5771
|
+
largura: p.largura ?? 170,
|
|
5772
|
+
altura: p.altura ?? 240,
|
|
5773
|
+
sangria: p.sangria ?? 3,
|
|
5774
|
+
marcasCorte: p.marcasCorte ?? false
|
|
5775
|
+
};
|
|
5776
|
+
}
|
|
5777
|
+
/** A neutral example theme (registered nowhere by default): a small press over `semanario`, in two inks. */
|
|
5778
|
+
const TEMA_EXEMPLO_EDITORA = {
|
|
5779
|
+
id: "editora-exemplo",
|
|
5780
|
+
base: "semanario",
|
|
5781
|
+
label: "Editora Exemplo · coleção ensaios",
|
|
5782
|
+
fontes: { titulo: "\"Source Serif 4\", Georgia, serif" },
|
|
5783
|
+
cor: {
|
|
5784
|
+
destaque: "#1f4e79",
|
|
5785
|
+
destaque2: "#b5562b",
|
|
5786
|
+
marcaTexto: "#e8eef5"
|
|
5787
|
+
},
|
|
5788
|
+
pb: {
|
|
5789
|
+
destaque: "#333333",
|
|
5790
|
+
destaque2: "#8a8a8a"
|
|
5791
|
+
},
|
|
5792
|
+
texto: { nomesProprios: "preservar" },
|
|
5793
|
+
folio: {
|
|
5794
|
+
folio: "centro",
|
|
5795
|
+
cabeco: "externo"
|
|
5796
|
+
},
|
|
5797
|
+
pagina: {
|
|
5798
|
+
largura: 160,
|
|
5799
|
+
altura: 230,
|
|
5800
|
+
sangria: 3
|
|
5801
|
+
}
|
|
5802
|
+
};
|
|
5803
|
+
/** Families named in a style's font stacks (quotes removed), in role order, without generic and system faces. */
|
|
5804
|
+
function familiasDoEstilo(style) {
|
|
5805
|
+
const out = [];
|
|
5806
|
+
for (const pilha of Object.values(style.fontes)) for (const f of pilha.split(",").map((x) => x.trim().replace(/^["']|["']$/g, ""))) if (f && !SYSTEM_FONT_FAMILIES.includes(f) && !out.includes(f)) out.push(f);
|
|
5807
|
+
return out;
|
|
5808
|
+
}
|
|
5809
|
+
/** Families the style names (first of each stack) that have neither a bundled file nor a theme `fontesLocais`. */
|
|
5810
|
+
function familiasSemArquivo(style, manifest) {
|
|
5811
|
+
const proprias = new Set((style.fontesLocais ?? []).map((f) => f.familia));
|
|
5812
|
+
const primeiras = Object.values(style.fontes).map((p) => p.split(",")[0].trim().replace(/^["']|["']$/g, ""));
|
|
5813
|
+
return [...new Set(primeiras)].filter((f) => !SYSTEM_FONT_FAMILIES.includes(f) && !proprias.has(f) && !manifest.families[f]);
|
|
5814
|
+
}
|
|
5815
|
+
/**
|
|
5816
|
+
* @font-face rules for a style from the fonts bundled in this package (`fonts/manifest.json`): every face of
|
|
5817
|
+
* every family its font stacks name (so a mono or label family outside `googleFonts` is not forgotten), with
|
|
5818
|
+
* URLs `<base><file>`, then the theme's own `fontesLocais`, which win for their family.
|
|
5819
|
+
*/
|
|
5820
|
+
function fontesEmpacotadasCss(style, manifest, base) {
|
|
5821
|
+
const proprias = new Set((style.fontesLocais ?? []).map((f) => f.familia));
|
|
5822
|
+
const familias = new Set(familiasDoEstilo(style).filter((f) => manifest.families[f] && !proprias.has(f)));
|
|
5823
|
+
const specs = Object.keys(manifest.specs).filter((s) => familias.has(s.split(":")[0]));
|
|
5824
|
+
return [specs.length ? fontFaceCss(manifest, specs, base) : "", fontesLocaisCss(style)].filter(Boolean).join("\n");
|
|
5825
|
+
}
|
|
5826
|
+
//#endregion
|
|
5295
5827
|
//#region src/index.ts
|
|
5296
5828
|
const allThemes = [...presets, ...printThemePresets];
|
|
5297
5829
|
//#endregion
|
|
5298
|
-
export { BASE_FONT_SPECS, CJK_FONT_FAMILIES, CJK_FONT_SPECS, CORE_FONT_SPECS, DEFAULT_CHART_HUES, DEFAULT_PRINT_STYLE, DEFAULT_THEME, DENSITIES, ESTADOS_PROVA, FLOW_TOKENS, FLOW_TONES, FONT_ROLE_TOKENS, FORCED_COLORS_VARS, OPAQUE_VARS, PRINT_PRESET_NAMES, PRINT_STYLE_ALIASES, PRINT_THEME_ALIASES, PRINT_THEME_OVERRIDES, PRINT_THEME_PREFIX, RAMP_STEPS, ROLE_ALIASES, ROLE_NAMES, ROTULOS_PROVA, SCRIPT_FONT_FAMILIES, SCRIPT_FONT_SPECS, SYSTEM_FONT_FAMILIES, allThemes, apcaContrast, astrlabeControlePreset, astrlabePreset, buildStylesheet, composite, contrastPairs, contrastRatio, deltaE2000, densityToDtcg, densityVariables, fakhirPreset, flatten, flowCssName, flowToDtcg, flowTokenCss, flowToneRules, flowVariables, fontFaceCss, fontStackToCss, fromDtcgColor, generatePrintThemesCss, generateRamp, generateThemeCss, googleFontsUrl, gradientToCss, highContrastPreset, legibleOn, luminance, mergePrintStyle, neutralPreset, oklchToRgb, papelEscuro, parseColor, parseFontStack, presetThemeVars, presets, printPresetById, printPresets, printStyleAccent, printStyleCoresPb, printStyleToCss, printStyleToTheme, printStyleVariables, printThemeDroppedPins, printThemeFontSpecs, printThemeFontUrls, printThemePresets, resolvePrintStyle, resolvePrintStyleName, resolvePrintThemeName, resolveTheme, rgbToLab, rgbToOklab, rgbToOklch, seedFromColor, shadowToCss, themeSelectors, themeToDtcg, themeVariables, themeVarsFor, toCss, toDtcgColor, toGrey, toHex, tympanPreset, warnDeprecatedPrintId };
|
|
5830
|
+
export { BASE_FONT_SPECS, CATEGORICA_PADRAO, CJK_FONT_FAMILIES, CJK_FONT_SPECS, CORE_FONT_SPECS, DEFAULT_CHART_HUES, DEFAULT_PRINT_STYLE, DEFAULT_THEME, DENSITIES, ESTADOS_PROVA, FLOW_TOKENS, FLOW_TONES, FONT_ROLE_TOKENS, FORCED_COLORS_VARS, OPAQUE_VARS, PRINT_PRESET_NAMES, PRINT_STYLE_ALIASES, PRINT_THEME_ALIASES, PRINT_THEME_OVERRIDES, PRINT_THEME_PREFIX, RAMP_STEPS, ROLE_ALIASES, ROLE_NAMES, ROTULOS_PROVA, ROTULOS_PROVA_EN, SCRIPT_FONT_FAMILIES, SCRIPT_FONT_SPECS, SYSTEM_FONT_FAMILIES, TEMA_EXEMPLO_EDITORA, allThemes, apcaContrast, astrlabeControlePreset, astrlabePreset, buildStylesheet, categoricaDoEstilo, composite, contrastPairs, contrastRatio, contrasteMinimo, deltaE2000, densityToDtcg, densityVariables, fakhirPreset, familiasDoEstilo, familiasSemArquivo, flatten, flowCssName, flowToDtcg, flowTokenCss, flowToneRules, flowVariables, fontFaceCss, fontStackToCss, fontesEmpacotadasCss, fontesLocaisCss, fromDtcgColor, generatePrintThemesCss, generateRamp, generateThemeCss, googleFontsUrl, gradientToCss, highContrastPreset, isPrintThemeId, legibleOn, luminance, mergePrintStyle, mergePrintTheme, neutralPreset, oklchToRgb, paginaDoEstilo, papelEscuro, parseColor, parseFontStack, presetThemeVars, presets, printPresetById, printPresets, printStyleAccent, printStyleCoresPb, printStyleToCss, printStyleToTheme, printStyleVariables, printTextoRolesCss, printThemeById, printThemeDroppedPins, printThemeFontSpecs, printThemeFontUrls, printThemeFromDtcg, printThemeFromJson, printThemePresets, registerPrintTheme, registeredPrintThemes, resolvePrintStyle, resolvePrintStyleName, resolvePrintThemeName, resolveTheme, rgbToLab, rgbToOklab, rgbToOklch, seedFromColor, shadowToCss, themeSelectors, themeToDtcg, themeVariables, themeVarsFor, toCss, toDtcgColor, toGrey, toHex, tympanPreset, unregisterPrintTheme, warnDeprecatedPrintId };
|
|
5299
5831
|
|
|
5300
5832
|
//# sourceMappingURL=index.js.map
|