Skip to content

Commit 2b8eb8d

Browse files
Demos.JQuery. Refactor demos with extarnal deps for setting deps versions from package.json
1 parent 0f9eab9 commit 2b8eb8d

4 files changed

Lines changed: 33 additions & 18 deletions

File tree

apps/demos/Demos/Chat/AIAndChatbotIntegration/jQuery/index.html

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,28 @@
99
<link rel="stylesheet" type="text/css" href="../../../../node_modules/devextreme-dist/css/dx.light.css" />
1010

1111
<script type="module">
12-
import { AzureOpenAI } from "https://esm.sh/openai@4.73.1";
13-
import { unified } from "https://esm.sh/unified@11?bundle";
14-
import remarkParse from "https://esm.sh/remark-parse@11?bundle";
15-
import remarkRehype from "https://esm.sh/remark-rehype@11?bundle";
16-
import rehypeStringify from "https://esm.sh/rehype-stringify@10?bundle";
17-
import rehypeMinifyWhitespace from "https://esm.sh/rehype-minify-whitespace@6?bundle";
18-
12+
const { getDepWithVersion } = await import('../../../../utils/deps-version-helper.mjs');
13+
14+
const { AzureOpenAI } = await import(`https://esm.sh/${getDepWithVersion('openai', false)}`);
15+
const { unified } = await import(`https://esm.sh/${getDepWithVersion('unified')}?bundle`);
16+
const remarkParse = await import(`https://esm.sh/${getDepWithVersion('remark-parse')}?bundle`);
17+
const remarkRehype = await import(`https://esm.sh/${getDepWithVersion('remark-rehype')}?bundle`);
18+
const rehypeStringify = await import(`https://esm.sh/${getDepWithVersion('rehype-stringify')}?bundle`);
19+
const rehypeMinifyWhitespace = await import(`https://esm.sh/${getDepWithVersion('rehype-minify-whitespace')}?bundle`);
20+
1921
window.AzureOpenAI = AzureOpenAI;
2022
window.unified = unified;
2123
window.remarkParse = remarkParse;
2224
window.remarkRehype = remarkRehype;
2325
window.rehypeMinifyWhitespace = rehypeMinifyWhitespace;
2426
window.rehypeStringify = rehypeStringify;
27+
28+
await import("./index.js");
2529
</script>
2630

2731
<script src="../../../../node_modules/devextreme-dist/js/dx.all.js"></script>
2832
<script src="data.js"></script>
2933
<link rel="stylesheet" type="text/css" href="styles.css" />
30-
<script src="index.js"></script>
3134
</head>
3235
<body class="dx-viewport">
3336
<div class="demo-container">

apps/demos/Demos/HtmlEditor/AITextEditing/jQuery/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@
1010
<script src="../../../../node_modules/devextreme-quill/dist/dx-quill.min.js"></script>
1111

1212
<script type="module">
13-
import { AzureOpenAI } from "https://esm.sh/openai@4.73.1";
13+
const { getDepWithVersion } = await import('../../../../utils/deps-version-helper.mjs');
14+
15+
const { AzureOpenAI } = await import(`https://esm.sh/${getDepWithVersion('openai', false)}`);
1416

1517
window.AzureOpenAI = AzureOpenAI;
18+
19+
await import("./index.js");
1620
</script>
1721

1822
<script src="../../../../node_modules/devextreme-dist/js/dx.all.js"></script>
1923
<script src="../../../../node_modules/devextreme-dist/js/dx.ai-integration.js"></script>
2024
<script src="data.js"></script>
2125
<link rel="stylesheet" type="text/css" href="styles.css" />
22-
<script src="index.js"></script>
2326
</head>
2427
<body class="dx-viewport">
2528
<div class="demo-container">

apps/demos/Demos/HtmlEditor/MarkdownSupport/jQuery/index.html

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
<script src="../../../../node_modules/devextreme-quill/dist/dx-quill.min.js"></script>
1111

1212
<script type="module">
13-
import { unified } from "https://esm.sh/unified@11?bundle";
14-
import remarkParse from "https://esm.sh/remark-parse@11?bundle";
15-
import remarkRehype from "https://esm.sh/remark-rehype@11?bundle";
16-
import rehypeStringify from "https://esm.sh/rehype-stringify@10?bundle";
17-
import rehypeParse from "https://esm.sh/rehype-parse@9?bundle";
18-
import rehypeRemark from "https://esm.sh/rehype-remark@10?bundle";
19-
import remarkStringify from "https://esm.sh/remark-stringify@11?bundle";
13+
const { getDepWithVersion } = await import('../../../../utils/deps-version-helper.mjs');
14+
15+
const { unified } = await import(`https://esm.sh/${getDepWithVersion('unified')}?bundle`);
16+
const remarkParse = await import(`https://esm.sh/${getDepWithVersion('remark-parse')}?bundle`);
17+
const remarkRehype = await import(`https://esm.sh/${getDepWithVersion('remark-rehype')}?bundle`);
18+
const rehypeStringify = await import(`https://esm.sh/${getDepWithVersion('rehype-stringify')}?bundle`);
19+
const rehypeParse = await import(`https://esm.sh/${getDepWithVersion('rehype-parse')}?bundle`);
20+
const rehypeRemark = await import(`https://esm.sh/${getDepWithVersion('rehype-remark')}?bundle`);
21+
const remarkStringify = await import(`https://esm.sh/${getDepWithVersion('remark-stringify')}?bundle`);
2022

2123
window.unified = unified;
2224
window.remarkParse = remarkParse;
@@ -25,12 +27,13 @@
2527
window.rehypeParse = rehypeParse;
2628
window.rehypeRemark = rehypeRemark;
2729
window.remarkStringify = remarkStringify;
30+
31+
await import("./index.js");
2832
</script>
2933

3034
<script src="../../../../node_modules/devextreme-dist/js/dx.all.js"></script>
3135
<script src="data.js"></script>
3236
<link rel="stylesheet" type="text/css" href="styles.css" />
33-
<script src="index.js"></script>
3437
</head>
3538
<body class="dx-viewport">
3639
<div class="demo-container">
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const deps = (await (await fetch('../../../../package.json')).json()).dependencies;
2+
const trimVersion = (versionNmb, needTrim) => needTrim ? versionNmb.replace(/\.\d+\.\d+/,'') : versionNmb;
3+
4+
export function getDepWithVersion(dep, needTrim = true) {
5+
return `${dep}@` + trimVersion(deps[dep].replace(/^\D/,''), needTrim);
6+
}

0 commit comments

Comments
 (0)