@nhtio/adk 0.1.0-master-e6c58205 → 0.1.0-master-89b47bec
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/CHANGELOG.md +94 -0
- package/__vite-browser-external-CU7uua8b.mjs +9 -0
- package/__vite-browser-external-CU7uua8b.mjs.map +1 -0
- package/__vite-browser-external-DAHxjh-D.js +13 -0
- package/__vite-browser-external-DAHxjh-D.js.map +1 -0
- package/batteries/embeddings/openai/adapter.cjs +1 -1
- package/batteries/embeddings/openai/adapter.mjs +1 -1
- package/batteries/embeddings/webllm/adapter.cjs +1 -1
- package/batteries/embeddings/webllm/adapter.mjs +1 -1
- package/batteries/llm/ollama/adapter.cjs +5 -5
- package/batteries/llm/ollama/adapter.mjs +5 -5
- package/batteries/llm/ollama/helpers.cjs +2 -2
- package/batteries/llm/ollama/helpers.mjs +2 -2
- package/batteries/llm/ollama/validation.cjs +1 -1
- package/batteries/llm/ollama/validation.mjs +1 -1
- package/batteries/llm/openai_chat_completions/adapter.cjs +5 -5
- package/batteries/llm/openai_chat_completions/adapter.mjs +5 -5
- package/batteries/llm/openai_chat_completions/helpers.cjs +2 -2
- package/batteries/llm/openai_chat_completions/helpers.mjs +2 -2
- package/batteries/llm/openai_chat_completions/validation.cjs +1 -1
- package/batteries/llm/openai_chat_completions/validation.mjs +1 -1
- package/batteries/llm/webllm_chat_completions/adapter.cjs +5 -5
- package/batteries/llm/webllm_chat_completions/adapter.mjs +5 -5
- package/batteries/llm/webllm_chat_completions/validation.cjs +1 -1
- package/batteries/llm/webllm_chat_completions/validation.mjs +1 -1
- package/batteries/media/contracts.cjs +38 -8
- package/batteries/media/contracts.cjs.map +1 -1
- package/batteries/media/contracts.d.ts +86 -6
- package/batteries/media/contracts.mjs +37 -9
- package/batteries/media/contracts.mjs.map +1 -1
- package/batteries/media/engines/audio_decode.cjs +46 -6
- package/batteries/media/engines/audio_decode.cjs.map +1 -1
- package/batteries/media/engines/audio_decode.d.ts +9 -5
- package/batteries/media/engines/audio_decode.mjs +47 -7
- package/batteries/media/engines/audio_decode.mjs.map +1 -1
- package/batteries/media/engines/data.cjs +159 -0
- package/batteries/media/engines/data.cjs.map +1 -0
- package/batteries/media/engines/data.d.ts +36 -0
- package/batteries/media/engines/data.mjs +157 -0
- package/batteries/media/engines/data.mjs.map +1 -0
- package/batteries/media/engines/exceljs.cjs +290 -0
- package/batteries/media/engines/exceljs.cjs.map +1 -0
- package/batteries/media/engines/exceljs.d.ts +41 -0
- package/batteries/media/engines/exceljs.mjs +288 -0
- package/batteries/media/engines/exceljs.mjs.map +1 -0
- package/batteries/media/engines/execa_executor.cjs +1 -1
- package/batteries/media/engines/execa_executor.mjs +1 -1
- package/batteries/media/engines/fs_workspace.cjs +1 -1
- package/batteries/media/engines/fs_workspace.mjs +1 -1
- package/batteries/media/engines/jimp.cjs +24 -2
- package/batteries/media/engines/jimp.cjs.map +1 -1
- package/batteries/media/engines/jimp.d.ts +3 -1
- package/batteries/media/engines/jimp.mjs +24 -2
- package/batteries/media/engines/jimp.mjs.map +1 -1
- package/batteries/media/engines/sharp.cjs +37 -4
- package/batteries/media/engines/sharp.cjs.map +1 -1
- package/batteries/media/engines/sharp.d.ts +5 -3
- package/batteries/media/engines/sharp.mjs +37 -4
- package/batteries/media/engines/sharp.mjs.map +1 -1
- package/batteries/media/engines/sheetjs.cjs +438 -0
- package/batteries/media/engines/sheetjs.cjs.map +1 -0
- package/batteries/media/engines/sheetjs.d.ts +51 -0
- package/batteries/media/engines/sheetjs.mjs +436 -0
- package/batteries/media/engines/sheetjs.mjs.map +1 -0
- package/batteries/media/engines/soffice.cjs +37 -3
- package/batteries/media/engines/soffice.cjs.map +1 -1
- package/batteries/media/engines/soffice.mjs +38 -4
- package/batteries/media/engines/soffice.mjs.map +1 -1
- package/batteries/media/engines/tesseract_js.cjs +1 -1
- package/batteries/media/engines/tesseract_js.mjs +1 -1
- package/batteries/media/engines/transformers_asr.cjs +1 -1
- package/batteries/media/engines/transformers_asr.mjs +1 -1
- package/batteries/media/forge.cjs +89 -20
- package/batteries/media/forge.cjs.map +1 -1
- package/batteries/media/forge.mjs +89 -20
- package/batteries/media/forge.mjs.map +1 -1
- package/batteries/media/formats.d.ts +9 -0
- package/batteries/media/index.d.ts +8 -6
- package/batteries/media/lint.cjs +270 -58
- package/batteries/media/lint.cjs.map +1 -1
- package/batteries/media/lint.d.ts +45 -0
- package/batteries/media/lint.mjs +267 -58
- package/batteries/media/lint.mjs.map +1 -1
- package/batteries/media/registry.d.ts +11 -2
- package/batteries/media/steps/data.d.ts +26 -0
- package/batteries/media/steps/doc.d.ts +17 -7
- package/batteries/media/steps/patch.d.ts +90 -0
- package/batteries/media/steps/sheet.d.ts +10 -6
- package/batteries/media/steps/text.d.ts +4 -1
- package/batteries/media/validate.d.ts +5 -0
- package/batteries/media/verbs.d.ts +12 -1
- package/batteries/media.cjs +869 -448
- package/batteries/media.cjs.map +1 -1
- package/batteries/media.mjs +829 -409
- package/batteries/media.mjs.map +1 -1
- package/batteries/storage/flydrive.cjs +3 -6
- package/batteries/storage/flydrive.cjs.map +1 -1
- package/batteries/storage/flydrive.mjs +3 -6
- package/batteries/storage/flydrive.mjs.map +1 -1
- package/batteries/storage/in_memory.cjs +1 -1
- package/batteries/storage/in_memory.mjs +1 -1
- package/batteries/storage/opfs.cjs +1 -1
- package/batteries/storage/opfs.mjs +1 -1
- package/batteries/tools/_shared.cjs +2 -2
- package/batteries/tools/_shared.mjs +2 -2
- package/batteries/tools/color.cjs +2 -2
- package/batteries/tools/color.mjs +2 -2
- package/batteries/tools/comparison.cjs +3 -3
- package/batteries/tools/comparison.mjs +3 -3
- package/batteries/tools/data_structure.cjs +3 -3
- package/batteries/tools/data_structure.mjs +3 -3
- package/batteries/tools/datetime_extended.cjs +3 -3
- package/batteries/tools/datetime_extended.mjs +3 -3
- package/batteries/tools/datetime_math.cjs +3 -3
- package/batteries/tools/datetime_math.mjs +3 -3
- package/batteries/tools/encoding.cjs +3 -3
- package/batteries/tools/encoding.mjs +3 -3
- package/batteries/tools/formatting.cjs +3 -3
- package/batteries/tools/formatting.mjs +3 -3
- package/batteries/tools/geo_basics.cjs +2 -2
- package/batteries/tools/geo_basics.mjs +2 -2
- package/batteries/tools/math.cjs +3 -3
- package/batteries/tools/math.mjs +3 -3
- package/batteries/tools/memory.cjs +6 -6
- package/batteries/tools/memory.mjs +6 -6
- package/batteries/tools/parsing.cjs +4 -4
- package/batteries/tools/parsing.mjs +4 -4
- package/batteries/tools/retrievables.cjs +5 -5
- package/batteries/tools/retrievables.mjs +5 -5
- package/batteries/tools/scrapper.cjs +1 -1
- package/batteries/tools/scrapper.mjs +1 -1
- package/batteries/tools/searxng.cjs +1 -1
- package/batteries/tools/searxng.mjs +1 -1
- package/batteries/tools/standing_instructions.cjs +4 -4
- package/batteries/tools/standing_instructions.mjs +4 -4
- package/batteries/tools/statistics.cjs +4 -4
- package/batteries/tools/statistics.mjs +4 -4
- package/batteries/tools/string_processing.cjs +3 -3
- package/batteries/tools/string_processing.mjs +3 -3
- package/batteries/tools/structured_data.cjs +3 -3
- package/batteries/tools/structured_data.mjs +3 -3
- package/batteries/tools/text_analysis.cjs +3 -3
- package/batteries/tools/text_analysis.mjs +3 -3
- package/batteries/tools/text_comparison.cjs +2 -2
- package/batteries/tools/text_comparison.mjs +2 -2
- package/batteries/tools/time.cjs +3 -3
- package/batteries/tools/time.mjs +3 -3
- package/batteries/tools/unit_conversion.cjs +2 -2
- package/batteries/tools/unit_conversion.mjs +2 -2
- package/batteries/tools/web_retrieval.cjs +1 -1
- package/batteries/tools/web_retrieval.mjs +1 -1
- package/batteries/tools.cjs +2 -2
- package/batteries/tools.mjs +2 -2
- package/batteries/vector/arangodb.cjs +1 -1
- package/batteries/vector/arangodb.mjs +1 -1
- package/batteries/vector/clickhouse.cjs +1 -1
- package/batteries/vector/clickhouse.mjs +1 -1
- package/batteries/vector/cloudflare.cjs +1 -1
- package/batteries/vector/cloudflare.mjs +1 -1
- package/batteries/vector/couchbase.cjs +1 -1
- package/batteries/vector/couchbase.mjs +1 -1
- package/batteries/vector/duckdb.cjs +1 -1
- package/batteries/vector/duckdb.mjs +1 -1
- package/batteries/vector/elasticsearch.cjs +1 -1
- package/batteries/vector/elasticsearch.mjs +1 -1
- package/batteries/vector/filters.cjs +1 -1
- package/batteries/vector/filters.mjs +1 -1
- package/batteries/vector/hnswlib.cjs +1 -1
- package/batteries/vector/hnswlib.mjs +1 -1
- package/batteries/vector/lancedb.cjs +1 -1
- package/batteries/vector/lancedb.mjs +1 -1
- package/batteries/vector/mariadb.cjs +1 -1
- package/batteries/vector/mariadb.mjs +1 -1
- package/batteries/vector/meilisearch.cjs +1 -1
- package/batteries/vector/meilisearch.mjs +1 -1
- package/batteries/vector/migrate.cjs +1 -1
- package/batteries/vector/migrate.mjs +1 -1
- package/batteries/vector/mongodb.cjs +1 -1
- package/batteries/vector/mongodb.mjs +1 -1
- package/batteries/vector/neo4j.cjs +1 -1
- package/batteries/vector/neo4j.mjs +1 -1
- package/batteries/vector/opensearch.cjs +1 -1
- package/batteries/vector/opensearch.mjs +1 -1
- package/batteries/vector/oracle23ai.cjs +1 -1
- package/batteries/vector/oracle23ai.mjs +1 -1
- package/batteries/vector/pinecone.cjs +1 -1
- package/batteries/vector/pinecone.mjs +1 -1
- package/batteries/vector/redis.cjs +1 -1
- package/batteries/vector/redis.mjs +1 -1
- package/batteries/vector/retrievable.cjs +1 -1
- package/batteries/vector/retrievable.mjs +1 -1
- package/batteries/vector/s3vectors.cjs +1 -1
- package/batteries/vector/s3vectors.mjs +1 -1
- package/batteries/vector/solr.cjs +1 -1
- package/batteries/vector/solr.mjs +1 -1
- package/batteries/vector/surrealdb.cjs +1 -1
- package/batteries/vector/surrealdb.mjs +1 -1
- package/batteries/vector/typesense.cjs +1 -1
- package/batteries/vector/typesense.mjs +1 -1
- package/batteries/vector/vespa.cjs +1 -1
- package/batteries/vector/vespa.mjs +1 -1
- package/batteries/vector/weaviate.cjs +1 -1
- package/batteries/vector/weaviate.mjs +1 -1
- package/batteries.cjs +2 -2
- package/batteries.mjs +2 -2
- package/bundled_xlsx.d.ts +1075 -0
- package/{common-BxoznqbX.mjs → common-BQoFv108.mjs} +7 -7
- package/{common-BxoznqbX.mjs.map → common-BQoFv108.mjs.map} +1 -1
- package/{common-BBK2e5ro.js → common-DmDn4Gfl.js} +7 -7
- package/{common-BBK2e5ro.js.map → common-DmDn4Gfl.js.map} +1 -1
- package/common.cjs +7 -7
- package/common.mjs +7 -7
- package/{dispatch_runner-Hn5idJYx.js → dispatch_runner-BwplbCPr.js} +3 -3
- package/{dispatch_runner-Hn5idJYx.js.map → dispatch_runner-BwplbCPr.js.map} +1 -1
- package/{dispatch_runner-DUrpj0xR.mjs → dispatch_runner-C1ar_D7W.mjs} +3 -3
- package/{dispatch_runner-DUrpj0xR.mjs.map → dispatch_runner-C1ar_D7W.mjs.map} +1 -1
- package/dispatch_runner.cjs +1 -1
- package/dispatch_runner.mjs +1 -1
- package/eslint.cjs +1 -1
- package/eslint.mjs +1 -1
- package/forge.cjs +4 -4
- package/forge.mjs +4 -4
- package/formats-CCylUHZw.mjs +161 -0
- package/formats-CCylUHZw.mjs.map +1 -0
- package/formats-DZVuqZUN.js +196 -0
- package/formats-DZVuqZUN.js.map +1 -0
- package/guards.cjs +8 -8
- package/guards.mjs +8 -8
- package/index.cjs +11 -11
- package/index.mjs +11 -11
- package/mcp/adk-docs-corpus.json +1 -1
- package/package.json +198 -182
- package/{scrapper-DLj_KkxK.mjs → scrapper-Dn2wXu0Y.mjs} +5 -5
- package/{scrapper-DLj_KkxK.mjs.map → scrapper-Dn2wXu0Y.mjs.map} +1 -1
- package/{scrapper-Cmf1CSA-.js → scrapper-mBZ0Odq7.js} +5 -5
- package/{scrapper-Cmf1CSA-.js.map → scrapper-mBZ0Odq7.js.map} +1 -1
- package/{searxng-BKs5s8Su.js → searxng-Dj-iP_Vz.js} +5 -5
- package/{searxng-BKs5s8Su.js.map → searxng-Dj-iP_Vz.js.map} +1 -1
- package/{searxng-BJ-aZcMz.mjs → searxng-DjFxtFf6.mjs} +5 -5
- package/{searxng-BJ-aZcMz.mjs.map → searxng-DjFxtFf6.mjs.map} +1 -1
- package/server.json +21 -0
- package/skills/adk-assembly/SKILL.md +2 -2
- package/{spooled_artifact-BR0IhU9y.js → spooled_artifact-BCmPrxZS.js} +3 -3
- package/{spooled_artifact-BR0IhU9y.js.map → spooled_artifact-BCmPrxZS.js.map} +1 -1
- package/{spooled_artifact-nTE6ujM8.mjs → spooled_artifact-DL36jnqA.mjs} +3 -3
- package/{spooled_artifact-nTE6ujM8.mjs.map → spooled_artifact-DL36jnqA.mjs.map} +1 -1
- package/spooled_artifact.cjs +2 -2
- package/spooled_artifact.mjs +2 -2
- package/{spooled_markdown_artifact-Dj3fNowz.js → spooled_markdown_artifact-CD4PrrpV.js} +3 -3
- package/{spooled_markdown_artifact-Dj3fNowz.js.map → spooled_markdown_artifact-CD4PrrpV.js.map} +1 -1
- package/{spooled_markdown_artifact-DIYzbQv8.mjs → spooled_markdown_artifact-Da-Xnebh.mjs} +3 -3
- package/{spooled_markdown_artifact-DIYzbQv8.mjs.map → spooled_markdown_artifact-Da-Xnebh.mjs.map} +1 -1
- package/{thought-Cde2Y_GK.mjs → thought-CtOoZUSE.mjs} +3 -3
- package/{thought-Cde2Y_GK.mjs.map → thought-CtOoZUSE.mjs.map} +1 -1
- package/{thought-BFtsnUTU.js → thought-eka4iUHa.js} +3 -3
- package/{thought-BFtsnUTU.js.map → thought-eka4iUHa.js.map} +1 -1
- package/{tool-CcxYxA5X.mjs → tool-CITF20yJ.mjs} +3 -3
- package/{tool-CcxYxA5X.mjs.map → tool-CITF20yJ.mjs.map} +1 -1
- package/{tool-B2nnkwNU.js → tool-Dhjca7rC.js} +3 -3
- package/{tool-B2nnkwNU.js.map → tool-Dhjca7rC.js.map} +1 -1
- package/{tool_call-BxL3eU1k.js → tool_call-Cyi0hUUc.js} +4 -4
- package/{tool_call-BxL3eU1k.js.map → tool_call-Cyi0hUUc.js.map} +1 -1
- package/{tool_call-B3MOog2R.mjs → tool_call-D_k36aI4.mjs} +4 -4
- package/{tool_call-B3MOog2R.mjs.map → tool_call-D_k36aI4.mjs.map} +1 -1
- package/{tool_registry-BaLUIzWz.mjs → tool_registry-CZ55mIti.mjs} +152 -143
- package/tool_registry-CZ55mIti.mjs.map +1 -0
- package/{tool_registry-BdKlPuHS.js → tool_registry-DwZ6pzN4.js} +151 -142
- package/tool_registry-DwZ6pzN4.js.map +1 -0
- package/{turn_runner-M2I8G2ok.js → turn_runner-CCZcsoDU.js} +5 -5
- package/{turn_runner-M2I8G2ok.js.map → turn_runner-CCZcsoDU.js.map} +1 -1
- package/{turn_runner-BV4BaZK9.mjs → turn_runner-DRPpVvsd.mjs} +5 -5
- package/{turn_runner-BV4BaZK9.mjs.map → turn_runner-DRPpVvsd.mjs.map} +1 -1
- package/turn_runner.cjs +1 -1
- package/turn_runner.mjs +1 -1
- package/{validate-JOHfh-BB.mjs → validate-C_hTnDBE.mjs} +95 -8
- package/validate-C_hTnDBE.mjs.map +1 -0
- package/{validate-DgDZkUKs.js → validate-gaSa9bsk.js} +95 -8
- package/validate-gaSa9bsk.js.map +1 -0
- package/xlsx-B0sTpEC2.js +30615 -0
- package/xlsx-B0sTpEC2.js.map +1 -0
- package/xlsx-DiMpn_Xv.mjs +30596 -0
- package/xlsx-DiMpn_Xv.mjs.map +1 -0
- package/xlsx.zahl-D2_Q-Xs4.mjs +6 -0
- package/xlsx.zahl-D2_Q-Xs4.mjs.map +1 -0
- package/xlsx.zahl-ZIcUQVv8.js +7 -0
- package/xlsx.zahl-ZIcUQVv8.js.map +1 -0
- package/tool_registry-BaLUIzWz.mjs.map +0 -1
- package/tool_registry-BdKlPuHS.js.map +0 -1
- package/validate-DgDZkUKs.js.map +0 -1
- package/validate-JOHfh-BB.mjs.map +0 -1
package/batteries/media/lint.cjs
CHANGED
|
@@ -3,33 +3,11 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
+
const require___vite_browser_external$1 = require("../../__vite-browser-external-DAHxjh-D.js");
|
|
7
|
+
let _typescript_eslint_utils = require("@typescript-eslint/utils");
|
|
6
8
|
//#region src/batteries/media/lint.ts
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* ESLint rules for consumers of the media pipeline battery: machine-checkable enforcement of
|
|
11
|
-
* the engine-composition contracts implementors are most likely to get wrong.
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
* Battery-scoped rules ship with the battery, not with the core `@nhtio/adk/eslint` plugin —
|
|
15
|
-
* they only matter to deployments that compose this battery, and they version with the
|
|
16
|
-
* battery's own API. The rules are report-only (no autofix); carve out a deliberate exception
|
|
17
|
-
* with an inline `// eslint-disable-next-line adk-media/{rule} -- {reason}` comment.
|
|
18
|
-
*
|
|
19
|
-
* `@typescript-eslint/utils` and `eslint` are OPTIONAL peer dependencies of `@nhtio/adk` —
|
|
20
|
-
* installed only by consumers who lint with this plugin. The battery never imports this
|
|
21
|
-
* module at runtime.
|
|
22
|
-
*
|
|
23
|
-
* @example Flat config
|
|
24
|
-
* ```ts
|
|
25
|
-
* import adkMedia from '@nhtio/adk/batteries/media/lint'
|
|
26
|
-
*
|
|
27
|
-
* export default [
|
|
28
|
-
* { plugins: { 'adk-media': adkMedia.plugin }, rules: adkMedia.configs.recommended.rules },
|
|
29
|
-
* ]
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
var createRule = require("@typescript-eslint/utils").ESLintUtils.RuleCreator((name) => `https://adk.nht.io/batteries/media/lint#${name}`);
|
|
9
|
+
var import___vite_browser_external = require___vite_browser_external$1.require___vite_browser_external();
|
|
10
|
+
var createRule = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://adk.nht.io/batteries/media/lint#${name}`);
|
|
33
11
|
var ENGINE_SUBPATH = /^@nhtio\/adk\/batteries\/media\/engines\//;
|
|
34
12
|
/**
|
|
35
13
|
* Flags a static value import of a bundled engine subpath. The documented canonical supply
|
|
@@ -65,6 +43,48 @@ var preferEngineResolver = createRule({
|
|
|
65
43
|
} };
|
|
66
44
|
}
|
|
67
45
|
});
|
|
46
|
+
var SHEET_OPS = [
|
|
47
|
+
"sheet.add_rows",
|
|
48
|
+
"sheet.add_columns",
|
|
49
|
+
"sheet.update_cells",
|
|
50
|
+
"sheet.delete_rows",
|
|
51
|
+
"sheet.delete_columns",
|
|
52
|
+
"sheet.rename_sheet",
|
|
53
|
+
"sheet.add_sheet",
|
|
54
|
+
"sheet.remove_sheet",
|
|
55
|
+
"sheet.reorder_sheets",
|
|
56
|
+
"sheet.transform_table"
|
|
57
|
+
];
|
|
58
|
+
var SHEET_WRITE_TARGETS = [
|
|
59
|
+
"xlsx",
|
|
60
|
+
"xlsm",
|
|
61
|
+
"xlsb",
|
|
62
|
+
"xls",
|
|
63
|
+
"ods",
|
|
64
|
+
"fods",
|
|
65
|
+
"csv",
|
|
66
|
+
"txt",
|
|
67
|
+
"html",
|
|
68
|
+
"rtf",
|
|
69
|
+
"sylk",
|
|
70
|
+
"dif",
|
|
71
|
+
"dbf",
|
|
72
|
+
"numbers",
|
|
73
|
+
"json"
|
|
74
|
+
];
|
|
75
|
+
var SHEET_READ_MIMES = [
|
|
76
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
77
|
+
"application/vnd.ms-excel.sheet.macroEnabled.12",
|
|
78
|
+
"application/vnd.ms-excel.sheet.binary.macroEnabled.12",
|
|
79
|
+
"application/vnd.ms-excel",
|
|
80
|
+
"application/vnd.oasis.opendocument.spreadsheet",
|
|
81
|
+
"application/vnd.oasis.opendocument.spreadsheet-flat-xml",
|
|
82
|
+
"text/csv",
|
|
83
|
+
"application/x-iwork-numbers-sffnumbers",
|
|
84
|
+
"application/x-sylk",
|
|
85
|
+
"application/x-dif",
|
|
86
|
+
"application/x-dbf"
|
|
87
|
+
];
|
|
68
88
|
/**
|
|
69
89
|
* Known declarations of the bundled engine factories, for shadow analysis. An ESLint rule
|
|
70
90
|
* cannot execute the factories it lints, so this table mirrors their declarations by hand —
|
|
@@ -72,6 +92,52 @@ var preferEngineResolver = createRule({
|
|
|
72
92
|
* Exported for that test only.
|
|
73
93
|
*/
|
|
74
94
|
var BUNDLED_SUMMARIES = {
|
|
95
|
+
dataEngine: {
|
|
96
|
+
label: "dataEngine",
|
|
97
|
+
mutates: [],
|
|
98
|
+
converts: [
|
|
99
|
+
{
|
|
100
|
+
from: ["application/x-adk-empty"],
|
|
101
|
+
to: [
|
|
102
|
+
"txt",
|
|
103
|
+
"md",
|
|
104
|
+
"json",
|
|
105
|
+
"yaml",
|
|
106
|
+
"csv",
|
|
107
|
+
"html"
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
from: ["application/json"],
|
|
112
|
+
to: [
|
|
113
|
+
"yaml",
|
|
114
|
+
"txt",
|
|
115
|
+
"csv"
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
from: ["application/yaml"],
|
|
120
|
+
to: ["json"]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
from: ["text/csv"],
|
|
124
|
+
to: ["json"]
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
edits: []
|
|
128
|
+
},
|
|
129
|
+
exceljsEngine: {
|
|
130
|
+
label: "exceljsEngine",
|
|
131
|
+
mutates: [],
|
|
132
|
+
converts: [{
|
|
133
|
+
from: ["application/x-adk-empty"],
|
|
134
|
+
to: ["xlsx"]
|
|
135
|
+
}],
|
|
136
|
+
edits: [{
|
|
137
|
+
over: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
|
|
138
|
+
ops: SHEET_OPS
|
|
139
|
+
}]
|
|
140
|
+
},
|
|
75
141
|
jimpEngine: {
|
|
76
142
|
label: "jimpEngine",
|
|
77
143
|
mutates: [{
|
|
@@ -97,7 +163,18 @@ var BUNDLED_SUMMARIES = {
|
|
|
97
163
|
"tiff"
|
|
98
164
|
]
|
|
99
165
|
}],
|
|
100
|
-
converts: [
|
|
166
|
+
converts: [{
|
|
167
|
+
from: ["application/x-adk-empty"],
|
|
168
|
+
to: [
|
|
169
|
+
"png",
|
|
170
|
+
"jpg",
|
|
171
|
+
"jpeg",
|
|
172
|
+
"bmp",
|
|
173
|
+
"gif",
|
|
174
|
+
"tiff"
|
|
175
|
+
]
|
|
176
|
+
}],
|
|
177
|
+
edits: []
|
|
101
178
|
},
|
|
102
179
|
sharpEngine: {
|
|
103
180
|
label: "sharpEngine",
|
|
@@ -119,7 +196,34 @@ var BUNDLED_SUMMARIES = {
|
|
|
119
196
|
"gif"
|
|
120
197
|
]
|
|
121
198
|
}],
|
|
122
|
-
converts: [
|
|
199
|
+
converts: [{
|
|
200
|
+
from: ["application/x-adk-empty"],
|
|
201
|
+
to: [
|
|
202
|
+
"png",
|
|
203
|
+
"jpg",
|
|
204
|
+
"jpeg",
|
|
205
|
+
"webp",
|
|
206
|
+
"tiff",
|
|
207
|
+
"avif",
|
|
208
|
+
"gif"
|
|
209
|
+
]
|
|
210
|
+
}],
|
|
211
|
+
edits: []
|
|
212
|
+
},
|
|
213
|
+
sheetjsEngine: {
|
|
214
|
+
label: "sheetjsEngine",
|
|
215
|
+
mutates: [],
|
|
216
|
+
converts: [{
|
|
217
|
+
from: ["application/x-adk-empty"],
|
|
218
|
+
to: SHEET_WRITE_TARGETS
|
|
219
|
+
}, {
|
|
220
|
+
from: SHEET_READ_MIMES,
|
|
221
|
+
to: SHEET_WRITE_TARGETS
|
|
222
|
+
}],
|
|
223
|
+
edits: [{
|
|
224
|
+
over: SHEET_READ_MIMES,
|
|
225
|
+
ops: SHEET_OPS
|
|
226
|
+
}]
|
|
123
227
|
}
|
|
124
228
|
};
|
|
125
229
|
var literalStrings = (node) => {
|
|
@@ -168,7 +272,8 @@ var summarize = (node) => {
|
|
|
168
272
|
const summary = {
|
|
169
273
|
label: idNode?.type === "Literal" && typeof idNode.value === "string" ? idNode.value : "engine",
|
|
170
274
|
mutates: [],
|
|
171
|
-
converts: []
|
|
275
|
+
converts: [],
|
|
276
|
+
edits: []
|
|
172
277
|
};
|
|
173
278
|
const mutates = propOf(node, "mutates");
|
|
174
279
|
if (mutates) {
|
|
@@ -200,7 +305,21 @@ var summarize = (node) => {
|
|
|
200
305
|
});
|
|
201
306
|
}
|
|
202
307
|
}
|
|
203
|
-
|
|
308
|
+
const edits = propOf(node, "edits");
|
|
309
|
+
if (edits) {
|
|
310
|
+
if (edits.type !== "ArrayExpression") return void 0;
|
|
311
|
+
for (const el of edits.elements) {
|
|
312
|
+
if (!el || el.type !== "ObjectExpression") return void 0;
|
|
313
|
+
const over = literalStrings(propOf(el, "over"));
|
|
314
|
+
const ops = literalStrings(propOf(el, "ops"));
|
|
315
|
+
if (!over || !ops) return void 0;
|
|
316
|
+
summary.edits.push({
|
|
317
|
+
over,
|
|
318
|
+
ops
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (summary.mutates.length + summary.converts.length + summary.edits.length === 0) return;
|
|
204
323
|
return summary;
|
|
205
324
|
};
|
|
206
325
|
var patternCovers = (broad, narrow) => {
|
|
@@ -212,10 +331,11 @@ var patternsCover = (broad, narrow) => narrow.every((n) => broad.some((b) => pat
|
|
|
212
331
|
var subset = (sup, sub) => sub.every((s) => sup.includes(s));
|
|
213
332
|
/** `true` when EVERY capability of `later` is subsumed by some capability of `earlier`. */
|
|
214
333
|
var shadows = (earlier, later) => {
|
|
215
|
-
if (later.mutates.length + later.converts.length === 0) return false;
|
|
334
|
+
if (later.mutates.length + later.converts.length + later.edits.length === 0) return false;
|
|
216
335
|
const mutatesCovered = later.mutates.every((lm) => earlier.mutates.some((em) => patternsCover(em.over, lm.over) && subset(em.ops, lm.ops) && subset(em.encodes, lm.encodes)));
|
|
217
336
|
const convertsCovered = later.converts.every((lc) => earlier.converts.some((ec) => patternsCover(ec.from, lc.from) && subset(ec.to, lc.to)));
|
|
218
|
-
|
|
337
|
+
const editsCovered = later.edits.every((le) => earlier.edits.some((ee) => patternsCover(ee.over, le.over) && subset(ee.ops, le.ops)));
|
|
338
|
+
return mutatesCovered && convertsCovered && editsCovered;
|
|
219
339
|
};
|
|
220
340
|
/**
|
|
221
341
|
* Flags an engines-array element whose statically-known capabilities are entirely covered by
|
|
@@ -262,40 +382,130 @@ var noShadowedEngine = createRule({
|
|
|
262
382
|
});
|
|
263
383
|
var CONTRACTS_SUBPATH = "@nhtio/adk/batteries/media/contracts";
|
|
264
384
|
/**
|
|
385
|
+
* Flags a `ConvertOptions` declaration-merging block whose module specifier is not the
|
|
386
|
+
* contracts subpath. Augmenting the barrel (or any other module) silently does nothing —
|
|
387
|
+
* the keys never merge, and the typo costs hours.
|
|
388
|
+
*/
|
|
389
|
+
var augmentContractsModule = createRule({
|
|
390
|
+
name: "augment-contracts-module",
|
|
391
|
+
meta: {
|
|
392
|
+
type: "problem",
|
|
393
|
+
docs: { description: "ConvertOptions augmentation must target the contracts subpath — declaration merging against any other module specifier silently fails to merge." },
|
|
394
|
+
schema: [],
|
|
395
|
+
messages: { wrongModule: "This ConvertOptions augmentation targets \"{{actual}}\", so it will silently never merge. Declaration merging must target the module that declares the interface: declare module '{{expected}}'." }
|
|
396
|
+
},
|
|
397
|
+
defaultOptions: [],
|
|
398
|
+
create(context) {
|
|
399
|
+
return { TSModuleDeclaration(node) {
|
|
400
|
+
if (node.global) return;
|
|
401
|
+
if (node.id.type !== "Literal" || typeof node.id.value !== "string") return;
|
|
402
|
+
const specifier = node.id.value;
|
|
403
|
+
if (specifier === CONTRACTS_SUBPATH || specifier.endsWith("/media/contracts")) return;
|
|
404
|
+
if (!specifier.includes("media") && !specifier.includes("@nhtio/adk")) return;
|
|
405
|
+
const body = node.body;
|
|
406
|
+
if (!body || body.type !== "TSModuleBlock") return;
|
|
407
|
+
if (!body.body.some((stmt) => stmt.type === "TSInterfaceDeclaration" && stmt.id.name === "ConvertOptions")) return;
|
|
408
|
+
context.report({
|
|
409
|
+
node: node.id,
|
|
410
|
+
messageId: "wrongModule",
|
|
411
|
+
data: {
|
|
412
|
+
actual: specifier,
|
|
413
|
+
expected: CONTRACTS_SUBPATH
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
} };
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
/**
|
|
420
|
+
* The optional peer dependencies each bundled engine subpath lazily imports at runtime.
|
|
421
|
+
* Keyed by the engine's subpath suffix (after `engines/`). An engine with no external peer
|
|
422
|
+
* (soffice, fs_workspace) is absent — there's nothing to install. Kept in lockstep with the
|
|
423
|
+
* engines' actual `import(...)` calls by `engine_peers_drift.node.spec.ts`.
|
|
424
|
+
*/
|
|
425
|
+
var ENGINE_PEERS = {
|
|
426
|
+
jimp: ["jimp"],
|
|
427
|
+
sharp: ["sharp"],
|
|
428
|
+
sheetjs: ["xlsx"],
|
|
429
|
+
exceljs: ["exceljs"],
|
|
430
|
+
data: ["js-yaml", "papaparse"],
|
|
431
|
+
tesseract_js: ["tesseract.js"],
|
|
432
|
+
audio_decode: ["audio-decode"],
|
|
433
|
+
transformers_asr: ["@huggingface/transformers"],
|
|
434
|
+
execa_executor: ["execa"]
|
|
435
|
+
};
|
|
436
|
+
/** Map a bundled engine subpath to its peer list, or undefined when it isn't a known engine. */
|
|
437
|
+
var peersForSubpath = (source) => {
|
|
438
|
+
const m = /^@nhtio\/adk\/batteries\/media\/engines\/([a-z_]+)$/.exec(source);
|
|
439
|
+
if (!m) return void 0;
|
|
440
|
+
return ENGINE_PEERS[m[1]];
|
|
441
|
+
};
|
|
442
|
+
var defaultPeerResolver = (peer, fromFile) => {
|
|
443
|
+
try {
|
|
444
|
+
(0, import___vite_browser_external.createRequire)(fromFile).resolve(peer);
|
|
445
|
+
return true;
|
|
446
|
+
} catch {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
var activePeerResolver = defaultPeerResolver;
|
|
451
|
+
/** Override the peer resolver (spec-only seam). Pass nothing to restore the Node default. */
|
|
452
|
+
var setPeerResolverForTesting = (resolver) => {
|
|
453
|
+
activePeerResolver = resolver ?? defaultPeerResolver;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
265
456
|
* Map of rule id (without the `adk-media/` plugin prefix) to its rule object. Registered on
|
|
266
457
|
* the plugin as `rules`, so configs reference them as `adk-media/{id}`.
|
|
267
458
|
*/
|
|
268
459
|
var rules = {
|
|
269
460
|
"prefer-engine-resolver": preferEngineResolver,
|
|
270
461
|
"no-shadowed-engine": noShadowedEngine,
|
|
271
|
-
"augment-contracts-module":
|
|
272
|
-
|
|
462
|
+
"augment-contracts-module": augmentContractsModule,
|
|
463
|
+
"require-engine-peers": createRule({
|
|
464
|
+
name: "require-engine-peers",
|
|
273
465
|
meta: {
|
|
274
466
|
type: "problem",
|
|
275
|
-
docs: { description: "
|
|
276
|
-
schema: [
|
|
277
|
-
|
|
467
|
+
docs: { description: "A bundled media engine's optional peer dependency must be installed where it's composed — otherwise the pipeline throws at first use, not at construction." },
|
|
468
|
+
schema: [{
|
|
469
|
+
type: "object",
|
|
470
|
+
properties: { ignore: {
|
|
471
|
+
type: "array",
|
|
472
|
+
items: { type: "string" },
|
|
473
|
+
description: "Peer package names to skip (e.g. one resolved via a custom loader the linter cannot see)."
|
|
474
|
+
} },
|
|
475
|
+
additionalProperties: false
|
|
476
|
+
}],
|
|
477
|
+
messages: { missingPeer: "The \"{{engine}}\" media engine requires the optional peer \"{{peer}}\", which cannot be resolved from this file. Install it ({{install}}) or the pipeline will throw E_INVALID_MEDIA_PIPELINE_CONFIG the first time this engine runs. Opt out with an eslint-disable-next-line adk-media/require-engine-peers comment + reason." }
|
|
278
478
|
},
|
|
279
|
-
defaultOptions: [],
|
|
280
|
-
create(context) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (!
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
479
|
+
defaultOptions: [{ ignore: [] }],
|
|
480
|
+
create(context, [options]) {
|
|
481
|
+
const ignore = new Set(options?.ignore ?? []);
|
|
482
|
+
/** SheetJS ships only from its CDN tarball, so the install hint must not say the registry. */
|
|
483
|
+
const installHint = (peer) => peer === "xlsx" ? "pnpm add xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz" : `pnpm add ${peer}`;
|
|
484
|
+
const checkSource = (source, reportNode) => {
|
|
485
|
+
const peers = peersForSubpath(source);
|
|
486
|
+
if (!peers) return;
|
|
487
|
+
const engine = source.slice(source.lastIndexOf("/") + 1);
|
|
488
|
+
for (const peer of peers) {
|
|
489
|
+
if (ignore.has(peer)) continue;
|
|
490
|
+
if (!activePeerResolver(peer, context.filename)) context.report({
|
|
491
|
+
node: reportNode,
|
|
492
|
+
messageId: "missingPeer",
|
|
493
|
+
data: {
|
|
494
|
+
engine,
|
|
495
|
+
peer,
|
|
496
|
+
install: installHint(peer)
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
return {
|
|
502
|
+
ImportDeclaration(node) {
|
|
503
|
+
if (typeof node.source.value === "string") checkSource(node.source.value, node.source);
|
|
504
|
+
},
|
|
505
|
+
ImportExpression(node) {
|
|
506
|
+
if (node.source.type === "Literal" && typeof node.source.value === "string") checkSource(node.source.value, node.source);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
299
509
|
}
|
|
300
510
|
})
|
|
301
511
|
};
|
|
@@ -306,7 +516,7 @@ var rules = {
|
|
|
306
516
|
var plugin = {
|
|
307
517
|
meta: {
|
|
308
518
|
name: "@nhtio/adk/batteries/media/lint",
|
|
309
|
-
version: "0.1.0-master-
|
|
519
|
+
version: "0.1.0-master-89b47bec"
|
|
310
520
|
},
|
|
311
521
|
rules
|
|
312
522
|
};
|
|
@@ -331,9 +541,11 @@ var lint_default = {
|
|
|
331
541
|
};
|
|
332
542
|
//#endregion
|
|
333
543
|
exports.BUNDLED_SUMMARIES = BUNDLED_SUMMARIES;
|
|
544
|
+
exports.ENGINE_PEERS = ENGINE_PEERS;
|
|
334
545
|
exports.configs = configs;
|
|
335
546
|
exports.default = lint_default;
|
|
336
547
|
exports.plugin = plugin;
|
|
337
548
|
exports.rules = rules;
|
|
549
|
+
exports.setPeerResolverForTesting = setPeerResolverForTesting;
|
|
338
550
|
|
|
339
551
|
//# sourceMappingURL=lint.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.cjs","names":[],"sources":["../../../src/batteries/media/lint.ts"],"sourcesContent":["/**\n * @module @nhtio/adk/batteries/media/lint\n *\n * ESLint rules for consumers of the media pipeline battery: machine-checkable enforcement of\n * the engine-composition contracts implementors are most likely to get wrong.\n *\n * @remarks\n * Battery-scoped rules ship with the battery, not with the core `@nhtio/adk/eslint` plugin —\n * they only matter to deployments that compose this battery, and they version with the\n * battery's own API. The rules are report-only (no autofix); carve out a deliberate exception\n * with an inline `// eslint-disable-next-line adk-media/{rule} -- {reason}` comment.\n *\n * `@typescript-eslint/utils` and `eslint` are OPTIONAL peer dependencies of `@nhtio/adk` —\n * installed only by consumers who lint with this plugin. The battery never imports this\n * module at runtime.\n *\n * @example Flat config\n * ```ts\n * import adkMedia from '@nhtio/adk/batteries/media/lint'\n *\n * export default [\n * { plugins: { 'adk-media': adkMedia.plugin }, rules: adkMedia.configs.recommended.rules },\n * ]\n * ```\n */\n\nimport { ESLintUtils } from '@typescript-eslint/utils'\nimport type { TSESTree } from '@typescript-eslint/utils'\nimport type { FlatConfig } from '@typescript-eslint/utils/ts-eslint'\n\nconst createRule = ESLintUtils.RuleCreator(\n (name) => `https://adk.nht.io/batteries/media/lint#${name}`\n)\n\n// ── prefer-engine-resolver ───────────────────────────────────────────────────\n\nconst ENGINE_SUBPATH = /^@nhtio\\/adk\\/batteries\\/media\\/engines\\//\n\n/**\n * Flags a static value import of a bundled engine subpath. The documented canonical supply\n * form is the dynamic-import resolver, which keeps the engine wrapper module out of every\n * bundle that merely might use it. Type-only imports are fine.\n */\nconst preferEngineResolver = createRule({\n name: 'prefer-engine-resolver',\n meta: {\n type: 'suggestion',\n docs: {\n description:\n 'Supply bundled media engines as dynamic-import resolvers, not static imports — a static import puts the engine wrapper in every bundle, even when the engine is conditional.',\n },\n schema: [],\n messages: {\n preferResolver:\n \"Import bundled engines lazily: supply `() => import('{{source}}').then((m) => m.{{hint}}(…))` in the engines array instead of a static import. Static imports put the engine wrapper module in every bundle. Opt out with an eslint-disable-next-line adk-media/prefer-engine-resolver comment + reason.\",\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (typeof node.source.value !== 'string') return\n if (!ENGINE_SUBPATH.test(node.source.value)) return\n if (node.importKind === 'type') return\n const valueSpecifiers = node.specifiers.filter(\n (s) => !(s.type === 'ImportSpecifier' && s.importKind === 'type')\n )\n if (valueSpecifiers.length === 0) return\n const first = valueSpecifiers[0]\n const hint =\n first.type === 'ImportSpecifier' && first.imported.type === 'Identifier'\n ? first.imported.name\n : 'engineFactory'\n context.report({\n node,\n messageId: 'preferResolver',\n data: { source: node.source.value, hint },\n })\n },\n }\n },\n})\n\n// ── no-shadowed-engine ───────────────────────────────────────────────────────\n\n/** A statically-derived capability summary for one engines-array element. */\nexport interface EngineSummary {\n /** Display label for the diagnostic. */\n label: string\n /** Mutate groups: input patterns, ops, encodes. */\n mutates: Array<{ over: string[]; ops: string[]; encodes: string[] }>\n /** Convert groups: input patterns, target tokens. */\n converts: Array<{ from: string[]; to: string[] }>\n}\n\n/**\n * Known declarations of the bundled engine factories, for shadow analysis. An ESLint rule\n * cannot execute the factories it lints, so this table mirrors their declarations by hand —\n * and is pinned against the live factories by a drift test (`lint_drift.node.spec.ts`).\n * Exported for that test only.\n */\nexport const BUNDLED_SUMMARIES: Record<string, EngineSummary> = {\n jimpEngine: {\n label: 'jimpEngine',\n mutates: [\n {\n over: ['image/png', 'image/jpeg', 'image/bmp', 'image/gif', 'image/tiff'],\n ops: ['resize', 'rotate', 'flip', 'strip_metadata'],\n encodes: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'tiff'],\n },\n ],\n converts: [],\n },\n sharpEngine: {\n label: 'sharpEngine',\n mutates: [\n {\n over: ['image/*'],\n ops: ['resize', 'rotate', 'flip', 'strip_metadata'],\n encodes: ['png', 'jpg', 'jpeg', 'webp', 'tiff', 'avif', 'gif'],\n },\n ],\n converts: [],\n },\n}\n\nconst literalStrings = (node: TSESTree.Node | undefined): string[] | undefined => {\n if (!node || node.type !== 'ArrayExpression') return undefined\n const out: string[] = []\n for (const el of node.elements) {\n if (!el || el.type !== 'Literal' || typeof el.value !== 'string') return undefined\n out.push(el.value)\n }\n return out\n}\n\nconst propOf = (obj: TSESTree.ObjectExpression, name: string): TSESTree.Node | undefined =>\n obj.properties.find(\n (p): p is TSESTree.Property =>\n p.type === 'Property' && !p.computed && p.key.type === 'Identifier' && p.key.name === name\n )?.value\n\n/** Find the bundled factory name referenced by an element (direct call or resolver arrow). */\nconst bundledFactoryName = (node: TSESTree.Node): string | undefined => {\n if (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n node.callee.name in BUNDLED_SUMMARIES\n ) {\n return node.callee.name\n }\n // Resolver forms: () => …; scan the body for m.jimpEngine(…) / jimpEngine(…).\n if (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression') {\n let found: string | undefined\n const visit = (n: TSESTree.Node): void => {\n if (found) return\n if (n.type === 'CallExpression') {\n if (n.callee.type === 'Identifier' && n.callee.name in BUNDLED_SUMMARIES) {\n found = n.callee.name\n } else if (\n n.callee.type === 'MemberExpression' &&\n n.callee.property.type === 'Identifier' &&\n n.callee.property.name in BUNDLED_SUMMARIES\n ) {\n found = n.callee.property.name\n }\n }\n for (const key of Object.keys(n)) {\n if (key === 'parent') continue\n const value = (n as unknown as Record<string, unknown>)[key]\n const children = Array.isArray(value) ? value : [value]\n for (const child of children) {\n if (!child || typeof child !== 'object') continue\n const childNode = child as TSESTree.Node\n if (typeof childNode.type !== 'string') continue\n visit(childNode)\n }\n }\n }\n visit(node.body)\n return found\n }\n return undefined\n}\n\n/** Derive a capability summary from an element, or undefined when not statically known. */\nconst summarize = (node: TSESTree.Node): EngineSummary | undefined => {\n const factory = bundledFactoryName(node)\n if (factory) return BUNDLED_SUMMARIES[factory]\n if (node.type !== 'ObjectExpression') return undefined\n const idNode = propOf(node, 'id')\n const label =\n idNode?.type === 'Literal' && typeof idNode.value === 'string' ? idNode.value : 'engine'\n const summary: EngineSummary = { label, mutates: [], converts: [] }\n const mutates = propOf(node, 'mutates')\n if (mutates) {\n if (mutates.type !== 'ArrayExpression') return undefined\n for (const el of mutates.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const over = literalStrings(propOf(el, 'over'))\n const ops = literalStrings(propOf(el, 'ops'))\n const encodes = literalStrings(propOf(el, 'encodes'))\n if (!over || !ops || !encodes) return undefined\n summary.mutates.push({ over, ops, encodes })\n }\n }\n const converts = propOf(node, 'converts')\n if (converts) {\n if (converts.type !== 'ArrayExpression') return undefined\n for (const el of converts.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const from = literalStrings(propOf(el, 'from'))\n const to = literalStrings(propOf(el, 'to'))\n if (!from || !to) return undefined\n summary.converts.push({ from, to })\n }\n }\n if (summary.mutates.length + summary.converts.length === 0) return undefined\n return summary\n}\n\nconst patternCovers = (broad: string, narrow: string): boolean => {\n if (broad === narrow) return true\n if (broad.endsWith('/*')) return narrow.startsWith(broad.slice(0, -1))\n return false\n}\n\nconst patternsCover = (broad: string[], narrow: string[]): boolean =>\n narrow.every((n) => broad.some((b) => patternCovers(b, n)))\n\nconst subset = (sup: string[], sub: string[]): boolean => sub.every((s) => sup.includes(s))\n\n/** `true` when EVERY capability of `later` is subsumed by some capability of `earlier`. */\nconst shadows = (earlier: EngineSummary, later: EngineSummary): boolean => {\n if (later.mutates.length + later.converts.length === 0) return false\n const mutatesCovered = later.mutates.every((lm) =>\n earlier.mutates.some(\n (em) =>\n patternsCover(em.over, lm.over) && subset(em.ops, lm.ops) && subset(em.encodes, lm.encodes)\n )\n )\n const convertsCovered = later.converts.every((lc) =>\n earlier.converts.some((ec) => patternsCover(ec.from, lc.from) && subset(ec.to, lc.to))\n )\n return mutatesCovered && convertsCovered\n}\n\n/**\n * Flags an engines-array element whose statically-known capabilities are entirely covered by\n * an EARLIER element — dispatch is first-capable-wins, so the later engine is dead code.\n */\nconst noShadowedEngine = createRule({\n name: 'no-shadowed-engine',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'An engine whose declared capabilities are a subset of an earlier engine in the array can never be selected — first-capable-wins dispatch makes it dead code. Reorder (narrow before broad) or remove it.',\n },\n schema: [],\n messages: {\n shadowed:\n 'Engine \"{{later}}\" can never be selected: \"{{earlier}}\" appears earlier in the array and declares a superset of its capabilities (dispatch is first-capable-wins). Put the narrower engine first, or remove it. Opt out with an eslint-disable-next-line adk-media/no-shadowed-engine comment + reason.',\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n CallExpression(node: TSESTree.CallExpression) {\n if (node.callee.type !== 'Identifier' || node.callee.name !== 'createMediaPipeline') {\n return\n }\n const config = node.arguments[0]\n if (!config || config.type !== 'ObjectExpression') return\n const engines = propOf(config, 'engines')\n if (!engines || engines.type !== 'ArrayExpression') return\n const summaries = engines.elements.map((el) => (el ? summarize(el) : undefined))\n for (let i = 1; i < summaries.length; i++) {\n const later = summaries[i]\n if (!later) continue\n for (let j = 0; j < i; j++) {\n const earlier = summaries[j]\n if (!earlier) continue\n if (shadows(earlier, later)) {\n context.report({\n node: engines.elements[i]!,\n messageId: 'shadowed',\n data: { earlier: earlier.label, later: later.label },\n })\n break\n }\n }\n }\n },\n }\n },\n})\n\n// ── augment-contracts-module ─────────────────────────────────────────────────\n\nconst CONTRACTS_SUBPATH = '@nhtio/adk/batteries/media/contracts'\n\n/**\n * Flags a `ConvertOptions` declaration-merging block whose module specifier is not the\n * contracts subpath. Augmenting the barrel (or any other module) silently does nothing —\n * the keys never merge, and the typo costs hours.\n */\nconst augmentContractsModule = createRule({\n name: 'augment-contracts-module',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'ConvertOptions augmentation must target the contracts subpath — declaration merging against any other module specifier silently fails to merge.',\n },\n schema: [],\n messages: {\n wrongModule:\n 'This ConvertOptions augmentation targets \"{{actual}}\", so it will silently never merge. Declaration merging must target the module that declares the interface: declare module \\'{{expected}}\\'.',\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n TSModuleDeclaration(node: TSESTree.TSModuleDeclaration) {\n if (node.global) return\n if (node.id.type !== 'Literal' || typeof node.id.value !== 'string') return\n const specifier = node.id.value\n if (specifier === CONTRACTS_SUBPATH || specifier.endsWith('/media/contracts')) return\n // Only flag specifiers that are plausibly aimed at this battery.\n if (!specifier.includes('media') && !specifier.includes('@nhtio/adk')) return\n const body = node.body\n if (!body || body.type !== 'TSModuleBlock') return\n const declaresConvertOptions = body.body.some(\n (stmt) => stmt.type === 'TSInterfaceDeclaration' && stmt.id.name === 'ConvertOptions'\n )\n if (!declaresConvertOptions) return\n context.report({\n node: node.id,\n messageId: 'wrongModule',\n data: { actual: specifier, expected: CONTRACTS_SUBPATH },\n })\n },\n }\n },\n})\n\n// ── plugin assembly ──────────────────────────────────────────────────────────\n\n/**\n * Map of rule id (without the `adk-media/` plugin prefix) to its rule object. Registered on\n * the plugin as `rules`, so configs reference them as `adk-media/{id}`.\n */\nexport const rules = {\n 'prefer-engine-resolver': preferEngineResolver,\n 'no-shadowed-engine': noShadowedEngine,\n 'augment-contracts-module': augmentContractsModule,\n} satisfies FlatConfig.Plugin['rules']\n\n/**\n * The media battery's ESLint plugin object. Register under the `adk-media` namespace:\n * `plugins: { 'adk-media': plugin }`.\n */\nexport const plugin: FlatConfig.Plugin = {\n meta: { name: '@nhtio/adk/batteries/media/lint', version: __VERSION__ },\n rules,\n}\n\nconst recommendedRules: NonNullable<FlatConfig.Config['rules']> = Object.fromEntries(\n Object.keys(rules).map((id) => [`adk-media/${id}`, 'error'])\n)\n\n/**\n * Named config presets. `recommended` enables every rule at `error` and registers the plugin\n * under the `adk-media` namespace — spread it into a flat config to adopt the full set.\n */\nexport const configs = {\n recommended: {\n name: '@nhtio/adk/batteries/media/lint/recommended',\n plugins: { 'adk-media': plugin },\n rules: recommendedRules,\n } satisfies FlatConfig.Config,\n}\n\n/**\n * Default export bundles the plugin and its config presets, mirroring the shape ESLint flat\n * configs expect from a plugin module.\n */\nexport default { plugin, rules, configs }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,+CAAa,EAAA,YAAY,aAC5B,SAAS,2CAA2C,MACvD;AAIA,IAAM,iBAAiB;;;;;;AAOvB,IAAM,uBAAuB,WAAW;CACtC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aACE,+KACJ;EACA,QAAQ,CAAC;EACT,UAAU,EACR,gBACE,2SACJ;CACF;CACA,gBAAgB,CAAC;CACjB,OAAO,SAAS;EACd,OAAO,EACL,kBAAkB,MAAkC;GAClD,IAAI,OAAO,KAAK,OAAO,UAAU,UAAU;GAC3C,IAAI,CAAC,eAAe,KAAK,KAAK,OAAO,KAAK,GAAG;GAC7C,IAAI,KAAK,eAAe,QAAQ;GAChC,MAAM,kBAAkB,KAAK,WAAW,QACrC,MAAM,EAAE,EAAE,SAAS,qBAAqB,EAAE,eAAe,OAC5D;GACA,IAAI,gBAAgB,WAAW,GAAG;GAClC,MAAM,QAAQ,gBAAgB;GAC9B,MAAM,OACJ,MAAM,SAAS,qBAAqB,MAAM,SAAS,SAAS,eACxD,MAAM,SAAS,OACf;GACN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,MAAM;EACN,MAAM;GACJ,MAAM;GACN,MAAM,EACJ,aACE,kJACJ;GACA,QAAQ,CAAC;GACT,UAAU,EACR,aACE,mMACJ;EACF;EACA,gBAAgB,CAAC;EACjB,OAAO,SAAS;GACd,OAAO,EACL,oBAAoB,MAAoC;IACtD,IAAI,KAAK,QAAQ;IACjB,IAAI,KAAK,GAAG,SAAS,aAAa,OAAO,KAAK,GAAG,UAAU,UAAU;IACrE,MAAM,YAAY,KAAK,GAAG;IAC1B,IAAI,cAAc,qBAAqB,UAAU,SAAS,kBAAkB,GAAG;IAE/E,IAAI,CAAC,UAAU,SAAS,OAAO,KAAK,CAAC,UAAU,SAAS,YAAY,GAAG;IACvE,MAAM,OAAO,KAAK;IAClB,IAAI,CAAC,QAAQ,KAAK,SAAS,iBAAiB;IAI5C,IAAI,CAH2B,KAAK,KAAK,MACtC,SAAS,KAAK,SAAS,4BAA4B,KAAK,GAAG,SAAS,gBAElE,GAAwB;IAC7B,QAAQ,OAAO;KACb,MAAM,KAAK;KACX,WAAW;KACX,MAAM;MAAE,QAAQ;MAAW,UAAU;KAAkB;IACzD,CAAC;GACH,EACF;EACF;CACF,CAW8B;AAC9B;;;;;AAMA,IAAa,SAA4B;CACvC,MAAM;EAAE,MAAM;EAAmC,SAAA;CAAqB;CACtE;AACF;AAEA,IAAM,mBAA4D,OAAO,YACvE,OAAO,KAAK,KAAK,EAAE,KAAK,OAAO,CAAC,aAAa,MAAM,OAAO,CAAC,CAC7D;;;;;AAMA,IAAa,UAAU,EACrB,aAAa;CACX,MAAM;CACN,SAAS,EAAE,aAAa,OAAO;CAC/B,OAAO;AACT,EACF;;;;;AAMA,IAAA,eAAe;CAAE;CAAQ;CAAO;AAAQ"}
|
|
1
|
+
{"version":3,"file":"lint.cjs","names":[],"sources":["../../../src/batteries/media/lint.ts"],"sourcesContent":["/**\n * @module @nhtio/adk/batteries/media/lint\n *\n * ESLint rules for consumers of the media pipeline battery: machine-checkable enforcement of\n * the engine-composition contracts implementors are most likely to get wrong.\n *\n * @remarks\n * Battery-scoped rules ship with the battery, not with the core `@nhtio/adk/eslint` plugin —\n * they only matter to deployments that compose this battery, and they version with the\n * battery's own API. The rules are report-only (no autofix); carve out a deliberate exception\n * with an inline `// eslint-disable-next-line adk-media/{rule} -- {reason}` comment.\n *\n * `@typescript-eslint/utils` and `eslint` are OPTIONAL peer dependencies of `@nhtio/adk` —\n * installed only by consumers who lint with this plugin. The battery never imports this\n * module at runtime.\n *\n * @example Flat config\n * ```ts\n * import adkMedia from '@nhtio/adk/batteries/media/lint'\n *\n * export default [\n * { plugins: { 'adk-media': adkMedia.plugin }, rules: adkMedia.configs.recommended.rules },\n * ]\n * ```\n */\n\nimport { createRequire } from 'node:module'\nimport { ESLintUtils } from '@typescript-eslint/utils'\nimport type { TSESTree } from '@typescript-eslint/utils'\nimport type { FlatConfig } from '@typescript-eslint/utils/ts-eslint'\n\nconst createRule = ESLintUtils.RuleCreator(\n (name) => `https://adk.nht.io/batteries/media/lint#${name}`\n)\n\n// ── prefer-engine-resolver ───────────────────────────────────────────────────\n\nconst ENGINE_SUBPATH = /^@nhtio\\/adk\\/batteries\\/media\\/engines\\//\n\n/**\n * Flags a static value import of a bundled engine subpath. The documented canonical supply\n * form is the dynamic-import resolver, which keeps the engine wrapper module out of every\n * bundle that merely might use it. Type-only imports are fine.\n */\nconst preferEngineResolver = createRule({\n name: 'prefer-engine-resolver',\n meta: {\n type: 'suggestion',\n docs: {\n description:\n 'Supply bundled media engines as dynamic-import resolvers, not static imports — a static import puts the engine wrapper in every bundle, even when the engine is conditional.',\n },\n schema: [],\n messages: {\n preferResolver:\n \"Import bundled engines lazily: supply `() => import('{{source}}').then((m) => m.{{hint}}(…))` in the engines array instead of a static import. Static imports put the engine wrapper module in every bundle. Opt out with an eslint-disable-next-line adk-media/prefer-engine-resolver comment + reason.\",\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (typeof node.source.value !== 'string') return\n if (!ENGINE_SUBPATH.test(node.source.value)) return\n if (node.importKind === 'type') return\n const valueSpecifiers = node.specifiers.filter(\n (s) => !(s.type === 'ImportSpecifier' && s.importKind === 'type')\n )\n if (valueSpecifiers.length === 0) return\n const first = valueSpecifiers[0]\n const hint =\n first.type === 'ImportSpecifier' && first.imported.type === 'Identifier'\n ? first.imported.name\n : 'engineFactory'\n context.report({\n node,\n messageId: 'preferResolver',\n data: { source: node.source.value, hint },\n })\n },\n }\n },\n})\n\n// ── no-shadowed-engine ───────────────────────────────────────────────────────\n\n/** A statically-derived capability summary for one engines-array element. */\nexport interface EngineSummary {\n /** Display label for the diagnostic. */\n label: string\n /** Mutate groups: input patterns, ops, encodes. */\n mutates: Array<{ over: string[]; ops: string[]; encodes: string[] }>\n /** Convert groups: input patterns, target tokens. */\n converts: Array<{ from: string[]; to: string[] }>\n /** Edit groups: input patterns, ops. */\n edits: Array<{ over: string[]; ops: string[] }>\n}\n\nconst SHEET_OPS = [\n 'sheet.add_rows',\n 'sheet.add_columns',\n 'sheet.update_cells',\n 'sheet.delete_rows',\n 'sheet.delete_columns',\n 'sheet.rename_sheet',\n 'sheet.add_sheet',\n 'sheet.remove_sheet',\n 'sheet.reorder_sheets',\n 'sheet.transform_table',\n]\n\nconst SHEET_WRITE_TARGETS = [\n 'xlsx',\n 'xlsm',\n 'xlsb',\n 'xls',\n 'ods',\n 'fods',\n 'csv',\n 'txt',\n 'html',\n 'rtf',\n 'sylk',\n 'dif',\n 'dbf',\n 'numbers',\n 'json',\n]\n\nconst SHEET_READ_MIMES = [\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel.sheet.macroEnabled.12',\n 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',\n 'application/vnd.ms-excel',\n 'application/vnd.oasis.opendocument.spreadsheet',\n 'application/vnd.oasis.opendocument.spreadsheet-flat-xml',\n 'text/csv',\n 'application/x-iwork-numbers-sffnumbers',\n 'application/x-sylk',\n 'application/x-dif',\n 'application/x-dbf',\n]\n\n/**\n * Known declarations of the bundled engine factories, for shadow analysis. An ESLint rule\n * cannot execute the factories it lints, so this table mirrors their declarations by hand —\n * and is pinned against the live factories by a drift test (`lint_drift.node.spec.ts`).\n * Exported for that test only.\n */\nexport const BUNDLED_SUMMARIES: Record<string, EngineSummary> = {\n dataEngine: {\n label: 'dataEngine',\n mutates: [],\n converts: [\n { from: ['application/x-adk-empty'], to: ['txt', 'md', 'json', 'yaml', 'csv', 'html'] },\n { from: ['application/json'], to: ['yaml', 'txt', 'csv'] },\n { from: ['application/yaml'], to: ['json'] },\n { from: ['text/csv'], to: ['json'] },\n ],\n edits: [],\n },\n exceljsEngine: {\n label: 'exceljsEngine',\n mutates: [],\n converts: [{ from: ['application/x-adk-empty'], to: ['xlsx'] }],\n edits: [\n {\n over: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],\n ops: SHEET_OPS,\n },\n ],\n },\n jimpEngine: {\n label: 'jimpEngine',\n mutates: [\n {\n over: ['image/png', 'image/jpeg', 'image/bmp', 'image/gif', 'image/tiff'],\n ops: ['resize', 'rotate', 'flip', 'strip_metadata'],\n encodes: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'tiff'],\n },\n ],\n converts: [\n { from: ['application/x-adk-empty'], to: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'tiff'] },\n ],\n edits: [],\n },\n sharpEngine: {\n label: 'sharpEngine',\n mutates: [\n {\n over: ['image/*'],\n ops: ['resize', 'rotate', 'flip', 'strip_metadata'],\n encodes: ['png', 'jpg', 'jpeg', 'webp', 'tiff', 'avif', 'gif'],\n },\n ],\n converts: [\n {\n from: ['application/x-adk-empty'],\n to: ['png', 'jpg', 'jpeg', 'webp', 'tiff', 'avif', 'gif'],\n },\n ],\n edits: [],\n },\n sheetjsEngine: {\n label: 'sheetjsEngine',\n mutates: [],\n converts: [\n { from: ['application/x-adk-empty'], to: SHEET_WRITE_TARGETS },\n { from: SHEET_READ_MIMES, to: SHEET_WRITE_TARGETS },\n ],\n edits: [{ over: SHEET_READ_MIMES, ops: SHEET_OPS }],\n },\n}\n\nconst literalStrings = (node: TSESTree.Node | undefined): string[] | undefined => {\n if (!node || node.type !== 'ArrayExpression') return undefined\n const out: string[] = []\n for (const el of node.elements) {\n if (!el || el.type !== 'Literal' || typeof el.value !== 'string') return undefined\n out.push(el.value)\n }\n return out\n}\n\nconst propOf = (obj: TSESTree.ObjectExpression, name: string): TSESTree.Node | undefined =>\n obj.properties.find(\n (p): p is TSESTree.Property =>\n p.type === 'Property' && !p.computed && p.key.type === 'Identifier' && p.key.name === name\n )?.value\n\n/** Find the bundled factory name referenced by an element (direct call or resolver arrow). */\nconst bundledFactoryName = (node: TSESTree.Node): string | undefined => {\n if (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n node.callee.name in BUNDLED_SUMMARIES\n ) {\n return node.callee.name\n }\n // Resolver forms: () => …; scan the body for m.jimpEngine(…) / jimpEngine(…).\n if (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression') {\n let found: string | undefined\n const visit = (n: TSESTree.Node): void => {\n if (found) return\n if (n.type === 'CallExpression') {\n if (n.callee.type === 'Identifier' && n.callee.name in BUNDLED_SUMMARIES) {\n found = n.callee.name\n } else if (\n n.callee.type === 'MemberExpression' &&\n n.callee.property.type === 'Identifier' &&\n n.callee.property.name in BUNDLED_SUMMARIES\n ) {\n found = n.callee.property.name\n }\n }\n for (const key of Object.keys(n)) {\n if (key === 'parent') continue\n const value = (n as unknown as Record<string, unknown>)[key]\n const children = Array.isArray(value) ? value : [value]\n for (const child of children) {\n if (!child || typeof child !== 'object') continue\n const childNode = child as TSESTree.Node\n if (typeof childNode.type !== 'string') continue\n visit(childNode)\n }\n }\n }\n visit(node.body)\n return found\n }\n return undefined\n}\n\n/** Derive a capability summary from an element, or undefined when not statically known. */\nconst summarize = (node: TSESTree.Node): EngineSummary | undefined => {\n const factory = bundledFactoryName(node)\n if (factory) return BUNDLED_SUMMARIES[factory]\n if (node.type !== 'ObjectExpression') return undefined\n const idNode = propOf(node, 'id')\n const label =\n idNode?.type === 'Literal' && typeof idNode.value === 'string' ? idNode.value : 'engine'\n const summary: EngineSummary = { label, mutates: [], converts: [], edits: [] }\n const mutates = propOf(node, 'mutates')\n if (mutates) {\n if (mutates.type !== 'ArrayExpression') return undefined\n for (const el of mutates.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const over = literalStrings(propOf(el, 'over'))\n const ops = literalStrings(propOf(el, 'ops'))\n const encodes = literalStrings(propOf(el, 'encodes'))\n if (!over || !ops || !encodes) return undefined\n summary.mutates.push({ over, ops, encodes })\n }\n }\n const converts = propOf(node, 'converts')\n if (converts) {\n if (converts.type !== 'ArrayExpression') return undefined\n for (const el of converts.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const from = literalStrings(propOf(el, 'from'))\n const to = literalStrings(propOf(el, 'to'))\n if (!from || !to) return undefined\n summary.converts.push({ from, to })\n }\n }\n const edits = propOf(node, 'edits')\n if (edits) {\n if (edits.type !== 'ArrayExpression') return undefined\n for (const el of edits.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const over = literalStrings(propOf(el, 'over'))\n const ops = literalStrings(propOf(el, 'ops'))\n if (!over || !ops) return undefined\n summary.edits.push({ over, ops })\n }\n }\n if (summary.mutates.length + summary.converts.length + summary.edits.length === 0) {\n return undefined\n }\n return summary\n}\n\nconst patternCovers = (broad: string, narrow: string): boolean => {\n if (broad === narrow) return true\n if (broad.endsWith('/*')) return narrow.startsWith(broad.slice(0, -1))\n return false\n}\n\nconst patternsCover = (broad: string[], narrow: string[]): boolean =>\n narrow.every((n) => broad.some((b) => patternCovers(b, n)))\n\nconst subset = (sup: string[], sub: string[]): boolean => sub.every((s) => sup.includes(s))\n\n/** `true` when EVERY capability of `later` is subsumed by some capability of `earlier`. */\nconst shadows = (earlier: EngineSummary, later: EngineSummary): boolean => {\n if (later.mutates.length + later.converts.length + later.edits.length === 0) return false\n const mutatesCovered = later.mutates.every((lm) =>\n earlier.mutates.some(\n (em) =>\n patternsCover(em.over, lm.over) && subset(em.ops, lm.ops) && subset(em.encodes, lm.encodes)\n )\n )\n const convertsCovered = later.converts.every((lc) =>\n earlier.converts.some((ec) => patternsCover(ec.from, lc.from) && subset(ec.to, lc.to))\n )\n const editsCovered = later.edits.every((le) =>\n earlier.edits.some((ee) => patternsCover(ee.over, le.over) && subset(ee.ops, le.ops))\n )\n return mutatesCovered && convertsCovered && editsCovered\n}\n\n/**\n * Flags an engines-array element whose statically-known capabilities are entirely covered by\n * an EARLIER element — dispatch is first-capable-wins, so the later engine is dead code.\n */\nconst noShadowedEngine = createRule({\n name: 'no-shadowed-engine',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'An engine whose declared capabilities are a subset of an earlier engine in the array can never be selected — first-capable-wins dispatch makes it dead code. Reorder (narrow before broad) or remove it.',\n },\n schema: [],\n messages: {\n shadowed:\n 'Engine \"{{later}}\" can never be selected: \"{{earlier}}\" appears earlier in the array and declares a superset of its capabilities (dispatch is first-capable-wins). Put the narrower engine first, or remove it. Opt out with an eslint-disable-next-line adk-media/no-shadowed-engine comment + reason.',\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n CallExpression(node: TSESTree.CallExpression) {\n if (node.callee.type !== 'Identifier' || node.callee.name !== 'createMediaPipeline') {\n return\n }\n const config = node.arguments[0]\n if (!config || config.type !== 'ObjectExpression') return\n const engines = propOf(config, 'engines')\n if (!engines || engines.type !== 'ArrayExpression') return\n const summaries = engines.elements.map((el) => (el ? summarize(el) : undefined))\n for (let i = 1; i < summaries.length; i++) {\n const later = summaries[i]\n if (!later) continue\n for (let j = 0; j < i; j++) {\n const earlier = summaries[j]\n if (!earlier) continue\n if (shadows(earlier, later)) {\n context.report({\n node: engines.elements[i]!,\n messageId: 'shadowed',\n data: { earlier: earlier.label, later: later.label },\n })\n break\n }\n }\n }\n },\n }\n },\n})\n\n// ── augment-contracts-module ─────────────────────────────────────────────────\n\nconst CONTRACTS_SUBPATH = '@nhtio/adk/batteries/media/contracts'\n\n/**\n * Flags a `ConvertOptions` declaration-merging block whose module specifier is not the\n * contracts subpath. Augmenting the barrel (or any other module) silently does nothing —\n * the keys never merge, and the typo costs hours.\n */\nconst augmentContractsModule = createRule({\n name: 'augment-contracts-module',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'ConvertOptions augmentation must target the contracts subpath — declaration merging against any other module specifier silently fails to merge.',\n },\n schema: [],\n messages: {\n wrongModule:\n 'This ConvertOptions augmentation targets \"{{actual}}\", so it will silently never merge. Declaration merging must target the module that declares the interface: declare module \\'{{expected}}\\'.',\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n TSModuleDeclaration(node: TSESTree.TSModuleDeclaration) {\n if (node.global) return\n if (node.id.type !== 'Literal' || typeof node.id.value !== 'string') return\n const specifier = node.id.value\n if (specifier === CONTRACTS_SUBPATH || specifier.endsWith('/media/contracts')) return\n // Only flag specifiers that are plausibly aimed at this battery.\n if (!specifier.includes('media') && !specifier.includes('@nhtio/adk')) return\n const body = node.body\n if (!body || body.type !== 'TSModuleBlock') return\n const declaresConvertOptions = body.body.some(\n (stmt) => stmt.type === 'TSInterfaceDeclaration' && stmt.id.name === 'ConvertOptions'\n )\n if (!declaresConvertOptions) return\n context.report({\n node: node.id,\n messageId: 'wrongModule',\n data: { actual: specifier, expected: CONTRACTS_SUBPATH },\n })\n },\n }\n },\n})\n\n// ── require-engine-peers ─────────────────────────────────────────────────────\n\n/**\n * The optional peer dependencies each bundled engine subpath lazily imports at runtime.\n * Keyed by the engine's subpath suffix (after `engines/`). An engine with no external peer\n * (soffice, fs_workspace) is absent — there's nothing to install. Kept in lockstep with the\n * engines' actual `import(...)` calls by `engine_peers_drift.node.spec.ts`.\n */\nexport const ENGINE_PEERS: Record<string, readonly string[]> = {\n jimp: ['jimp'],\n sharp: ['sharp'],\n sheetjs: ['xlsx'],\n exceljs: ['exceljs'],\n data: ['js-yaml', 'papaparse'],\n tesseract_js: ['tesseract.js'],\n audio_decode: ['audio-decode'],\n transformers_asr: ['@huggingface/transformers'],\n execa_executor: ['execa'],\n}\n\n/** Map a bundled engine subpath to its peer list, or undefined when it isn't a known engine. */\nconst peersForSubpath = (source: string): readonly string[] | undefined => {\n const m = /^@nhtio\\/adk\\/batteries\\/media\\/engines\\/([a-z_]+)$/.exec(source)\n if (!m) return undefined\n return ENGINE_PEERS[m[1]]\n}\n\n/**\n * Flags an import of a bundled engine subpath whose optional peer dependency cannot be\n * resolved from the linting file — the \"I composed `sheetjsEngine()` but never installed\n * `xlsx`, and now my pipeline throws `E_INVALID_MEDIA_PIPELINE_CONFIG` at the first sheet\n * op\" footgun, caught at lint time instead of runtime. Resolution uses Node's resolver from\n * the file's own directory, so it honors the consumer's real `node_modules` layout.\n *\n * Reports once per missing peer per engine import (whether the import is a static value\n * import or a dynamic-import resolver — both reference the engine and both need the peer).\n */\n/**\n * The peer-resolution probe: returns `true` when `peer` resolves from `fromFile`. Defaults to\n * Node's resolver anchored at the linted file (so it sees the consumer's `node_modules`).\n * Exposed as a settable seam so the rule's spec can simulate installed/missing peers without\n * depending on the test runner's own `node_modules` layout — production never sets it.\n */\nexport type PeerResolver = (peer: string, fromFile: string) => boolean\n\nconst defaultPeerResolver: PeerResolver = (peer, fromFile) => {\n try {\n createRequire(fromFile).resolve(peer)\n return true\n } catch {\n return false\n }\n}\n\nlet activePeerResolver: PeerResolver = defaultPeerResolver\n\n/** Override the peer resolver (spec-only seam). Pass nothing to restore the Node default. */\nexport const setPeerResolverForTesting = (resolver?: PeerResolver): void => {\n activePeerResolver = resolver ?? defaultPeerResolver\n}\n\nconst requireEnginePeers = createRule<[{ ignore?: readonly string[] }], 'missingPeer'>({\n name: 'require-engine-peers',\n meta: {\n type: 'problem',\n docs: {\n description:\n \"A bundled media engine's optional peer dependency must be installed where it's composed — otherwise the pipeline throws at first use, not at construction.\",\n },\n schema: [\n {\n type: 'object',\n properties: {\n ignore: {\n type: 'array',\n items: { type: 'string' },\n description:\n 'Peer package names to skip (e.g. one resolved via a custom loader the linter cannot see).',\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n missingPeer:\n 'The \"{{engine}}\" media engine requires the optional peer \"{{peer}}\", which cannot be resolved from this file. Install it ({{install}}) or the pipeline will throw E_INVALID_MEDIA_PIPELINE_CONFIG the first time this engine runs. Opt out with an eslint-disable-next-line adk-media/require-engine-peers comment + reason.',\n },\n },\n defaultOptions: [{ ignore: [] }],\n create(context, [options]) {\n const ignore = new Set(options?.ignore ?? [])\n\n /** SheetJS ships only from its CDN tarball, so the install hint must not say the registry. */\n const installHint = (peer: string): string =>\n peer === 'xlsx'\n ? 'pnpm add xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz'\n : `pnpm add ${peer}`\n\n const checkSource = (source: string, reportNode: TSESTree.Node): void => {\n const peers = peersForSubpath(source)\n if (!peers) return\n const engine = source.slice(source.lastIndexOf('/') + 1)\n for (const peer of peers) {\n if (ignore.has(peer)) continue\n if (!activePeerResolver(peer, context.filename)) {\n context.report({\n node: reportNode,\n messageId: 'missingPeer',\n data: { engine, peer, install: installHint(peer) },\n })\n }\n }\n }\n\n return {\n // Static value/type import of an engine subpath.\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (typeof node.source.value === 'string') checkSource(node.source.value, node.source)\n },\n // The canonical resolver form: import('@nhtio/adk/batteries/media/engines/…').\n ImportExpression(node: TSESTree.ImportExpression) {\n if (node.source.type === 'Literal' && typeof node.source.value === 'string') {\n checkSource(node.source.value, node.source)\n }\n },\n }\n },\n})\n\n// ── plugin assembly ──────────────────────────────────────────────────────────\n\n/**\n * Map of rule id (without the `adk-media/` plugin prefix) to its rule object. Registered on\n * the plugin as `rules`, so configs reference them as `adk-media/{id}`.\n */\nexport const rules = {\n 'prefer-engine-resolver': preferEngineResolver,\n 'no-shadowed-engine': noShadowedEngine,\n 'augment-contracts-module': augmentContractsModule,\n 'require-engine-peers': requireEnginePeers,\n} satisfies FlatConfig.Plugin['rules']\n\n/**\n * The media battery's ESLint plugin object. Register under the `adk-media` namespace:\n * `plugins: { 'adk-media': plugin }`.\n */\nexport const plugin: FlatConfig.Plugin = {\n meta: { name: '@nhtio/adk/batteries/media/lint', version: __VERSION__ },\n rules,\n}\n\nconst recommendedRules: NonNullable<FlatConfig.Config['rules']> = Object.fromEntries(\n Object.keys(rules).map((id) => [`adk-media/${id}`, 'error'])\n)\n\n/**\n * Named config presets. `recommended` enables every rule at `error` and registers the plugin\n * under the `adk-media` namespace — spread it into a flat config to adopt the full set.\n */\nexport const configs = {\n recommended: {\n name: '@nhtio/adk/batteries/media/lint/recommended',\n plugins: { 'adk-media': plugin },\n rules: recommendedRules,\n } satisfies FlatConfig.Config,\n}\n\n/**\n * Default export bundles the plugin and its config presets, mirroring the shape ESLint flat\n * configs expect from a plugin module.\n */\nexport default { plugin, rules, configs }\n"],"mappings":";;;;;;;;;AA+BA,IAAM,aAAa,yBAAA,YAAY,aAC5B,SAAS,2CAA2C,MACvD;AAIA,IAAM,iBAAiB;;;;;;AAOvB,IAAM,uBAAuB,WAAW;CACtC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aACE,+KACJ;EACA,QAAQ,CAAC;EACT,UAAU,EACR,gBACE,2SACJ;CACF;CACA,gBAAgB,CAAC;CACjB,OAAO,SAAS;EACd,OAAO,EACL,kBAAkB,MAAkC;GAClD,IAAI,OAAO,KAAK,OAAO,UAAU,UAAU;GAC3C,IAAI,CAAC,eAAe,KAAK,KAAK,OAAO,KAAK,GAAG;GAC7C,IAAI,KAAK,eAAe,QAAQ;GAChC,MAAM,kBAAkB,KAAK,WAAW,QACrC,MAAM,EAAE,EAAE,SAAS,qBAAqB,EAAE,eAAe,OAC5D;GACA,IAAI,gBAAgB,WAAW,GAAG;GAClC,MAAM,QAAQ,gBAAgB;GAC9B,MAAM,OACJ,MAAM,SAAS,qBAAqB,MAAM,SAAS,SAAS,eACxD,MAAM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AgB,eAAoC;IACvE,MAAM,QAAQ,gBAAgB,MAAM;IACpC,IAAI,CAAC,OAAO;IACZ,MAAM,SAAS,OAAO,MAAM,OAAO,YAAY,GAAG,IAAI,CAAC;IACvD,KAAK,MAAM,QAAQ,OAAO;KACxB,IAAI,OAAO,IAAI,IAAI,GAAG;KACtB,IAAI,CAAC,mBAAmB,MAAM,QAAQ,QAAQ,GAC5C,QAAQ,OAAO;MACb,MAAM;MACN,WAAW;MACX,MAAM;OAAE;OAAQ;OAAM,SAAS,YAAY,IAAI;MAAE;KACnD,CAAC;IAEL;GACF;GAEA,OAAO;IAEL,kBAAkB,MAAkC;KAClD,IAAI,OAAO,KAAK,OAAO,UAAU,UAAU,YAAY,KAAK,OAAO,OAAO,KAAK,MAAM;IACvF;IAEA,iBAAiB,MAAiC;KAChD,IAAI,KAAK,OAAO,SAAS,aAAa,OAAO,KAAK,OAAO,UAAU,UACjE,YAAY,KAAK,OAAO,OAAO,KAAK,MAAM;IAE9C;GACF;EACF;CACF,CAY0B;AAC1B;;;;;AAMA,IAAa,SAA4B;CACvC,MAAM;EAAE,MAAM;EAAmC,SAAA;CAAqB;CACtE;AACF;AAEA,IAAM,mBAA4D,OAAO,YACvE,OAAO,KAAK,KAAK,EAAE,KAAK,OAAO,CAAC,aAAa,MAAM,OAAO,CAAC,CAC7D;;;;;AAMA,IAAa,UAAU,EACrB,aAAa;CACX,MAAM;CACN,SAAS,EAAE,aAAa,OAAO;CAC/B,OAAO;AACT,EACF;;;;;AAMA,IAAA,eAAe;CAAE;CAAQ;CAAO;AAAQ"}
|
|
@@ -40,6 +40,11 @@ export interface EngineSummary {
|
|
|
40
40
|
from: string[];
|
|
41
41
|
to: string[];
|
|
42
42
|
}>;
|
|
43
|
+
/** Edit groups: input patterns, ops. */
|
|
44
|
+
edits: Array<{
|
|
45
|
+
over: string[];
|
|
46
|
+
ops: string[];
|
|
47
|
+
}>;
|
|
43
48
|
}
|
|
44
49
|
/**
|
|
45
50
|
* Known declarations of the bundled engine factories, for shadow analysis. An ESLint rule
|
|
@@ -48,6 +53,32 @@ export interface EngineSummary {
|
|
|
48
53
|
* Exported for that test only.
|
|
49
54
|
*/
|
|
50
55
|
export declare const BUNDLED_SUMMARIES: Record<string, EngineSummary>;
|
|
56
|
+
/**
|
|
57
|
+
* The optional peer dependencies each bundled engine subpath lazily imports at runtime.
|
|
58
|
+
* Keyed by the engine's subpath suffix (after `engines/`). An engine with no external peer
|
|
59
|
+
* (soffice, fs_workspace) is absent — there's nothing to install. Kept in lockstep with the
|
|
60
|
+
* engines' actual `import(...)` calls by `engine_peers_drift.node.spec.ts`.
|
|
61
|
+
*/
|
|
62
|
+
export declare const ENGINE_PEERS: Record<string, readonly string[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Flags an import of a bundled engine subpath whose optional peer dependency cannot be
|
|
65
|
+
* resolved from the linting file — the "I composed `sheetjsEngine()` but never installed
|
|
66
|
+
* `xlsx`, and now my pipeline throws `E_INVALID_MEDIA_PIPELINE_CONFIG` at the first sheet
|
|
67
|
+
* op" footgun, caught at lint time instead of runtime. Resolution uses Node's resolver from
|
|
68
|
+
* the file's own directory, so it honors the consumer's real `node_modules` layout.
|
|
69
|
+
*
|
|
70
|
+
* Reports once per missing peer per engine import (whether the import is a static value
|
|
71
|
+
* import or a dynamic-import resolver — both reference the engine and both need the peer).
|
|
72
|
+
*/
|
|
73
|
+
/**
|
|
74
|
+
* The peer-resolution probe: returns `true` when `peer` resolves from `fromFile`. Defaults to
|
|
75
|
+
* Node's resolver anchored at the linted file (so it sees the consumer's `node_modules`).
|
|
76
|
+
* Exposed as a settable seam so the rule's spec can simulate installed/missing peers without
|
|
77
|
+
* depending on the test runner's own `node_modules` layout — production never sets it.
|
|
78
|
+
*/
|
|
79
|
+
export type PeerResolver = (peer: string, fromFile: string) => boolean;
|
|
80
|
+
/** Override the peer resolver (spec-only seam). Pass nothing to restore the Node default. */
|
|
81
|
+
export declare const setPeerResolverForTesting: (resolver?: PeerResolver) => void;
|
|
51
82
|
/**
|
|
52
83
|
* Map of rule id (without the `adk-media/` plugin prefix) to its rule object. Registered on
|
|
53
84
|
* the plugin as `rules`, so configs reference them as `adk-media/{id}`.
|
|
@@ -65,6 +96,13 @@ export declare const rules: {
|
|
|
65
96
|
], unknown, ESLintUtils.RuleListener> & {
|
|
66
97
|
name: string;
|
|
67
98
|
};
|
|
99
|
+
'require-engine-peers': ESLintUtils.RuleModule<"missingPeer", [
|
|
100
|
+
{
|
|
101
|
+
ignore?: readonly string[];
|
|
102
|
+
}
|
|
103
|
+
], unknown, ESLintUtils.RuleListener> & {
|
|
104
|
+
name: string;
|
|
105
|
+
};
|
|
68
106
|
};
|
|
69
107
|
/**
|
|
70
108
|
* The media battery's ESLint plugin object. Register under the `adk-media` namespace:
|
|
@@ -103,6 +141,13 @@ declare const _default: {
|
|
|
103
141
|
], unknown, ESLintUtils.RuleListener> & {
|
|
104
142
|
name: string;
|
|
105
143
|
};
|
|
144
|
+
'require-engine-peers': ESLintUtils.RuleModule<"missingPeer", [
|
|
145
|
+
{
|
|
146
|
+
ignore?: readonly string[];
|
|
147
|
+
}
|
|
148
|
+
], unknown, ESLintUtils.RuleListener> & {
|
|
149
|
+
name: string;
|
|
150
|
+
};
|
|
106
151
|
};
|
|
107
152
|
configs: {
|
|
108
153
|
recommended: {
|