@fedify/vocab 2.4.0-dev.1431 → 2.4.0-dev.1488

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/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab",
3
- "version": "2.4.0-dev.1431+9ef6f5e8",
3
+ "version": "2.4.0-dev.1488+a9fe1094",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts"
package/dist/mod.cjs CHANGED
@@ -33,7 +33,7 @@ let _fedify_vocab_runtime_temporal = require("@fedify/vocab-runtime/temporal");
33
33
  let es_toolkit = require("es-toolkit");
34
34
  //#region deno.json
35
35
  var name = "@fedify/vocab";
36
- var version = "2.4.0-dev.1431+9ef6f5e8";
36
+ var version = "2.4.0-dev.1488+a9fe1094";
37
37
  //#endregion
38
38
  //#region src/type.ts
39
39
  function getTypeId(object) {
package/dist/mod.js CHANGED
@@ -9,7 +9,7 @@ import { isTemporalDuration, isTemporalInstant } from "@fedify/vocab-runtime/tem
9
9
  import { delay } from "es-toolkit";
10
10
  //#region deno.json
11
11
  var name = "@fedify/vocab";
12
- var version = "2.4.0-dev.1431+9ef6f5e8";
12
+ var version = "2.4.0-dev.1488+a9fe1094";
13
13
  //#endregion
14
14
  //#region src/type.ts
15
15
  function getTypeId(object) {
@@ -1206,7 +1206,7 @@ var esm_default = new class FetchMock {
1206
1206
  //#endregion
1207
1207
  //#region deno.json
1208
1208
  var name = "@fedify/vocab";
1209
- var version = "2.4.0-dev.1431+9ef6f5e8";
1209
+ var version = "2.4.0-dev.1488+a9fe1094";
1210
1210
  //#endregion
1211
1211
  //#region src/actor.ts
1212
1212
  const ACTOR_DISCOVERY_HISTOGRAM_BUCKETS = [
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  globalThis.addEventListener = () => {};
3
3
  import { B as __exportAll, E as Person, N as Service, T as Organization, a as Application, m as Group } from "./vocab-XnSGFOqq.mjs";
4
- import { a as normalizeActorHandle, c as esm_default, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-0UbrRRrx.mjs";
4
+ import { a as normalizeActorHandle, c as esm_default, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-Cw0Y6V0k.mjs";
5
5
  import { createTestMeterProvider, test } from "@fedify/fixture";
6
6
  import { deepStrictEqual, ok, rejects, strictEqual, throws } from "node:assert/strict";
7
7
  //#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/check/precondition/PreconditionFailure.js
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  globalThis.addEventListener = () => {};
3
3
  import { E as Person, S as Object$1, o as Collection, x as Note } from "./vocab-XnSGFOqq.mjs";
4
- import { c as esm_default, i as isActor, o as name, s as version } from "./actor-0UbrRRrx.mjs";
4
+ import { c as esm_default, i as isActor, o as name, s as version } from "./actor-Cw0Y6V0k.mjs";
5
5
  import { t as getTypeId } from "./type-Cf-vxmre.mjs";
6
6
  import { t as assertInstanceOf } from "./utils-CE8Dk5hm.mjs";
7
7
  import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab",
3
- "version": "2.4.0-dev.1431+9ef6f5e8",
3
+ "version": "2.4.0-dev.1488+a9fe1094",
4
4
  "homepage": "https://fedify.dev/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,10 +10,7 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/fedify-dev/fedify/issues"
12
12
  },
13
- "funding": [
14
- "https://opencollective.com/fedify",
15
- "https://github.com/sponsors/dahlia"
16
- ],
13
+ "funding": "https://opencollective.com/fedify",
17
14
  "engines": {
18
15
  "deno": ">=2.0.0",
19
16
  "node": ">=22.0.0",
@@ -46,9 +43,9 @@
46
43
  "es-toolkit": "1.46.1",
47
44
  "jsonld": "^9.0.0",
48
45
  "pkijs": "^3.3.3",
49
- "@fedify/vocab-tools": "2.4.0-dev.1431+9ef6f5e8",
50
- "@fedify/webfinger": "2.4.0-dev.1431+9ef6f5e8",
51
- "@fedify/vocab-runtime": "2.4.0-dev.1431+9ef6f5e8"
46
+ "@fedify/webfinger": "2.4.0-dev.1488+a9fe1094",
47
+ "@fedify/vocab-runtime": "2.4.0-dev.1488+a9fe1094",
48
+ "@fedify/vocab-tools": "2.4.0-dev.1488+a9fe1094"
52
49
  },
53
50
  "devDependencies": {
54
51
  "@types/node": "^22.17.0",
@@ -7,36 +7,49 @@ const LOCK_RETRY_MS = 100;
7
7
  const LOCK_TIMEOUT_MS = 60 * 1000; // 1 minute
8
8
 
9
9
  /**
10
- * Get the latest mtime from all YAML files in the schema directory.
10
+ * Get the latest mtime among files under a directory tree (recursively),
11
+ * limited to the given file extensions. Returns 0 if the directory is absent.
11
12
  */
12
- async function getLatestSourceMtime(schemaDir: Path): Promise<number> {
13
+ async function getLatestMtimeUnder(
14
+ dir: Path,
15
+ exts: readonly string[],
16
+ ): Promise<number> {
17
+ if (!(await dir.exists())) return 0;
13
18
  let latestMtime = 0;
14
- for await (const entry of schemaDir.readDir()) {
15
- if (!entry.isFile) continue;
16
- if (!entry.name.match(/\.ya?ml$/i)) continue;
17
- if (entry.name === "schema.yaml") continue;
18
- const fileStat = await schemaDir.join(entry.name).stat();
19
- if (fileStat?.mtime && fileStat.mtime.getTime() > latestMtime) {
20
- latestMtime = fileStat.mtime.getTime();
19
+ for await (const entry of Deno.readDir(dir.toString())) {
20
+ const child = dir.join(entry.name);
21
+ if (entry.isDirectory) {
22
+ const mtime = await getLatestMtimeUnder(child, exts);
23
+ if (mtime > latestMtime) latestMtime = mtime;
24
+ } else if (entry.isFile && exts.some((ext) => entry.name.endsWith(ext))) {
25
+ const fileStat = await child.stat();
26
+ const mtime = fileStat?.mtime?.getTime() ?? 0;
27
+ if (mtime > latestMtime) latestMtime = mtime;
21
28
  }
22
29
  }
23
30
  return latestMtime;
24
31
  }
25
32
 
26
33
  /**
27
- * Check if the generated file is up to date compared to source files.
34
+ * Check if the generated file is up to date compared to its source files,
35
+ * including the generator itself (`@fedify/vocab-tools` and this codegen
36
+ * script): changing the generator changes the generated output, so the
37
+ * generated file must be at least as new as those too.
28
38
  */
29
39
  async function isUpToDate(
30
40
  schemaDir: Path,
31
41
  generatedPath: Path,
42
+ generatorMtime: number,
32
43
  ): Promise<boolean> {
33
44
  try {
34
45
  const [sourceMtime, generatedStat] = await Promise.all([
35
- getLatestSourceMtime(schemaDir),
46
+ // Match loadSchemaFiles()'s /\.ya?ml$/i: a .yml schema is a real input.
47
+ getLatestMtimeUnder(schemaDir, [".yaml", ".yml"]),
36
48
  generatedPath.stat(),
37
49
  ]);
38
50
  if (!generatedStat?.mtime) return false;
39
- return generatedStat.mtime.getTime() >= sourceMtime;
51
+ return generatedStat.mtime.getTime() >=
52
+ Math.max(sourceMtime, generatorMtime);
40
53
  } catch {
41
54
  // If generated file doesn't exist, it's not up to date
42
55
  return false;
@@ -117,8 +130,20 @@ async function codegen() {
117
130
  // Acquire lock to prevent concurrent codegen
118
131
  const lock = await acquireLock(lockPath);
119
132
  try {
133
+ // The generated vocab.ts depends not only on the YAML schemas but on the
134
+ // generator itself: @fedify/vocab-tools and this codegen script. Sample
135
+ // its mtime inside the lock so that a generator edit made while we were
136
+ // waiting for the lock is not missed by the freshness check below.
137
+ const generatorMtime = Math.max(
138
+ await getLatestMtimeUnder(
139
+ packageDir.parent()!.join("vocab-tools", "src"),
140
+ [".ts", ".yaml", ".yml"],
141
+ ),
142
+ await getLatestMtimeUnder(scriptsDir, [".ts"]),
143
+ );
144
+
120
145
  // Check if regeneration is needed (after acquiring lock)
121
- if (await isUpToDate(schemaDir, realPath)) {
146
+ if (await isUpToDate(schemaDir, realPath, generatorMtime)) {
122
147
  $.log("vocab.ts is up to date, skipping codegen");
123
148
  return;
124
149
  }