@canofold/plugins 0.2.1 → 0.3.1
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 +23 -2
- package/dist/kroki.js +20 -1
- package/dist/plantuml.js +18 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -175,6 +175,21 @@ function diagramFence(options) {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
// src/shared/externalDiagramService.ts
|
|
179
|
+
function externalDiagramServiceGate({ plugin, appliesTo }) {
|
|
180
|
+
let warned = false;
|
|
181
|
+
return (context) => {
|
|
182
|
+
const active = appliesTo(context);
|
|
183
|
+
if (active && !warned) {
|
|
184
|
+
console.warn(
|
|
185
|
+
`[canofold/plugins] ${plugin} sends diagram source to its configured external service. Use a trusted self-hosted service for private content.`
|
|
186
|
+
);
|
|
187
|
+
warned = true;
|
|
188
|
+
}
|
|
189
|
+
return active;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
178
193
|
// src/shared/markdownSource.ts
|
|
179
194
|
function stripColumns(value, columns) {
|
|
180
195
|
let index = 0;
|
|
@@ -309,6 +324,10 @@ function kroki(options = {}) {
|
|
|
309
324
|
const languageMap = Object.fromEntries(
|
|
310
325
|
Object.entries(languages).map(([language, type]) => [language.trim().toLowerCase(), type.trim().toLowerCase()]).filter(([language, type]) => language && type)
|
|
311
326
|
);
|
|
327
|
+
const appliesTo = externalDiagramServiceGate({
|
|
328
|
+
plugin: "Kroki",
|
|
329
|
+
appliesTo: ({ source }) => hasMarkdownFenceLanguage(source, new Set(Object.keys(languageMap)))
|
|
330
|
+
});
|
|
312
331
|
return defineMarkdownPlugin({
|
|
313
332
|
name: "kroki",
|
|
314
333
|
version: PLUGIN_VERSION,
|
|
@@ -319,7 +338,7 @@ function kroki(options = {}) {
|
|
|
319
338
|
options: { server, languages: languageMap, format }
|
|
320
339
|
},
|
|
321
340
|
fenceLanguages: Object.keys(languageMap),
|
|
322
|
-
appliesTo
|
|
341
|
+
appliesTo,
|
|
323
342
|
assets: {
|
|
324
343
|
clients: [{ id: "kroki", module: "@canofold/plugins/client/kroki" }],
|
|
325
344
|
styles: [{ id: "diagrams", module: "@canofold/plugins/diagram.css" }]
|
|
@@ -681,6 +700,8 @@ ${source}
|
|
|
681
700
|
}
|
|
682
701
|
function plantUml(options = {}) {
|
|
683
702
|
const server = options.server === false ? "" : stripTrailingSlashes2(options.server?.trim() ?? "");
|
|
703
|
+
const hasPlantUmlFence = ({ source }) => hasMarkdownFenceLanguage(source, /* @__PURE__ */ new Set(["plantuml", "puml"]));
|
|
704
|
+
const appliesTo = server ? externalDiagramServiceGate({ plugin: "PlantUML", appliesTo: hasPlantUmlFence }) : hasPlantUmlFence;
|
|
684
705
|
return defineMarkdownPlugin6({
|
|
685
706
|
name: "plantuml",
|
|
686
707
|
version: PLUGIN_VERSION7,
|
|
@@ -691,7 +712,7 @@ function plantUml(options = {}) {
|
|
|
691
712
|
options: { server: server || false }
|
|
692
713
|
},
|
|
693
714
|
fenceLanguages: ["plantuml", "puml"],
|
|
694
|
-
appliesTo
|
|
715
|
+
appliesTo,
|
|
695
716
|
assets: {
|
|
696
717
|
clients: [{ id: "plantuml", module: "@canofold/plugins/client/plantuml" }],
|
|
697
718
|
styles: [{ id: "diagrams", module: "@canofold/plugins/diagram.css" }]
|
package/dist/kroki.js
CHANGED
|
@@ -175,6 +175,21 @@ function diagramFence(options) {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
// src/shared/externalDiagramService.ts
|
|
179
|
+
function externalDiagramServiceGate({ plugin, appliesTo }) {
|
|
180
|
+
let warned = false;
|
|
181
|
+
return (context) => {
|
|
182
|
+
const active = appliesTo(context);
|
|
183
|
+
if (active && !warned) {
|
|
184
|
+
console.warn(
|
|
185
|
+
`[canofold/plugins] ${plugin} sends diagram source to its configured external service. Use a trusted self-hosted service for private content.`
|
|
186
|
+
);
|
|
187
|
+
warned = true;
|
|
188
|
+
}
|
|
189
|
+
return active;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
178
193
|
// src/shared/markdownSource.ts
|
|
179
194
|
function stripColumns(value, columns) {
|
|
180
195
|
let index = 0;
|
|
@@ -268,6 +283,10 @@ function kroki(options = {}) {
|
|
|
268
283
|
const languageMap = Object.fromEntries(
|
|
269
284
|
Object.entries(languages).map(([language, type]) => [language.trim().toLowerCase(), type.trim().toLowerCase()]).filter(([language, type]) => language && type)
|
|
270
285
|
);
|
|
286
|
+
const appliesTo = externalDiagramServiceGate({
|
|
287
|
+
plugin: "Kroki",
|
|
288
|
+
appliesTo: ({ source }) => hasMarkdownFenceLanguage(source, new Set(Object.keys(languageMap)))
|
|
289
|
+
});
|
|
271
290
|
return defineMarkdownPlugin({
|
|
272
291
|
name: "kroki",
|
|
273
292
|
version: PLUGIN_VERSION,
|
|
@@ -278,7 +297,7 @@ function kroki(options = {}) {
|
|
|
278
297
|
options: { server, languages: languageMap, format }
|
|
279
298
|
},
|
|
280
299
|
fenceLanguages: Object.keys(languageMap),
|
|
281
|
-
appliesTo
|
|
300
|
+
appliesTo,
|
|
282
301
|
assets: {
|
|
283
302
|
clients: [{ id: "kroki", module: "@canofold/plugins/client/kroki" }],
|
|
284
303
|
styles: [{ id: "diagrams", module: "@canofold/plugins/diagram.css" }]
|
package/dist/plantuml.js
CHANGED
|
@@ -175,6 +175,21 @@ function diagramFence(options) {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
// src/shared/externalDiagramService.ts
|
|
179
|
+
function externalDiagramServiceGate({ plugin, appliesTo }) {
|
|
180
|
+
let warned = false;
|
|
181
|
+
return (context) => {
|
|
182
|
+
const active = appliesTo(context);
|
|
183
|
+
if (active && !warned) {
|
|
184
|
+
console.warn(
|
|
185
|
+
`[canofold/plugins] ${plugin} sends diagram source to its configured external service. Use a trusted self-hosted service for private content.`
|
|
186
|
+
);
|
|
187
|
+
warned = true;
|
|
188
|
+
}
|
|
189
|
+
return active;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
178
193
|
// src/shared/markdownSource.ts
|
|
179
194
|
function stripColumns(value, columns) {
|
|
180
195
|
let index = 0;
|
|
@@ -272,6 +287,8 @@ ${source}
|
|
|
272
287
|
}
|
|
273
288
|
function plantUml(options = {}) {
|
|
274
289
|
const server = options.server === false ? "" : stripTrailingSlashes(options.server?.trim() ?? "");
|
|
290
|
+
const hasPlantUmlFence = ({ source }) => hasMarkdownFenceLanguage(source, /* @__PURE__ */ new Set(["plantuml", "puml"]));
|
|
291
|
+
const appliesTo = server ? externalDiagramServiceGate({ plugin: "PlantUML", appliesTo: hasPlantUmlFence }) : hasPlantUmlFence;
|
|
275
292
|
return defineMarkdownPlugin({
|
|
276
293
|
name: "plantuml",
|
|
277
294
|
version: PLUGIN_VERSION,
|
|
@@ -282,7 +299,7 @@ function plantUml(options = {}) {
|
|
|
282
299
|
options: { server: server || false }
|
|
283
300
|
},
|
|
284
301
|
fenceLanguages: ["plantuml", "puml"],
|
|
285
|
-
appliesTo
|
|
302
|
+
appliesTo,
|
|
286
303
|
assets: {
|
|
287
304
|
clients: [{ id: "plantuml", module: "@canofold/plugins/client/plantuml" }],
|
|
288
305
|
styles: [{ id: "diagrams", module: "@canofold/plugins/diagram.css" }]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canofold/plugins",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Official plugins and providers for Canofold and @canofold/markdown.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Canofold Contributors",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"rehype-katex": "^7.0.1",
|
|
85
85
|
"remark-math": "^6.0.0",
|
|
86
86
|
"unist-util-visit": "^5.1.0",
|
|
87
|
-
"@canofold/markdown": "0.
|
|
87
|
+
"@canofold/markdown": "0.3.1"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"mermaid": "^11.12.0",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@types/mdast": "^4.0.4",
|
|
104
104
|
"@types/node": "^22.10.0",
|
|
105
105
|
"@types/react": "^19.2.18",
|
|
106
|
-
"@types/react-dom": "^19.2.
|
|
106
|
+
"@types/react-dom": "^19.2.7",
|
|
107
107
|
"esbuild": "^0.28.2",
|
|
108
108
|
"mermaid": "^11.17.2",
|
|
109
109
|
"pagefind": "^1.5.2",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"react-dom": "^19.2.8",
|
|
112
112
|
"tsup": "^8.3.5",
|
|
113
113
|
"typescript": "^6.0.3",
|
|
114
|
-
"canofold": "0.
|
|
114
|
+
"canofold": "0.3.1"
|
|
115
115
|
},
|
|
116
116
|
"scripts": {
|
|
117
117
|
"build": "tsup && node scripts/verify-client-assets.mjs && node scripts/build-math-css.mjs",
|