@acdh-oeaw/content-lib 0.1.1 → 0.1.2

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.js CHANGED
@@ -82,7 +82,7 @@ function serialize(value, contentProcessorConfigFilePath, collectionName) {
82
82
  }
83
83
  if (value$1 instanceof JavaScriptImport) {
84
84
  const hash = createContentHash(value$1.content);
85
- const filePath = `./${hash}.js`;
85
+ const filePath = `./${hash}.jsx`;
86
86
  debug(`Adding javascript import for "${filePath}".`);
87
87
  const identifier = addImport(filePath);
88
88
  addFiles(filePath, `// @ts-nocheck\n${value$1.content}`);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["path","imports: Array<string>","value","collections: Array<Collection>","context: TransformContext","item: CollectionItem","timer: ReturnType<typeof setTimeout> | null","controller: AbortController | null","events","error"],"sources":["../src/index.ts"],"sourcesContent":["import * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs/promises\";\nimport { availableParallelism } from \"node:os\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { debuglog } from \"node:util\";\n\nimport { addTrailingSlash, log } from \"@acdh-oeaw/lib\";\nimport * as watcher from \"@parcel/watcher\";\nimport { pascalCase } from \"change-case\";\nimport plimit from \"p-limit\";\nimport pluralize from \"pluralize\";\n\n//\n\nconst debug = debuglog(\"content-lib\");\n\n//\n\nfunction createContentHash(value: string): string {\n\treturn crypto.createHash(\"sha256\").update(value).digest(\"hex\");\n}\n\nfunction createIdFromFilePath(filePath: string): string {\n\tconst parsed = path.parse(filePath);\n\n\tif (parsed.name.toLowerCase() === \"index\") {\n\t\treturn path.basename(parsed.dir);\n\t}\n\n\treturn parsed.name;\n}\n\n//\n\ntype MaybePromise<T> = T | Promise<T>;\n\ntype NonEmptyReadonlyArray<T> = readonly [T, ...Array<T>];\n\ntype GlobString = string;\n\ninterface CollectionItem {\n\t/** Unique identifier. */\n\tid: string;\n\t/** File path relative to colleciton directory. */\n\tfilePath: string;\n\t/** File path relative to current working directory. */\n\tabsoluteFilePath: string;\n\t/** File modification timestamp. */\n\ttimestamp: number;\n}\n\ninterface TransformContext {\n\tcollections: Array<Collection>;\n\tcreateImportDeclaration: <T>(path: string) => ImportDeclaration<T>;\n\tcreateJavaScriptImport: <T>(content: string) => JavaScriptImport<T>;\n\tcreateJsonImport: <T>(content: string) => JsonImport<T>;\n}\n\nexport interface CollectionConfig<\n\tTCollectionName extends string = string,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTCollectionItemContent = any,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTCollectionDocument = any,\n> {\n\tname: TCollectionName;\n\tdirectory: string;\n\tinclude: NonEmptyReadonlyArray<GlobString>;\n\texclude?: ReadonlyArray<GlobString>;\n\tread: (item: CollectionItem) => MaybePromise<TCollectionItemContent>;\n\ttransform: (\n\t\tcontent: TCollectionItemContent,\n\t\titem: CollectionItem,\n\t\tcontext: TransformContext,\n\t) => MaybePromise<TCollectionDocument>;\n}\n\nexport function createCollection<\n\tTCollectionName extends string,\n\tTCollectionItemContent,\n\tTCollectionDocument,\n>(\n\tconfig: CollectionConfig<TCollectionName, TCollectionItemContent, TCollectionDocument>,\n): CollectionConfig<TCollectionName, TCollectionItemContent, TCollectionDocument> {\n\treturn config;\n}\n\nexport interface ContentConfig {\n\tcollections: Array<CollectionConfig>;\n}\n\nexport function createConfig<T extends ContentConfig>(config: T): T {\n\treturn config;\n}\n\n//\n\n// function createItemCacheKey(item: CollectionItem): string {\n// \treturn String(item.timestamp);\n// }\n\n//\n\nclass ImportDeclaration<T> {\n\tprivate __brand!: never;\n\tvalue!: T;\n\tpath: string;\n\n\tconstructor(path: string) {\n\t\tthis.path = path;\n\t}\n}\n\nfunction createImportDeclaration<T>(path: string): ImportDeclaration<T> {\n\treturn new ImportDeclaration<T>(path);\n}\n\nclass JavaScriptImport<T> {\n\tprivate __brand!: never;\n\tvalue!: T;\n\tcontent: string;\n\n\tconstructor(content: string) {\n\t\tthis.content = content;\n\t}\n}\n\nfunction createJavaScriptImport<T>(content: string): JavaScriptImport<T> {\n\treturn new JavaScriptImport<T>(content);\n}\n\nclass JsonImport<T> {\n\tprivate __brand!: never;\n\tvalue!: T;\n\tcontent: string;\n\n\tconstructor(content: string) {\n\t\tthis.content = content;\n\t}\n}\n\nfunction createJsonImport<T>(content: string): JsonImport<T> {\n\treturn new JsonImport<T>(content);\n}\n\n//\n\nexport type GetCollection<TConfig extends ContentConfig, TName extends string> = Extract<\n\tTConfig[\"collections\"][number],\n\t{ name: TName }\n>;\n\ntype Simplify<T> = { [K in keyof T]: T[K] } & {};\n\ntype Replace<T> = {\n\t[K in keyof T]: T[K] extends JavaScriptImport<infer U>\n\t\t? U\n\t\t: T[K] extends JsonImport<infer U>\n\t\t\t? U\n\t\t\t: T[K] extends ImportDeclaration<infer U>\n\t\t\t\t? U\n\t\t\t\t: T[K] extends object\n\t\t\t\t\t? Simplify<Replace<T[K]>>\n\t\t\t\t\t: T[K];\n};\n\nexport type CollectionEntry<TCollection extends Collection> = Simplify<{\n\titem: { id: string };\n\tcontent: Simplify<Awaited<ReturnType<TCollection[\"read\"]>>>;\n\tdocument: Simplify<Replace<Awaited<ReturnType<TCollection[\"transform\"]>>>>;\n}>;\n\n//\n\nconst prefix = \"__i__\";\nconst re = new RegExp(`\"(${prefix}\\\\d+)\"`, \"g\");\n\nfunction serialize(\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tvalue: Map<string, any>,\n\tcontentProcessorConfigFilePath: string,\n\tcollectionName: string,\n): Map<string, string> {\n\tdebug(\"Serializing...\\n\");\n\n\tconst imports: Array<string> = [];\n\n\tfunction addImport(filePath: string, type: \"js\" | \"json\" = \"js\"): string {\n\t\tconst identifier = [prefix, imports.length].join(\"\");\n\t\timports.push(\n\t\t\t`import ${identifier} from \"${filePath}\"${type !== \"js\" ? ` with { type: \"${type}\" }` : \"\"};`,\n\t\t);\n\n\t\treturn identifier;\n\t}\n\n\tconst files = new Map<string, string>();\n\n\tfunction addFiles(filePath: string, content: string): void {\n\t\tfiles.set(filePath, content);\n\t}\n\n\tconst json = JSON.stringify(\n\t\tArray.from(value),\n\t\t// TODO: Should we support (multiple) named imports?\n\t\t(_key, value) => {\n\t\t\tif (value instanceof ImportDeclaration) {\n\t\t\t\tconst filePath = value.path;\n\n\t\t\t\tdebug(`Adding import declaration for \"${filePath}\".`);\n\t\t\t\tconst identifier = addImport(filePath);\n\n\t\t\t\treturn identifier;\n\t\t\t}\n\n\t\t\tif (value instanceof JavaScriptImport) {\n\t\t\t\tconst hash = createContentHash(value.content);\n\t\t\t\tconst filePath = `./${hash}.js`;\n\n\t\t\t\tdebug(`Adding javascript import for \"${filePath}\".`);\n\t\t\t\tconst identifier = addImport(filePath);\n\t\t\t\taddFiles(filePath, `// @ts-nocheck\\n${value.content}`);\n\n\t\t\t\treturn identifier;\n\t\t\t}\n\n\t\t\tif (value instanceof JsonImport) {\n\t\t\t\tconst hash = createContentHash(value.content);\n\t\t\t\tconst filePath = `./${hash}.json`;\n\n\t\t\t\tdebug(`Adding json import for \"${filePath}\".`);\n\t\t\t\tconst identifier = addImport(filePath, \"json\");\n\t\t\t\taddFiles(filePath, value.content);\n\n\t\t\t\treturn identifier;\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value;\n\t\t},\n\t\t2,\n\t)\n\t\t/** Remove quotes from import identifiers. */\n\t\t.replaceAll(re, \"$1\");\n\n\tlet result = \"\";\n\n\tif (imports.length > 0) {\n\t\tresult += imports.join(\"\\n\");\n\t\tresult += \"\\n\\n\";\n\t}\n\n\tresult += [`const items = new Map(${json});`, \"export default items;\"].join(\"\\n\\n\");\n\n\tfiles.set(\"index.js\", result);\n\n\t// eslint-disable-next-line import-x/no-named-as-default-member\n\tconst typeName = pascalCase(pluralize.singular(collectionName));\n\n\tfiles.set(\n\t\t\"index.d.ts\",\n\t\t[\n\t\t\t`import type { GetCollection, CollectionEntry } from \"@acdh-oeaw/content-lib\";`,\n\t\t\t\"\",\n\t\t\t`import type { config } from \"${contentProcessorConfigFilePath}\";`,\n\t\t\t\"\",\n\t\t\t`type Collection = GetCollection<typeof config, \"${collectionName}\">;`,\n\t\t\t`type ${typeName} = CollectionEntry<Collection>;`,\n\t\t\t\"\",\n\t\t\t`declare const items: Map<string, ${typeName}>;`,\n\t\t\t`export { type ${typeName}, items as default };`,\n\t\t].join(\"\\n\"),\n\t);\n\n\treturn files;\n}\n\n//\n\ninterface Collection extends CollectionConfig {\n\tabsoluteDirectoryPath: string;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdata: Map<CollectionItem[\"id\"], { item: CollectionItem; content: any; document: any }>; // TODO: revisit\n\toutputDirectoryPath: string;\n}\n\ninterface BuildStats {\n\tcollections: number;\n\tdocuments: number;\n}\n\nexport interface ContentProcessorConfig {\n\t/** Path to config file, relative to `process.cwd()`, which provides a named export `config`. */\n\tconfigFilePath: string;\n}\n\nexport interface ContentProcessor {\n\tbuild: () => Promise<BuildStats>;\n\twatch: () => Promise<Set<watcher.AsyncSubscription>>;\n}\n\nexport async function createContentProcessor(\n\tcontentProcessorConfig: ContentProcessorConfig,\n): Promise<ContentProcessor> {\n\tdebug(\"Creating content processor...\\n\");\n\n\tdebug(\"Reading config file...\");\n\tconst contentProcessorConfigUrl = pathToFileURL(\n\t\tpath.resolve(contentProcessorConfig.configFilePath),\n\t);\n\tcontentProcessorConfigUrl.searchParams.set(\"cache-key\", String(Date.now()));\n\tconst contentProcessorConfigFilePath = String(contentProcessorConfigUrl);\n\tconst { config } = (await import(contentProcessorConfigFilePath)) as { config: ContentConfig }; // TODO: validate\n\tdebug(`Done reading config file \"${contentProcessorConfigFilePath}\".`);\n\n\tconst concurrency = availableParallelism();\n\tconst limit = plimit(concurrency);\n\tdebug(`Concurrency: ${String(concurrency)}.\\n`);\n\n\tconst outputDirectoryBasePath = path.join(process.cwd(), \".content\", \"generated\");\n\n\tconst collections: Array<Collection> = [];\n\n\tconst context: TransformContext = {\n\t\tcollections,\n\t\tcreateImportDeclaration,\n\t\tcreateJavaScriptImport,\n\t\tcreateJsonImport,\n\t};\n\n\tfor (const collection of config.collections) {\n\t\tconst absoluteDirectoryPath = addTrailingSlash(path.resolve(collection.directory));\n\n\t\t/** Ensure directory exists, which is expected by `@parcel/watcher`. */\n\t\tawait fs.mkdir(absoluteDirectoryPath, { recursive: true });\n\n\t\tconst outputDirectoryPath = path.join(\n\t\t\toutputDirectoryBasePath,\n\t\t\tcollection.name.toLowerCase().replaceAll(/[^a-z0-9_-]/g, \"-\"),\n\t\t);\n\n\t\tcollections.push({\n\t\t\t...collection,\n\t\t\tabsoluteDirectoryPath,\n\t\t\tdata: new Map(),\n\t\t\toutputDirectoryPath,\n\t\t});\n\t}\n\n\tasync function generate(signal?: AbortSignal): Promise<void> {\n\t\tdebug(\"Generating...\\n\");\n\n\t\tfor (const collection of collections) {\n\t\t\tdebug(`Reading collection \"${collection.name}\"...`);\n\n\t\t\tawait limit.map(Array.from(collection.data), async ([id, { item }]) => {\n\t\t\t\tif (signal?.aborted === true) {\n\t\t\t\t\tdebug(\"Aborted reading collections.\");\n\t\t\t\t\tlimit.clearQueue();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// FIXME: race condition: what if file has been deleted in the meantime\n\t\t\t\t// TODO: skip item when `read()` returns `null`?\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tconst content = await collection.read(item);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tcollection.data.get(id)!.content = content;\n\n\t\t\t\tdebug(`- Read item \"${id}\".`);\n\t\t\t});\n\n\t\t\tdebug(\n\t\t\t\t`Done reading ${String(collection.data.size)} item(s) in collection \"${collection.name}\".\\n`,\n\t\t\t);\n\t\t}\n\n\t\tfor (const collection of collections) {\n\t\t\tdebug(`Transforming collection \"${collection.name}\"...`);\n\n\t\t\tawait limit.map(Array.from(collection.data), async ([id, { content, item }]) => {\n\t\t\t\tif (signal?.aborted === true) {\n\t\t\t\t\tdebug(\"Aborted transforming collections.\");\n\t\t\t\t\tlimit.clearQueue();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tconst document = await collection.transform(content, item, context);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tcollection.data.get(id)!.document = document;\n\n\t\t\t\tdebug(`- Transformed item \"${id}\".`);\n\t\t\t});\n\n\t\t\tdebug(\n\t\t\t\t`Done transforming ${String(collection.data.size)} item(s) in collection \"${collection.name}\".\\n`,\n\t\t\t);\n\t\t}\n\n\t\tif (signal?.aborted === true) {\n\t\t\tdebug(\"Aborted writing collections.\");\n\t\t\treturn;\n\t\t}\n\n\t\tdebug(\"Clearing output directory...\\n\");\n\t\tawait fs.rm(outputDirectoryBasePath, { force: true, recursive: true });\n\n\t\tfor (const collection of collections) {\n\t\t\tdebug(`Writing collection \"${collection.name}\".`);\n\n\t\t\tdebug(`Creating output directory for \"${collection.name}\".`);\n\t\t\tawait fs.mkdir(collection.outputDirectoryPath, { recursive: true });\n\n\t\t\tconst files = serialize(\n\t\t\t\tcollection.data,\n\t\t\t\tpath.relative(collection.outputDirectoryPath, contentProcessorConfig.configFilePath),\n\t\t\t\tcollection.name,\n\t\t\t);\n\n\t\t\tawait limit.map(Array.from(files), async ([filePath, fileContent]) => {\n\t\t\t\tconst outputFilePath = path.join(collection.outputDirectoryPath, filePath);\n\t\t\t\tawait fs.writeFile(outputFilePath, fileContent, { encoding: \"utf-8\" });\n\t\t\t});\n\t\t}\n\t}\n\n\tasync function build(): Promise<BuildStats> {\n\t\tdebug(\"Building...\\n\");\n\n\t\tfor (const collection of collections) {\n\t\t\tdebug(`Building collection \"${collection.name}\"...`);\n\n\t\t\t// eslint-disable-next-line n/no-unsupported-features/node-builtins\n\t\t\tfor await (const filePath of fs.glob(collection.include, {\n\t\t\t\tcwd: collection.directory,\n\t\t\t\texclude: collection.exclude,\n\t\t\t})) {\n\t\t\t\tconst absoluteFilePath = path.join(collection.directory, filePath);\n\t\t\t\tconst id = createIdFromFilePath(filePath);\n\n\t\t\t\tconst stats = await fs.stat(absoluteFilePath).catch((error: unknown) => {\n\t\t\t\t\tif (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t\tif (stats == null) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst { mtimeMs: timestamp } = stats;\n\n\t\t\t\tconst item: CollectionItem = { id, filePath, absoluteFilePath, timestamp };\n\n\t\t\t\tcollection.data.set(id, { item, content: null, document: null });\n\n\t\t\t\tdebug(`- Added item \"${id}\" (path: \"${filePath}\").`);\n\t\t\t}\n\n\t\t\tdebug(\n\t\t\t\t`Done adding ${String(collection.data.size)} item(s) to collection \"${collection.name}\".\\n`,\n\t\t\t);\n\t\t}\n\n\t\tawait generate();\n\n\t\treturn {\n\t\t\tcollections: collections.length,\n\t\t\tdocuments: collections.reduce((acc, collection) => {\n\t\t\t\treturn acc + collection.data.size;\n\t\t\t}, 0),\n\t\t};\n\t}\n\n\tasync function watch(): Promise<Set<watcher.AsyncSubscription>> {\n\t\tdebug(\"Watching...\\n\");\n\n\t\tconst subscriptions = new Set<watcher.AsyncSubscription>();\n\n\t\tconst debounceDelayMs = 150;\n\t\tlet timer: ReturnType<typeof setTimeout> | null = null;\n\t\tlet controller: AbortController | null = null;\n\t\tlet batch = new Map<watcher.Event[\"path\"], watcher.Event & { relativeFilePath: string }>();\n\n\t\tfor (const collection of collections) {\n\t\t\tdebug(`Watching collection \"${collection.name}\"...`);\n\n\t\t\t/**\n\t\t\t * Ideally, we could just add `include` as a negative ignore pattern.\n\t\t\t *\n\t\t\t * This is currently not supported by `@parcel/watcher`. Simple patterns like \"!*.md\" do seem\n\t\t\t * to work, but others like \"!*\\/index.md\" do not.\n\t\t\t *\n\t\t\t * Therefore we need to filter out matching events in the javascript main thread\n\t\t\t * (see `path.matchesGlob` below).\n\t\t\t *\n\t\t\t * @see https://github.com/parcel-bundler/watcher/issues/166\n\t\t\t */\n\t\t\t// const ignore = [\n\t\t\t// \t...collection.include.map((glob) => {\n\t\t\t// \t\treturn `!${glob}`;\n\t\t\t// \t}),\n\t\t\t// \t...(collection.exclude ?? []),\n\t\t\t// ];\n\t\t\tconst ignore = (collection.exclude ?? []) as Array<string>;\n\n\t\t\tconst subscription = await watcher.subscribe(\n\t\t\t\tcollection.directory,\n\t\t\t\t(error, events) => {\n\t\t\t\t\tif (error != null) {\n\t\t\t\t\t\tlog.error(error);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tdebug(`- ${String(events.length)} events in collection \"${collection.name}\".`);\n\n\t\t\t\t\tfor (const event of events) {\n\t\t\t\t\t\t// const relativeFilePath = path.relative(collection.directory, event.path);\n\t\t\t\t\t\tconst relativeFilePath = event.path.slice(collection.absoluteDirectoryPath.length);\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcollection.include.some((pattern) => {\n\t\t\t\t\t\t\t\t// eslint-disable-next-line n/no-unsupported-features/node-builtins\n\t\t\t\t\t\t\t\treturn path.matchesGlob(relativeFilePath, pattern);\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t(event as watcher.Event & { relativeFilePath: string }).relativeFilePath =\n\t\t\t\t\t\t\t\trelativeFilePath;\n\t\t\t\t\t\t\tbatch.set(event.path, event as watcher.Event & { relativeFilePath: string });\n\n\t\t\t\t\t\t\tdebug(`- Added \"${event.type}\" event for \"${relativeFilePath}\" to queue.`);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdebug(`- Discarded \"${event.type}\" event for \"${relativeFilePath}\".`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (timer != null) {\n\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t}\n\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-misused-promises\n\t\t\t\t\ttimer = setTimeout(async () => {\n\t\t\t\t\t\tif (controller != null) {\n\t\t\t\t\t\t\tcontroller.abort();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontroller = new AbortController();\n\n\t\t\t\t\t\tconst events = batch;\n\t\t\t\t\t\tbatch = new Map();\n\t\t\t\t\t\ttimer = null;\n\n\t\t\t\t\t\tlet isCollectionChanged = false;\n\n\t\t\t\t\t\tfor (const event of events.values()) {\n\t\t\t\t\t\t\tconst filePath = event.relativeFilePath;\n\t\t\t\t\t\t\tconst id = createIdFromFilePath(filePath);\n\n\t\t\t\t\t\t\tdebug(`Processing \"${event.type}\" event for \"${id}\".`);\n\n\t\t\t\t\t\t\tswitch (event.type) {\n\t\t\t\t\t\t\t\tcase \"create\":\n\t\t\t\t\t\t\t\tcase \"update\": {\n\t\t\t\t\t\t\t\t\tisCollectionChanged ||= event.type === \"create\" || collection.data.has(id);\n\n\t\t\t\t\t\t\t\t\tconst absoluteFilePath = path.join(collection.directory, filePath);\n\n\t\t\t\t\t\t\t\t\tconst stats = await fs.stat(absoluteFilePath).catch((error: unknown) => {\n\t\t\t\t\t\t\t\t\t\tif (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n\t\t\t\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tif (stats == null) {\n\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst { mtimeMs: timestamp } = stats;\n\n\t\t\t\t\t\t\t\t\tconst item: CollectionItem = { id, filePath, absoluteFilePath, timestamp };\n\n\t\t\t\t\t\t\t\t\tcollection.data.set(id, { item, content: null, document: null });\n\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tcase \"delete\": {\n\t\t\t\t\t\t\t\t\tisCollectionChanged ||= collection.data.has(id);\n\n\t\t\t\t\t\t\t\t\tcollection.data.delete(id);\n\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (isCollectionChanged) {\n\t\t\t\t\t\t\tawait generate(controller.signal);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, debounceDelayMs);\n\t\t\t\t},\n\t\t\t\t{ ignore },\n\t\t\t);\n\n\t\t\tsubscriptions.add(subscription);\n\t\t}\n\n\t\tasync function unsubscribe() {\n\t\t\tdebug(\"Cleaning up...\");\n\n\t\t\tif (timer != null) {\n\t\t\t\tclearTimeout(timer);\n\t\t\t}\n\t\t\ttimer = null;\n\n\t\t\tif (controller != null) {\n\t\t\t\tcontroller.abort();\n\t\t\t}\n\t\t\tcontroller = null;\n\n\t\t\tfor (const subscription of subscriptions) {\n\t\t\t\tawait subscription.unsubscribe();\n\t\t\t}\n\t\t\tsubscriptions.clear();\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-misused-promises\n\t\tprocess.once(\"SIGINT\", unsubscribe);\n\t\t// eslint-disable-next-line @typescript-eslint/no-misused-promises\n\t\tprocess.once(\"SIGTERM\", unsubscribe);\n\n\t\treturn subscriptions;\n\t}\n\n\treturn {\n\t\tbuild,\n\t\twatch,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,QAAQ,SAAS;AAIvB,SAAS,kBAAkB,OAAuB;AACjD,QAAO,OAAO,WAAW,UAAU,OAAO,OAAO,OAAO;AACxD;AAED,SAAS,qBAAqB,UAA0B;CACvD,MAAM,SAAS,KAAK,MAAM;AAE1B,KAAI,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SAAS,YAAY,WAAW,KAAK,IAAI;QAEvE,MAAM,mBAAmB,KAAK,KAAK,WAAW,WAAW;QAEzD,MAAM,QAAQ,MAAM,GAAG,KAAK,kBAAkB,OAAO,YAAmB;AACvE,aAAIC,mBAAiB,SAAS,UAAUA,WAASA,QAAM,SAAS,SAC/D,QAAO;AAER,eAAMA;QACN;AACD,YAAI,SAAS,KACZ;QAED,MAAM,EAAE,SAAS,WAAW,GAAG;QAE/B,MAAMJ,OAAuB;SAAE;SAAI;SAAU;SAAkB;SAAW;AAE1E,mBAAW,KAAK,IAAI,IAAI;SAAE;SAAM,SAAS;SAAM,UAAU;SAAM;AAE/D;OACA;OAED,KAAK;AACJ,gCAAwB,WAAW,KAAK,IAAI;AAE5C,mBAAW,KAAK,OAAO;AAEvB;MAED;KACD;AAED,SAAI,oBACH,OAAM,SAAS,WAAW;IAE3B,GAAE;GACH,GACD,EAAE,QAAQ;AAGX,iBAAc,IAAI;EAClB;EAED,eAAe,cAAc;AAC5B,SAAM;AAEN,OAAI,SAAS,KACZ,cAAa;AAEd,WAAQ;AAER,OAAI,cAAc,KACjB,YAAW;AAEZ,gBAAa;AAEb,QAAK,MAAM,gBAAgB,cAC1B,OAAM,aAAa;AAEpB,iBAAc;EACd;AAGD,UAAQ,KAAK,UAAU;AAEvB,UAAQ,KAAK,WAAW;AAExB,SAAO;CACP;AAED,QAAO;EACN;EACA;EACA;AACD"}
1
+ {"version":3,"file":"index.js","names":["path","imports: Array<string>","value","collections: Array<Collection>","context: TransformContext","item: CollectionItem","timer: ReturnType<typeof setTimeout> | null","controller: AbortController | null","events","error"],"sources":["../src/index.ts"],"sourcesContent":["import * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs/promises\";\nimport { availableParallelism } from \"node:os\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { debuglog } from \"node:util\";\n\nimport { addTrailingSlash, log } from \"@acdh-oeaw/lib\";\nimport * as watcher from \"@parcel/watcher\";\nimport { pascalCase } from \"change-case\";\nimport plimit from \"p-limit\";\nimport pluralize from \"pluralize\";\n\n//\n\nconst debug = debuglog(\"content-lib\");\n\n//\n\nfunction createContentHash(value: string): string {\n\treturn crypto.createHash(\"sha256\").update(value).digest(\"hex\");\n}\n\nfunction createIdFromFilePath(filePath: string): string {\n\tconst parsed = path.parse(filePath);\n\n\tif (parsed.name.toLowerCase() === \"index\") {\n\t\treturn path.basename(parsed.dir);\n\t}\n\n\treturn parsed.name;\n}\n\n//\n\ntype MaybePromise<T> = T | Promise<T>;\n\ntype NonEmptyReadonlyArray<T> = readonly [T, ...Array<T>];\n\ntype GlobString = string;\n\ninterface CollectionItem {\n\t/** Unique identifier. */\n\tid: string;\n\t/** File path relative to colleciton directory. */\n\tfilePath: string;\n\t/** File path relative to current working directory. */\n\tabsoluteFilePath: string;\n\t/** File modification timestamp. */\n\ttimestamp: number;\n}\n\ninterface TransformContext {\n\tcollections: Array<Collection>;\n\tcreateImportDeclaration: <T>(path: string) => ImportDeclaration<T>;\n\tcreateJavaScriptImport: <T>(content: string) => JavaScriptImport<T>;\n\tcreateJsonImport: <T>(content: string) => JsonImport<T>;\n}\n\nexport interface CollectionConfig<\n\tTCollectionName extends string = string,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTCollectionItemContent = any,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTCollectionDocument = any,\n> {\n\tname: TCollectionName;\n\tdirectory: string;\n\tinclude: NonEmptyReadonlyArray<GlobString>;\n\texclude?: ReadonlyArray<GlobString>;\n\tread: (item: CollectionItem) => MaybePromise<TCollectionItemContent>;\n\ttransform: (\n\t\tcontent: TCollectionItemContent,\n\t\titem: CollectionItem,\n\t\tcontext: TransformContext,\n\t) => MaybePromise<TCollectionDocument>;\n}\n\nexport function createCollection<\n\tTCollectionName extends string,\n\tTCollectionItemContent,\n\tTCollectionDocument,\n>(\n\tconfig: CollectionConfig<TCollectionName, TCollectionItemContent, TCollectionDocument>,\n): CollectionConfig<TCollectionName, TCollectionItemContent, TCollectionDocument> {\n\treturn config;\n}\n\nexport interface ContentConfig {\n\tcollections: Array<CollectionConfig>;\n}\n\nexport function createConfig<T extends ContentConfig>(config: T): T {\n\treturn config;\n}\n\n//\n\n// function createItemCacheKey(item: CollectionItem): string {\n// \treturn String(item.timestamp);\n// }\n\n//\n\nclass ImportDeclaration<T> {\n\tprivate __brand!: never;\n\tvalue!: T;\n\tpath: string;\n\n\tconstructor(path: string) {\n\t\tthis.path = path;\n\t}\n}\n\nfunction createImportDeclaration<T>(path: string): ImportDeclaration<T> {\n\treturn new ImportDeclaration<T>(path);\n}\n\nclass JavaScriptImport<T> {\n\tprivate __brand!: never;\n\tvalue!: T;\n\tcontent: string;\n\n\tconstructor(content: string) {\n\t\tthis.content = content;\n\t}\n}\n\nfunction createJavaScriptImport<T>(content: string): JavaScriptImport<T> {\n\treturn new JavaScriptImport<T>(content);\n}\n\nclass JsonImport<T> {\n\tprivate __brand!: never;\n\tvalue!: T;\n\tcontent: string;\n\n\tconstructor(content: string) {\n\t\tthis.content = content;\n\t}\n}\n\nfunction createJsonImport<T>(content: string): JsonImport<T> {\n\treturn new JsonImport<T>(content);\n}\n\n//\n\nexport type GetCollection<TConfig extends ContentConfig, TName extends string> = Extract<\n\tTConfig[\"collections\"][number],\n\t{ name: TName }\n>;\n\ntype Simplify<T> = { [K in keyof T]: T[K] } & {};\n\ntype Replace<T> = {\n\t[K in keyof T]: T[K] extends JavaScriptImport<infer U>\n\t\t? U\n\t\t: T[K] extends JsonImport<infer U>\n\t\t\t? U\n\t\t\t: T[K] extends ImportDeclaration<infer U>\n\t\t\t\t? U\n\t\t\t\t: T[K] extends object\n\t\t\t\t\t? Simplify<Replace<T[K]>>\n\t\t\t\t\t: T[K];\n};\n\nexport type CollectionEntry<TCollection extends Collection> = Simplify<{\n\titem: { id: string };\n\tcontent: Simplify<Awaited<ReturnType<TCollection[\"read\"]>>>;\n\tdocument: Simplify<Replace<Awaited<ReturnType<TCollection[\"transform\"]>>>>;\n}>;\n\n//\n\nconst prefix = \"__i__\";\nconst re = new RegExp(`\"(${prefix}\\\\d+)\"`, \"g\");\n\nfunction serialize(\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tvalue: Map<string, any>,\n\tcontentProcessorConfigFilePath: string,\n\tcollectionName: string,\n): Map<string, string> {\n\tdebug(\"Serializing...\\n\");\n\n\tconst imports: Array<string> = [];\n\n\tfunction addImport(filePath: string, type: \"js\" | \"json\" = \"js\"): string {\n\t\tconst identifier = [prefix, imports.length].join(\"\");\n\t\timports.push(\n\t\t\t`import ${identifier} from \"${filePath}\"${type !== \"js\" ? ` with { type: \"${type}\" }` : \"\"};`,\n\t\t);\n\n\t\treturn identifier;\n\t}\n\n\tconst files = new Map<string, string>();\n\n\tfunction addFiles(filePath: string, content: string): void {\n\t\tfiles.set(filePath, content);\n\t}\n\n\tconst json = JSON.stringify(\n\t\tArray.from(value),\n\t\t// TODO: Should we support (multiple) named imports?\n\t\t(_key, value) => {\n\t\t\tif (value instanceof ImportDeclaration) {\n\t\t\t\tconst filePath = value.path;\n\n\t\t\t\tdebug(`Adding import declaration for \"${filePath}\".`);\n\t\t\t\tconst identifier = addImport(filePath);\n\n\t\t\t\treturn identifier;\n\t\t\t}\n\n\t\t\tif (value instanceof JavaScriptImport) {\n\t\t\t\tconst hash = createContentHash(value.content);\n\t\t\t\tconst filePath = `./${hash}.jsx`;\n\n\t\t\t\tdebug(`Adding javascript import for \"${filePath}\".`);\n\t\t\t\tconst identifier = addImport(filePath);\n\t\t\t\taddFiles(filePath, `// @ts-nocheck\\n${value.content}`);\n\n\t\t\t\treturn identifier;\n\t\t\t}\n\n\t\t\tif (value instanceof JsonImport) {\n\t\t\t\tconst hash = createContentHash(value.content);\n\t\t\t\tconst filePath = `./${hash}.json`;\n\n\t\t\t\tdebug(`Adding json import for \"${filePath}\".`);\n\t\t\t\tconst identifier = addImport(filePath, \"json\");\n\t\t\t\taddFiles(filePath, value.content);\n\n\t\t\t\treturn identifier;\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value;\n\t\t},\n\t\t2,\n\t)\n\t\t/** Remove quotes from import identifiers. */\n\t\t.replaceAll(re, \"$1\");\n\n\tlet result = \"\";\n\n\tif (imports.length > 0) {\n\t\tresult += imports.join(\"\\n\");\n\t\tresult += \"\\n\\n\";\n\t}\n\n\tresult += [`const items = new Map(${json});`, \"export default items;\"].join(\"\\n\\n\");\n\n\tfiles.set(\"index.js\", result);\n\n\t// eslint-disable-next-line import-x/no-named-as-default-member\n\tconst typeName = pascalCase(pluralize.singular(collectionName));\n\n\tfiles.set(\n\t\t\"index.d.ts\",\n\t\t[\n\t\t\t`import type { GetCollection, CollectionEntry } from \"@acdh-oeaw/content-lib\";`,\n\t\t\t\"\",\n\t\t\t`import type { config } from \"${contentProcessorConfigFilePath}\";`,\n\t\t\t\"\",\n\t\t\t`type Collection = GetCollection<typeof config, \"${collectionName}\">;`,\n\t\t\t`type ${typeName} = CollectionEntry<Collection>;`,\n\t\t\t\"\",\n\t\t\t`declare const items: Map<string, ${typeName}>;`,\n\t\t\t`export { type ${typeName}, items as default };`,\n\t\t].join(\"\\n\"),\n\t);\n\n\treturn files;\n}\n\n//\n\ninterface Collection extends CollectionConfig {\n\tabsoluteDirectoryPath: string;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdata: Map<CollectionItem[\"id\"], { item: CollectionItem; content: any; document: any }>; // TODO: revisit\n\toutputDirectoryPath: string;\n}\n\ninterface BuildStats {\n\tcollections: number;\n\tdocuments: number;\n}\n\nexport interface ContentProcessorConfig {\n\t/** Path to config file, relative to `process.cwd()`, which provides a named export `config`. */\n\tconfigFilePath: string;\n}\n\nexport interface ContentProcessor {\n\tbuild: () => Promise<BuildStats>;\n\twatch: () => Promise<Set<watcher.AsyncSubscription>>;\n}\n\nexport async function createContentProcessor(\n\tcontentProcessorConfig: ContentProcessorConfig,\n): Promise<ContentProcessor> {\n\tdebug(\"Creating content processor...\\n\");\n\n\tdebug(\"Reading config file...\");\n\tconst contentProcessorConfigUrl = pathToFileURL(\n\t\tpath.resolve(contentProcessorConfig.configFilePath),\n\t);\n\tcontentProcessorConfigUrl.searchParams.set(\"cache-key\", String(Date.now()));\n\tconst contentProcessorConfigFilePath = String(contentProcessorConfigUrl);\n\tconst { config } = (await import(contentProcessorConfigFilePath)) as { config: ContentConfig }; // TODO: validate\n\tdebug(`Done reading config file \"${contentProcessorConfigFilePath}\".`);\n\n\tconst concurrency = availableParallelism();\n\tconst limit = plimit(concurrency);\n\tdebug(`Concurrency: ${String(concurrency)}.\\n`);\n\n\tconst outputDirectoryBasePath = path.join(process.cwd(), \".content\", \"generated\");\n\n\tconst collections: Array<Collection> = [];\n\n\tconst context: TransformContext = {\n\t\tcollections,\n\t\tcreateImportDeclaration,\n\t\tcreateJavaScriptImport,\n\t\tcreateJsonImport,\n\t};\n\n\tfor (const collection of config.collections) {\n\t\tconst absoluteDirectoryPath = addTrailingSlash(path.resolve(collection.directory));\n\n\t\t/** Ensure directory exists, which is expected by `@parcel/watcher`. */\n\t\tawait fs.mkdir(absoluteDirectoryPath, { recursive: true });\n\n\t\tconst outputDirectoryPath = path.join(\n\t\t\toutputDirectoryBasePath,\n\t\t\tcollection.name.toLowerCase().replaceAll(/[^a-z0-9_-]/g, \"-\"),\n\t\t);\n\n\t\tcollections.push({\n\t\t\t...collection,\n\t\t\tabsoluteDirectoryPath,\n\t\t\tdata: new Map(),\n\t\t\toutputDirectoryPath,\n\t\t});\n\t}\n\n\tasync function generate(signal?: AbortSignal): Promise<void> {\n\t\tdebug(\"Generating...\\n\");\n\n\t\tfor (const collection of collections) {\n\t\t\tdebug(`Reading collection \"${collection.name}\"...`);\n\n\t\t\tawait limit.map(Array.from(collection.data), async ([id, { item }]) => {\n\t\t\t\tif (signal?.aborted === true) {\n\t\t\t\t\tdebug(\"Aborted reading collections.\");\n\t\t\t\t\tlimit.clearQueue();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// FIXME: race condition: what if file has been deleted in the meantime\n\t\t\t\t// TODO: skip item when `read()` returns `null`?\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tconst content = await collection.read(item);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tcollection.data.get(id)!.content = content;\n\n\t\t\t\tdebug(`- Read item \"${id}\".`);\n\t\t\t});\n\n\t\t\tdebug(\n\t\t\t\t`Done reading ${String(collection.data.size)} item(s) in collection \"${collection.name}\".\\n`,\n\t\t\t);\n\t\t}\n\n\t\tfor (const collection of collections) {\n\t\t\tdebug(`Transforming collection \"${collection.name}\"...`);\n\n\t\t\tawait limit.map(Array.from(collection.data), async ([id, { content, item }]) => {\n\t\t\t\tif (signal?.aborted === true) {\n\t\t\t\t\tdebug(\"Aborted transforming collections.\");\n\t\t\t\t\tlimit.clearQueue();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tconst document = await collection.transform(content, item, context);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tcollection.data.get(id)!.document = document;\n\n\t\t\t\tdebug(`- Transformed item \"${id}\".`);\n\t\t\t});\n\n\t\t\tdebug(\n\t\t\t\t`Done transforming ${String(collection.data.size)} item(s) in collection \"${collection.name}\".\\n`,\n\t\t\t);\n\t\t}\n\n\t\tif (signal?.aborted === true) {\n\t\t\tdebug(\"Aborted writing collections.\");\n\t\t\treturn;\n\t\t}\n\n\t\tdebug(\"Clearing output directory...\\n\");\n\t\tawait fs.rm(outputDirectoryBasePath, { force: true, recursive: true });\n\n\t\tfor (const collection of collections) {\n\t\t\tdebug(`Writing collection \"${collection.name}\".`);\n\n\t\t\tdebug(`Creating output directory for \"${collection.name}\".`);\n\t\t\tawait fs.mkdir(collection.outputDirectoryPath, { recursive: true });\n\n\t\t\tconst files = serialize(\n\t\t\t\tcollection.data,\n\t\t\t\tpath.relative(collection.outputDirectoryPath, contentProcessorConfig.configFilePath),\n\t\t\t\tcollection.name,\n\t\t\t);\n\n\t\t\tawait limit.map(Array.from(files), async ([filePath, fileContent]) => {\n\t\t\t\tconst outputFilePath = path.join(collection.outputDirectoryPath, filePath);\n\t\t\t\tawait fs.writeFile(outputFilePath, fileContent, { encoding: \"utf-8\" });\n\t\t\t});\n\t\t}\n\t}\n\n\tasync function build(): Promise<BuildStats> {\n\t\tdebug(\"Building...\\n\");\n\n\t\tfor (const collection of collections) {\n\t\t\tdebug(`Building collection \"${collection.name}\"...`);\n\n\t\t\t// eslint-disable-next-line n/no-unsupported-features/node-builtins\n\t\t\tfor await (const filePath of fs.glob(collection.include, {\n\t\t\t\tcwd: collection.directory,\n\t\t\t\texclude: collection.exclude,\n\t\t\t})) {\n\t\t\t\tconst absoluteFilePath = path.join(collection.directory, filePath);\n\t\t\t\tconst id = createIdFromFilePath(filePath);\n\n\t\t\t\tconst stats = await fs.stat(absoluteFilePath).catch((error: unknown) => {\n\t\t\t\t\tif (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t\tif (stats == null) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst { mtimeMs: timestamp } = stats;\n\n\t\t\t\tconst item: CollectionItem = { id, filePath, absoluteFilePath, timestamp };\n\n\t\t\t\tcollection.data.set(id, { item, content: null, document: null });\n\n\t\t\t\tdebug(`- Added item \"${id}\" (path: \"${filePath}\").`);\n\t\t\t}\n\n\t\t\tdebug(\n\t\t\t\t`Done adding ${String(collection.data.size)} item(s) to collection \"${collection.name}\".\\n`,\n\t\t\t);\n\t\t}\n\n\t\tawait generate();\n\n\t\treturn {\n\t\t\tcollections: collections.length,\n\t\t\tdocuments: collections.reduce((acc, collection) => {\n\t\t\t\treturn acc + collection.data.size;\n\t\t\t}, 0),\n\t\t};\n\t}\n\n\tasync function watch(): Promise<Set<watcher.AsyncSubscription>> {\n\t\tdebug(\"Watching...\\n\");\n\n\t\tconst subscriptions = new Set<watcher.AsyncSubscription>();\n\n\t\tconst debounceDelayMs = 150;\n\t\tlet timer: ReturnType<typeof setTimeout> | null = null;\n\t\tlet controller: AbortController | null = null;\n\t\tlet batch = new Map<watcher.Event[\"path\"], watcher.Event & { relativeFilePath: string }>();\n\n\t\tfor (const collection of collections) {\n\t\t\tdebug(`Watching collection \"${collection.name}\"...`);\n\n\t\t\t/**\n\t\t\t * Ideally, we could just add `include` as a negative ignore pattern.\n\t\t\t *\n\t\t\t * This is currently not supported by `@parcel/watcher`. Simple patterns like \"!*.md\" do seem\n\t\t\t * to work, but others like \"!*\\/index.md\" do not.\n\t\t\t *\n\t\t\t * Therefore we need to filter out matching events in the javascript main thread\n\t\t\t * (see `path.matchesGlob` below).\n\t\t\t *\n\t\t\t * @see https://github.com/parcel-bundler/watcher/issues/166\n\t\t\t */\n\t\t\t// const ignore = [\n\t\t\t// \t...collection.include.map((glob) => {\n\t\t\t// \t\treturn `!${glob}`;\n\t\t\t// \t}),\n\t\t\t// \t...(collection.exclude ?? []),\n\t\t\t// ];\n\t\t\tconst ignore = (collection.exclude ?? []) as Array<string>;\n\n\t\t\tconst subscription = await watcher.subscribe(\n\t\t\t\tcollection.directory,\n\t\t\t\t(error, events) => {\n\t\t\t\t\tif (error != null) {\n\t\t\t\t\t\tlog.error(error);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tdebug(`- ${String(events.length)} events in collection \"${collection.name}\".`);\n\n\t\t\t\t\tfor (const event of events) {\n\t\t\t\t\t\t// const relativeFilePath = path.relative(collection.directory, event.path);\n\t\t\t\t\t\tconst relativeFilePath = event.path.slice(collection.absoluteDirectoryPath.length);\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcollection.include.some((pattern) => {\n\t\t\t\t\t\t\t\t// eslint-disable-next-line n/no-unsupported-features/node-builtins\n\t\t\t\t\t\t\t\treturn path.matchesGlob(relativeFilePath, pattern);\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t(event as watcher.Event & { relativeFilePath: string }).relativeFilePath =\n\t\t\t\t\t\t\t\trelativeFilePath;\n\t\t\t\t\t\t\tbatch.set(event.path, event as watcher.Event & { relativeFilePath: string });\n\n\t\t\t\t\t\t\tdebug(`- Added \"${event.type}\" event for \"${relativeFilePath}\" to queue.`);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdebug(`- Discarded \"${event.type}\" event for \"${relativeFilePath}\".`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (timer != null) {\n\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t}\n\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-misused-promises\n\t\t\t\t\ttimer = setTimeout(async () => {\n\t\t\t\t\t\tif (controller != null) {\n\t\t\t\t\t\t\tcontroller.abort();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontroller = new AbortController();\n\n\t\t\t\t\t\tconst events = batch;\n\t\t\t\t\t\tbatch = new Map();\n\t\t\t\t\t\ttimer = null;\n\n\t\t\t\t\t\tlet isCollectionChanged = false;\n\n\t\t\t\t\t\tfor (const event of events.values()) {\n\t\t\t\t\t\t\tconst filePath = event.relativeFilePath;\n\t\t\t\t\t\t\tconst id = createIdFromFilePath(filePath);\n\n\t\t\t\t\t\t\tdebug(`Processing \"${event.type}\" event for \"${id}\".`);\n\n\t\t\t\t\t\t\tswitch (event.type) {\n\t\t\t\t\t\t\t\tcase \"create\":\n\t\t\t\t\t\t\t\tcase \"update\": {\n\t\t\t\t\t\t\t\t\tisCollectionChanged ||= event.type === \"create\" || collection.data.has(id);\n\n\t\t\t\t\t\t\t\t\tconst absoluteFilePath = path.join(collection.directory, filePath);\n\n\t\t\t\t\t\t\t\t\tconst stats = await fs.stat(absoluteFilePath).catch((error: unknown) => {\n\t\t\t\t\t\t\t\t\t\tif (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n\t\t\t\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tif (stats == null) {\n\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst { mtimeMs: timestamp } = stats;\n\n\t\t\t\t\t\t\t\t\tconst item: CollectionItem = { id, filePath, absoluteFilePath, timestamp };\n\n\t\t\t\t\t\t\t\t\tcollection.data.set(id, { item, content: null, document: null });\n\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tcase \"delete\": {\n\t\t\t\t\t\t\t\t\tisCollectionChanged ||= collection.data.has(id);\n\n\t\t\t\t\t\t\t\t\tcollection.data.delete(id);\n\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (isCollectionChanged) {\n\t\t\t\t\t\t\tawait generate(controller.signal);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, debounceDelayMs);\n\t\t\t\t},\n\t\t\t\t{ ignore },\n\t\t\t);\n\n\t\t\tsubscriptions.add(subscription);\n\t\t}\n\n\t\tasync function unsubscribe() {\n\t\t\tdebug(\"Cleaning up...\");\n\n\t\t\tif (timer != null) {\n\t\t\t\tclearTimeout(timer);\n\t\t\t}\n\t\t\ttimer = null;\n\n\t\t\tif (controller != null) {\n\t\t\t\tcontroller.abort();\n\t\t\t}\n\t\t\tcontroller = null;\n\n\t\t\tfor (const subscription of subscriptions) {\n\t\t\t\tawait subscription.unsubscribe();\n\t\t\t}\n\t\t\tsubscriptions.clear();\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-misused-promises\n\t\tprocess.once(\"SIGINT\", unsubscribe);\n\t\t// eslint-disable-next-line @typescript-eslint/no-misused-promises\n\t\tprocess.once(\"SIGTERM\", unsubscribe);\n\n\t\treturn subscriptions;\n\t}\n\n\treturn {\n\t\tbuild,\n\t\twatch,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,QAAQ,SAAS;AAIvB,SAAS,kBAAkB,OAAuB;AACjD,QAAO,OAAO,WAAW,UAAU,OAAO,OAAO,OAAO;AACxD;AAED,SAAS,qBAAqB,UAA0B;CACvD,MAAM,SAAS,KAAK,MAAM;AAE1B,KAAI,OAAO,KAAK,kBAAkB,QACjC,QAAO,KAAK,SAAS,OAAO;AAG7B,QAAO,OAAO;AACd;AA+CD,SAAgB,iBAKf,QACiF;AACjF,QAAO;AACP;AAMD,SAAgB,aAAsC,QAAc;AACnE,QAAO;AACP;AAUD,IAAM,oBAAN,MAA2B;CAC1B,AAAQ;CACR;CACA;CAEA,YAAY,QAAc;AACzB,OAAK,OAAOA;CACZ;AACD;AAED,SAAS,wBAA2B,QAAoC;AACvE,QAAO,IAAI,kBAAqBA;AAChC;AAED,IAAM,mBAAN,MAA0B;CACzB,AAAQ;CACR;CACA;CAEA,YAAY,SAAiB;AAC5B,OAAK,UAAU;CACf;AACD;AAED,SAAS,uBAA0B,SAAsC;AACxE,QAAO,IAAI,iBAAoB;AAC/B;AAED,IAAM,aAAN,MAAoB;CACnB,AAAQ;CACR;CACA;CAEA,YAAY,SAAiB;AAC5B,OAAK,UAAU;CACf;AACD;AAED,SAAS,iBAAoB,SAAgC;AAC5D,QAAO,IAAI,WAAc;AACzB;AA+BD,MAAM,SAAS;AACf,MAAM,KAAK,IAAI,OAAO,KAAK,OAAO,SAAS;AAE3C,SAAS,UAER,OACA,gCACA,gBACsB;AACtB,OAAM;CAEN,MAAMC,UAAyB,EAAE;CAEjC,SAAS,UA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,KAAK,UAAU;AAEvB,UAAQ,KAAK,WAAW;AAExB,SAAO;CACP;AAED,QAAO;EACN;EACA;EACA;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acdh-oeaw/content-lib",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {