@cerefox/memory 0.9.1 → 0.9.2

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.
@@ -7184,7 +7184,7 @@ var exports_meta = {};
7184
7184
  __export(exports_meta, {
7185
7185
  PKG_VERSION: () => PKG_VERSION
7186
7186
  });
7187
- var PKG_VERSION = "0.9.1";
7187
+ var PKG_VERSION = "0.9.2";
7188
7188
  var init_meta = () => {};
7189
7189
 
7190
7190
  // ../../node_modules/.bun/tslib@2.8.1/node_modules/tslib/tslib.js
@@ -40005,106 +40005,173 @@ init_cli_core();
40005
40005
  import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
40006
40006
  import { homedir as homedir3 } from "node:os";
40007
40007
  import { join as join3 } from "node:path";
40008
- function collectCompletionInfo() {
40008
+ function isHidden(cmd) {
40009
+ return Boolean(cmd._hidden);
40010
+ }
40011
+ function visibleSubs(cmd) {
40012
+ return cmd.commands.filter((c2) => c2.name() !== "help" && !isHidden(c2));
40013
+ }
40014
+ function longFlags(cmd) {
40015
+ const flags = [];
40016
+ for (const opt of cmd.options) {
40017
+ if (opt.long)
40018
+ flags.push(opt.long);
40019
+ }
40020
+ return flags;
40021
+ }
40022
+ function collectNodes() {
40009
40023
  const program2 = buildProgram();
40010
- const subcommands = [];
40011
- for (const cmd of program2.commands) {
40012
- if (cmd.name() === "help")
40013
- continue;
40014
- const flags = [];
40015
- for (const opt of cmd.options) {
40016
- const long = opt.long;
40017
- if (long)
40018
- flags.push(long);
40019
- }
40020
- flags.push("--help");
40021
- subcommands.push({ name: cmd.name(), flags });
40022
- }
40023
- subcommands.sort((a, b) => a.name.localeCompare(b.name));
40024
- return { subcommands };
40025
- }
40026
- function bashScript(info2) {
40027
- const cmdNames = info2.subcommands.map((s) => s.name).join(" ");
40028
- const cases = info2.subcommands.map((s) => ` ${s.name})
40029
- opts="${s.flags.join(" ")}"
40030
- ;;`).join(`
40024
+ const nodes = [];
40025
+ const walk = (cmd, path) => {
40026
+ const subs = visibleSubs(cmd);
40027
+ const candidates = [...subs.map((s) => s.name()), ...longFlags(cmd), "--help"];
40028
+ nodes.push({ path, candidates });
40029
+ for (const s of subs) {
40030
+ walk(s, path === "" ? s.name() : `${path} ${s.name()}`);
40031
+ }
40032
+ };
40033
+ walk(program2, "");
40034
+ nodes.sort((a, b) => a.path.localeCompare(b.path));
40035
+ return nodes;
40036
+ }
40037
+ function bashScript(nodes) {
40038
+ const candCases = nodes.map((n) => ` "${n.path}") echo "${n.candidates.join(" ")}" ;;`).join(`
40031
40039
  `);
40040
+ const pathPatterns = nodes.filter((n) => n.path !== "").map((n) => `"${n.path}"`).join("|");
40032
40041
  return `# Cerefox bash completion. Source from ~/.bashrc:
40033
40042
  # source <(cerefox completion bash)
40034
40043
  #
40044
+ _cerefox_candidates() {
40045
+ case "$1" in
40046
+ ${candCases}
40047
+ *) echo "--help" ;;
40048
+ esac
40049
+ }
40050
+ _cerefox_is_path() {
40051
+ case "$1" in
40052
+ ${pathPatterns}) return 0 ;;
40053
+ *) return 1 ;;
40054
+ esac
40055
+ }
40035
40056
  _cerefox_completion() {
40036
- local cur prev cmd opts
40057
+ local cur path trial w i
40037
40058
  COMPREPLY=()
40038
40059
  cur="\${COMP_WORDS[COMP_CWORD]}"
40039
- cmd="\${COMP_WORDS[1]}"
40040
- if [ "\${COMP_CWORD}" -eq 1 ]; then
40041
- opts="${cmdNames}"
40042
- COMPREPLY=( $(compgen -W "\${opts}" -- "\${cur}") )
40043
- return 0
40044
- fi
40045
- case "\${cmd}" in
40046
- ${cases}
40047
- *)
40048
- opts="--help"
40049
- ;;
40050
- esac
40051
- COMPREPLY=( $(compgen -W "\${opts}" -- "\${cur}") )
40060
+ path=""
40061
+ i=1
40062
+ while [ "$i" -lt "\${COMP_CWORD}" ]; do
40063
+ w="\${COMP_WORDS[$i]}"
40064
+ case "$w" in -*) break ;; esac
40065
+ if [ -z "$path" ]; then trial="$w"; else trial="$path $w"; fi
40066
+ if _cerefox_is_path "$trial"; then
40067
+ path="$trial"; i=$((i + 1))
40068
+ else
40069
+ break
40070
+ fi
40071
+ done
40072
+ COMPREPLY=( $(compgen -W "$(_cerefox_candidates "$path")" -- "$cur") )
40052
40073
  return 0
40053
40074
  }
40054
40075
  complete -F _cerefox_completion cerefox
40055
40076
  `;
40056
40077
  }
40057
- function zshScript(info2) {
40058
- const cmdNames = info2.subcommands.map((s) => `'${s.name}'`).join(" ");
40059
- const cases = info2.subcommands.map((s) => {
40060
- const flagList = s.flags.map((f) => `'${f}'`).join(" ");
40061
- return ` ${s.name}) flags=(${flagList}) ;;`;
40062
- }).join(`
40078
+ function zshScript(nodes) {
40079
+ const candCases = nodes.map((n) => ` "${n.path}") REPLY="${n.candidates.join(" ")}" ;;`).join(`
40063
40080
  `);
40081
+ const pathPatterns = nodes.filter((n) => n.path !== "").map((n) => `"${n.path}"`).join("|");
40064
40082
  return `#compdef cerefox
40065
40083
  # Cerefox zsh completion. Save and source from ~/.zshrc:
40066
40084
  # source <(cerefox completion zsh)
40067
40085
  #
40068
- _cerefox() {
40069
- local -a cmds flags
40070
- cmds=(${cmdNames})
40071
- if (( CURRENT == 2 )); then
40072
- _values 'cerefox subcommand' $cmds
40073
- return
40074
- fi
40075
- case "$words[2]" in
40076
- ${cases}
40077
- *) flags=() ;;
40086
+ _cerefox_candidates() {
40087
+ case "$1" in
40088
+ ${candCases}
40089
+ *) REPLY="--help" ;;
40090
+ esac
40091
+ }
40092
+ _cerefox_is_path() {
40093
+ case "$1" in
40094
+ ${pathPatterns}) return 0 ;;
40095
+ *) return 1 ;;
40078
40096
  esac
40079
- _values 'flag' $flags
40097
+ }
40098
+ _cerefox() {
40099
+ local path trial w i REPLY
40100
+ path=""
40101
+ i=2
40102
+ while (( i < CURRENT )); do
40103
+ w="\${words[i]}"
40104
+ case "$w" in -*) break ;; esac
40105
+ if [[ -z "$path" ]]; then trial="$w"; else trial="$path $w"; fi
40106
+ if _cerefox_is_path "$trial"; then
40107
+ path="$trial"; (( i++ ))
40108
+ else
40109
+ break
40110
+ fi
40111
+ done
40112
+ _cerefox_candidates "$path"
40113
+ compadd -- \${=REPLY}
40080
40114
  }
40081
40115
  compdef _cerefox cerefox
40082
40116
  `;
40083
40117
  }
40084
- function fishScript(info2) {
40085
- const lines = [
40086
- "# Cerefox fish completion. Save to ~/.config/fish/completions/cerefox.fish",
40087
- ""
40088
- ];
40089
- for (const sub of info2.subcommands) {
40090
- lines.push(`complete -c cerefox -n '__fish_use_subcommand' -a '${sub.name}'`);
40091
- for (const flag of sub.flags) {
40092
- lines.push(`complete -c cerefox -n '__fish_seen_subcommand_from ${sub.name}' -l '${flag.replace(/^--/, "")}'`);
40093
- }
40094
- }
40095
- return lines.join(`
40096
- `) + `
40118
+ function fishScript(nodes) {
40119
+ const candCases = nodes.map((n) => ` case "${n.path}"
40120
+ echo "${n.candidates.join(" ")}"`).join(`
40121
+ `);
40122
+ const pathList = nodes.filter((n) => n.path !== "").map((n) => `"${n.path}"`).join(" ");
40123
+ return `# Cerefox fish completion. Save to ~/.config/fish/completions/cerefox.fish
40124
+ function __cerefox_candidates
40125
+ switch "$argv[1]"
40126
+ ${candCases}
40127
+ case '*'
40128
+ echo "--help"
40129
+ end
40130
+ end
40131
+ function __cerefox_is_path
40132
+ for p in ${pathList}
40133
+ if test "$argv[1]" = "$p"
40134
+ return 0
40135
+ end
40136
+ end
40137
+ return 1
40138
+ end
40139
+ function __cerefox_complete
40140
+ set -l tokens (commandline -opc)
40141
+ set -l path ""
40142
+ set -l i 2
40143
+ while test $i -le (count $tokens)
40144
+ set -l w $tokens[$i]
40145
+ if string match -q -- '-*' $w
40146
+ break
40147
+ end
40148
+ set -l trial
40149
+ if test -z "$path"
40150
+ set trial $w
40151
+ else
40152
+ set trial "$path $w"
40153
+ end
40154
+ if __cerefox_is_path "$trial"
40155
+ set path "$trial"
40156
+ set i (math $i + 1)
40157
+ else
40158
+ break
40159
+ end
40160
+ end
40161
+ string split ' ' -- (__cerefox_candidates "$path")
40162
+ end
40163
+ complete -c cerefox -f -a '(__cerefox_complete)'
40097
40164
  `;
40098
40165
  }
40099
40166
  function scriptFor(shell) {
40100
- const info2 = collectCompletionInfo();
40167
+ const nodes = collectNodes();
40101
40168
  switch (shell) {
40102
40169
  case "bash":
40103
- return bashScript(info2);
40170
+ return bashScript(nodes);
40104
40171
  case "zsh":
40105
- return zshScript(info2);
40172
+ return zshScript(nodes);
40106
40173
  case "fish":
40107
- return fishScript(info2);
40174
+ return fishScript(nodes);
40108
40175
  }
40109
40176
  }
40110
40177
  function detectShell() {
@@ -43118,13 +43185,13 @@ var restoreCursor = terminal ? onetime_default(() => {
43118
43185
  var restore_cursor_default = restoreCursor;
43119
43186
 
43120
43187
  // ../../node_modules/.bun/cli-cursor@5.0.0/node_modules/cli-cursor/index.js
43121
- var isHidden = false;
43188
+ var isHidden2 = false;
43122
43189
  var cliCursor = {};
43123
43190
  cliCursor.show = (writableStream = process5.stderr) => {
43124
43191
  if (!writableStream.isTTY) {
43125
43192
  return;
43126
43193
  }
43127
- isHidden = false;
43194
+ isHidden2 = false;
43128
43195
  writableStream.write("\x1B[?25h");
43129
43196
  };
43130
43197
  cliCursor.hide = (writableStream = process5.stderr) => {
@@ -43132,14 +43199,14 @@ cliCursor.hide = (writableStream = process5.stderr) => {
43132
43199
  return;
43133
43200
  }
43134
43201
  restore_cursor_default();
43135
- isHidden = true;
43202
+ isHidden2 = true;
43136
43203
  writableStream.write("\x1B[?25l");
43137
43204
  };
43138
43205
  cliCursor.toggle = (force, writableStream) => {
43139
43206
  if (force !== undefined) {
43140
- isHidden = force;
43207
+ isHidden2 = force;
43141
43208
  }
43142
- if (isHidden) {
43209
+ if (isHidden2) {
43143
43210
  cliCursor.show(writableStream);
43144
43211
  } else {
43145
43212
  cliCursor.hide(writableStream);