kaabalah 6.4.4 → 6.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/dist/{chunk-EVH4J5E2.mjs → chunk-BKNWKD32.mjs} +364 -23
- package/dist/chunk-BKNWKD32.mjs.map +1 -0
- package/dist/{chunk-EMTVK46M.js → chunk-SW5O2BJI.js} +364 -22
- package/dist/chunk-SW5O2BJI.js.map +1 -0
- package/dist/cli.js +535 -27
- package/dist/cli.js.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -7
- package/dist/index.mjs +1 -1
- package/dist/visual/index.d.mts +116 -1
- package/dist/visual/index.d.ts +116 -1
- package/dist/visual/index.js +11 -7
- package/dist/visual/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-EMTVK46M.js.map +0 -1
- package/dist/chunk-EVH4J5E2.mjs.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -8932,7 +8932,7 @@ var import_config3 = require("dotenv/config");
|
|
|
8932
8932
|
// package.json
|
|
8933
8933
|
var package_default = {
|
|
8934
8934
|
name: "kaabalah",
|
|
8935
|
-
version: "6.
|
|
8935
|
+
version: "6.5.0",
|
|
8936
8936
|
description: "The de-facto library for any esoteric calculations and tooling",
|
|
8937
8937
|
engines: {
|
|
8938
8938
|
node: ">=18.18.0"
|
|
@@ -9215,11 +9215,20 @@ var COMMANDS = [
|
|
|
9215
9215
|
args: [],
|
|
9216
9216
|
flags: [
|
|
9217
9217
|
{ name: "system", type: "string", default: "kaabalah", description: "Tree system: kaabalah, hermetic-qabalah, lurianic-kabbalah" },
|
|
9218
|
-
{ name: "units", type: "string", default: "both", description: "Coordinate space: percentages, viewBoxUnits, or both" }
|
|
9218
|
+
{ name: "units", type: "string", default: "both", description: "Coordinate space: percentages, viewBoxUnits, or both" },
|
|
9219
|
+
{ name: "render-model", type: "boolean", default: false, description: "Return activation-aware render model geometry instead of the basic layout" },
|
|
9220
|
+
{ name: "activations", type: "string", description: "Path to activation JSON array or object with an activations array" },
|
|
9221
|
+
{ name: "palette", type: "string", default: "color", description: 'Render-model palette metadata: "color" or "monochrome"' },
|
|
9222
|
+
{ name: "daath-layer", type: "string", default: "front", description: 'Render-model Daath layer: "front" or "back"' },
|
|
9223
|
+
{ name: "viewbox-width", type: "number", description: "Override render-model viewBox width" },
|
|
9224
|
+
{ name: "viewbox-height", type: "number", description: "Override render-model viewBox height" },
|
|
9225
|
+
{ name: "viewbox-min-x", type: "number", default: 0, description: "Override render-model viewBox min-x" },
|
|
9226
|
+
{ name: "viewbox-min-y", type: "number", default: 0, description: "Override render-model viewBox min-y" }
|
|
9219
9227
|
],
|
|
9220
9228
|
examples: [
|
|
9221
9229
|
"kaabalah tree:layout --json --compact",
|
|
9222
|
-
"kaabalah tree:layout --system=hermetic-qabalah --units=percentages --json"
|
|
9230
|
+
"kaabalah tree:layout --system=hermetic-qabalah --units=percentages --json",
|
|
9231
|
+
"kaabalah tree:layout --render-model --activations=activations.json --json --compact"
|
|
9223
9232
|
]
|
|
9224
9233
|
},
|
|
9225
9234
|
{
|
|
@@ -9233,6 +9242,7 @@ var COMMANDS = [
|
|
|
9233
9242
|
{ name: "background", type: "string", default: "white", description: 'Background fill color, or "transparent"' },
|
|
9234
9243
|
{ name: "palette", type: "string", default: "color", description: 'Palette: "color" or "monochrome"' },
|
|
9235
9244
|
{ name: "daath-layer", type: "string", default: "front", description: 'Render Daath in front of or behind the paths: "front" or "back"' },
|
|
9245
|
+
{ name: "activations", type: "string", description: "Path to activation JSON array or object with an activations array" },
|
|
9236
9246
|
{ name: "output", type: "string", description: "Write the SVG to a file instead of stdout" },
|
|
9237
9247
|
{ name: "viewbox-width", type: "number", description: "Override SVG viewBox width" },
|
|
9238
9248
|
{ name: "viewbox-height", type: "number", description: "Override SVG viewBox height" },
|
|
@@ -9242,7 +9252,8 @@ var COMMANDS = [
|
|
|
9242
9252
|
examples: [
|
|
9243
9253
|
"kaabalah tree:svg --json --compact --fields=svg",
|
|
9244
9254
|
"kaabalah tree:svg --background=transparent --palette=monochrome --output=tree.svg --json",
|
|
9245
|
-
"kaabalah tree:svg --background=transparent --daath-layer=back --json --compact"
|
|
9255
|
+
"kaabalah tree:svg --background=transparent --daath-layer=back --json --compact",
|
|
9256
|
+
"kaabalah tree:svg --background=transparent --activations=activations.json --json --compact --fields=svg"
|
|
9246
9257
|
]
|
|
9247
9258
|
},
|
|
9248
9259
|
{
|
|
@@ -22906,6 +22917,9 @@ var DEFAULT_SPHERE_RADIUS = 30;
|
|
|
22906
22917
|
var DEFAULT_PATH_EDGE_WIDTH = 26;
|
|
22907
22918
|
var DEFAULT_PATH_MAIN_WIDTH = 22;
|
|
22908
22919
|
var DEFAULT_PATH_HIGHLIGHT_WIDTH = 8;
|
|
22920
|
+
var DEFAULT_SPHERE_HIT_RADIUS = DEFAULT_SPHERE_RADIUS + 8;
|
|
22921
|
+
var DEFAULT_PATH_HIT_STROKE_WIDTH = DEFAULT_PATH_EDGE_WIDTH + 8;
|
|
22922
|
+
var MUTED_TARGET_COLOR = "#AAA";
|
|
22909
22923
|
var sphereId = (name) => id("sphere" /* SPHERE */, name);
|
|
22910
22924
|
var pathId = (pathNumber) => id("path" /* PATH */, String(pathNumber));
|
|
22911
22925
|
var TREE_SPHERE_IDS = TREE_SPHERE_NAMES.map(
|
|
@@ -22943,6 +22957,155 @@ function getTreeLayout(system = "kaabalah") {
|
|
|
22943
22957
|
viewBoxUnits
|
|
22944
22958
|
};
|
|
22945
22959
|
}
|
|
22960
|
+
function getTreeRenderModel(options = {}) {
|
|
22961
|
+
const system = options.system ?? "kaabalah";
|
|
22962
|
+
const tree = createTree({ system, parts: ["colors"] });
|
|
22963
|
+
const viewBox = normalizeViewBox(options.viewBox);
|
|
22964
|
+
const palette = resolvePalette(options.palette);
|
|
22965
|
+
const highlights = resolveHighlights(options.highlights);
|
|
22966
|
+
const activationMap = resolveActivationMap(options.activations);
|
|
22967
|
+
const layout = getTreeLayout(system);
|
|
22968
|
+
const spherePositions = scaleCoordinates(CANONICAL_SPHERE_PERCENTAGES, viewBox);
|
|
22969
|
+
const viewBoxLayout = buildLayoutMap(tree, spherePositions);
|
|
22970
|
+
const scale = Math.min(
|
|
22971
|
+
viewBox.width / TREE_SVG_DEFAULT_VIEWBOX.width,
|
|
22972
|
+
viewBox.height / TREE_SVG_DEFAULT_VIEWBOX.height
|
|
22973
|
+
);
|
|
22974
|
+
const radius = round(DEFAULT_SPHERE_RADIUS * scale);
|
|
22975
|
+
const pathEdgeWidth = round(DEFAULT_PATH_EDGE_WIDTH * scale);
|
|
22976
|
+
const pathMainWidth = round(DEFAULT_PATH_MAIN_WIDTH * scale);
|
|
22977
|
+
const pathHighlightWidth = round(DEFAULT_PATH_HIGHLIGHT_WIDTH * scale);
|
|
22978
|
+
const sphereHitRadius = round(DEFAULT_SPHERE_HIT_RADIUS * scale);
|
|
22979
|
+
const pathHitStrokeWidth = round(DEFAULT_PATH_HIT_STROKE_WIDTH * scale);
|
|
22980
|
+
const layers = [
|
|
22981
|
+
{ name: "background", order: 0, description: "Background rectangle when requested." },
|
|
22982
|
+
...options.daathLayer === "back" ? [{ name: "spheres-behind-paths", order: 1, description: "Daath behind the paths." }] : [],
|
|
22983
|
+
{ name: "paths", order: options.daathLayer === "back" ? 2 : 1, description: "Canonical paths and activation emphasis." },
|
|
22984
|
+
{ name: "spheres", order: options.daathLayer === "back" ? 3 : 2, description: "Canonical sphere material and activation halos." },
|
|
22985
|
+
{ name: "hit-targets", order: options.daathLayer === "back" ? 4 : 3, description: "Invisible anchors for interaction." }
|
|
22986
|
+
];
|
|
22987
|
+
const layerOrder = layers.map((layer) => layer.name);
|
|
22988
|
+
const spheres = TREE_SPHERE_NAMES.map((sphereName) => {
|
|
22989
|
+
const sphereIdValue = sphereId(sphereName);
|
|
22990
|
+
const canonicalColor = resolveSphereCanonicalColor({
|
|
22991
|
+
palette,
|
|
22992
|
+
sphereId: sphereIdValue,
|
|
22993
|
+
tree
|
|
22994
|
+
});
|
|
22995
|
+
const point = spherePositions[sphereIdValue];
|
|
22996
|
+
const activation = resolveTargetActivation({
|
|
22997
|
+
activation: activationMap.get(sphereIdValue),
|
|
22998
|
+
canonicalColor
|
|
22999
|
+
});
|
|
23000
|
+
const activeFill = resolveSphereDisplayFill({
|
|
23001
|
+
palette,
|
|
23002
|
+
highlights,
|
|
23003
|
+
sphereId: sphereIdValue,
|
|
23004
|
+
canonicalColor,
|
|
23005
|
+
activation
|
|
23006
|
+
});
|
|
23007
|
+
return {
|
|
23008
|
+
id: sphereIdValue,
|
|
23009
|
+
name: sphereName,
|
|
23010
|
+
slug: sphereName.toLowerCase(),
|
|
23011
|
+
canonicalColor,
|
|
23012
|
+
geometry: {
|
|
23013
|
+
percentages: {
|
|
23014
|
+
center: { ...layout.percentages.spheres[sphereIdValue] },
|
|
23015
|
+
anchor: getPercentageAnchor(layout.percentages.spheres[sphereIdValue])
|
|
23016
|
+
},
|
|
23017
|
+
viewBoxUnits: {
|
|
23018
|
+
center: { ...point },
|
|
23019
|
+
anchor: getViewBoxAnchor(point, viewBox),
|
|
23020
|
+
hitTarget: {
|
|
23021
|
+
kind: "circle",
|
|
23022
|
+
cx: point.x,
|
|
23023
|
+
cy: point.y,
|
|
23024
|
+
r: sphereHitRadius
|
|
23025
|
+
}
|
|
23026
|
+
},
|
|
23027
|
+
radius: {
|
|
23028
|
+
viewBoxUnits: radius
|
|
23029
|
+
}
|
|
23030
|
+
},
|
|
23031
|
+
material: getSphereMaterial({
|
|
23032
|
+
sphereName,
|
|
23033
|
+
preserveSpecialMaterial: shouldPreserveSpecialRenderer({
|
|
23034
|
+
palette,
|
|
23035
|
+
highlights,
|
|
23036
|
+
hasPaintOverride: activation !== null || highlights.sphereFills[sphereIdValue] !== void 0,
|
|
23037
|
+
activation
|
|
23038
|
+
})
|
|
23039
|
+
}),
|
|
23040
|
+
activation,
|
|
23041
|
+
displayFill: activeFill
|
|
23042
|
+
};
|
|
23043
|
+
});
|
|
23044
|
+
const paths = TREE_PATH_IDS.map((pathIdValue) => {
|
|
23045
|
+
const canonicalColor = resolvePathCanonicalColor({
|
|
23046
|
+
palette,
|
|
23047
|
+
tree,
|
|
23048
|
+
pathId: pathIdValue
|
|
23049
|
+
});
|
|
23050
|
+
const path = viewBoxLayout.paths[pathIdValue];
|
|
23051
|
+
const activation = resolveTargetActivation({
|
|
23052
|
+
activation: activationMap.get(pathIdValue),
|
|
23053
|
+
canonicalColor
|
|
23054
|
+
});
|
|
23055
|
+
const displayColor = activation ? resolvePathDisplayColor({
|
|
23056
|
+
canonicalColor,
|
|
23057
|
+
activation
|
|
23058
|
+
}) : resolvePathBaseColor({
|
|
23059
|
+
canonicalColor,
|
|
23060
|
+
highlights,
|
|
23061
|
+
pathId: pathIdValue
|
|
23062
|
+
});
|
|
23063
|
+
return {
|
|
23064
|
+
id: pathIdValue,
|
|
23065
|
+
canonicalColor,
|
|
23066
|
+
geometry: {
|
|
23067
|
+
percentages: {
|
|
23068
|
+
from: { ...layout.percentages.paths[pathIdValue].from },
|
|
23069
|
+
to: { ...layout.percentages.paths[pathIdValue].to },
|
|
23070
|
+
anchor: getPercentagePathAnchor(layout.percentages.paths[pathIdValue])
|
|
23071
|
+
},
|
|
23072
|
+
viewBoxUnits: {
|
|
23073
|
+
from: { ...path.from },
|
|
23074
|
+
to: { ...path.to },
|
|
23075
|
+
anchor: getViewBoxPathAnchor(path, viewBox),
|
|
23076
|
+
hitTarget: {
|
|
23077
|
+
kind: "line",
|
|
23078
|
+
x1: path.from.x,
|
|
23079
|
+
y1: path.from.y,
|
|
23080
|
+
x2: path.to.x,
|
|
23081
|
+
y2: path.to.y,
|
|
23082
|
+
strokeWidth: pathHitStrokeWidth
|
|
23083
|
+
}
|
|
23084
|
+
},
|
|
23085
|
+
widths: {
|
|
23086
|
+
edge: pathEdgeWidth,
|
|
23087
|
+
main: pathMainWidth,
|
|
23088
|
+
highlight: pathHighlightWidth,
|
|
23089
|
+
hitTarget: pathHitStrokeWidth
|
|
23090
|
+
}
|
|
23091
|
+
},
|
|
23092
|
+
activation,
|
|
23093
|
+
displayColor
|
|
23094
|
+
};
|
|
23095
|
+
});
|
|
23096
|
+
return {
|
|
23097
|
+
system,
|
|
23098
|
+
viewBox,
|
|
23099
|
+
scale,
|
|
23100
|
+
layout,
|
|
23101
|
+
layerOrder,
|
|
23102
|
+
layers,
|
|
23103
|
+
spheres,
|
|
23104
|
+
paths,
|
|
23105
|
+
sphereById: Object.fromEntries(spheres.map((entry) => [entry.id, entry])),
|
|
23106
|
+
pathById: Object.fromEntries(paths.map((entry) => [entry.id, entry]))
|
|
23107
|
+
};
|
|
23108
|
+
}
|
|
22946
23109
|
function generateTreeSvg(options = {}) {
|
|
22947
23110
|
const system = options.system ?? "kaabalah";
|
|
22948
23111
|
const daathLayer = options.daathLayer ?? "front";
|
|
@@ -22950,6 +23113,7 @@ function generateTreeSvg(options = {}) {
|
|
|
22950
23113
|
const viewBox = normalizeViewBox(options.viewBox);
|
|
22951
23114
|
const palette = resolvePalette(options.palette);
|
|
22952
23115
|
const highlights = resolveHighlights(options.highlights);
|
|
23116
|
+
const activationMap = resolveActivationMap(options.activations);
|
|
22953
23117
|
const spherePositions = scaleCoordinates(CANONICAL_SPHERE_PERCENTAGES, viewBox);
|
|
22954
23118
|
const layout = buildLayoutMap(tree, spherePositions);
|
|
22955
23119
|
const scale = Math.min(
|
|
@@ -23027,6 +23191,14 @@ function generateTreeSvg(options = {}) {
|
|
|
23027
23191
|
push(`<g id="spheres-behind-paths">`);
|
|
23028
23192
|
renderSphere(push, {
|
|
23029
23193
|
highlights,
|
|
23194
|
+
activation: resolveTargetActivation({
|
|
23195
|
+
activation: activationMap.get(sphereId("Daath")),
|
|
23196
|
+
canonicalColor: resolveSphereCanonicalColor({
|
|
23197
|
+
palette,
|
|
23198
|
+
sphereId: sphereId("Daath"),
|
|
23199
|
+
tree
|
|
23200
|
+
})
|
|
23201
|
+
}),
|
|
23030
23202
|
tree,
|
|
23031
23203
|
palette,
|
|
23032
23204
|
radius,
|
|
@@ -23039,12 +23211,24 @@ function generateTreeSvg(options = {}) {
|
|
|
23039
23211
|
push(`<g id="paths">`);
|
|
23040
23212
|
for (const currentPathId of TREE_PATH_IDS) {
|
|
23041
23213
|
const path = layout.paths[currentPathId];
|
|
23042
|
-
const
|
|
23043
|
-
highlights,
|
|
23214
|
+
const canonicalColor = resolvePathCanonicalColor({
|
|
23044
23215
|
palette,
|
|
23045
23216
|
tree,
|
|
23046
23217
|
pathId: currentPathId
|
|
23047
23218
|
});
|
|
23219
|
+
const baseColor = resolvePathBaseColor({
|
|
23220
|
+
canonicalColor,
|
|
23221
|
+
highlights,
|
|
23222
|
+
pathId: currentPathId
|
|
23223
|
+
});
|
|
23224
|
+
const activation = resolveTargetActivation({
|
|
23225
|
+
activation: activationMap.get(currentPathId),
|
|
23226
|
+
canonicalColor
|
|
23227
|
+
});
|
|
23228
|
+
const color = activation ? resolvePathDisplayColor({
|
|
23229
|
+
canonicalColor,
|
|
23230
|
+
activation
|
|
23231
|
+
}) : baseColor;
|
|
23048
23232
|
const edgeColor = resolvePathEdgeColor({
|
|
23049
23233
|
palette,
|
|
23050
23234
|
pathColor: color
|
|
@@ -23052,6 +23236,11 @@ function generateTreeSvg(options = {}) {
|
|
|
23052
23236
|
push(
|
|
23053
23237
|
`<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(edgeColor)}" stroke-width="${pathEdgeWidth}" stroke-linecap="round"${palette.pathEdgeUseFilter ? ` filter="url(#pathDarken)"` : ""}/>`
|
|
23054
23238
|
);
|
|
23239
|
+
if (activation?.visible && activation.emphasis > 0) {
|
|
23240
|
+
push(
|
|
23241
|
+
`<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(color)}" stroke-opacity="${round(0.18 + activation.emphasis * 0.28)}" stroke-width="${round(pathEdgeWidth + activation.emphasis * 10)}" stroke-linecap="round"/>`
|
|
23242
|
+
);
|
|
23243
|
+
}
|
|
23055
23244
|
push(
|
|
23056
23245
|
`<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(color)}" stroke-width="${pathMainWidth}" stroke-linecap="round"/>`
|
|
23057
23246
|
);
|
|
@@ -23063,8 +23252,18 @@ function generateTreeSvg(options = {}) {
|
|
|
23063
23252
|
const frontSphereNames = daathLayer === "back" ? TREE_SPHERE_NAMES.filter((name) => name !== "Daath") : TREE_SPHERE_NAMES;
|
|
23064
23253
|
push(`<g id="spheres">`);
|
|
23065
23254
|
for (const sphereName of frontSphereNames) {
|
|
23255
|
+
const currentSphereId = sphereId(sphereName);
|
|
23256
|
+
const canonicalColor = resolveSphereCanonicalColor({
|
|
23257
|
+
palette,
|
|
23258
|
+
sphereId: currentSphereId,
|
|
23259
|
+
tree
|
|
23260
|
+
});
|
|
23066
23261
|
renderSphere(push, {
|
|
23067
23262
|
highlights,
|
|
23263
|
+
activation: resolveTargetActivation({
|
|
23264
|
+
activation: activationMap.get(currentSphereId),
|
|
23265
|
+
canonicalColor
|
|
23266
|
+
}),
|
|
23068
23267
|
tree,
|
|
23069
23268
|
palette,
|
|
23070
23269
|
radius,
|
|
@@ -23093,9 +23292,23 @@ function renderSphere(push, params) {
|
|
|
23093
23292
|
sphereId: currentSphereId,
|
|
23094
23293
|
defaultColors: colorData
|
|
23095
23294
|
});
|
|
23096
|
-
const
|
|
23097
|
-
const
|
|
23098
|
-
const
|
|
23295
|
+
const activationFill = params.activation && (params.activation.state === "inactive" || params.activation.colorOverride) ? params.activation.displayColor : void 0;
|
|
23296
|
+
const highlightFill = activationFill ?? params.highlights.sphereFills[currentSphereId];
|
|
23297
|
+
const activeFill = params.activation ? params.activation.displayColor : highlightFill ?? sphereFill;
|
|
23298
|
+
const preserveSpecialRenderer = shouldPreserveSpecialRenderer({
|
|
23299
|
+
palette: params.palette,
|
|
23300
|
+
highlights: params.highlights,
|
|
23301
|
+
hasPaintOverride: highlightFill !== void 0,
|
|
23302
|
+
activation: params.activation
|
|
23303
|
+
});
|
|
23304
|
+
if (params.activation?.visible && params.activation.emphasis > 0) {
|
|
23305
|
+
const haloStrokeWidth = round(3.2 + params.activation.emphasis * 4.8);
|
|
23306
|
+
const haloRadius = round(params.radius + haloStrokeWidth / 2 + 0.7);
|
|
23307
|
+
const haloColor = params.activation.displayColor;
|
|
23308
|
+
push(
|
|
23309
|
+
`<circle cx="${point.x}" cy="${point.y}" r="${haloRadius}" fill="none" stroke="${escapeAttr(haloColor)}" stroke-opacity="${round(0.24 + params.activation.emphasis * 0.28)}" stroke-width="${haloStrokeWidth}"/>`
|
|
23310
|
+
);
|
|
23311
|
+
}
|
|
23099
23312
|
push(`<g id="sphere-${slug}" clip-path="url(#clip-${slug})">`);
|
|
23100
23313
|
if (preserveSpecialRenderer) {
|
|
23101
23314
|
if (params.sphereName === "Kether") {
|
|
@@ -23199,6 +23412,160 @@ function normalizeViewBox(viewBox) {
|
|
|
23199
23412
|
height: viewBox?.height ?? TREE_SVG_DEFAULT_VIEWBOX.height
|
|
23200
23413
|
};
|
|
23201
23414
|
}
|
|
23415
|
+
function resolveActivationMap(activations) {
|
|
23416
|
+
const map = /* @__PURE__ */ new Map();
|
|
23417
|
+
for (const activation of activations ?? []) {
|
|
23418
|
+
map.set(activation.targetId, activation);
|
|
23419
|
+
}
|
|
23420
|
+
return map;
|
|
23421
|
+
}
|
|
23422
|
+
function resolveTargetActivation(params) {
|
|
23423
|
+
if (!params.activation) {
|
|
23424
|
+
return null;
|
|
23425
|
+
}
|
|
23426
|
+
const state = params.activation.state ?? (params.activation.count > 0 ? "active" : "inactive");
|
|
23427
|
+
const strength = clamp01(
|
|
23428
|
+
params.activation.strength ?? (params.activation.total > 0 ? params.activation.count / params.activation.total : 0)
|
|
23429
|
+
);
|
|
23430
|
+
const displayColor = state === "inactive" ? params.activation.color ?? MUTED_TARGET_COLOR : params.activation.color ?? params.canonicalColor;
|
|
23431
|
+
return {
|
|
23432
|
+
state,
|
|
23433
|
+
count: params.activation.count,
|
|
23434
|
+
total: params.activation.total,
|
|
23435
|
+
strength,
|
|
23436
|
+
canonicalColor: params.canonicalColor,
|
|
23437
|
+
displayColor,
|
|
23438
|
+
colorOverride: params.activation.color,
|
|
23439
|
+
mutedColor: MUTED_TARGET_COLOR,
|
|
23440
|
+
visible: state !== "inactive",
|
|
23441
|
+
emphasis: state === "selected" ? clamp01(Math.max(strength, 0.9)) : state === "hovered" ? clamp01(Math.max(strength, 0.72)) : state === "active" ? clamp01(Math.max(strength, 0.56)) : 0
|
|
23442
|
+
};
|
|
23443
|
+
}
|
|
23444
|
+
function resolveSphereCanonicalColor(params) {
|
|
23445
|
+
const override = params.palette.sphereFills[params.sphereId];
|
|
23446
|
+
if (override) {
|
|
23447
|
+
return toPrimaryFill(override, params.palette.defaultSphereFill);
|
|
23448
|
+
}
|
|
23449
|
+
if (params.palette.mode === "monochrome" || params.palette.mode === "custom") {
|
|
23450
|
+
return params.palette.defaultSphereFill;
|
|
23451
|
+
}
|
|
23452
|
+
const treeColor = params.tree.relatedFirst(params.sphereId, "color" /* COLOR */)?.data?.colorHexCodes?.[0];
|
|
23453
|
+
return treeColor ?? params.palette.defaultSphereFill;
|
|
23454
|
+
}
|
|
23455
|
+
function resolvePathCanonicalColor(params) {
|
|
23456
|
+
const override = params.palette.pathColors[params.pathId];
|
|
23457
|
+
if (override) {
|
|
23458
|
+
return override;
|
|
23459
|
+
}
|
|
23460
|
+
if (params.palette.mode === "monochrome" || params.palette.mode === "custom") {
|
|
23461
|
+
return params.palette.defaultPathColor;
|
|
23462
|
+
}
|
|
23463
|
+
const treeColor = params.tree.relatedFirst(params.pathId, "color" /* COLOR */)?.data?.colorHexCodes?.[0];
|
|
23464
|
+
return treeColor ?? params.palette.defaultPathColor;
|
|
23465
|
+
}
|
|
23466
|
+
function resolvePathBaseColor(params) {
|
|
23467
|
+
const highlightOverride = params.highlights.pathColors[params.pathId];
|
|
23468
|
+
if (highlightOverride) {
|
|
23469
|
+
return highlightOverride;
|
|
23470
|
+
}
|
|
23471
|
+
return params.canonicalColor;
|
|
23472
|
+
}
|
|
23473
|
+
function resolveSphereDisplayFill(params) {
|
|
23474
|
+
const highlightOverride = params.highlights.sphereFills[params.sphereId];
|
|
23475
|
+
const fallbackFill = Array.isArray(params.canonicalColor) ? params.canonicalColor[0] ?? params.palette.defaultSphereFill : params.canonicalColor;
|
|
23476
|
+
if (params.activation) {
|
|
23477
|
+
if (params.activation.state !== "inactive" && !params.activation.colorOverride) {
|
|
23478
|
+
return params.canonicalColor ?? fallbackFill;
|
|
23479
|
+
}
|
|
23480
|
+
return params.activation.displayColor;
|
|
23481
|
+
}
|
|
23482
|
+
if (highlightOverride) {
|
|
23483
|
+
return highlightOverride;
|
|
23484
|
+
}
|
|
23485
|
+
return params.canonicalColor ?? fallbackFill;
|
|
23486
|
+
}
|
|
23487
|
+
function resolvePathDisplayColor(params) {
|
|
23488
|
+
if (!params.activation) {
|
|
23489
|
+
return params.canonicalColor;
|
|
23490
|
+
}
|
|
23491
|
+
return params.activation.displayColor;
|
|
23492
|
+
}
|
|
23493
|
+
function getPercentageAnchor(point) {
|
|
23494
|
+
return {
|
|
23495
|
+
x: point.x,
|
|
23496
|
+
y: point.y,
|
|
23497
|
+
vertical: point.y < 18 ? "below" : "above"
|
|
23498
|
+
};
|
|
23499
|
+
}
|
|
23500
|
+
function getViewBoxAnchor(point, viewBox) {
|
|
23501
|
+
return {
|
|
23502
|
+
x: point.x,
|
|
23503
|
+
y: point.y,
|
|
23504
|
+
vertical: point.y - viewBox.minY < viewBox.height * 0.18 ? "below" : "above"
|
|
23505
|
+
};
|
|
23506
|
+
}
|
|
23507
|
+
function getPercentagePathAnchor(path) {
|
|
23508
|
+
const y = round((path.from.y + path.to.y) / 2);
|
|
23509
|
+
return {
|
|
23510
|
+
x: round((path.from.x + path.to.x) / 2),
|
|
23511
|
+
y,
|
|
23512
|
+
vertical: y < 18 ? "below" : "above"
|
|
23513
|
+
};
|
|
23514
|
+
}
|
|
23515
|
+
function getViewBoxPathAnchor(path, viewBox) {
|
|
23516
|
+
const y = round((path.from.y + path.to.y) / 2);
|
|
23517
|
+
return {
|
|
23518
|
+
x: round((path.from.x + path.to.x) / 2),
|
|
23519
|
+
y,
|
|
23520
|
+
vertical: y - viewBox.minY < viewBox.height * 0.18 ? "below" : "above"
|
|
23521
|
+
};
|
|
23522
|
+
}
|
|
23523
|
+
function shouldPreserveSpecialRenderer(params) {
|
|
23524
|
+
return params.palette.specialSphereMode === "preserve" && (params.activation !== null || !params.hasPaintOverride || params.highlights.specialSphereMode === "preserve");
|
|
23525
|
+
}
|
|
23526
|
+
function getSphereMaterial(params) {
|
|
23527
|
+
if (!params.preserveSpecialMaterial) {
|
|
23528
|
+
return {
|
|
23529
|
+
kind: "standard",
|
|
23530
|
+
preserveOnActivation: false
|
|
23531
|
+
};
|
|
23532
|
+
}
|
|
23533
|
+
if (params.sphereName === "Kether") {
|
|
23534
|
+
return {
|
|
23535
|
+
kind: "special",
|
|
23536
|
+
specialSphereName: "Kether",
|
|
23537
|
+
preserveOnActivation: true
|
|
23538
|
+
};
|
|
23539
|
+
}
|
|
23540
|
+
if (params.sphereName === "Chokhmah") {
|
|
23541
|
+
return {
|
|
23542
|
+
kind: "special",
|
|
23543
|
+
specialSphereName: "Chokhmah",
|
|
23544
|
+
preserveOnActivation: true
|
|
23545
|
+
};
|
|
23546
|
+
}
|
|
23547
|
+
if (params.sphereName === "Daath") {
|
|
23548
|
+
return {
|
|
23549
|
+
kind: "special",
|
|
23550
|
+
specialSphereName: "Daath",
|
|
23551
|
+
preserveOnActivation: true
|
|
23552
|
+
};
|
|
23553
|
+
}
|
|
23554
|
+
if (params.sphereName === "Malkuth") {
|
|
23555
|
+
return {
|
|
23556
|
+
kind: "special",
|
|
23557
|
+
specialSphereName: "Malkuth",
|
|
23558
|
+
preserveOnActivation: true
|
|
23559
|
+
};
|
|
23560
|
+
}
|
|
23561
|
+
return {
|
|
23562
|
+
kind: "standard",
|
|
23563
|
+
preserveOnActivation: false
|
|
23564
|
+
};
|
|
23565
|
+
}
|
|
23566
|
+
function clamp01(value) {
|
|
23567
|
+
return Math.max(0, Math.min(1, value));
|
|
23568
|
+
}
|
|
23202
23569
|
function resolvePalette(palette) {
|
|
23203
23570
|
if (palette === void 0 || palette === "color") {
|
|
23204
23571
|
return {
|
|
@@ -23252,21 +23619,6 @@ function resolveHighlights(highlights) {
|
|
|
23252
23619
|
specialSphereMode: highlights?.specialSphereMode ?? "preserve"
|
|
23253
23620
|
};
|
|
23254
23621
|
}
|
|
23255
|
-
function resolvePathColor(params) {
|
|
23256
|
-
const highlightOverride = params.highlights.pathColors[params.pathId];
|
|
23257
|
-
if (highlightOverride) {
|
|
23258
|
-
return highlightOverride;
|
|
23259
|
-
}
|
|
23260
|
-
const override = params.palette.pathColors[params.pathId];
|
|
23261
|
-
if (override) {
|
|
23262
|
-
return override;
|
|
23263
|
-
}
|
|
23264
|
-
if (params.palette.mode === "monochrome" || params.palette.mode === "custom") {
|
|
23265
|
-
return params.palette.defaultPathColor;
|
|
23266
|
-
}
|
|
23267
|
-
const treeColor = params.tree.relatedFirst(params.pathId, "color" /* COLOR */)?.data?.colorHexCodes?.[0];
|
|
23268
|
-
return treeColor ?? params.palette.defaultPathColor;
|
|
23269
|
-
}
|
|
23270
23622
|
function resolvePathEdgeColor(params) {
|
|
23271
23623
|
if (params.palette.mode === "color") {
|
|
23272
23624
|
return params.pathColor;
|
|
@@ -23595,6 +23947,20 @@ function serializeLayout(layout, units) {
|
|
|
23595
23947
|
}
|
|
23596
23948
|
return base;
|
|
23597
23949
|
}
|
|
23950
|
+
function serializeRenderModel(model) {
|
|
23951
|
+
return {
|
|
23952
|
+
system: model.system,
|
|
23953
|
+
viewBox: model.viewBox,
|
|
23954
|
+
scale: model.scale,
|
|
23955
|
+
layerOrder: model.layerOrder,
|
|
23956
|
+
layers: model.layers,
|
|
23957
|
+
layout: model.layout,
|
|
23958
|
+
spheres: model.spheres,
|
|
23959
|
+
paths: model.paths,
|
|
23960
|
+
sphereById: model.sphereById,
|
|
23961
|
+
pathById: model.pathById
|
|
23962
|
+
};
|
|
23963
|
+
}
|
|
23598
23964
|
function buildViewBox(flags) {
|
|
23599
23965
|
const width = getFlagNumber(flags, "viewbox-width");
|
|
23600
23966
|
const height = getFlagNumber(flags, "viewbox-height");
|
|
@@ -23617,6 +23983,97 @@ function buildViewBox(flags) {
|
|
|
23617
23983
|
height
|
|
23618
23984
|
};
|
|
23619
23985
|
}
|
|
23986
|
+
var TREE_SPHERE_ID_SET = new Set(TREE_SPHERE_IDS);
|
|
23987
|
+
var TREE_PATH_ID_SET = new Set(TREE_PATH_IDS);
|
|
23988
|
+
var TREE_TARGET_STATES = /* @__PURE__ */ new Set(["active", "hovered", "selected", "inactive"]);
|
|
23989
|
+
function readJsonFile(pathFlag, flags) {
|
|
23990
|
+
const filePath = (0, import_node_path2.resolve)(pathFlag);
|
|
23991
|
+
let raw;
|
|
23992
|
+
try {
|
|
23993
|
+
raw = (0, import_node_fs2.readFileSync)(filePath, "utf8");
|
|
23994
|
+
} catch (err) {
|
|
23995
|
+
exitWithError(
|
|
23996
|
+
"INVALID_ARGUMENT",
|
|
23997
|
+
`Could not read activations file "${filePath}": ${err instanceof Error ? err.message : String(err)}.`,
|
|
23998
|
+
flags
|
|
23999
|
+
);
|
|
24000
|
+
}
|
|
24001
|
+
try {
|
|
24002
|
+
return JSON.parse(raw);
|
|
24003
|
+
} catch {
|
|
24004
|
+
exitWithError(
|
|
24005
|
+
"INVALID_JSON",
|
|
24006
|
+
`Invalid JSON in activations file "${filePath}".`,
|
|
24007
|
+
flags
|
|
24008
|
+
);
|
|
24009
|
+
}
|
|
24010
|
+
}
|
|
24011
|
+
function validateActivationEntry(entry, index, flags) {
|
|
24012
|
+
const label = `activations[${index}]`;
|
|
24013
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
|
|
24014
|
+
exitWithError("INVALID_JSON", `${label} must be a JSON object.`, flags);
|
|
24015
|
+
}
|
|
24016
|
+
const raw = entry;
|
|
24017
|
+
const targetId = raw.targetId;
|
|
24018
|
+
const targetType = raw.targetType;
|
|
24019
|
+
const count = raw.count;
|
|
24020
|
+
const total = raw.total;
|
|
24021
|
+
const strength = raw.strength;
|
|
24022
|
+
const state = raw.state;
|
|
24023
|
+
const color = raw.color;
|
|
24024
|
+
if (typeof targetId !== "string" || !targetId) {
|
|
24025
|
+
exitWithError("INVALID_JSON", `${label}.targetId must be a non-empty string.`, flags);
|
|
24026
|
+
}
|
|
24027
|
+
if (targetType !== "sphere" && targetType !== "path") {
|
|
24028
|
+
exitWithError("INVALID_JSON", `${label}.targetType must be "sphere" or "path".`, flags);
|
|
24029
|
+
}
|
|
24030
|
+
if (targetType === "sphere" && !TREE_SPHERE_ID_SET.has(targetId)) {
|
|
24031
|
+
exitWithError("INVALID_ARGUMENT", `${label}.targetId "${targetId}" is not a known sphere target.`, flags);
|
|
24032
|
+
}
|
|
24033
|
+
if (targetType === "path" && !TREE_PATH_ID_SET.has(targetId)) {
|
|
24034
|
+
exitWithError("INVALID_ARGUMENT", `${label}.targetId "${targetId}" is not a known path target.`, flags);
|
|
24035
|
+
}
|
|
24036
|
+
if (!Number.isFinite(count) || typeof count !== "number" || count < 0) {
|
|
24037
|
+
exitWithError("INVALID_JSON", `${label}.count must be a non-negative number.`, flags);
|
|
24038
|
+
}
|
|
24039
|
+
if (!Number.isFinite(total) || typeof total !== "number" || total < 0) {
|
|
24040
|
+
exitWithError("INVALID_JSON", `${label}.total must be a non-negative number.`, flags);
|
|
24041
|
+
}
|
|
24042
|
+
if (strength !== void 0 && (typeof strength !== "number" || !Number.isFinite(strength) || strength < 0 || strength > 1)) {
|
|
24043
|
+
exitWithError("INVALID_JSON", `${label}.strength must be a number between 0 and 1.`, flags);
|
|
24044
|
+
}
|
|
24045
|
+
if (state !== void 0 && (typeof state !== "string" || !TREE_TARGET_STATES.has(state))) {
|
|
24046
|
+
exitWithError("INVALID_JSON", `${label}.state must be active, hovered, selected, or inactive.`, flags);
|
|
24047
|
+
}
|
|
24048
|
+
if (color !== void 0 && typeof color !== "string") {
|
|
24049
|
+
exitWithError("INVALID_JSON", `${label}.color must be a string when provided.`, flags);
|
|
24050
|
+
}
|
|
24051
|
+
return {
|
|
24052
|
+
targetId,
|
|
24053
|
+
targetType,
|
|
24054
|
+
count,
|
|
24055
|
+
total,
|
|
24056
|
+
...strength !== void 0 ? { strength } : {},
|
|
24057
|
+
...state !== void 0 ? { state } : {},
|
|
24058
|
+
...color !== void 0 ? { color } : {}
|
|
24059
|
+
};
|
|
24060
|
+
}
|
|
24061
|
+
function readActivations(flags) {
|
|
24062
|
+
const activationsPath = getFlagString(flags, "activations");
|
|
24063
|
+
if (!activationsPath) {
|
|
24064
|
+
return void 0;
|
|
24065
|
+
}
|
|
24066
|
+
const parsed = readJsonFile(activationsPath, flags);
|
|
24067
|
+
const payload = Array.isArray(parsed) ? parsed : typeof parsed === "object" && parsed !== null && Array.isArray(parsed.activations) ? parsed.activations : null;
|
|
24068
|
+
if (!payload) {
|
|
24069
|
+
exitWithError(
|
|
24070
|
+
"INVALID_JSON",
|
|
24071
|
+
'Activations file must be a JSON array or an object with an "activations" array.',
|
|
24072
|
+
flags
|
|
24073
|
+
);
|
|
24074
|
+
}
|
|
24075
|
+
return payload.map((entry, index) => validateActivationEntry(entry, index, flags));
|
|
24076
|
+
}
|
|
23620
24077
|
function buildSvgOptions(flags) {
|
|
23621
24078
|
const palette = getFlagString(flags, "palette");
|
|
23622
24079
|
if (palette && palette !== "color" && palette !== "monochrome") {
|
|
@@ -23641,7 +24098,33 @@ function buildSvgOptions(flags) {
|
|
|
23641
24098
|
background: getFlagString(flags, "background") ?? void 0,
|
|
23642
24099
|
palette: palette ?? void 0,
|
|
23643
24100
|
viewBox: buildViewBox(flags),
|
|
23644
|
-
daathLayer: daathLayer ?? void 0
|
|
24101
|
+
daathLayer: daathLayer ?? void 0,
|
|
24102
|
+
activations: readActivations(flags)
|
|
24103
|
+
};
|
|
24104
|
+
}
|
|
24105
|
+
function buildRenderModelOptions(flags) {
|
|
24106
|
+
const palette = getFlagString(flags, "palette");
|
|
24107
|
+
if (palette && palette !== "color" && palette !== "monochrome") {
|
|
24108
|
+
exitWithError(
|
|
24109
|
+
"INVALID_ARGUMENT",
|
|
24110
|
+
`Unknown SVG palette "${palette}". Expected "color" or "monochrome".`,
|
|
24111
|
+
flags
|
|
24112
|
+
);
|
|
24113
|
+
}
|
|
24114
|
+
const daathLayer = getFlagString(flags, "daath-layer");
|
|
24115
|
+
if (daathLayer && daathLayer !== "front" && daathLayer !== "back") {
|
|
24116
|
+
exitWithError(
|
|
24117
|
+
"INVALID_ARGUMENT",
|
|
24118
|
+
`Unknown Daath layer "${daathLayer}". Expected "front" or "back".`,
|
|
24119
|
+
flags
|
|
24120
|
+
);
|
|
24121
|
+
}
|
|
24122
|
+
return {
|
|
24123
|
+
system: resolveSystem(flags),
|
|
24124
|
+
palette: palette ?? void 0,
|
|
24125
|
+
viewBox: buildViewBox(flags),
|
|
24126
|
+
daathLayer: daathLayer ?? void 0,
|
|
24127
|
+
activations: readActivations(flags)
|
|
23645
24128
|
};
|
|
23646
24129
|
}
|
|
23647
24130
|
function renderAsciiTree(layout, columns, rows) {
|
|
@@ -23924,6 +24407,29 @@ Tree search
|
|
|
23924
24407
|
console.log();
|
|
23925
24408
|
}
|
|
23926
24409
|
function cmdTreeLayout(flags) {
|
|
24410
|
+
if (getFlagBool(flags, "render-model")) {
|
|
24411
|
+
const modelOptions = buildRenderModelOptions(flags);
|
|
24412
|
+
const model = getTreeRenderModel(modelOptions);
|
|
24413
|
+
const payload2 = serializeRenderModel(model);
|
|
24414
|
+
if (isJsonMode(flags)) {
|
|
24415
|
+
outputJson(payload2, flags);
|
|
24416
|
+
return;
|
|
24417
|
+
}
|
|
24418
|
+
console.log(`
|
|
24419
|
+
Tree render model (${model.system})
|
|
24420
|
+
`);
|
|
24421
|
+
console.log(
|
|
24422
|
+
` ViewBox: ${model.viewBox.minX} ${model.viewBox.minY} ${model.viewBox.width} ${model.viewBox.height}`
|
|
24423
|
+
);
|
|
24424
|
+
console.log(` Layers: ${model.layerOrder.join(" -> ")}`);
|
|
24425
|
+
console.log(` Spheres: ${model.spheres.length}`);
|
|
24426
|
+
console.log(` Paths: ${model.paths.length}`);
|
|
24427
|
+
console.log(
|
|
24428
|
+
` Activations: ${model.spheres.filter((sphere) => sphere.activation).length + model.paths.filter((path) => path.activation).length}
|
|
24429
|
+
`
|
|
24430
|
+
);
|
|
24431
|
+
return;
|
|
24432
|
+
}
|
|
23927
24433
|
const system = resolveSystem(flags);
|
|
23928
24434
|
const units = resolveLayoutUnits(flags);
|
|
23929
24435
|
const layout = getTreeLayout(system);
|
|
@@ -23970,7 +24476,8 @@ function cmdTreeSvg(flags) {
|
|
|
23970
24476
|
background: svgOptions.background ?? null,
|
|
23971
24477
|
palette: svgOptions.palette ?? "color",
|
|
23972
24478
|
viewBox: svgOptions.viewBox ?? null,
|
|
23973
|
-
daathLayer: svgOptions.daathLayer ?? "front"
|
|
24479
|
+
daathLayer: svgOptions.daathLayer ?? "front",
|
|
24480
|
+
activationCount: svgOptions.activations?.length ?? 0
|
|
23974
24481
|
}
|
|
23975
24482
|
},
|
|
23976
24483
|
flags
|
|
@@ -23984,7 +24491,8 @@ function cmdTreeSvg(flags) {
|
|
|
23984
24491
|
outputJson(
|
|
23985
24492
|
{
|
|
23986
24493
|
system,
|
|
23987
|
-
svg
|
|
24494
|
+
svg,
|
|
24495
|
+
activationCount: svgOptions.activations?.length ?? 0
|
|
23988
24496
|
},
|
|
23989
24497
|
flags
|
|
23990
24498
|
);
|