@fedify/vocab-tools 2.1.0-dev.405 → 2.1.0-dev.406

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/mod.js CHANGED
@@ -8,7 +8,7 @@ import { pascalCase } from "es-toolkit";
8
8
 
9
9
  //#region deno.json
10
10
  var name = "@fedify/vocab-tools";
11
- var version = "2.1.0-dev.405+f4e278ae";
11
+ var version = "2.1.0-dev.406+61a21e4e";
12
12
  var license = "MIT";
13
13
  var exports = { ".": "./src/mod.ts" };
14
14
  var author = {
@@ -1390,25 +1390,41 @@ async function* generateInspector(typeUri, types) {
1390
1390
  yield `
1391
1391
  return proxy;
1392
1392
  }
1393
-
1394
- // @ts-ignore: suppressing TS4127
1395
- ${emitOverride(typeUri, types)} [Symbol.for("Deno.customInspect")](
1393
+ `;
1394
+ }
1395
+ /**
1396
+ * Generates code that must appear *after* the class closing brace: prototype
1397
+ * assignments for the Deno and Node.js custom-inspect hooks.
1398
+ *
1399
+ * These are emitted outside the class body because computed property names
1400
+ * using `Symbol.for()` are incompatible with `isolatedDeclarations` mode.
1401
+ */
1402
+ async function* generateInspectorPostClass(typeUri, types) {
1403
+ const type = types[typeUri];
1404
+ const className = type.name;
1405
+ yield `
1406
+ // deno-lint-ignore no-explicit-any
1407
+ (${className}.prototype as any)[Symbol.for("Deno.customInspect")] =
1408
+ function (
1409
+ this: ${className},
1396
1410
  inspect: typeof Deno.inspect,
1397
1411
  options: Deno.InspectOptions,
1398
1412
  ): string {
1399
1413
  const proxy = this._getCustomInspectProxy();
1400
1414
  return ${JSON.stringify(type.name + " ")} + inspect(proxy, options);
1401
- }
1415
+ };
1402
1416
 
1403
- // @ts-ignore: suppressing TS4127
1404
- ${emitOverride(typeUri, types)} [Symbol.for("nodejs.util.inspect.custom")](
1417
+ // deno-lint-ignore no-explicit-any
1418
+ (${className}.prototype as any)[Symbol.for("nodejs.util.inspect.custom")] =
1419
+ function (
1420
+ this: ${className},
1405
1421
  _depth: number,
1406
1422
  options: unknown,
1407
1423
  inspect: (value: unknown, options: unknown) => string,
1408
1424
  ): string {
1409
1425
  const proxy = this._getCustomInspectProxy();
1410
1426
  return ${JSON.stringify(type.name + " ")} + inspect(proxy, options);
1411
- }
1427
+ };
1412
1428
  `;
1413
1429
  }
1414
1430
 
@@ -1867,6 +1883,7 @@ async function* generateClass(typeUri, types) {
1867
1883
  for await (const code of generateDecoder(typeUri, types)) yield code;
1868
1884
  for await (const code of generateInspector(typeUri, types)) yield code;
1869
1885
  yield "}\n\n";
1886
+ for await (const code of generateInspectorPostClass(typeUri, types)) yield code;
1870
1887
  }
1871
1888
  /**
1872
1889
  * Generates the TypeScript classes from the given types.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-tools",
3
- "version": "2.1.0-dev.405+f4e278ae",
3
+ "version": "2.1.0-dev.406+61a21e4e",
4
4
  "description": "Code generator for Activity Vocabulary APIs",
5
5
  "homepage": "https://fedify.dev/",
6
6
  "repository": {