@dimina-kit/devkit 0.1.2-dev.20260525152421 → 0.1.2-dev.20260601115343

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiDA,MAAM,WAAW,OAAO;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1B;AAED,MAAM,WAAW,kBAAkB;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oFAAoF;IACpF,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CACrC;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CA4GnF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAClC;IAAE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAgBhC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiDA,MAAM,WAAW,OAAO;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1B;AAED,MAAM,WAAW,kBAAkB;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oFAAoF;IACpF,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CACrC;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CA4GnF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAClC;IAAE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAmChC"}
package/dist/index.js CHANGED
@@ -135,8 +135,27 @@ export async function openProject(opts) {
135
135
  * watcher.
136
136
  */
137
137
  export function createProjectWatcher(projectPath, onChange) {
138
+ // Ignore dotfiles/dot-directories that live *inside* the project (.git,
139
+ // .DS_Store, editor scratch, etc.) without nuking the whole watch when the
140
+ // project itself sits under a dotted ancestor path. A regex like
141
+ // /(^|[/\\])\../ runs against the full absolute path, so a project under
142
+ // e.g. /…/.claude/worktrees/app would match on the ancestor ".claude" and
143
+ // chokidar would silently ignore everything — editing source files never
144
+ // triggers a rebuild. The function form scopes the dot check to the path
145
+ // segments *below* projectPath. chokidar v5 passes posix-normalized
146
+ // (forward-slash) absolute paths to the matcher, so we normalize both sides
147
+ // before computing the relative path.
148
+ const toPosix = (p) => p.replace(/\\/g, '/');
149
+ const projectPathPosix = toPosix(path.resolve(projectPath));
138
150
  const watcher = chokidar.watch(projectPath, {
139
- ignored: /(^|[/\\])\../,
151
+ ignored: (candidate) => {
152
+ const rel = path.posix.relative(projectPathPosix, toPosix(candidate));
153
+ // The root itself (rel === '') or anything outside the project
154
+ // (rel starts with '..') must never be ignored.
155
+ if (!rel || rel.startsWith('..'))
156
+ return false;
157
+ return rel.split('/').some(seg => seg.startsWith('.'));
158
+ },
140
159
  persistent: true,
141
160
  ignoreInitial: true,
142
161
  });
@@ -130,6 +130,43 @@ describe('createProjectWatcher', () => {
130
130
  await settle(500);
131
131
  expect(onChange).not.toHaveBeenCalled();
132
132
  });
133
+ it('fires onChange for source edits when the project sits under a dotted ancestor directory', async () => {
134
+ // Why this matters: regression for the bug where `ignored` was a regex
135
+ // (/(^|[/\\])\../) matched against the full absolute path. When the
136
+ // project lives under a dotted ancestor — e.g. a Claude worktree at
137
+ // /…/.claude/worktrees/app — that regex matched the ancestor ".claude"
138
+ // and chokidar ignored the entire project. Editing source then never
139
+ // triggered a rebuild. The ancestor dot must NOT disable the watch;
140
+ // only dotfiles/dirs *inside* the project should be ignored.
141
+ const dottedAncestor = path.join(tempDir, '.claude', 'worktrees');
142
+ const projectRoot = path.join(dottedAncestor, 'app');
143
+ fs.mkdirSync(projectRoot, { recursive: true });
144
+ const target = path.join(projectRoot, 'app.json');
145
+ fs.writeFileSync(target, '{}');
146
+ const onChange = vi.fn();
147
+ handle = createProjectWatcher(projectRoot, onChange);
148
+ await settle();
149
+ fs.writeFileSync(target, '{"a":1}');
150
+ await vi.waitFor(() => expect(onChange).toHaveBeenCalled(), { timeout: 2000 });
151
+ });
152
+ it('still ignores dotfiles inside a project that sits under a dotted ancestor directory', async () => {
153
+ // Companion to the regression above: confirm the fix didn't over-correct
154
+ // by disabling dot-ignoring entirely. A .git change *inside* the project
155
+ // must stay quiet even though the project path itself contains a dotted
156
+ // ancestor segment.
157
+ const dottedAncestor = path.join(tempDir, '.claude', 'worktrees');
158
+ const projectRoot = path.join(dottedAncestor, 'app');
159
+ const gitDir = path.join(projectRoot, '.git');
160
+ fs.mkdirSync(gitDir, { recursive: true });
161
+ const head = path.join(gitDir, 'HEAD');
162
+ fs.writeFileSync(head, 'ref: refs/heads/main\n');
163
+ const onChange = vi.fn();
164
+ handle = createProjectWatcher(projectRoot, onChange);
165
+ await settle();
166
+ fs.writeFileSync(head, 'ref: refs/heads/other\n');
167
+ await settle(500);
168
+ expect(onChange).not.toHaveBeenCalled();
169
+ });
133
170
  it('stops firing onChange after close() is called', async () => {
134
171
  // Why this matters: when a project session ends (user closes the
135
172
  // devtools window, switches projects), lingering watchers would keep
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimina-kit/devkit",
3
- "version": "0.1.2-dev.20260525152421",
3
+ "version": "0.1.2-dev.20260601115343",
4
4
  "description": "Development toolkit for Dimina mini-apps with H5 container preview",
5
5
  "keywords": [
6
6
  "dimina",