@pixerate/editor 0.164.0 → 0.165.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.
Files changed (141) hide show
  1. package/dist/agent/index.cjs +54 -39
  2. package/dist/agent/index.js +24 -9
  3. package/dist/animation/index.cjs +6 -5
  4. package/dist/animation/index.js +5 -4
  5. package/dist/animation-editor/index.cjs +65 -64
  6. package/dist/animation-editor/index.js +8 -7
  7. package/dist/bridge/cli.cjs +3 -3
  8. package/dist/bridge/cli.js +2 -2
  9. package/dist/bridge/index.cjs +3 -3
  10. package/dist/bridge/index.js +2 -2
  11. package/dist/canvas/index.cjs +89 -87
  12. package/dist/canvas/index.js +11 -9
  13. package/dist/chart/controller.d.cts +31 -2
  14. package/dist/chart/controller.d.ts +31 -2
  15. package/dist/chart/index.cjs +504 -132
  16. package/dist/chart/index.d.cts +2 -0
  17. package/dist/chart/index.d.ts +2 -0
  18. package/dist/chart/index.js +386 -14
  19. package/dist/chart/layout-families.d.cts +7 -0
  20. package/dist/chart/layout-families.d.ts +7 -0
  21. package/dist/chart/links.d.cts +34 -0
  22. package/dist/chart/links.d.ts +34 -0
  23. package/dist/chart/mermaid.d.cts +9 -6
  24. package/dist/chart/mermaid.d.ts +9 -6
  25. package/dist/chart/schemas.d.cts +3 -0
  26. package/dist/chart/schemas.d.ts +3 -0
  27. package/dist/chart/spec.d.cts +3 -2
  28. package/dist/chart/spec.d.ts +3 -2
  29. package/dist/chart/style.d.cts +33 -0
  30. package/dist/chart/style.d.ts +33 -0
  31. package/dist/chart/types.d.cts +24 -2
  32. package/dist/chart/types.d.ts +24 -2
  33. package/dist/{chunk-TALQONZ5.js → chunk-2J5VLJHC.js} +3 -3
  34. package/dist/{chunk-3NEZJCBY.js → chunk-2ZRN43IN.js} +340 -201
  35. package/dist/{chunk-ZVNAMTFO.cjs → chunk-3FSUJIXN.cjs} +18 -174
  36. package/dist/{chunk-RQCMSEM5.cjs → chunk-4QUUHTGJ.cjs} +2 -2
  37. package/dist/{chunk-CIPIESX4.cjs → chunk-4ZC5QJE2.cjs} +3 -3
  38. package/dist/{chunk-S6X2QRVU.cjs → chunk-5UEFBM2M.cjs} +1 -138
  39. package/dist/{chunk-YSAGBIRW.cjs → chunk-64VWWR5U.cjs} +16 -16
  40. package/dist/{chunk-QYZGBVNC.js → chunk-7272D3K2.js} +10 -8
  41. package/dist/{chunk-462WGGXX.cjs → chunk-AMX23CSN.cjs} +27 -16
  42. package/dist/{chunk-3VLOOO3G.js → chunk-BDIM6NVW.js} +1 -1
  43. package/dist/{chunk-POR54B55.js → chunk-CRFSQWKQ.js} +4 -1
  44. package/dist/{chunk-GZ2FM3ZB.js → chunk-DKNEQX7T.js} +6 -162
  45. package/dist/{chunk-JCXMJUQO.cjs → chunk-EGZM52EO.cjs} +3 -3
  46. package/dist/{chunk-ES3UEVUT.cjs → chunk-EUIDTZNQ.cjs} +112 -110
  47. package/dist/{chunk-H3OEM3Q2.js → chunk-F6R67I3A.js} +1 -1
  48. package/dist/{chunk-5FNGLV2D.js → chunk-FEU2XVQH.js} +15 -3
  49. package/dist/{chunk-SZA42R4N.js → chunk-FRBRLKNQ.js} +154 -16
  50. package/dist/chunk-HIDFL5LQ.js +484 -0
  51. package/dist/{chunk-MKTDELCD.js → chunk-I5MRJW7B.js} +1 -1
  52. package/dist/{chunk-SDHZG5TF.js → chunk-ILP77UD6.js} +160 -2
  53. package/dist/{chunk-GKNEJ6EN.cjs → chunk-IMRXC7OA.cjs} +241 -103
  54. package/dist/chunk-KGRZMHZB.js +204 -0
  55. package/dist/{chunk-SET6KJOP.js → chunk-LPIKXPBM.js} +1 -1
  56. package/dist/{chunk-BQWGN5WH.js → chunk-M2TPMYJE.js} +1 -1
  57. package/dist/{chunk-GTELFJRE.cjs → chunk-M5GLQQWG.cjs} +2 -2
  58. package/dist/{chunk-4VU4CP7R.js → chunk-MHLU6GRJ.js} +1 -138
  59. package/dist/{chunk-D54JHQK2.cjs → chunk-MKXK6E4O.cjs} +51 -51
  60. package/dist/{chunk-DAPQGA55.js → chunk-N7NBGT2Y.js} +2 -2
  61. package/dist/chunk-O6OGNDND.js +164 -0
  62. package/dist/{chunk-22KLZZGH.cjs → chunk-ODFCS7HF.cjs} +8 -8
  63. package/dist/{chunk-PA3IMPPS.cjs → chunk-OVYQAYGH.cjs} +81 -81
  64. package/dist/{chunk-YXOW456B.js → chunk-PPEDZ5WR.js} +1 -1
  65. package/dist/{chunk-YGG7WDWT.cjs → chunk-Q25WAFTD.cjs} +21 -18
  66. package/dist/{chunk-SBQVEBSU.cjs → chunk-QO2T6KA5.cjs} +165 -67
  67. package/dist/{chunk-24M7VD6M.cjs → chunk-S4EIAIEW.cjs} +7 -7
  68. package/dist/{chunk-M4MIZPQI.cjs → chunk-SJ2CPTQC.cjs} +189 -15
  69. package/dist/chunk-TFF2GTGN.cjs +153 -0
  70. package/dist/chunk-TTCJPX4U.cjs +204 -0
  71. package/dist/{chunk-NZD2MZJC.cjs → chunk-TVQW26AV.cjs} +35 -23
  72. package/dist/{chunk-R3P2M7HU.cjs → chunk-UVXTOZ2B.cjs} +346 -207
  73. package/dist/{chunk-WI7QJA7A.cjs → chunk-UXETV2NC.cjs} +161 -3
  74. package/dist/{chunk-Z4P2RBMJ.js → chunk-V5GSY3NC.js} +101 -3
  75. package/dist/{chunk-QY4KUDMY.js → chunk-VRXXAXUT.js} +2 -2
  76. package/dist/chunk-VU6WQSMB.cjs +164 -0
  77. package/dist/{chunk-OXERWBKE.js → chunk-X5W645RI.js} +3 -3
  78. package/dist/{chunk-NHLYK3AX.js → chunk-XBQX76CT.js} +182 -8
  79. package/dist/{chunk-5AARIS3R.cjs → chunk-XCDGM7TD.cjs} +37 -37
  80. package/dist/{chunk-EVXQNQND.js → chunk-XZB3TJ6K.js} +16 -5
  81. package/dist/chunk-YBAPT7NL.js +153 -0
  82. package/dist/chunk-Z2UQYMPS.cjs +484 -0
  83. package/dist/color/index.cjs +5 -3
  84. package/dist/color/index.js +12 -10
  85. package/dist/diagram/index.cjs +55 -243
  86. package/dist/diagram/index.js +12 -200
  87. package/dist/export/index.cjs +7 -6
  88. package/dist/export/index.js +6 -5
  89. package/dist/extensions/index.cjs +12 -9
  90. package/dist/extensions/index.js +11 -8
  91. package/dist/gradient/index.cjs +29 -27
  92. package/dist/gradient/index.js +6 -4
  93. package/dist/image-editor/index.cjs +644 -643
  94. package/dist/image-editor/index.js +7 -6
  95. package/dist/index.cjs +21 -18
  96. package/dist/index.js +14 -11
  97. package/dist/paint-editor/index.cjs +19 -18
  98. package/dist/paint-editor/index.js +7 -6
  99. package/dist/parameters/index.cjs +2 -2
  100. package/dist/parameters/index.js +1 -1
  101. package/dist/persistence/assetWrites.d.cts +22 -0
  102. package/dist/persistence/assetWrites.d.ts +22 -0
  103. package/dist/persistence/assets.d.cts +71 -0
  104. package/dist/persistence/assets.d.ts +71 -0
  105. package/dist/persistence/documentStore.d.cts +17 -1
  106. package/dist/persistence/documentStore.d.ts +17 -1
  107. package/dist/persistence/documentTools.d.cts +5 -1
  108. package/dist/persistence/documentTools.d.ts +5 -1
  109. package/dist/persistence/editorAutosave.d.cts +7 -0
  110. package/dist/persistence/editorAutosave.d.ts +7 -0
  111. package/dist/persistence/index.cjs +141 -21
  112. package/dist/persistence/index.js +130 -10
  113. package/dist/persistence/storage.d.cts +13 -1
  114. package/dist/persistence/storage.d.ts +13 -1
  115. package/dist/spreadsheet/index.cjs +3 -3
  116. package/dist/spreadsheet/index.js +2 -2
  117. package/dist/tokens/index.cjs +11 -3
  118. package/dist/tokens/index.d.cts +1 -0
  119. package/dist/tokens/index.d.ts +1 -0
  120. package/dist/tokens/index.js +10 -2
  121. package/dist/tokens/style.d.cts +36 -0
  122. package/dist/tokens/style.d.ts +36 -0
  123. package/dist/tools/index.cjs +15 -3
  124. package/dist/tools/index.d.cts +2 -0
  125. package/dist/tools/index.d.ts +2 -0
  126. package/dist/tools/index.js +14 -2
  127. package/dist/tools/style-tools.d.cts +19 -0
  128. package/dist/tools/style-tools.d.ts +19 -0
  129. package/dist/tools/style.d.cts +212 -0
  130. package/dist/tools/style.d.ts +212 -0
  131. package/dist/tools/view.d.cts +6 -0
  132. package/dist/tools/view.d.ts +6 -0
  133. package/dist/typography/index.cjs +8 -6
  134. package/dist/typography/index.js +5 -3
  135. package/dist/vector/index.cjs +953 -952
  136. package/dist/vector/index.js +7 -6
  137. package/dist/video-editor/index.cjs +8 -7
  138. package/dist/video-editor/index.js +6 -5
  139. package/package.json +1 -1
  140. package/dist/chunk-ERAGQL2N.cjs +0 -68
  141. package/dist/chunk-KMU6QJB7.js +0 -68
@@ -1,11 +1,15 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
2
 
3
- var _chunkM4MIZPQIcjs = require('./chunk-M4MIZPQI.cjs');
3
+ var _chunkSJ2CPTQCcjs = require('./chunk-SJ2CPTQC.cjs');
4
4
 
5
5
 
6
6
 
7
7
  var _chunkA6QWKBJPcjs = require('./chunk-A6QWKBJP.cjs');
8
8
 
9
+
10
+
11
+ var _chunk5UEFBM2Mcjs = require('./chunk-5UEFBM2M.cjs');
12
+
9
13
  // src/tokens/types.ts
10
14
  var TOKEN_TYPES = ["color", "number", "string", "boolean"];
11
15
  var TokenError = class extends Error {
@@ -1275,7 +1279,7 @@ function importW3CTokens(state, input, options = {}) {
1275
1279
 
1276
1280
  // src/tokens/editorDocument.ts
1277
1281
  function createTokensEditorDocument(store) {
1278
- return _chunkM4MIZPQIcjs.defineEditorDocument.call(void 0, {
1282
+ return _chunkSJ2CPTQCcjs.defineEditorDocument.call(void 0, {
1279
1283
  kind: "tokens",
1280
1284
  get: () => store.toJSON(),
1281
1285
  load: (document, { history }) => {
@@ -1307,6 +1311,160 @@ function createTokensEditorDocument(store) {
1307
1311
  });
1308
1312
  }
1309
1313
 
1314
+ // src/tokens/style.ts
1315
+ function findVariable(state, ref) {
1316
+ return _nullishCoalesce(getTokenVariable(state, ref), () => ( findTokenVariable(state, ref)));
1317
+ }
1318
+ function createTokenStyleSource(store) {
1319
+ return {
1320
+ resolve({ token, mode }) {
1321
+ const state = store.getState();
1322
+ const variable = findVariable(state, token);
1323
+ if (!variable) return { ok: false, message: `there is no design token "${token}".` };
1324
+ let modes;
1325
+ if (mode !== void 0) {
1326
+ const collection = getTokenCollection(state, variable.collectionId);
1327
+ const found = findTokenMode(collection, mode);
1328
+ if (!found) return { ok: false, message: `"${collection.name}" has no mode "${mode}"; its modes are ${collection.modes.map((m) => `"${m.name}"`).join(", ")}.` };
1329
+ modes = { [collection.id]: found.id };
1330
+ }
1331
+ const resolved = resolveToken(state, variable.id, modes);
1332
+ return resolved.ok ? { ok: true, value: resolved.value } : { ok: false, message: `"${token}" does not resolve: ${resolved.message}` };
1333
+ },
1334
+ subscribe: (listener) => store.subscribe(() => listener())
1335
+ };
1336
+ }
1337
+ var profileOf = (profile) => profile;
1338
+ var requiredVariables = {
1339
+ id: "required-variables",
1340
+ description: `Every variable named in the profile's "required" list exists.`,
1341
+ run(state, profile) {
1342
+ const required = profileOf(profile).required;
1343
+ if (!_optionalChain([required, 'optionalAccess', _23 => _23.length])) throw new Error('the profile has no "required" list.');
1344
+ return required.filter((name) => !findVariable(state, name)).map((name) => ({ severity: "error", message: `The token set has no variable "${name}"; add it (house style requires it).`, target: { variable: name } }));
1345
+ }
1346
+ };
1347
+ var namePattern = {
1348
+ id: "name-pattern",
1349
+ description: `Every variable name matches the profile's "namePattern" regular expression.`,
1350
+ run(state, profile) {
1351
+ const pattern = profileOf(profile).namePattern;
1352
+ if (!pattern) throw new Error('the profile has no "namePattern".');
1353
+ let re;
1354
+ try {
1355
+ re = new RegExp(pattern);
1356
+ } catch (e4) {
1357
+ throw new Error(`"namePattern" ${pattern} is not a valid regular expression.`);
1358
+ }
1359
+ return state.variables.filter((v) => !re.test(v.name)).map((v) => ({ severity: "warning", message: `Variable "${v.name}" does not match the naming pattern ${pattern}; rename it.`, target: { variableId: v.id } }));
1360
+ }
1361
+ };
1362
+ var requiredModes = {
1363
+ id: "required-modes",
1364
+ description: `Every collection has the modes named in the profile's "modes" list (e.g. Light and Dark).`,
1365
+ run(state, profile) {
1366
+ const modes = profileOf(profile).modes;
1367
+ if (!_optionalChain([modes, 'optionalAccess', _24 => _24.length])) throw new Error('the profile has no "modes" list.');
1368
+ return state.collections.flatMap(
1369
+ (c) => modes.filter((m) => !findTokenMode(c, m)).map((m) => ({ severity: "error", message: `Collection "${c.name}" has no "${m}" mode; add it.`, target: { collectionId: c.id } }))
1370
+ );
1371
+ }
1372
+ };
1373
+ var contrastPairs = {
1374
+ id: "contrast-pairs",
1375
+ description: `Each foreground / background pair in "contrastPairs" reaches its contrast ratio (default 4.5) in every mode of the foreground's collection.`,
1376
+ run(state, profile) {
1377
+ const pairs = profileOf(profile).contrastPairs;
1378
+ if (!_optionalChain([pairs, 'optionalAccess', _25 => _25.length])) throw new Error('the profile has no "contrastPairs".');
1379
+ const findings = [];
1380
+ for (const { fg, bg, ratio = 4.5 } of pairs) {
1381
+ const f = findVariable(state, fg);
1382
+ const b = findVariable(state, bg);
1383
+ if (!f || !b) {
1384
+ findings.push({ severity: "error", message: `Contrast pair ${fg} on ${bg} names a variable the token set lacks (${!f ? fg : bg}).`, target: { variable: !f ? fg : bg } });
1385
+ continue;
1386
+ }
1387
+ const collection = getTokenCollection(state, f.collectionId);
1388
+ for (const mode of collection.modes) {
1389
+ const modes = { [collection.id]: mode.id, [b.collectionId]: _nullishCoalesce(_optionalChain([findTokenMode, 'call', _26 => _26(getTokenCollection(state, b.collectionId), mode.name), 'optionalAccess', _27 => _27.id]), () => ( mode.id)) };
1390
+ const fv = resolveToken(state, f.id, modes);
1391
+ const bv = resolveToken(state, b.id, modes);
1392
+ const fc = fv.ok && typeof fv.value === "string" ? _chunk5UEFBM2Mcjs.parseColor.call(void 0, fv.value) : null;
1393
+ const bc = bv.ok && typeof bv.value === "string" ? _chunk5UEFBM2Mcjs.parseColor.call(void 0, bv.value) : null;
1394
+ if (!fc || !bc) continue;
1395
+ const r = _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, fc, bc);
1396
+ if (r < ratio) {
1397
+ findings.push({
1398
+ severity: "error",
1399
+ message: `${f.name} on ${b.name} has contrast ${Math.round(r * 100) / 100}:1 in ${mode.name}; want at least ${ratio}:1, so darken or lighten one of them in that mode.`,
1400
+ target: { variableId: f.id, modeId: mode.id }
1401
+ });
1402
+ }
1403
+ }
1404
+ }
1405
+ return findings;
1406
+ }
1407
+ };
1408
+ var tokensStyleDomain = {
1409
+ id: "tokens",
1410
+ title: "Design tokens",
1411
+ description: "Rules for the token set itself: variables that must exist, a naming pattern, required modes and colour pairs that must reach a contrast ratio.",
1412
+ profileSchema: {
1413
+ type: "object",
1414
+ properties: {
1415
+ required: { type: "array", items: { type: "string", minLength: 1 }, description: 'Variable names that must exist, e.g. "brand/primary".' },
1416
+ namePattern: { type: "string", minLength: 1, description: 'Regular expression every variable name must match, e.g. "^[a-z0-9-]+(/[a-z0-9-]+)*$".' },
1417
+ modes: { type: "array", items: { type: "string", minLength: 1 }, description: 'Mode names every collection must have, e.g. ["Light", "Dark"].' },
1418
+ contrastPairs: {
1419
+ type: "array",
1420
+ items: {
1421
+ type: "object",
1422
+ properties: {
1423
+ fg: { type: "string", minLength: 1, description: "Foreground variable name or id." },
1424
+ bg: { type: "string", minLength: 1, description: "Background variable name or id." },
1425
+ ratio: { type: "number", minimum: 1, maximum: 21, description: "Smallest contrast ratio (default 4.5, WCAG AA for text)." }
1426
+ },
1427
+ required: ["fg", "bg"],
1428
+ additionalProperties: false
1429
+ },
1430
+ description: "Colour pairs checked in every mode."
1431
+ }
1432
+ },
1433
+ additionalProperties: false
1434
+ },
1435
+ checks: [requiredVariables, namePattern, requiredModes, contrastPairs]
1436
+ };
1437
+ function createTokensStyleToolProvider(store, styles, options = {}) {
1438
+ if (!styles.domains.some((d) => d.id === "tokens")) throw new Error('The style resolver has no "tokens" domain; add tokensStyleDomain to its domains.');
1439
+ const check = {
1440
+ name: "check_tokens_style",
1441
+ title: "Check token house style",
1442
+ description: 'Checks the design-token set against the house style (see get_style with domain "tokens"): runs the checks its profile turns on (required-variables, name-pattern, required-modes, contrast-pairs). Returns findings with a severity, a sentence saying how to fix it, a target (variable id or name, mode id, collection id) and the layer that asked for it; plus the checks that ran and the ones skipped with the reason. Fix findings with get_tokens_document / load_tokens_document, then check again.',
1443
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
1444
+ annotations: { title: "Check token house style", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1445
+ handler: async () => {
1446
+ const { style, ...report } = await styles.check("tokens", store.getState());
1447
+ return {
1448
+ ...report,
1449
+ ok: report.findings.length === 0,
1450
+ ...style.skills.length ? {} : { note: "No house style applies to design tokens." },
1451
+ ...style.issues.length ? { issues: style.issues } : {}
1452
+ };
1453
+ }
1454
+ };
1455
+ return {
1456
+ id: _nullishCoalesce(options.id, () => ( "tokens-style")),
1457
+ namespace: _nullishCoalesce(options.namespace, () => ( "tokens")),
1458
+ title: "Token house style",
1459
+ description: "Check the design-token set against the house style.",
1460
+ skill: "pixerate-tokens",
1461
+ tools: [check]
1462
+ };
1463
+ }
1464
+
1465
+
1466
+
1467
+
1310
1468
 
1311
1469
 
1312
1470
 
@@ -1361,4 +1519,4 @@ function createTokensEditorDocument(store) {
1361
1519
 
1362
1520
 
1363
1521
 
1364
- exports.TOKEN_TYPES = TOKEN_TYPES; exports.TokenError = TokenError; exports.isTokenAlias = isTokenAlias; exports.EMPTY_TOKEN_STATE = EMPTY_TOKEN_STATE; exports.getTokenCollection = getTokenCollection; exports.getTokenVariable = getTokenVariable; exports.findTokenCollection = findTokenCollection; exports.findTokenVariable = findTokenVariable; exports.getCollectionVariables = getCollectionVariables; exports.getDefaultMode = getDefaultMode; exports.findTokenMode = findTokenMode; exports.getCurrentMode = getCurrentMode; exports.defaultTokenValue = defaultTokenValue; exports.coerceTokenLiteral = coerceTokenLiteral; exports.literalTokenType = literalTokenType; exports.formatTokenValue = formatTokenValue; exports.resolveToken = resolveToken; exports.resolveTokenValue = resolveTokenValue; exports.resolveTokenInMode = resolveTokenInMode; exports.checkTokenAlias = checkTokenAlias; exports.TOKEN_SCOPES_BY_TYPE = TOKEN_SCOPES_BY_TYPE; exports.isTokenScopeKnown = isTokenScopeKnown; exports.normalizeTokenScopes = normalizeTokenScopes; exports.isTokenInScope = isTokenInScope; exports.normalizeTokenName = normalizeTokenName; exports.defaultTokenId = defaultTokenId; exports.createTokenCollection = createTokenCollection; exports.renameTokenCollection = renameTokenCollection; exports.deleteTokenVariables = deleteTokenVariables; exports.deleteTokenCollection = deleteTokenCollection; exports.addTokenMode = addTokenMode; exports.renameTokenMode = renameTokenMode; exports.removeTokenMode = removeTokenMode; exports.moveTokenMode = moveTokenMode; exports.prepareTokenValue = prepareTokenValue; exports.createTokenVariable = createTokenVariable; exports.setTokenValue = setTokenValue; exports.renameTokenVariable = renameTokenVariable; exports.updateTokenVariable = updateTokenVariable; exports.parseTokenState = parseTokenState; exports.TokenStore = TokenStore; exports.createTokenStore = createTokenStore; exports.tokenSlug = tokenSlug; exports.getTokenCssName = getTokenCssName; exports.cssString = cssString; exports.formatTokenCssValue = formatTokenCssValue; exports.exportTokensCss = exportTokensCss; exports.getTokenCssVariables = getTokenCssVariables; exports.W3C_TOKENS_EXTENSION = W3C_TOKENS_EXTENSION; exports.exportW3CTokens = exportW3CTokens; exports.exportW3CTokensJson = exportW3CTokensJson; exports.importW3CTokens = importW3CTokens; exports.createTokensEditorDocument = createTokensEditorDocument;
1522
+ exports.TOKEN_TYPES = TOKEN_TYPES; exports.TokenError = TokenError; exports.isTokenAlias = isTokenAlias; exports.EMPTY_TOKEN_STATE = EMPTY_TOKEN_STATE; exports.getTokenCollection = getTokenCollection; exports.getTokenVariable = getTokenVariable; exports.findTokenCollection = findTokenCollection; exports.findTokenVariable = findTokenVariable; exports.getCollectionVariables = getCollectionVariables; exports.getDefaultMode = getDefaultMode; exports.findTokenMode = findTokenMode; exports.getCurrentMode = getCurrentMode; exports.defaultTokenValue = defaultTokenValue; exports.coerceTokenLiteral = coerceTokenLiteral; exports.literalTokenType = literalTokenType; exports.formatTokenValue = formatTokenValue; exports.resolveToken = resolveToken; exports.resolveTokenValue = resolveTokenValue; exports.resolveTokenInMode = resolveTokenInMode; exports.checkTokenAlias = checkTokenAlias; exports.TOKEN_SCOPES_BY_TYPE = TOKEN_SCOPES_BY_TYPE; exports.isTokenScopeKnown = isTokenScopeKnown; exports.normalizeTokenScopes = normalizeTokenScopes; exports.isTokenInScope = isTokenInScope; exports.normalizeTokenName = normalizeTokenName; exports.defaultTokenId = defaultTokenId; exports.createTokenCollection = createTokenCollection; exports.renameTokenCollection = renameTokenCollection; exports.deleteTokenVariables = deleteTokenVariables; exports.deleteTokenCollection = deleteTokenCollection; exports.addTokenMode = addTokenMode; exports.renameTokenMode = renameTokenMode; exports.removeTokenMode = removeTokenMode; exports.moveTokenMode = moveTokenMode; exports.prepareTokenValue = prepareTokenValue; exports.createTokenVariable = createTokenVariable; exports.setTokenValue = setTokenValue; exports.renameTokenVariable = renameTokenVariable; exports.updateTokenVariable = updateTokenVariable; exports.parseTokenState = parseTokenState; exports.TokenStore = TokenStore; exports.createTokenStore = createTokenStore; exports.tokenSlug = tokenSlug; exports.getTokenCssName = getTokenCssName; exports.cssString = cssString; exports.formatTokenCssValue = formatTokenCssValue; exports.exportTokensCss = exportTokensCss; exports.getTokenCssVariables = getTokenCssVariables; exports.W3C_TOKENS_EXTENSION = W3C_TOKENS_EXTENSION; exports.exportW3CTokens = exportW3CTokens; exports.exportW3CTokensJson = exportW3CTokensJson; exports.importW3CTokens = importW3CTokens; exports.createTokensEditorDocument = createTokensEditorDocument; exports.createTokenStyleSource = createTokenStyleSource; exports.tokensStyleDomain = tokensStyleDomain; exports.createTokensStyleToolProvider = createTokensStyleToolProvider;
@@ -12,7 +12,7 @@ import {
12
12
  chartTreeTotal,
13
13
  chartVariesColors,
14
14
  shadeChartColor
15
- } from "./chunk-3NEZJCBY.js";
15
+ } from "./chunk-2ZRN43IN.js";
16
16
  import {
17
17
  NumberFormat
18
18
  } from "./chunk-II2WIF5Z.js";
@@ -948,7 +948,7 @@ function drawCallouts(ctx, plot) {
948
948
  }
949
949
  if (unplaced) ctx.warn("annotations-skipped", `${unplaced} callout${unplaced === 1 ? " points" : "s point"} at a gap or a hidden value and ${unplaced === 1 ? "is" : "are"} not drawn.`);
950
950
  }
951
- var MUTED = /* @__PURE__ */ new Set(["bar", "line", "area", "point", "slice", "cell", "box", "whisker", "outlier", "connector", "trendline", "trendline-label", "error-bar", "data-label", "legend-swatch", "legend-label"]);
951
+ var MUTED = /* @__PURE__ */ new Set(["node", "bar", "line", "area", "point", "slice", "cell", "box", "whisker", "outlier", "connector", "trendline", "trendline-label", "error-bar", "data-label", "legend-swatch", "legend-label"]);
952
952
  function applyHighlight(ctx) {
953
953
  const { spec, marks } = ctx;
954
954
  if (!spec.highlight.length) return;
@@ -2349,11 +2349,103 @@ function layoutSunburst(ctx, area, series) {
2349
2349
  }
2350
2350
  return { plot };
2351
2351
  }
2352
+ function layoutSankey(ctx, area, series) {
2353
+ const { spec, theme, marks, fs, measure } = ctx;
2354
+ const nodes = spec.sankeyNodes;
2355
+ const links = spec.links;
2356
+ const at = new Map(nodes.map((n, i) => [n, i]));
2357
+ const incoming = nodes.map(() => []);
2358
+ const outgoing = nodes.map(() => []);
2359
+ links.forEach((l, k) => {
2360
+ outgoing[at.get(l.source)].push(k);
2361
+ incoming[at.get(l.target)].push(k);
2362
+ });
2363
+ const column = nodes.map(() => -1);
2364
+ const depth = (i) => {
2365
+ if (column[i] >= 0) return column[i];
2366
+ column[i] = 0;
2367
+ column[i] = incoming[i].reduce((d, k) => Math.max(d, depth(at.get(links[k].source)) + 1), 0);
2368
+ return column[i];
2369
+ };
2370
+ nodes.forEach((_, i) => depth(i));
2371
+ const last = Math.max(...column);
2372
+ nodes.forEach((_, i) => {
2373
+ if (!outgoing[i].length) column[i] = last;
2374
+ });
2375
+ const value = series?.values.map((v) => v ?? 0) ?? nodes.map(() => 0);
2376
+ const nodeW = Math.max(6, Math.min(16, area.width * 0.02));
2377
+ const gap = last > 0 ? (area.width - nodeW) / last : 0;
2378
+ const xOf = (c) => last > 0 ? area.x + c * gap : area.x + area.width / 2 - nodeW / 2;
2379
+ const columns = Array.from({ length: last + 1 }, (_, c) => nodes.map((_2, i) => i).filter((i) => column[i] === c));
2380
+ const pad = Math.max(4, Math.min(fs * 1.2, area.height / Math.max(1, Math.max(...columns.map((c) => c.length))) / 3));
2381
+ const ky = Math.min(...columns.filter((c) => c.length).map((c) => (area.height - pad * (c.length - 1)) / Math.max(1e-9, c.reduce((t, i) => t + value[i], 0))));
2382
+ const top = nodes.map(() => 0);
2383
+ for (const col of columns) {
2384
+ const used = col.reduce((t, i) => t + value[i] * ky, 0) + pad * Math.max(0, col.length - 1);
2385
+ let y = area.y + (area.height - used) / 2;
2386
+ for (const i of col) {
2387
+ top[i] = y;
2388
+ y += value[i] * ky + pad;
2389
+ }
2390
+ }
2391
+ const color = (i) => series?.pointColors?.[i] || chartSliceColor(spec, i);
2392
+ const named = new Set(spec.highlight);
2393
+ const lit = nodes.map((n) => named.has(n));
2394
+ const dimLinks = lit.some(Boolean);
2395
+ const outOffset = nodes.map(() => 0);
2396
+ const inOffset = nodes.map(() => 0);
2397
+ const startY = /* @__PURE__ */ new Map();
2398
+ const endY = /* @__PURE__ */ new Map();
2399
+ nodes.forEach((_, i) => {
2400
+ for (const k of [...outgoing[i]].sort((a, b) => top[at.get(links[a].target)] - top[at.get(links[b].target)])) {
2401
+ startY.set(k, top[i] + outOffset[i]);
2402
+ outOffset[i] += links[k].value * ky;
2403
+ }
2404
+ for (const k of [...incoming[i]].sort((a, b) => top[at.get(links[a].source)] - top[at.get(links[b].source)])) {
2405
+ endY.set(k, top[i] + inOffset[i]);
2406
+ inOffset[i] += links[k].value * ky;
2407
+ }
2408
+ });
2409
+ const selectedNode = (i) => ctx.isSelected({ kind: "category", index: i }) || ctx.isSelected({ kind: "point", seriesId: series?.id ?? "", index: i });
2410
+ links.forEach((l, k) => {
2411
+ const s = at.get(l.source);
2412
+ const t = at.get(l.target);
2413
+ const w = l.value * ky;
2414
+ const x0 = xOf(column[s]) + nodeW;
2415
+ const x1 = xOf(column[t]);
2416
+ const y0 = startY.get(k);
2417
+ const y1 = endY.get(k);
2418
+ const xm = (x0 + x1) / 2;
2419
+ const d = `M${r2(x0)},${r2(y0)}C${r2(xm)},${r2(y0)} ${r2(xm)},${r2(y1)} ${r2(x1)},${r2(y1)}L${r2(x1)},${r2(y1 + w)}C${r2(xm)},${r2(y1 + w)} ${r2(xm)},${r2(y0 + w)} ${r2(x0)},${r2(y0 + w)}Z`;
2420
+ const fill = l.color ?? (spec.sankeyLinkColor === "gray" ? theme.mutedText : color(spec.sankeyLinkColor === "target" ? t : s));
2421
+ const emphasis = selectedNode(s) || selectedNode(t) ? 0.6 : 0.35;
2422
+ const opacity = dimLinks && !lit[s] && !lit[t] ? emphasis * 0.25 : emphasis;
2423
+ marks.push({ kind: "path", key: `link-${k}`, role: "link", d, fill, opacity });
2424
+ });
2425
+ const labelsOn = series?.dataLabels ?? spec.dataLabels;
2426
+ const format = series?.format ?? spec.yAxis.format;
2427
+ let hidden = 0;
2428
+ nodes.forEach((name, i) => {
2429
+ const x = xOf(column[i]);
2430
+ const h = Math.max(1, value[i] * ky);
2431
+ const target = { kind: "category", index: i };
2432
+ const selected = selectedNode(i);
2433
+ marks.push({ kind: "rect", key: `node-${i}`, role: "node", x, y: top[i], width: nodeW, height: h, fill: color(i), radius: 1, ...selected ? { stroke: theme.selection, strokeWidth: 2 } : {}, target, selected });
2434
+ const text = labelsOn ? `${name} ${formatChartNumber(value[i], format)}` : name;
2435
+ const room = (last > 0 ? gap : area.width / 2) - nodeW - 10;
2436
+ const shown = truncate(text, Math.max(fs * 2, room), fs, measure);
2437
+ if (shown !== text) hidden++;
2438
+ const right = column[i] < last || last === 0;
2439
+ marks.push({ kind: "text", key: `label-node-${i}`, role: "data-label", x: right ? x + nodeW + 5 : x - 5, y: top[i] + h / 2, text: shown, anchor: right ? "start" : "end", baseline: "middle", size: fs, weight: selected ? 600 : void 0, fill: selected ? theme.selection : theme.text, target, selected });
2440
+ });
2441
+ if (hidden) ctx.warn("labels-truncated", `${hidden} node label${hidden === 1 ? " was" : "s were"} shortened to fit between the columns.`);
2442
+ return { plot: area };
2443
+ }
2352
2444
 
2353
2445
  // src/chart/layout.ts
2354
2446
  function legendItems(spec, ctx) {
2355
2447
  const family = chartFamily(spec);
2356
- if (spec.type === "funnel" || spec.type === "slope") return [];
2448
+ if (spec.type === "funnel" || spec.type === "slope" || spec.type === "sankey") return [];
2357
2449
  if (chartSpecColorsByCategory(spec)) {
2358
2450
  const first = spec.series.find((s) => !s.hidden);
2359
2451
  const seats = (i) => Math.max(0, Math.round(first?.values[i] ?? 0));
@@ -2493,6 +2585,12 @@ function layoutChart(spec, options) {
2493
2585
  return finish(layoutFunnel(ctx, area, visible[0]));
2494
2586
  case "treemap":
2495
2587
  return finish(spec.tree.length ? layoutTreemapTree(ctx, area, spec.series[0]) : layoutTreemap(ctx, area, visible[0]));
2588
+ case "sankey":
2589
+ if (!spec.links.length) {
2590
+ ctx.warn("type-fallback", "A Sankey diagram needs flows (set_chart_links); it is drawn as a bar chart until then.");
2591
+ return finish(layoutCartesian(ctx, area, visible));
2592
+ }
2593
+ return finish(layoutSankey(ctx, area, spec.series[0]));
2496
2594
  case "sunburst":
2497
2595
  return finish(layoutSunburst(ctx, area, spec.tree.length ? spec.series[0] : visible[0]));
2498
2596
  case "slope":
@@ -18,7 +18,7 @@ import {
18
18
  unionBounds,
19
19
  vectorGradientPoints,
20
20
  widthProfileAt
21
- } from "./chunk-SET6KJOP.js";
21
+ } from "./chunk-LPIKXPBM.js";
22
22
  import {
23
23
  segmentLength,
24
24
  segmentParamAtLength,
@@ -29,7 +29,7 @@ import {
29
29
  } from "./chunk-5UJHB3BW.js";
30
30
  import {
31
31
  mixColorsOklab
32
- } from "./chunk-BQWGN5WH.js";
32
+ } from "./chunk-M2TPMYJE.js";
33
33
 
34
34
  // src/vector/blend.ts
35
35
  var lerpN = (a, b, t) => a + (b - a) * t;
@@ -0,0 +1,164 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/diagram/source/lines.ts
2
+ var HEADER_PATTERNS = [
3
+ [/^\s*(flowchart|graph)(?:-elk)?\b/i, "flowchart"],
4
+ [/^\s*stateDiagram(?:-v2)?\b/i, "state"],
5
+ [/^\s*classDiagram(?:-v2)?\b/i, "class"],
6
+ [/^\s*erDiagram\b/i, "er"],
7
+ [/^\s*requirementDiagram\b/i, "requirement"],
8
+ [/^\s*mindmap\b/i, "mindmap"],
9
+ [/^\s*sequenceDiagram\b/i, "sequence"],
10
+ [/^\s*gantt\b/i, "gantt"],
11
+ [/^\s*pie\b/i, "pie"],
12
+ [/^\s*journey\b/i, "journey"],
13
+ [/^\s*timeline\b/i, "timeline"],
14
+ [/^\s*gitGraph\b/i, "gitGraph"],
15
+ [/^\s*C4(Context|Container|Component|Dynamic|Deployment)\b/, "c4"],
16
+ [/^\s*quadrantChart\b/i, "quadrant"],
17
+ [/^\s*sankey(?:-beta)?\b/i, "sankey"],
18
+ [/^\s*xychart(?:-beta)?\b/i, "xychart"],
19
+ [/^\s*block(?:-beta)?\b/i, "block"],
20
+ [/^\s*architecture(?:-beta)?\b/i, "architecture"],
21
+ [/^\s*packet(?:-beta)?\b/i, "packet"],
22
+ [/^\s*kanban\b/i, "kanban"],
23
+ [/^\s*radar(?:-beta)?\b/i, "radar"],
24
+ [/^\s*treemap(?:-beta)?\b/i, "treemap"],
25
+ [/^\s*info\b/i, "info"]
26
+ ];
27
+ function detectFamilyFromHeader(header) {
28
+ for (const [re, family] of HEADER_PATTERNS) {
29
+ if (re.test(header)) return family;
30
+ }
31
+ return "unknown";
32
+ }
33
+ function isCommentLine(line) {
34
+ const t = line.trim();
35
+ return t.startsWith("%%") && !t.startsWith("%%{");
36
+ }
37
+ function isDirectiveLine(line) {
38
+ return /^\s*%%\{.*\}%%\s*$/.test(line);
39
+ }
40
+ function splitSource(source) {
41
+ const eol = source.includes("\r\n") ? "\r\n" : "\n";
42
+ const rawLines = source.split(/\r\n|\n/);
43
+ let end = rawLines.length;
44
+ while (end > 0 && rawLines[end - 1].trim() === "") end--;
45
+ const trailingLines = rawLines.slice(end);
46
+ const trailing = trailingLines.length ? eol + trailingLines.join(eol) : "";
47
+ const lines = rawLines.slice(0, end);
48
+ const preambleLines = [];
49
+ let i = 0;
50
+ let frontmatter;
51
+ if (lines[0] !== void 0 && /^---\s*$/.test(lines[0])) {
52
+ preambleLines.push(lines[0]);
53
+ i = 1;
54
+ const fm = [];
55
+ while (i < lines.length && !/^---\s*$/.test(lines[i])) {
56
+ fm.push(lines[i]);
57
+ preambleLines.push(lines[i]);
58
+ i++;
59
+ }
60
+ if (i < lines.length) {
61
+ preambleLines.push(lines[i]);
62
+ i++;
63
+ }
64
+ frontmatter = parseSimpleYaml(fm);
65
+ }
66
+ while (i < lines.length) {
67
+ const line = lines[i];
68
+ if (line.trim() === "" || isDirectiveLine(line) || isCommentLine(line)) {
69
+ preambleLines.push(line);
70
+ i++;
71
+ continue;
72
+ }
73
+ break;
74
+ }
75
+ const headerIndex = i;
76
+ const header = _nullishCoalesce(lines[i], () => ( ""));
77
+ const bodyLines = lines.slice(i + 1);
78
+ return {
79
+ eol,
80
+ preamble: { lines: preambleLines, frontmatter },
81
+ header,
82
+ headerIndex,
83
+ bodyLines,
84
+ trailing
85
+ };
86
+ }
87
+ function parseSimpleYaml(lines) {
88
+ const out = {};
89
+ let currentKey = null;
90
+ let nested = null;
91
+ for (const raw of lines) {
92
+ if (raw.trim() === "" || raw.trim().startsWith("#")) continue;
93
+ const indent = raw.length - raw.trimStart().length;
94
+ const m = /^([A-Za-z_][\w-]*)\s*:\s*(.*)$/.exec(raw.trim());
95
+ if (!m) continue;
96
+ const [, key, valueRaw] = m;
97
+ const value = parseYamlScalar(valueRaw);
98
+ if (indent === 0) {
99
+ currentKey = key;
100
+ if (valueRaw.trim() === "") {
101
+ nested = {};
102
+ out[key] = nested;
103
+ } else {
104
+ nested = null;
105
+ out[key] = value;
106
+ }
107
+ } else if (nested && currentKey) {
108
+ nested[key] = value;
109
+ }
110
+ }
111
+ return out;
112
+ }
113
+ function parseYamlScalar(v) {
114
+ const t = v.trim();
115
+ if (t === "") return "";
116
+ if (t.startsWith("{") || t.startsWith("[")) {
117
+ try {
118
+ return JSON.parse(t);
119
+ } catch (e) {
120
+ return t;
121
+ }
122
+ }
123
+ if (/^(true|false)$/i.test(t)) return t.toLowerCase() === "true";
124
+ if (/^-?\d+(\.\d+)?$/.test(t)) return Number(t);
125
+ if (t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'")) {
126
+ return t.slice(1, -1);
127
+ }
128
+ return t;
129
+ }
130
+ function splitStatements(line) {
131
+ const parts = [];
132
+ let depth = 0;
133
+ let quote = null;
134
+ let cur = "";
135
+ for (let i = 0; i < line.length; i++) {
136
+ const ch = line[i];
137
+ if (quote) {
138
+ cur += ch;
139
+ if (ch === quote) quote = null;
140
+ continue;
141
+ }
142
+ if (ch === '"' || ch === "`") {
143
+ quote = ch;
144
+ cur += ch;
145
+ continue;
146
+ }
147
+ if (ch === "[" || ch === "(" || ch === "{") depth++;
148
+ else if (ch === "]" || ch === ")" || ch === "}") depth = Math.max(0, depth - 1);
149
+ if (ch === ";" && depth === 0) {
150
+ parts.push(cur);
151
+ cur = "";
152
+ continue;
153
+ }
154
+ cur += ch;
155
+ }
156
+ parts.push(cur);
157
+ return parts;
158
+ }
159
+
160
+
161
+
162
+
163
+
164
+ exports.detectFamilyFromHeader = detectFamilyFromHeader; exports.splitSource = splitSource; exports.splitStatements = splitStatements;
@@ -5,14 +5,14 @@ import {
5
5
  chartToMermaid,
6
6
  describeChart,
7
7
  layoutSparkline
8
- } from "./chunk-SZA42R4N.js";
8
+ } from "./chunk-FRBRLKNQ.js";
9
9
  import {
10
10
  layoutChart
11
- } from "./chunk-Z4P2RBMJ.js";
11
+ } from "./chunk-V5GSY3NC.js";
12
12
  import {
13
13
  DEFAULT_CHART_THEME,
14
14
  normalizeChartSpec
15
- } from "./chunk-3NEZJCBY.js";
15
+ } from "./chunk-2ZRN43IN.js";
16
16
  import {
17
17
  plainTextToSlice
18
18
  } from "./chunk-2INPJDNY.js";