@inventreedb/ui 0.0.9 → 0.1.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,36 +1,9 @@
1
1
  import { INVENTREE_PLUGIN_VERSION } from "../types/Plugins.js";
2
- function extractVersion(version) {
3
- if (!version) {
4
- return null;
5
- }
6
- version = version.toString().trim();
7
- if (!version.includes(".")) {
8
- return null;
9
- }
10
- const [major, minor, patch] = version.split(".").map((v) => Number.parseInt(v, 10));
11
- return {
12
- major,
13
- minor,
14
- patch
15
- };
16
- }
17
2
  function checkPluginVersion(context) {
18
- let pluginVersion = null;
19
- let systemVersion = null;
20
- try {
21
- pluginVersion = extractVersion(INVENTREE_PLUGIN_VERSION);
22
- systemVersion = extractVersion(context.version.inventree);
23
- } catch {
24
- console.warn("Failed to extract plugin version information");
25
- return;
26
- }
27
- const mismatch = `Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${context.version}`;
28
- if (!pluginVersion || !systemVersion) {
29
- console.warn("Could not extract plugin version information");
30
- } else if (pluginVersion.major !== systemVersion.major) {
31
- console.warn(mismatch);
32
- } else if (INVENTREE_PLUGIN_VERSION != context.version.inventree) {
33
- console.info(mismatch);
3
+ var _a;
4
+ const systemVersion = ((_a = context == null ? void 0 : context.version) == null ? void 0 : _a.inventree) || "";
5
+ if (INVENTREE_PLUGIN_VERSION != systemVersion) {
6
+ console.info(`Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${systemVersion}`);
34
7
  }
35
8
  }
36
9
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"Plugins.js","sources":["../../lib/functions/Plugins.tsx"],"sourcesContent":["import {\n INVENTREE_PLUGIN_VERSION,\n type InvenTreePluginContext\n} from '../types/Plugins';\n\nfunction extractVersion(version: string) {\n // Extract the version number from the string\n\n if (!version) {\n return null;\n }\n\n version = version.toString().trim();\n\n if (!version.includes('.')) {\n return null;\n }\n\n const [major, minor, patch] = version\n .split('.')\n .map((v) => Number.parseInt(v, 10));\n\n return { major, minor, patch };\n}\n\n/**\n * Check that the plugin version matches the expected version.\n * This is a helper function which only generates a warning if there is a mismatch.\n */\nexport function checkPluginVersion(context: InvenTreePluginContext) {\n let pluginVersion: any = null;\n let systemVersion: any = null;\n \n try {\n pluginVersion = extractVersion(INVENTREE_PLUGIN_VERSION);\n systemVersion = extractVersion(context.version.inventree);\n } catch {\n console.warn(\"Failed to extract plugin version information\");\n return;\n }\n\n const mismatch = `Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${context.version}`;\n\n if (!pluginVersion || !systemVersion) {\n console.warn(\"Could not extract plugin version information\");\n } else if (pluginVersion.major !== systemVersion.major) {\n // A major version mismatch indicates a potentially breaking change\n console.warn(mismatch);\n } else if (INVENTREE_PLUGIN_VERSION != context.version.inventree) {\n console.info(mismatch);\n }\n}\n"],"names":["extractVersion","version","toString","trim","includes","major","minor","patch","split","map","v","Number","parseInt","checkPluginVersion","context","pluginVersion","systemVersion","INVENTREE_PLUGIN_VERSION","inventree","console","warn","mismatch","info"],"mappings":";AAKA,SAASA,eAAeC,SAAiB;AAGvC,MAAI,CAACA,SAAS;AACL,WAAA;AAAA,EAAA;AAGCA,YAAAA,QAAQC,SAAS,EAAEC,KAAK;AAElC,MAAI,CAACF,QAAQG,SAAS,GAAG,GAAG;AACnB,WAAA;AAAA,EAAA;AAGT,QAAM,CAACC,OAAOC,OAAOC,KAAK,IAAIN,QAC3BO,MAAM,GAAG,EACTC,IAAKC,CAAMC,MAAAA,OAAOC,SAASF,GAAG,EAAE,CAAC;AAE7B,SAAA;AAAA,IAAEL;AAAAA,IAAOC;AAAAA,IAAOC;AAAAA,EAAM;AAC/B;AAMO,SAASM,mBAAmBC,SAAiC;AAClE,MAAIC,gBAAqB;AACzB,MAAIC,gBAAqB;AAErB,MAAA;AACFD,oBAAgBf,eAAeiB,wBAAwB;AACvCjB,oBAAAA,eAAec,QAAQb,QAAQiB,SAAS;AAAA,EAAA,QAClD;AACNC,YAAQC,KAAK,8CAA8C;AAC3D;AAAA,EAAA;AAGF,QAAMC,WAAW,6CAA6CJ,wBAAwB,SAASH,QAAQb,OAAO;AAE1G,MAAA,CAACc,iBAAiB,CAACC,eAAe;AACpCG,YAAQC,KAAK,8CAA8C;AAAA,EAClDL,WAAAA,cAAcV,UAAUW,cAAcX,OAAO;AAEtDc,YAAQC,KAAKC,QAAQ;AAAA,EACZJ,WAAAA,4BAA4BH,QAAQb,QAAQiB,WAAW;AAChEC,YAAQG,KAAKD,QAAQ;AAAA,EAAA;AAEzB;"}
1
+ {"version":3,"file":"Plugins.js","sources":["../../lib/functions/Plugins.tsx"],"sourcesContent":["import {\n INVENTREE_PLUGIN_VERSION,\n type InvenTreePluginContext\n} from '../types/Plugins';\n\n/**\n * Check that the plugin version matches the expected version.\n * This is a helper function which only generates a warning if there is a mismatch.\n */\nexport function checkPluginVersion(context: InvenTreePluginContext) {\n const systemVersion: string = context?.version?.inventree || '';\n \n if (INVENTREE_PLUGIN_VERSION != systemVersion) {\n console.info(`Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${systemVersion}`);\n }\n}\n"],"names":["checkPluginVersion","context","systemVersion","version","inventree","INVENTREE_PLUGIN_VERSION","console","info"],"mappings":";AASO,SAASA,mBAAmBC,SAAiC;;AAC5DC,QAAAA,kBAAwBD,wCAASE,YAATF,mBAAkBG,cAAa;AAE7D,MAAIC,4BAA4BH,eAAe;AAC7CI,YAAQC,KAAK,6CAA6CF,wBAAwB,SAASH,aAAa,EAAE;AAAA,EAAA;AAE9G;"}
@@ -1,4 +1,4 @@
1
- const INVENTREE_PLUGIN_VERSION = "0.0.9";
1
+ const INVENTREE_PLUGIN_VERSION = "0.1.0";
2
2
  const INVENTREE_REACT_VERSION = "18.3.1";
3
3
  const INVENTREE_REACT_DOM_VERSION = (
4
4
  // @ts-ignore
@@ -3,50 +3,14 @@ import {
3
3
  type InvenTreePluginContext
4
4
  } from '../types/Plugins';
5
5
 
6
- function extractVersion(version: string) {
7
- // Extract the version number from the string
8
-
9
- if (!version) {
10
- return null;
11
- }
12
-
13
- version = version.toString().trim();
14
-
15
- if (!version.includes('.')) {
16
- return null;
17
- }
18
-
19
- const [major, minor, patch] = version
20
- .split('.')
21
- .map((v) => Number.parseInt(v, 10));
22
-
23
- return { major, minor, patch };
24
- }
25
-
26
6
  /**
27
7
  * Check that the plugin version matches the expected version.
28
8
  * This is a helper function which only generates a warning if there is a mismatch.
29
9
  */
30
10
  export function checkPluginVersion(context: InvenTreePluginContext) {
31
- let pluginVersion: any = null;
32
- let systemVersion: any = null;
11
+ const systemVersion: string = context?.version?.inventree || '';
33
12
 
34
- try {
35
- pluginVersion = extractVersion(INVENTREE_PLUGIN_VERSION);
36
- systemVersion = extractVersion(context.version.inventree);
37
- } catch {
38
- console.warn("Failed to extract plugin version information");
39
- return;
40
- }
41
-
42
- const mismatch = `Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${context.version}`;
43
-
44
- if (!pluginVersion || !systemVersion) {
45
- console.warn("Could not extract plugin version information");
46
- } else if (pluginVersion.major !== systemVersion.major) {
47
- // A major version mismatch indicates a potentially breaking change
48
- console.warn(mismatch);
49
- } else if (INVENTREE_PLUGIN_VERSION != context.version.inventree) {
50
- console.info(mismatch);
13
+ if (INVENTREE_PLUGIN_VERSION != systemVersion) {
14
+ console.info(`Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${systemVersion}`);
51
15
  }
52
16
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inventreedb/ui",
3
3
  "description": "UI components for the InvenTree project",
4
- "version": "0.0.9",
4
+ "version": "0.1.0",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "license": "MIT",