@hasna/todos 0.15.49 → 0.15.51

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.
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "packageName": "@hasna/todos",
3
- "packageVersion": "0.15.49",
3
+ "packageVersion": "0.15.51",
4
4
  "repository": "https://github.com/hasna/todos.git",
5
- "gitCommit": "14795822057defb3fcb9f8137425757586506ab7",
6
- "gitTree": "b557e10785855f7b9166fecb0bf0e530b96c9be9",
7
- "sourceTreeSha256": "75a070897a6a70a16d0da16b1f14d810302fa6a1480470a10648bc227fa862d9",
8
- "generatedAt": "2026-08-25T02:18:57.000Z"
5
+ "gitCommit": "1706e8dce6e88252d66d2748a5d08a9e5fe52023",
6
+ "gitTree": "ffd26ee40e5d55cdc8faaae5bdaec12fcec4b812",
7
+ "sourceTreeSha256": "6e891cbbf2568f74bfcda98f450c6fcf018a7b983912a991b5f35ecfde8f7e70",
8
+ "generatedAt": "2026-08-29T07:08:49.000Z"
9
9
  }
package/dist/sdk/index.js CHANGED
@@ -53,19 +53,111 @@ class TodosTimeoutError extends Error {
53
53
  }
54
54
 
55
55
  // src/lib/config.ts
56
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
57
- import { dirname, join as join2 } from "path";
56
+ import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
57
+ import { dirname, join as join3 } from "path";
58
58
 
59
59
  // src/lib/sync-utils.ts
60
- import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "fs";
60
+ import { existsSync as existsSync2, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "fs";
61
+ import { homedir as homedir3 } from "os";
62
+
63
+ // src/lib/paths.ts
64
+ import { existsSync } from "fs";
65
+ import { homedir as homedir2 } from "os";
66
+ import { join as join2, resolve } from "path";
67
+
68
+ // node_modules/.bun/@hasna+paths@0.1.0/node_modules/@hasna/paths/dist/index.js
61
69
  import { homedir } from "os";
62
70
  import { join } from "path";
71
+ var KIND_ENV = {
72
+ config: "HASNA_CONFIG_HOME",
73
+ data: "HASNA_DATA_HOME",
74
+ state: "HASNA_STATE_HOME",
75
+ cache: "HASNA_CACHE_HOME"
76
+ };
77
+ var APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
78
+ function assertApp(app) {
79
+ if (typeof app !== "string" || app.length === 0) {
80
+ throw new TypeError("paths: app must be a non-empty string");
81
+ }
82
+ if (!APP_SLUG_RE.test(app)) {
83
+ throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
84
+ }
85
+ }
86
+ function envOf(options) {
87
+ return options.env ?? process.env;
88
+ }
89
+ function envValue(options, kind) {
90
+ const value = envOf(options)[KIND_ENV[kind]];
91
+ return typeof value === "string" && value.length > 0 ? value : undefined;
92
+ }
93
+ function isMacOS(platform) {
94
+ return platform === "darwin";
95
+ }
96
+ function baseDir(kind, options) {
97
+ const override = envValue(options, kind);
98
+ if (override)
99
+ return override;
100
+ const home = options.home ?? homedir();
101
+ const platform = options.platform ?? process.platform;
102
+ if (isMacOS(platform)) {
103
+ switch (kind) {
104
+ case "config":
105
+ case "data":
106
+ return join(home, "Library", "Application Support", "Hasna");
107
+ case "cache":
108
+ return join(home, "Library", "Caches", "Hasna");
109
+ case "state":
110
+ return join(home, "Library", "Logs", "Hasna");
111
+ }
112
+ }
113
+ switch (kind) {
114
+ case "config":
115
+ return join(home, ".config", "hasna");
116
+ case "data":
117
+ return join(home, ".local", "share", "hasna");
118
+ case "state":
119
+ return join(home, ".local", "state", "hasna");
120
+ case "cache":
121
+ return join(home, ".cache", "hasna");
122
+ }
123
+ }
124
+ function resolvePath(kind, options) {
125
+ assertApp(options.app);
126
+ const appSegment = options.internal === true ? join("internal", options.app) : options.app;
127
+ return join(baseDir(kind, options), appSegment);
128
+ }
129
+ function dataDir(options) {
130
+ return resolvePath("data", options);
131
+ }
132
+
133
+ // src/lib/paths.ts
134
+ function effectiveHome(env = process.env) {
135
+ return env.HOME || env.USERPROFILE || homedir2();
136
+ }
137
+ function legacyHomeDir(env = process.env) {
138
+ return join2(effectiveHome(env), ".hasna", "todos");
139
+ }
140
+ function resolverHome(env = process.env) {
141
+ return dataDir({ app: "todos", home: effectiveHome(env), env });
142
+ }
143
+ function adoptResolverHome(resolved, env = process.env) {
144
+ const dataOverride = env.HASNA_DATA_HOME;
145
+ if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
146
+ return true;
147
+ return existsSync(join2(resolved, "todos.db")) || existsSync(join2(resolved, "config.json"));
148
+ }
149
+ function getTodosDir(env = process.env) {
150
+ const resolved = resolverHome(env);
151
+ return resolve(adoptResolverHome(resolved, env) ? resolved : legacyHomeDir(env));
152
+ }
153
+
154
+ // src/lib/sync-utils.ts
63
155
  function getHomeDir() {
64
- return process.env["HOME"] || process.env["USERPROFILE"] || homedir();
156
+ return process.env["HOME"] || process.env["USERPROFILE"] || homedir3();
65
157
  }
66
158
  var HOME = getHomeDir();
67
159
  function getTodosGlobalDir() {
68
- return join(getHomeDir(), ".hasna", "todos");
160
+ return getTodosDir();
69
161
  }
70
162
  function readJsonFile(path) {
71
163
  try {
@@ -77,13 +169,13 @@ function readJsonFile(path) {
77
169
 
78
170
  // src/lib/config.ts
79
171
  function getConfigPath() {
80
- return join2(getTodosGlobalDir(), "config.json");
172
+ return join3(getTodosGlobalDir(), "config.json");
81
173
  }
82
174
  var cached = null;
83
175
  function loadConfig() {
84
176
  if (cached)
85
177
  return cached;
86
- if (!existsSync2(getConfigPath())) {
178
+ if (!existsSync3(getConfigPath())) {
87
179
  cached = {};
88
180
  return cached;
89
181
  }
@@ -559,7 +651,7 @@ class TodosClient {
559
651
  return this._fetchWithRetry(path, { method: "DELETE" });
560
652
  }
561
653
  _sleep(ms) {
562
- return new Promise((resolve) => setTimeout(resolve, ms));
654
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
563
655
  }
564
656
  async getHealth() {
565
657
  return this._get("/api/health");