@datawheel/bespoke 0.1.29 → 0.1.30
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/index.js +14 -3
- package/dist/server.js +14 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1224,21 +1224,26 @@ var init_runConsumers = __esm({
|
|
|
1224
1224
|
getDependencies = (bid, blocks, acc = [], crawlUp = true, crawlDown = true, withinSection = true, visited = []) => {
|
|
1225
1225
|
if (visited.includes(bid))
|
|
1226
1226
|
return [];
|
|
1227
|
-
|
|
1227
|
+
if (crawlDown)
|
|
1228
|
+
visited.push(bid);
|
|
1229
|
+
if (verbose2)
|
|
1230
|
+
console.log("%cpassing through block", "color:green", bid);
|
|
1228
1231
|
const rootBlock = blocks[bid];
|
|
1229
1232
|
if (rootBlock.inputs.length && crawlUp) {
|
|
1230
1233
|
rootBlock.inputs.forEach((iid) => {
|
|
1231
1234
|
const rel = `${iid}-${bid}`;
|
|
1232
|
-
if (!acc.includes(rel))
|
|
1235
|
+
if (!acc.includes(rel)) {
|
|
1233
1236
|
acc.push(rel);
|
|
1237
|
+
}
|
|
1234
1238
|
rootBlock.inputs.forEach((iid2) => getDependencies(iid2, blocks, acc, crawlUp, false, withinSection, visited));
|
|
1235
1239
|
});
|
|
1236
1240
|
}
|
|
1237
1241
|
if (rootBlock.consumers.length && crawlDown) {
|
|
1238
1242
|
rootBlock.consumers.forEach((cid) => {
|
|
1239
1243
|
const rel = `${bid}-${cid}`;
|
|
1240
|
-
if (!acc.includes(rel) && (blocks[cid].section_id === blocks[bid].section_id || !withinSection))
|
|
1244
|
+
if (!acc.includes(rel) && (blocks[cid].section_id === blocks[bid].section_id || !withinSection)) {
|
|
1241
1245
|
acc.push(rel);
|
|
1246
|
+
}
|
|
1242
1247
|
rootBlock.consumers.filter((cid2) => blocks[cid2].section_id === blocks[bid].section_id || !withinSection).forEach((cid2) => getDependencies(cid2, blocks, acc, crawlUp, crawlDown, withinSection, visited));
|
|
1243
1248
|
});
|
|
1244
1249
|
}
|
|
@@ -1273,8 +1278,12 @@ var init_runConsumers = __esm({
|
|
|
1273
1278
|
const parsedBlockContext = parseBlockContext(blockContext);
|
|
1274
1279
|
const attributes = parsedBlockContext.variables;
|
|
1275
1280
|
const rootBlocks = bid ? { [bid]: blocks[bid] } : sections.reduce((rootBlocks2, { id }) => ({ ...rootBlocks2, ...getRootBlocksForSection_default(id, blocks) }), {});
|
|
1281
|
+
if (verbose2)
|
|
1282
|
+
console.log("%crunConsumers: running root blocks", "color:blue", Object.keys(rootBlocks));
|
|
1276
1283
|
const withinSection = mode === "section";
|
|
1277
1284
|
const blockDeps = Object.keys(rootBlocks).reduce((deps, id) => {
|
|
1285
|
+
if (verbose2)
|
|
1286
|
+
console.log("%cresolving dependencies for", "color:red", id);
|
|
1278
1287
|
const dependencies = getDependencies(Number(id), blocks, [], !bid, true, withinSection).map((rel) => rel.split("-"));
|
|
1279
1288
|
return [...deps, ...dependencies];
|
|
1280
1289
|
}, []);
|
|
@@ -1282,6 +1291,8 @@ var init_runConsumers = __esm({
|
|
|
1282
1291
|
(orderedDAG2, bid2) => orderedDAG2.includes(bid2) ? [...orderedDAG2] : [bid2, ...orderedDAG2],
|
|
1283
1292
|
toposort(blockDeps)
|
|
1284
1293
|
);
|
|
1294
|
+
if (verbose2)
|
|
1295
|
+
console.log("resolved DAG: ", orderedDAG);
|
|
1285
1296
|
async function runTasksInParallel(executionOrder, blocks2) {
|
|
1286
1297
|
const runningBlocks = /* @__PURE__ */ new Map();
|
|
1287
1298
|
for (const bid2 of executionOrder) {
|
package/dist/server.js
CHANGED
|
@@ -4818,21 +4818,26 @@ async function runSingleBlock(block, formatterFunctions, blockContext, readMembe
|
|
|
4818
4818
|
var getDependencies = (bid, blocks, acc = [], crawlUp = true, crawlDown2 = true, withinSection = true, visited = []) => {
|
|
4819
4819
|
if (visited.includes(bid))
|
|
4820
4820
|
return [];
|
|
4821
|
-
|
|
4821
|
+
if (crawlDown2)
|
|
4822
|
+
visited.push(bid);
|
|
4823
|
+
if (verbose7)
|
|
4824
|
+
console.log("%cpassing through block", "color:green", bid);
|
|
4822
4825
|
const rootBlock = blocks[bid];
|
|
4823
4826
|
if (rootBlock.inputs.length && crawlUp) {
|
|
4824
4827
|
rootBlock.inputs.forEach((iid) => {
|
|
4825
4828
|
const rel = `${iid}-${bid}`;
|
|
4826
|
-
if (!acc.includes(rel))
|
|
4829
|
+
if (!acc.includes(rel)) {
|
|
4827
4830
|
acc.push(rel);
|
|
4831
|
+
}
|
|
4828
4832
|
rootBlock.inputs.forEach((iid2) => getDependencies(iid2, blocks, acc, crawlUp, false, withinSection, visited));
|
|
4829
4833
|
});
|
|
4830
4834
|
}
|
|
4831
4835
|
if (rootBlock.consumers.length && crawlDown2) {
|
|
4832
4836
|
rootBlock.consumers.forEach((cid) => {
|
|
4833
4837
|
const rel = `${bid}-${cid}`;
|
|
4834
|
-
if (!acc.includes(rel) && (blocks[cid].section_id === blocks[bid].section_id || !withinSection))
|
|
4838
|
+
if (!acc.includes(rel) && (blocks[cid].section_id === blocks[bid].section_id || !withinSection)) {
|
|
4835
4839
|
acc.push(rel);
|
|
4840
|
+
}
|
|
4836
4841
|
rootBlock.consumers.filter((cid2) => blocks[cid2].section_id === blocks[bid].section_id || !withinSection).forEach((cid2) => getDependencies(cid2, blocks, acc, crawlUp, crawlDown2, withinSection, visited));
|
|
4837
4842
|
});
|
|
4838
4843
|
}
|
|
@@ -4867,8 +4872,12 @@ var runConsumersV2 = async (blocks, sections, bid, formatterFunctions, blockCont
|
|
|
4867
4872
|
const parsedBlockContext = parseBlockContext(blockContext);
|
|
4868
4873
|
const attributes = parsedBlockContext.variables;
|
|
4869
4874
|
const rootBlocks = bid ? { [bid]: blocks[bid] } : sections.reduce((rootBlocks2, { id }) => ({ ...rootBlocks2, ...getRootBlocksForSection_default(id, blocks) }), {});
|
|
4875
|
+
if (verbose7)
|
|
4876
|
+
console.log("%crunConsumers: running root blocks", "color:blue", Object.keys(rootBlocks));
|
|
4870
4877
|
const withinSection = mode === "section";
|
|
4871
4878
|
const blockDeps = Object.keys(rootBlocks).reduce((deps, id) => {
|
|
4879
|
+
if (verbose7)
|
|
4880
|
+
console.log("%cresolving dependencies for", "color:red", id);
|
|
4872
4881
|
const dependencies = getDependencies(Number(id), blocks, [], !bid, true, withinSection).map((rel) => rel.split("-"));
|
|
4873
4882
|
return [...deps, ...dependencies];
|
|
4874
4883
|
}, []);
|
|
@@ -4876,6 +4885,8 @@ var runConsumersV2 = async (blocks, sections, bid, formatterFunctions, blockCont
|
|
|
4876
4885
|
(orderedDAG2, bid2) => orderedDAG2.includes(bid2) ? [...orderedDAG2] : [bid2, ...orderedDAG2],
|
|
4877
4886
|
toposort(blockDeps)
|
|
4878
4887
|
);
|
|
4888
|
+
if (verbose7)
|
|
4889
|
+
console.log("resolved DAG: ", orderedDAG);
|
|
4879
4890
|
async function runTasksInParallel(executionOrder, blocks2) {
|
|
4880
4891
|
const runningBlocks = /* @__PURE__ */ new Map();
|
|
4881
4892
|
for (const bid2 of executionOrder) {
|