simple-dynamsoft-mcp 6.2.0 → 6.4.0

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.
@@ -1,4 +1,5 @@
1
1
  import { readFileSync } from "node:fs";
2
+ import { createHash } from "node:crypto";
2
3
  import {
3
4
  normalizeSdkId,
4
5
  normalizePlatform,
@@ -23,26 +24,36 @@ import {
23
24
  discoverMobileSamples,
24
25
  discoverDbrServerSamples,
25
26
  discoverPythonSamples,
27
+ discoverDcvMobileSamples,
28
+ discoverDcvServerSamples,
29
+ discoverDcvWebSamples,
26
30
  discoverWebSamples,
27
31
  getWebSamplePath,
28
32
  discoverDwtSamples,
29
33
  discoverDdvSamples,
30
34
  mapDdvSampleToFramework,
31
35
  getDbrWebFrameworkPlatforms,
36
+ getDcvWebFrameworkPlatforms,
32
37
  getDdvWebFrameworkPlatforms,
33
38
  getWebFrameworkPlatforms,
34
39
  findCodeFilesInSample,
35
40
  getDbrMobilePlatforms,
36
41
  getDbrServerPlatforms,
42
+ getDcvMobilePlatforms,
43
+ getDcvServerPlatforms,
37
44
  getMobileSamplePath,
38
45
  getPythonSamplePath,
39
46
  getDbrServerSamplePath,
47
+ getDcvMobileSamplePath,
48
+ getDcvServerSamplePath,
49
+ getDcvWebSamplePath,
40
50
  getDwtSamplePath,
41
51
  getDdvSamplePath,
42
52
  readCodeFile,
43
53
  getMainCodeFile,
44
54
  getMimeTypeForExtension,
45
- getDbrServerSampleContent
55
+ getDbrServerSampleContent,
56
+ getDcvServerSampleContent
46
57
  } from "./resource-index/samples.js";
47
58
  import { parseResourceUri, parseSampleUri, getSampleIdFromUri } from "./resource-index/uri.js";
48
59
  import {
@@ -59,6 +70,7 @@ import {
59
70
  } from "./resource-index/builders.js";
60
71
 
61
72
  const registry = JSON.parse(readFileSync(registryPath, "utf8"));
73
+ const registrySha256 = createHash("sha256").update(readFileSync(registryPath)).digest("hex");
62
74
 
63
75
  function inferDbrMobilePlatform(articlePath) {
64
76
  const normalized = String(articlePath || "").replace(/\\/g, "/").toLowerCase();
@@ -82,7 +94,7 @@ function inferDbrServerPlatform(articlePath) {
82
94
  return "server";
83
95
  }
84
96
 
85
- function withDbrScope(articles, edition, platformResolver) {
97
+ function withEditionScope(articles, edition, platformResolver) {
86
98
  return (articles || []).map((article) => ({
87
99
  ...article,
88
100
  edition,
@@ -90,7 +102,31 @@ function withDbrScope(articles, edition, platformResolver) {
90
102
  }));
91
103
  }
92
104
 
93
- const dbrWebDocs = withDbrScope(
105
+ function inferDcvMobilePlatform(articlePath) {
106
+ const normalized = String(articlePath || "").replace(/\\/g, "/").toLowerCase();
107
+ const match = normalized.match(/^programming\/([^/]+)\//);
108
+ if (!match) return "mobile";
109
+ const segment = match[1];
110
+ if (segment === "objectivec-swift") return "ios";
111
+ if (segment === "android" || segment === "ios" || segment === "maui" || segment === "react-native" || segment === "flutter") {
112
+ return segment;
113
+ }
114
+ return "mobile";
115
+ }
116
+
117
+ function inferDcvServerPlatform(articlePath) {
118
+ const normalized = String(articlePath || "").replace(/\\/g, "/").toLowerCase();
119
+ const match = normalized.match(/^programming\/([^/]+)\//);
120
+ if (!match) return "server";
121
+ const segment = match[1];
122
+ if (segment === "cplusplus") return "cpp";
123
+ if (segment === "python" || segment === "java" || segment === "dotnet" || segment === "cpp" || segment === "nodejs") {
124
+ return segment;
125
+ }
126
+ return "server";
127
+ }
128
+
129
+ const dbrWebDocs = withEditionScope(
94
130
  loadMarkdownDocs({
95
131
  rootDir: DOC_ROOTS.dbrWeb,
96
132
  urlBase: DOCS_CONFIG.dbrWeb.urlBase,
@@ -101,7 +137,7 @@ const dbrWebDocs = withDbrScope(
101
137
  () => "web"
102
138
  );
103
139
 
104
- const dbrMobileDocs = withDbrScope(
140
+ const dbrMobileDocs = withEditionScope(
105
141
  loadMarkdownDocs({
106
142
  rootDir: DOC_ROOTS.dbrMobile,
107
143
  urlBase: DOCS_CONFIG.dbrMobile.urlBase,
@@ -112,7 +148,7 @@ const dbrMobileDocs = withDbrScope(
112
148
  inferDbrMobilePlatform
113
149
  );
114
150
 
115
- const dbrServerDocs = withDbrScope(
151
+ const dbrServerDocs = withEditionScope(
116
152
  loadMarkdownDocs({
117
153
  rootDir: DOC_ROOTS.dbrServer,
118
154
  urlBase: DOCS_CONFIG.dbrServer.urlBase,
@@ -123,6 +159,50 @@ const dbrServerDocs = withDbrScope(
123
159
  inferDbrServerPlatform
124
160
  );
125
161
 
162
+ const dcvCoreDocs = withEditionScope(
163
+ loadMarkdownDocs({
164
+ rootDir: DOC_ROOTS.dcvCore,
165
+ urlBase: DOCS_CONFIG.dcvCore.urlBase,
166
+ excludeDirs: DOCS_CONFIG.dcvCore.excludeDirs,
167
+ excludeFiles: DOCS_CONFIG.dcvCore.excludeFiles
168
+ }).articles,
169
+ "core",
170
+ () => "core"
171
+ );
172
+
173
+ const dcvWebDocs = withEditionScope(
174
+ loadMarkdownDocs({
175
+ rootDir: DOC_ROOTS.dcvWeb,
176
+ urlBase: DOCS_CONFIG.dcvWeb.urlBase,
177
+ excludeDirs: DOCS_CONFIG.dcvWeb.excludeDirs,
178
+ excludeFiles: DOCS_CONFIG.dcvWeb.excludeFiles
179
+ }).articles,
180
+ "web",
181
+ () => "web"
182
+ );
183
+
184
+ const dcvMobileDocs = withEditionScope(
185
+ loadMarkdownDocs({
186
+ rootDir: DOC_ROOTS.dcvMobile,
187
+ urlBase: DOCS_CONFIG.dcvMobile.urlBase,
188
+ excludeDirs: DOCS_CONFIG.dcvMobile.excludeDirs,
189
+ excludeFiles: DOCS_CONFIG.dcvMobile.excludeFiles
190
+ }).articles,
191
+ "mobile",
192
+ inferDcvMobilePlatform
193
+ );
194
+
195
+ const dcvServerDocs = withEditionScope(
196
+ loadMarkdownDocs({
197
+ rootDir: DOC_ROOTS.dcvServer,
198
+ urlBase: DOCS_CONFIG.dcvServer.urlBase,
199
+ excludeDirs: DOCS_CONFIG.dcvServer.excludeDirs,
200
+ excludeFiles: DOCS_CONFIG.dcvServer.excludeFiles
201
+ }).articles,
202
+ "server",
203
+ inferDcvServerPlatform
204
+ );
205
+
126
206
  const dwtDocs = loadMarkdownDocs({
127
207
  rootDir: DOC_ROOTS.dwtArticles,
128
208
  urlBase: DOCS_CONFIG.dwt.urlBase,
@@ -137,6 +217,10 @@ const ddvDocs = loadMarkdownDocs({
137
217
  });
138
218
 
139
219
  const dbrServerSdk = registry.sdks["dbr-server"];
220
+ const dcvMobileSdk = registry.sdks["dcv-mobile"];
221
+ const dcvWebSdk = registry.sdks["dcv-web"];
222
+ const dcvServerSdk = registry.sdks["dcv-server"];
223
+ const dcvCoreSdk = registry.sdks["dcv-core"];
140
224
 
141
225
  const LATEST_VERSIONS = {
142
226
  dbr: {
@@ -145,6 +229,12 @@ const LATEST_VERSIONS = {
145
229
  server: dbrServerSdk.version,
146
230
  python: dbrServerSdk.version
147
231
  },
232
+ dcv: {
233
+ core: dcvCoreSdk.version,
234
+ web: dcvWebSdk.version,
235
+ mobile: dcvMobileSdk.version,
236
+ server: dcvServerSdk.version
237
+ },
148
238
  dwt: {
149
239
  web: registry.sdks.dwt.version
150
240
  },
@@ -155,6 +245,7 @@ const LATEST_VERSIONS = {
155
245
 
156
246
  const LATEST_MAJOR = {
157
247
  dbr: parseMajorVersion(registry.sdks["dbr-mobile"].version),
248
+ dcv: parseMajorVersion(dcvMobileSdk.version),
158
249
  dwt: parseMajorVersion(registry.sdks.dwt.version),
159
250
  ddv: parseMajorVersion(registry.sdks.ddv.version)
160
251
  };
@@ -179,11 +270,21 @@ function buildIndexData() {
179
270
  return buildIndexDataFromBuilders({
180
271
  LATEST_VERSIONS,
181
272
  LATEST_MAJOR,
273
+ dcvCoreDocs,
274
+ dcvWebDocs,
275
+ dcvMobileDocs,
276
+ dcvServerDocs,
182
277
  dbrWebDocs,
183
278
  dbrMobileDocs,
184
279
  dbrServerDocs,
185
280
  dwtDocs,
186
281
  ddvDocs,
282
+ discoverDcvWebSamples,
283
+ getDcvWebFrameworkPlatforms,
284
+ getDcvMobilePlatforms,
285
+ getDcvServerPlatforms,
286
+ discoverDcvMobileSamples,
287
+ discoverDcvServerSamples,
187
288
  discoverWebSamples,
188
289
  getDbrWebFrameworkPlatforms,
189
290
  getDbrMobilePlatforms,
@@ -203,11 +304,23 @@ function buildResourceIndex() {
203
304
  buildVersionPolicyText,
204
305
  LATEST_VERSIONS,
205
306
  LATEST_MAJOR,
307
+ dcvCoreDocs,
308
+ dcvWebDocs,
309
+ dcvMobileDocs,
310
+ dcvServerDocs,
206
311
  dbrWebDocs,
207
312
  dbrMobileDocs,
208
313
  dbrServerDocs,
209
314
  dwtDocs,
210
315
  ddvDocs,
316
+ discoverDcvMobileSamples,
317
+ getDcvMobilePlatforms,
318
+ getDcvMobileSamplePath,
319
+ getDcvServerPlatforms,
320
+ discoverDcvServerSamples,
321
+ getDcvServerSampleContent,
322
+ discoverDcvWebSamples,
323
+ getDcvWebSamplePath,
211
324
  discoverMobileSamples,
212
325
  getDbrMobilePlatforms,
213
326
  getMobileSamplePath,
@@ -286,9 +399,49 @@ function getPinnedResources() {
286
399
  return resourceIndex.filter((entry) => entry.pinned);
287
400
  }
288
401
 
402
+ function safeDecodeURIComponent(value) {
403
+ try {
404
+ return decodeURIComponent(value);
405
+ } catch {
406
+ return value;
407
+ }
408
+ }
409
+
410
+ function buildResourceLookupCandidates(uri) {
411
+ const candidates = [];
412
+ if (typeof uri !== "string" || uri.length === 0) return candidates;
413
+ candidates.push(uri);
414
+
415
+ if (!uri.includes("://")) return candidates;
416
+ const [scheme, rest] = uri.split("://");
417
+ if (scheme !== "doc") return candidates;
418
+
419
+ const parts = String(rest || "").split("/").filter(Boolean);
420
+ if (parts.length < 5) return candidates;
421
+
422
+ const head = parts.slice(0, 4);
423
+ const slugRaw = parts.slice(4).join("/");
424
+ const decodedOnce = safeDecodeURIComponent(slugRaw);
425
+ const decodedTwice = safeDecodeURIComponent(decodedOnce);
426
+
427
+ for (const slug of [decodedOnce, decodedTwice]) {
428
+ const canonical = `${scheme}://${head.join("/")}/${encodeURIComponent(slug)}`;
429
+ if (!candidates.includes(canonical)) {
430
+ candidates.push(canonical);
431
+ }
432
+ }
433
+
434
+ return candidates;
435
+ }
436
+
289
437
  async function readResourceContent(uri) {
290
- const resource = resourceIndexByUri.get(uri);
438
+ let resource = null;
439
+ for (const candidate of buildResourceLookupCandidates(uri)) {
440
+ resource = resourceIndexByUri.get(candidate);
441
+ if (resource) break;
442
+ }
291
443
  if (!resource) return null;
444
+
292
445
  const content = await resource.loadContent();
293
446
  return {
294
447
  uri,
@@ -301,6 +454,10 @@ async function readResourceContent(uri) {
301
454
  function getRagSignatureData() {
302
455
  return {
303
456
  resourceCount: resourceIndex.length,
457
+ dcvCoreDocCount: dcvCoreDocs.length,
458
+ dcvWebDocCount: dcvWebDocs.length,
459
+ dcvMobileDocCount: dcvMobileDocs.length,
460
+ dcvServerDocCount: dcvServerDocs.length,
304
461
  dbrWebDocCount: dbrWebDocs.length,
305
462
  dbrMobileDocCount: dbrMobileDocs.length,
306
463
  dbrServerDocCount: dbrServerDocs.length,
@@ -318,14 +475,29 @@ function getRagSignatureData() {
318
475
  dbrReactNativeSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dbrReactNative),
319
476
  dbrFlutterSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dbrFlutter),
320
477
  dbrNodejsSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dbrNodejs),
478
+ dcvWebSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvWeb),
479
+ dcvMobileSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvMobile),
480
+ dcvPythonSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvPython),
481
+ dcvDotnetSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvDotnet),
482
+ dcvJavaSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvJava),
483
+ dcvCppSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvCpp),
484
+ dcvMauiSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvMaui),
485
+ dcvReactNativeSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvReactNative),
486
+ dcvFlutterSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvFlutter),
487
+ dcvNodejsSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvNodejs),
488
+ dcvSpmSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dcvSpm),
321
489
  dwtSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.dwt),
322
490
  ddvSamplesHead: readSubmoduleHead(SAMPLE_ROOTS.ddv),
323
491
  dbrWebDocsHead: readSubmoduleHead(DOC_ROOTS.dbrWeb),
324
492
  dbrMobileDocsHead: readSubmoduleHead(DOC_ROOTS.dbrMobile),
325
493
  dbrServerDocsHead: readSubmoduleHead(DOC_ROOTS.dbrServer),
494
+ dcvCoreDocsHead: readSubmoduleHead(DOC_ROOTS.dcvCore),
495
+ dcvWebDocsHead: readSubmoduleHead(DOC_ROOTS.dcvWeb),
496
+ dcvMobileDocsHead: readSubmoduleHead(DOC_ROOTS.dcvMobile),
497
+ dcvServerDocsHead: readSubmoduleHead(DOC_ROOTS.dcvServer),
326
498
  dwtDocsHead: readSubmoduleHead(DOC_ROOTS.dwt),
327
499
  ddvDocsHead: readSubmoduleHead(DOC_ROOTS.ddv),
328
- registryPath
500
+ registrySha256
329
501
  }
330
502
  };
331
503
  }
@@ -342,20 +514,29 @@ export {
342
514
  discoverMobileSamples,
343
515
  discoverDbrServerSamples,
344
516
  discoverPythonSamples,
517
+ discoverDcvMobileSamples,
518
+ discoverDcvServerSamples,
519
+ discoverDcvWebSamples,
345
520
  discoverWebSamples,
346
521
  getWebSamplePath,
347
522
  discoverDwtSamples,
348
523
  discoverDdvSamples,
349
524
  mapDdvSampleToFramework,
350
525
  getDbrWebFrameworkPlatforms,
526
+ getDcvWebFrameworkPlatforms,
351
527
  getDdvWebFrameworkPlatforms,
352
528
  getWebFrameworkPlatforms,
353
529
  findCodeFilesInSample,
354
530
  getDbrServerSamplePath,
355
531
  getDbrMobilePlatforms,
356
532
  getDbrServerPlatforms,
533
+ getDcvMobilePlatforms,
534
+ getDcvServerPlatforms,
357
535
  getMobileSamplePath,
358
536
  getPythonSamplePath,
537
+ getDcvMobileSamplePath,
538
+ getDcvServerSamplePath,
539
+ getDcvWebSamplePath,
359
540
  getDwtSamplePath,
360
541
  getDdvSamplePath,
361
542
  readCodeFile,