@atscript/core 0.1.91 → 0.1.92

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/dist/index.cjs CHANGED
@@ -5274,6 +5274,28 @@ var AtscriptRepo = class {
5274
5274
  }
5275
5275
  return atscript;
5276
5276
  }
5277
+ /**
5278
+ * Drops the cached document for `id` and detaches it from its dependencies
5279
+ * (which also removes it from each dependency's `dependants`).
5280
+ *
5281
+ * Documents are cached forever and an imported document is read from disk
5282
+ * only once, so a file that changed outside the repo (a watcher, a dev
5283
+ * server, an editor) keeps resolving to its stale parse until it is closed.
5284
+ * After closing, the next `openDocument(id)` without text re-reads the file.
5285
+ *
5286
+ * Dependants are left untouched on purpose: their next `checkDoc` re-runs
5287
+ * `checkImport` -> `openDocument(id)`, which re-reads the file and rewires
5288
+ * their `dependenciesMap` to the fresh document.
5289
+ *
5290
+ * @returns `true` when a cached document was dropped, `false` when nothing
5291
+ * was cached under `id`.
5292
+ */ closeDocument(id) {
5293
+ const cached = this.atscripts.get(id);
5294
+ if (!cached) return false;
5295
+ this.atscripts.delete(id);
5296
+ cached.then((d) => d.updateDependencies([]), () => {});
5297
+ return true;
5298
+ }
5277
5299
  async _openDocument(id, text) {
5278
5300
  const { manager } = await this.resolveConfig(id);
5279
5301
  const newId = await manager.resolve(id);
package/dist/index.d.ts CHANGED
@@ -157,6 +157,23 @@ declare class AtscriptRepo {
157
157
  loadPluginManagerFor(id: string): Promise<TPluginManagers>;
158
158
  resolveConfig(id: string): Promise<TPluginManagers>;
159
159
  openDocument(id: string, text?: string): Promise<AtscriptDoc>;
160
+ /**
161
+ * Drops the cached document for `id` and detaches it from its dependencies
162
+ * (which also removes it from each dependency's `dependants`).
163
+ *
164
+ * Documents are cached forever and an imported document is read from disk
165
+ * only once, so a file that changed outside the repo (a watcher, a dev
166
+ * server, an editor) keeps resolving to its stale parse until it is closed.
167
+ * After closing, the next `openDocument(id)` without text re-reads the file.
168
+ *
169
+ * Dependants are left untouched on purpose: their next `checkDoc` re-runs
170
+ * `checkImport` -> `openDocument(id)`, which re-reads the file and rewires
171
+ * their `dependenciesMap` to the fresh document.
172
+ *
173
+ * @returns `true` when a cached document was dropped, `false` when nothing
174
+ * was cached under `id`.
175
+ */
176
+ closeDocument(id: string): boolean;
160
177
  protected _openDocument(id: string, text?: string): Promise<AtscriptDoc>;
161
178
  checkDoc(atscript: AtscriptDoc): Promise<void>;
162
179
  checkImports(atscript: AtscriptDoc, checked?: Set<string>): Promise<void>;
package/dist/index.mjs CHANGED
@@ -5243,6 +5243,28 @@ var AtscriptRepo = class {
5243
5243
  }
5244
5244
  return atscript;
5245
5245
  }
5246
+ /**
5247
+ * Drops the cached document for `id` and detaches it from its dependencies
5248
+ * (which also removes it from each dependency's `dependants`).
5249
+ *
5250
+ * Documents are cached forever and an imported document is read from disk
5251
+ * only once, so a file that changed outside the repo (a watcher, a dev
5252
+ * server, an editor) keeps resolving to its stale parse until it is closed.
5253
+ * After closing, the next `openDocument(id)` without text re-reads the file.
5254
+ *
5255
+ * Dependants are left untouched on purpose: their next `checkDoc` re-runs
5256
+ * `checkImport` -> `openDocument(id)`, which re-reads the file and rewires
5257
+ * their `dependenciesMap` to the fresh document.
5258
+ *
5259
+ * @returns `true` when a cached document was dropped, `false` when nothing
5260
+ * was cached under `id`.
5261
+ */ closeDocument(id) {
5262
+ const cached = this.atscripts.get(id);
5263
+ if (!cached) return false;
5264
+ this.atscripts.delete(id);
5265
+ cached.then((d) => d.updateDependencies([]), () => {});
5266
+ return true;
5267
+ }
5246
5268
  async _openDocument(id, text) {
5247
5269
  const { manager } = await this.resolveConfig(id);
5248
5270
  const newId = await manager.resolve(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/core",
3
- "version": "0.1.91",
3
+ "version": "0.1.92",
4
4
  "description": "Core library for Atscript parsing and file generation.",
5
5
  "keywords": [
6
6
  "annotations",