@ccusage/codex 18.0.2 → 18.0.3

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 (2) hide show
  1. package/dist/index.js +28 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  enumerable: true
32
32
  }) : target, mod));
33
33
  var __require$1 = /* @__PURE__ */ createRequire(import.meta.url);
34
- const DEFAULT_LOCALE$1 = "en-US";
34
+ const DEFAULT_LOCALE$2 = "en-US";
35
35
  const BUILT_IN_PREFIX = "_";
36
36
  const ARG_PREFIX = "arg";
37
37
  const BUILT_IN_KEY_SEPARATOR = ":";
@@ -180,18 +180,18 @@ async function createCommandContext({ args, values, positionals, rest, argv: arg
180
180
  const localeStr = locale.toString();
181
181
  const adapter = (cliOptions.translationAdapterFactory || createTranslationAdapter)({
182
182
  locale: localeStr,
183
- fallbackLocale: DEFAULT_LOCALE$1
183
+ fallbackLocale: DEFAULT_LOCALE$2
184
184
  });
185
185
  const localeResources = /* @__PURE__ */ new Map();
186
186
  let builtInLoadedResources;
187
- localeResources.set(DEFAULT_LOCALE$1, mapResourceWithBuiltinKey(en_US_default));
188
- if (DEFAULT_LOCALE$1 !== localeStr) try {
187
+ localeResources.set(DEFAULT_LOCALE$2, mapResourceWithBuiltinKey(en_US_default));
188
+ if (DEFAULT_LOCALE$2 !== localeStr) try {
189
189
  builtInLoadedResources = (await import(`./locales/${localeStr}.json`, { with: { type: "json" } })).default;
190
190
  localeResources.set(localeStr, mapResourceWithBuiltinKey(builtInLoadedResources));
191
191
  } catch {}
192
192
  function translate(key, values$1 = create()) {
193
193
  const strKey = key;
194
- if (strKey.codePointAt(0) === BUILT_IN_PREFIX_CODE) return (localeResources.get(localeStr) || localeResources.get(DEFAULT_LOCALE$1))[strKey] || strKey;
194
+ if (strKey.codePointAt(0) === BUILT_IN_PREFIX_CODE) return (localeResources.get(localeStr) || localeResources.get(DEFAULT_LOCALE$2))[strKey] || strKey;
195
195
  else return adapter.translate(locale.toString(), strKey, values$1) || "";
196
196
  }
197
197
  let cachedCommands;
@@ -226,7 +226,7 @@ async function createCommandContext({ args, values, positionals, rest, argv: arg
226
226
  }, create());
227
227
  defaultCommandResource.description = command.description || "";
228
228
  defaultCommandResource.examples = await resolveExamples(ctx, command.examples);
229
- adapter.setResource(DEFAULT_LOCALE$1, defaultCommandResource);
229
+ adapter.setResource(DEFAULT_LOCALE$2, defaultCommandResource);
230
230
  const originalResource = await loadCommandResource(ctx, command);
231
231
  if (originalResource) {
232
232
  const resource = Object.assign(create(), originalResource, { examples: await resolveExamples(ctx, originalResource.examples) });
@@ -244,7 +244,7 @@ function getCommandName(cmd) {
244
244
  else return ANONYMOUS_COMMAND_NAME;
245
245
  }
246
246
  function resolveLocale(locale) {
247
- return locale instanceof Intl.Locale ? locale : typeof locale === "string" ? new Intl.Locale(locale) : new Intl.Locale(DEFAULT_LOCALE$1);
247
+ return locale instanceof Intl.Locale ? locale : typeof locale === "string" ? new Intl.Locale(locale) : new Intl.Locale(DEFAULT_LOCALE$2);
248
248
  }
249
249
  async function loadCommandResource(ctx, command) {
250
250
  let resource;
@@ -895,7 +895,7 @@ async function executeCommand(cmd, ctx, name$1) {
895
895
  await resolved.run(ctx);
896
896
  }
897
897
  var name = "@ccusage/codex";
898
- var version = "18.0.2";
898
+ var version = "18.0.3";
899
899
  var description = "Usage analysis tool for OpenAI Codex sessions";
900
900
  var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
901
901
  let messages = [];
@@ -2544,6 +2544,20 @@ function stringWidth$2(string$1, options = {}) {
2544
2544
  }
2545
2545
  return width;
2546
2546
  }
2547
+ const DEFAULT_LOCALE$1 = "en-CA";
2548
+ function createDatePartsFormatter(timezone, locale) {
2549
+ return new Intl.DateTimeFormat(locale, {
2550
+ year: "numeric",
2551
+ month: "2-digit",
2552
+ day: "2-digit",
2553
+ timeZone: timezone
2554
+ });
2555
+ }
2556
+ function formatDateCompact(dateStr, timezone, locale) {
2557
+ const date = /^\d{4}-\d{2}-\d{2}$/.test(dateStr) ? timezone != null ? /* @__PURE__ */ new Date(`${dateStr}T00:00:00Z`) : /* @__PURE__ */ new Date(`${dateStr}T00:00:00`) : new Date(dateStr);
2558
+ const parts = createDatePartsFormatter(timezone, locale ?? DEFAULT_LOCALE$1).formatToParts(date);
2559
+ return `${parts.find((p$1) => p$1.type === "year")?.value ?? ""}\n${parts.find((p$1) => p$1.type === "month")?.value ?? ""}-${parts.find((p$1) => p$1.type === "day")?.value ?? ""}`;
2560
+ }
2547
2561
  var ResponsiveTable = class {
2548
2562
  head;
2549
2563
  rows = [];
@@ -7519,7 +7533,8 @@ const dailyCommand = define({
7519
7533
  ],
7520
7534
  compactThreshold: 100,
7521
7535
  forceCompact: ctx.values.compact,
7522
- style: { head: ["cyan"] }
7536
+ style: { head: ["cyan"] },
7537
+ dateFormatter: (dateStr) => formatDateCompact(dateStr)
7523
7538
  });
7524
7539
  const totalsForDisplay = {
7525
7540
  inputTokens: 0,
@@ -7738,7 +7753,8 @@ const monthlyCommand = define({
7738
7753
  ],
7739
7754
  compactThreshold: 100,
7740
7755
  forceCompact: ctx.values.compact,
7741
- style: { head: ["cyan"] }
7756
+ style: { head: ["cyan"] },
7757
+ dateFormatter: (dateStr) => formatDateCompact(dateStr)
7742
7758
  });
7743
7759
  const totalsForDisplay = {
7744
7760
  inputTokens: 0,
@@ -7978,7 +7994,8 @@ const sessionCommand = define({
7978
7994
  ],
7979
7995
  compactThreshold: 100,
7980
7996
  forceCompact: ctx.values.compact,
7981
- style: { head: ["cyan"] }
7997
+ style: { head: ["cyan"] },
7998
+ dateFormatter: (dateStr) => formatDateCompact(dateStr)
7982
7999
  });
7983
8000
  const totalsForDisplay = {
7984
8001
  inputTokens: 0,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ccusage/codex",
3
3
  "type": "module",
4
- "version": "18.0.2",
4
+ "version": "18.0.3",
5
5
  "description": "Usage analysis tool for OpenAI Codex sessions",
6
6
  "author": "ryoppippi",
7
7
  "license": "MIT",