@riboseinc/anafero-cli 0.0.67 → 0.0.68

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/bootstrap.js CHANGED
@@ -69144,6 +69144,11 @@ schema (${ast._tag}): ${ast}`;
69144
69144
  version: Literal4("0.1"),
69145
69145
  /** The entry point, path to XML of a Metanorma document or collection. */
69146
69146
  entryPoint: String$2.pipe(nonEmptyString3()),
69147
+ /**
69148
+ * Workspace title.
69149
+ * If not provided, “document ID • document title” is used.
69150
+ */
69151
+ workspaceTitle: String$2.pipe(nonEmptyString3()).pipe(optional2),
69147
69152
  /**
69148
69153
  * Which reader modules to use.
69149
69154
  *
@@ -72101,7 +72106,88 @@ schema (${ast._tag}): ${ast}`;
72101
72106
  throw new Error("Requested key does not exist");
72102
72107
  }
72103
72108
  },
72104
- dump: () => cache
72109
+ dump: async (stream2, signal) => {
72110
+ async function* buildKeypaths(obj, currentPath, seen, paths2, signal2) {
72111
+ if (signal2.aborted) {
72112
+ throw new Error("Aborted");
72113
+ }
72114
+ for (const key of Object.keys(Object(obj))) {
72115
+ const val = obj[key];
72116
+ if (typeof val === "string" || Object.keys(Object(val)).length === 0) {
72117
+ yield [...currentPath, key];
72118
+ } else {
72119
+ const complexVal = val;
72120
+ if (!seen.has(complexVal)) {
72121
+ seen.add(complexVal);
72122
+ yield* buildKeypaths(
72123
+ complexVal,
72124
+ [...currentPath, key],
72125
+ seen,
72126
+ paths2,
72127
+ signal2
72128
+ );
72129
+ }
72130
+ }
72131
+ }
72132
+ }
72133
+ async function write(data, end) {
72134
+ return new Promise((resolve) => {
72135
+ if (end) {
72136
+ stream2.end(data, function() {
72137
+ resolve();
72138
+ });
72139
+ } else {
72140
+ stream2.write(data, function() {
72141
+ resolve();
72142
+ });
72143
+ }
72144
+ });
72145
+ }
72146
+ function serializeKeypath(idx2, keyPaths) {
72147
+ const keyPath = keyPaths[idx2];
72148
+ if (keyPath) {
72149
+ const keyString = keyPath.join(".");
72150
+ keyPath.reverse();
72151
+ let valueCursor = cache;
72152
+ while (true) {
72153
+ let part = keyPath.pop();
72154
+ if (part) {
72155
+ valueCursor = valueCursor[part];
72156
+ } else {
72157
+ break;
72158
+ }
72159
+ }
72160
+ return `
72161
+ ${JSON.stringify(keyString)}: ${valueCursor}`;
72162
+ } else {
72163
+ return null;
72164
+ }
72165
+ }
72166
+ const pathGen = buildKeypaths(cache, [], /* @__PURE__ */ new Set(), [], signal);
72167
+ const paths = [];
72168
+ for await (const p of pathGen) {
72169
+ paths.push(p);
72170
+ }
72171
+ await write(`
72172
+ -- starting dumping ${paths.length} paths --`);
72173
+ let idx = 0;
72174
+ const chunkSize = 1e3;
72175
+ let chunk3 = "";
72176
+ while (true) {
72177
+ if (idx > 0 && idx % chunkSize === 0) {
72178
+ await write(chunk3);
72179
+ chunk3 = "";
72180
+ }
72181
+ const nextItem = serializeKeypath(idx, paths);
72182
+ if (nextItem) {
72183
+ chunk3 = chunk3 + nextItem;
72184
+ } else {
72185
+ break;
72186
+ }
72187
+ idx += 1;
72188
+ }
72189
+ return;
72190
+ }
72105
72191
  };
72106
72192
  }
72107
72193
  var init_cache = __esm({