x4js 2.3.2 → 2.3.4

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.
@@ -3,6 +3,7 @@ import { fileURLToPath } from "node:url";
3
3
  import { sassPlugin } from "esbuild-sass-plugin";
4
4
  import { lessPlugin } from "./less-plugin.mjs";
5
5
  import { copyPlugin } from "./copy-plugin.mjs";
6
+ import { rawFilePlugin } from "./rawfile-plugin.mjs";
6
7
 
7
8
  const cliDir = path.dirname(fileURLToPath(import.meta.url));
8
9
  const devClient = path.join(cliDir, "dev-client.js");
@@ -28,7 +29,7 @@ export function createBuildOptions(config, mode) {
28
29
  format: "iife",
29
30
  target: "es2020",
30
31
  minify: production,
31
- sourcemap: production ? false : "inline",
32
+ sourcemap: production ? false : "linked",
32
33
  logLevel: "info",
33
34
  external: config.external,
34
35
  assetNames: "assets/[name]-[hash]",
@@ -47,6 +48,10 @@ export function createBuildOptions(config, mode) {
47
48
  VERSION_ID: versionId(),
48
49
  },
49
50
  plugins: [
51
+ rawFilePlugin({
52
+ filter: /\.svg$/,
53
+ mime: "image/svg+xml",
54
+ }),
50
55
  sassPlugin({
51
56
  type: "css",
52
57
  filter: /\.s[ac]ss$/,
package/cli/config.mjs CHANGED
@@ -132,7 +132,7 @@ export function loadConfig(root = process.cwd(), env = process.env) {
132
132
  })),
133
133
  external: [...external],
134
134
  define: { ...define },
135
- dev: {
135
+ dev: {
136
136
  host,
137
137
  port,
138
138
  https,
@@ -0,0 +1,43 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+
4
+ export function rawFilePlugin({ filter, mime }) {
5
+ const namespace = "x4-raw-file";
6
+
7
+ return {
8
+ name: "x4-raw-file",
9
+
10
+ setup(build) {
11
+ build.onResolve({ filter }, (args) => {
12
+ // Seulement les imports JS/TS.
13
+ if (
14
+ args.kind !== "import-statement" &&
15
+ args.kind !== "dynamic-import"
16
+ ) {
17
+ return;
18
+ }
19
+
20
+ return {
21
+ path: path.resolve(args.resolveDir, args.path),
22
+ namespace,
23
+ };
24
+ });
25
+
26
+ build.onLoad(
27
+ { filter: /.*/, namespace },
28
+ async (args) => {
29
+ const data = await fs.readFile(args.path);
30
+
31
+ const value =
32
+ `data:${mime};base64,${data.toString("base64")}`;
33
+
34
+ return {
35
+ contents:
36
+ `export default ${JSON.stringify(value)};`,
37
+ loader: "js",
38
+ };
39
+ }
40
+ );
41
+ },
42
+ };
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "type": "module",
5
5
  "main": "src/x4.ts",
6
6
  "module": "src/x4.ts",
@@ -14,7 +14,7 @@
14
14
  * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
15
  **/
16
16
 
17
- @import "../shared.scss";
17
+ @use "../shared";
18
18
 
19
19
  :root {
20
20
  --color-dialog-caption: var( --color-primary-a80 );
@@ -133,7 +133,6 @@ export class Icon extends Component<IconProps> {
133
133
  * import myicon from "./myicon.svg";
134
134
  * setIcon(myicon);
135
135
  */
136
-
137
136
  setIcon( iconId: string ) {
138
137
  this.clearContent( );
139
138
 
@@ -148,6 +147,9 @@ export class Icon extends Component<IconProps> {
148
147
  if( iconId.startsWith("data:image/svg+xml,<svg") ) {
149
148
  this.dom.insertAdjacentHTML('beforeend', iconId.substring(19) );
150
149
  }
150
+ else if( iconId.startsWith("data:image/svg+xml;base64,") ) {
151
+ this.dom.insertAdjacentHTML('beforeend', atob(iconId.substring(26)) );
152
+ }
151
153
  else if( iconId.startsWith("<svg") ) { // raw
152
154
  this.dom.insertAdjacentHTML('beforeend', iconId );
153
155
  }