@timardex/cluemart-shared 1.5.529 → 1.5.530

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.
@@ -4,7 +4,7 @@ import {
4
4
  normalizeUrl,
5
5
  timeFormat
6
6
  } from "../chunk-LZ2KFVBV.mjs";
7
- import "../chunk-PYMLMTOQ.mjs";
7
+ import "../chunk-G2YFRN6A.mjs";
8
8
  import {
9
9
  EnumEventDateStatus,
10
10
  EnumEventType,
@@ -17,7 +17,7 @@ import {
17
17
  EnumUserRole,
18
18
  EnumVendorType
19
19
  } from "../chunk-534WN2SR.mjs";
20
- import "../chunk-IBKLW65U.mjs";
20
+ import "../chunk-4PJQMQVX.mjs";
21
21
  import "../chunk-DWO35OY4.mjs";
22
22
  import "../chunk-I7WE3EBR.mjs";
23
23
  import {
Binary file
@@ -0,0 +1,2 @@
1
+ declare const src: string | number;
2
+ export default src;
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/images/index.ts
21
21
  var images_exports = {};
22
22
  __export(images_exports, {
23
+ otherFiles: () => otherFiles,
24
+ otherImages: () => otherImages,
23
25
  posterFiles: () => posterFiles,
24
26
  posters: () => posters
25
27
  });
@@ -30,11 +32,19 @@ var posterFiles = {
30
32
  poster2: "poster2.png",
31
33
  poster3: "poster3.png"
32
34
  };
35
+ var otherFiles = {
36
+ cluiTui: "cluiTui.png"
37
+ };
33
38
  var posters = Object.fromEntries(
34
39
  Object.entries(posterFiles).map(([key, file]) => [key, `${PKG}/images/${file}`])
35
40
  );
41
+ var otherImages = Object.fromEntries(
42
+ Object.entries(otherFiles).map(([key, file]) => [key, `${PKG}/images/${file}`])
43
+ );
36
44
  // Annotate the CommonJS export names for ESM import in node:
37
45
  0 && (module.exports = {
46
+ otherFiles,
47
+ otherImages,
38
48
  posterFiles,
39
49
  posters
40
50
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/images/index.ts"],"sourcesContent":["const PKG = \"@timardex/cluemart-shared\" as const;\n\n/**\n * Basenames under the shared images directory — use with `getSharedImagePath` from `@timardex/cluemart-shared/images/node` (Express / Node).\n * This object is the single source of poster keys; `posters` is derived from it. Add a PNG under `src/images/posters/` when adding an entry.\n * Keep `POSTER_FILE_BY_ID` in `src/images/node.cjs` / `node.mjs` in sync when you change this map.\n */\nexport const posterFiles = {\n poster1: \"poster1.png\",\n poster2: \"poster2.png\",\n poster3: \"poster3.png\",\n} as const;\n\n/**\n * Module specifiers for each poster (not resolved file URLs). Use a static import or require with these paths\n * so your bundler resolves the file, e.g.\n * `import poster1 from \"@timardex/cluemart-shared/images/poster1.png\"`\n * or `require(\"@timardex/cluemart-shared/images/poster1.png\")` (React Native / Metro).\n *\n * Derived from `posterFiles` so keys and filenames stay aligned.\n */\nexport const posters = Object.fromEntries(\n (\n Object.entries(posterFiles) as [\n keyof typeof posterFiles,\n (typeof posterFiles)[keyof typeof posterFiles],\n ][]\n ).map(([key, file]) => [key, `${PKG}/images/${file}`]),\n) as {\n readonly [K in keyof typeof posterFiles]: `${typeof PKG}/images/${(typeof posterFiles)[K]}`;\n};\n\nexport type PosterAssetId = keyof typeof posters;\n\n/** A single filename under the shared images directory (values of `posterFiles`). */\nexport type PosterImageBasename = (typeof posterFiles)[PosterAssetId];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,MAAM;AAOL,IAAM,cAAc;AAAA,EACzB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AACX;AAUO,IAAM,UAAU,OAAO;AAAA,EAE1B,OAAO,QAAQ,WAAW,EAI1B,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,GAAG,GAAG,WAAW,IAAI,EAAE,CAAC;AACvD;","names":[]}
1
+ {"version":3,"sources":["../../src/images/index.ts"],"sourcesContent":["const PKG = \"@timardex/cluemart-shared\" as const;\n\n/**\n * Basenames under the shared images directory — use with `getSharedImagePath` from `@timardex/cluemart-shared/images/node` (Express / Node).\n * This object is the single source of poster keys; `posters` is derived from it. Add a PNG under `src/images/posters/` when adding an entry.\n * `images/node` reads this at runtime for `getSharedImagePath` allow-listing.\n */\nexport const posterFiles = {\n poster1: \"poster1.png\",\n poster2: \"poster2.png\",\n poster3: \"poster3.png\",\n} as const;\n\n/**\n * Basenames for assets kept under `src/images/other/` in source; they are copied flat into `dist/images/` (same as posters).\n * `images/node` reads this at runtime for `getSharedImagePath` allow-listing.\n */\nexport const otherFiles = {\n cluiTui: \"cluiTui.png\",\n} as const;\n\n/**\n * Module specifiers for each poster (not resolved file URLs). Use a static import or require with these paths\n * so your bundler resolves the file, e.g.\n * `import poster1 from \"@timardex/cluemart-shared/images/poster1.png\"`\n * or `require(\"@timardex/cluemart-shared/images/poster1.png\")` (React Native / Metro).\n *\n * Derived from `posterFiles` so keys and filenames stay aligned.\n */\nexport const posters = Object.fromEntries(\n (\n Object.entries(posterFiles) as [\n keyof typeof posterFiles,\n (typeof posterFiles)[keyof typeof posterFiles],\n ][]\n ).map(([key, file]) => [key, `${PKG}/images/${file}`]),\n) as {\n readonly [K in keyof typeof posterFiles]: `${typeof PKG}/images/${(typeof posterFiles)[K]}`;\n};\n\n/**\n * Module specifiers for other images (same flat `@…/images/<file>.png` pattern as posters), e.g.\n * `import clui from \"@timardex/cluemart-shared/images/cluiTui.png\"`.\n */\nexport const otherImages = Object.fromEntries(\n (\n Object.entries(otherFiles) as [\n keyof typeof otherFiles,\n (typeof otherFiles)[keyof typeof otherFiles],\n ][]\n ).map(([key, file]) => [key, `${PKG}/images/${file}`]),\n) as {\n readonly [K in keyof typeof otherFiles]: `${typeof PKG}/images/${(typeof otherFiles)[K]}`;\n};\n\nexport type PosterAssetId = keyof typeof posters;\n\n/** A single filename under the shared images directory (values of `posterFiles`). */\nexport type PosterImageBasename = (typeof posterFiles)[PosterAssetId];\n\nexport type OtherImageId = keyof typeof otherImages;\n\n/** Basename under the shared images directory (values of `otherFiles`). */\nexport type OtherImageBasename = (typeof otherFiles)[OtherImageId];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,MAAM;AAOL,IAAM,cAAc;AAAA,EACzB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AACX;AAMO,IAAM,aAAa;AAAA,EACxB,SAAS;AACX;AAUO,IAAM,UAAU,OAAO;AAAA,EAE1B,OAAO,QAAQ,WAAW,EAI1B,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,GAAG,GAAG,WAAW,IAAI,EAAE,CAAC;AACvD;AAQO,IAAM,cAAc,OAAO;AAAA,EAE9B,OAAO,QAAQ,UAAU,EAIzB,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,GAAG,GAAG,WAAW,IAAI,EAAE,CAAC;AACvD;","names":[]}
@@ -2,13 +2,20 @@ declare const PKG: "@timardex/cluemart-shared";
2
2
  /**
3
3
  * Basenames under the shared images directory — use with `getSharedImagePath` from `@timardex/cluemart-shared/images/node` (Express / Node).
4
4
  * This object is the single source of poster keys; `posters` is derived from it. Add a PNG under `src/images/posters/` when adding an entry.
5
- * Keep `POSTER_FILE_BY_ID` in `src/images/node.cjs` / `node.mjs` in sync when you change this map.
5
+ * `images/node` reads this at runtime for `getSharedImagePath` allow-listing.
6
6
  */
7
7
  declare const posterFiles: {
8
8
  readonly poster1: "poster1.png";
9
9
  readonly poster2: "poster2.png";
10
10
  readonly poster3: "poster3.png";
11
11
  };
12
+ /**
13
+ * Basenames for assets kept under `src/images/other/` in source; they are copied flat into `dist/images/` (same as posters).
14
+ * `images/node` reads this at runtime for `getSharedImagePath` allow-listing.
15
+ */
16
+ declare const otherFiles: {
17
+ readonly cluiTui: "cluiTui.png";
18
+ };
12
19
  /**
13
20
  * Module specifiers for each poster (not resolved file URLs). Use a static import or require with these paths
14
21
  * so your bundler resolves the file, e.g.
@@ -18,8 +25,16 @@ declare const posterFiles: {
18
25
  * Derived from `posterFiles` so keys and filenames stay aligned.
19
26
  */
20
27
  declare const posters: { readonly [K in keyof typeof posterFiles]: `${typeof PKG}/images/${(typeof posterFiles)[K]}`; };
28
+ /**
29
+ * Module specifiers for other images (same flat `@…/images/<file>.png` pattern as posters), e.g.
30
+ * `import clui from "@timardex/cluemart-shared/images/cluiTui.png"`.
31
+ */
32
+ declare const otherImages: { readonly [K in keyof typeof otherFiles]: `${typeof PKG}/images/${(typeof otherFiles)[K]}`; };
21
33
  type PosterAssetId = keyof typeof posters;
22
34
  /** A single filename under the shared images directory (values of `posterFiles`). */
23
35
  type PosterImageBasename = (typeof posterFiles)[PosterAssetId];
36
+ type OtherImageId = keyof typeof otherImages;
37
+ /** Basename under the shared images directory (values of `otherFiles`). */
38
+ type OtherImageBasename = (typeof otherFiles)[OtherImageId];
24
39
 
25
- export { type PosterAssetId, type PosterImageBasename, posterFiles, posters };
40
+ export { type OtherImageBasename, type OtherImageId, type PosterAssetId, type PosterImageBasename, otherFiles, otherImages, posterFiles, posters };
@@ -2,13 +2,20 @@ declare const PKG: "@timardex/cluemart-shared";
2
2
  /**
3
3
  * Basenames under the shared images directory — use with `getSharedImagePath` from `@timardex/cluemart-shared/images/node` (Express / Node).
4
4
  * This object is the single source of poster keys; `posters` is derived from it. Add a PNG under `src/images/posters/` when adding an entry.
5
- * Keep `POSTER_FILE_BY_ID` in `src/images/node.cjs` / `node.mjs` in sync when you change this map.
5
+ * `images/node` reads this at runtime for `getSharedImagePath` allow-listing.
6
6
  */
7
7
  declare const posterFiles: {
8
8
  readonly poster1: "poster1.png";
9
9
  readonly poster2: "poster2.png";
10
10
  readonly poster3: "poster3.png";
11
11
  };
12
+ /**
13
+ * Basenames for assets kept under `src/images/other/` in source; they are copied flat into `dist/images/` (same as posters).
14
+ * `images/node` reads this at runtime for `getSharedImagePath` allow-listing.
15
+ */
16
+ declare const otherFiles: {
17
+ readonly cluiTui: "cluiTui.png";
18
+ };
12
19
  /**
13
20
  * Module specifiers for each poster (not resolved file URLs). Use a static import or require with these paths
14
21
  * so your bundler resolves the file, e.g.
@@ -18,8 +25,16 @@ declare const posterFiles: {
18
25
  * Derived from `posterFiles` so keys and filenames stay aligned.
19
26
  */
20
27
  declare const posters: { readonly [K in keyof typeof posterFiles]: `${typeof PKG}/images/${(typeof posterFiles)[K]}`; };
28
+ /**
29
+ * Module specifiers for other images (same flat `@…/images/<file>.png` pattern as posters), e.g.
30
+ * `import clui from "@timardex/cluemart-shared/images/cluiTui.png"`.
31
+ */
32
+ declare const otherImages: { readonly [K in keyof typeof otherFiles]: `${typeof PKG}/images/${(typeof otherFiles)[K]}`; };
21
33
  type PosterAssetId = keyof typeof posters;
22
34
  /** A single filename under the shared images directory (values of `posterFiles`). */
23
35
  type PosterImageBasename = (typeof posterFiles)[PosterAssetId];
36
+ type OtherImageId = keyof typeof otherImages;
37
+ /** Basename under the shared images directory (values of `otherFiles`). */
38
+ type OtherImageBasename = (typeof otherFiles)[OtherImageId];
24
39
 
25
- export { type PosterAssetId, type PosterImageBasename, posterFiles, posters };
40
+ export { type OtherImageBasename, type OtherImageId, type PosterAssetId, type PosterImageBasename, otherFiles, otherImages, posterFiles, posters };
@@ -1,8 +1,12 @@
1
1
  import {
2
+ otherFiles,
3
+ otherImages,
2
4
  posterFiles,
3
5
  posters
4
- } from "../chunk-IBKLW65U.mjs";
6
+ } from "../chunk-4PJQMQVX.mjs";
5
7
  export {
8
+ otherFiles,
9
+ otherImages,
6
10
  posterFiles,
7
11
  posters
8
12
  };
@@ -1,25 +1,19 @@
1
1
  "use strict";
2
2
 
3
- const { createRequire } = require("node:module");
4
3
  const path = require("node:path");
5
4
 
6
- const { basename, dirname, resolve, sep } = path;
5
+ const { basename, resolve, sep } = path;
7
6
 
8
- const nodeRequire = createRequire(__filename);
9
- const PKG = "@timardex/cluemart-shared";
10
- const IMAGES_RESOLVE_ANCHOR = `${PKG}/images/poster1.png`;
7
+ const { otherFiles, posterFiles } = require("./index.cjs");
11
8
 
12
- /** Keep in sync with `posterFiles` in `src/images/index.ts`. */
13
- const POSTER_FILE_BY_ID = {
14
- poster1: "poster1.png",
15
- poster2: "poster2.png",
16
- poster3: "poster3.png",
17
- };
18
-
19
- const ALLOWED_BASENAMES = new Set(Object.values(POSTER_FILE_BY_ID));
9
+ const ALLOWED_BASENAMES = new Set([
10
+ ...Object.values(posterFiles),
11
+ ...Object.values(otherFiles),
12
+ ]);
20
13
 
14
+ /** Directory containing this module and the shipped PNGs (`dist/images/` in the published package). */
21
15
  function getSharedImagesDir() {
22
- return dirname(nodeRequire.resolve(IMAGES_RESOLVE_ANCHOR));
16
+ return __dirname;
23
17
  }
24
18
 
25
19
  /**
@@ -44,6 +38,20 @@ function assertSafeImageBasename(fileName) {
44
38
  return fileName;
45
39
  }
46
40
 
41
+ /**
42
+ * @param {string} ref
43
+ * @returns {string}
44
+ */
45
+ function resolveToBasename(ref) {
46
+ if (Object.hasOwn(posterFiles, ref)) {
47
+ return posterFiles[ref];
48
+ }
49
+ if (Object.hasOwn(otherFiles, ref)) {
50
+ return otherFiles[ref];
51
+ }
52
+ return assertSafeImageBasename(ref);
53
+ }
54
+
47
55
  /**
48
56
  * @param {string} rootDir
49
57
  * @param {string} baseName
@@ -62,13 +70,11 @@ function resolvedPathUnderRoot(rootDir, baseName) {
62
70
  }
63
71
 
64
72
  function getSharedImagePath(ref) {
65
- const segment = Object.hasOwn(POSTER_FILE_BY_ID, ref)
66
- ? POSTER_FILE_BY_ID[ref]
67
- : assertSafeImageBasename(ref);
68
- if (!ALLOWED_BASENAMES.has(segment)) {
69
- throw new TypeError(`unknown poster image: ${ref}`);
73
+ const baseName = resolveToBasename(ref);
74
+ if (!ALLOWED_BASENAMES.has(baseName)) {
75
+ throw new TypeError(`unknown shared image: ${ref}`);
70
76
  }
71
- return resolvedPathUnderRoot(getSharedImagesDir(), segment);
77
+ return resolvedPathUnderRoot(getSharedImagesDir(), baseName);
72
78
  }
73
79
 
74
80
  module.exports = { getSharedImagePath, getSharedImagesDir };
@@ -1,13 +1,25 @@
1
- import type { PosterAssetId, PosterImageBasename } from "./index.js";
1
+ import type {
2
+ OtherImageBasename,
3
+ OtherImageId,
4
+ PosterAssetId,
5
+ PosterImageBasename,
6
+ } from "./index.js";
2
7
 
3
- export type { PosterAssetId, PosterImageBasename } from "./index.js";
8
+ export type {
9
+ OtherImageBasename,
10
+ OtherImageId,
11
+ PosterAssetId,
12
+ PosterImageBasename,
13
+ } from "./index.js";
4
14
 
5
- /** Absolute path to the directory containing shipped PNGs (`poster1.png`, ). */
15
+ /** Absolute path to `dist/images/` (directory of the shipped `node` entry and PNGs). */
6
16
  export function getSharedImagesDir(): string;
7
17
 
8
18
  /**
9
- * Absolute path to one shipped poster image.
10
- * Pass a `PosterAssetId` (e.g. `poster1`) or the matching `PosterImageBasename` (e.g. `poster1.png`).
11
- * Unknown values, path segments, and `..` are rejected at runtime.
19
+ * Absolute path to one shipped image (poster or other asset).
20
+ * Pass an id (`poster1`, `cluiTui`) or the flat basename (`poster1.png`, `cluiTui.png`).
21
+ * Unknown values and path segments are rejected at runtime.
12
22
  */
13
- export function getSharedImagePath(fileName: PosterAssetId | PosterImageBasename): string;
23
+ export function getSharedImagePath(
24
+ ref: PosterAssetId | PosterImageBasename | OtherImageId | OtherImageBasename,
25
+ ): string;
@@ -1,22 +1,16 @@
1
- import { createRequire } from "node:module";
2
1
  import { basename, dirname, resolve, sep } from "node:path";
3
2
  import { fileURLToPath } from "node:url";
4
3
 
5
- const nodeRequire = createRequire(fileURLToPath(import.meta.url));
6
- const PKG = "@timardex/cluemart-shared";
7
- const IMAGES_RESOLVE_ANCHOR = `${PKG}/images/poster1.png`;
4
+ import { otherFiles, posterFiles } from "./index.mjs";
8
5
 
9
- /** Keep in sync with `posterFiles` in `src/images/index.ts`. */
10
- const POSTER_FILE_BY_ID = {
11
- poster1: "poster1.png",
12
- poster2: "poster2.png",
13
- poster3: "poster3.png",
14
- };
15
-
16
- const ALLOWED_BASENAMES = new Set(Object.values(POSTER_FILE_BY_ID));
6
+ const ALLOWED_BASENAMES = new Set([
7
+ ...Object.values(posterFiles),
8
+ ...Object.values(otherFiles),
9
+ ]);
17
10
 
11
+ /** Directory containing this module and the shipped PNGs (`dist/images/` in the published package). */
18
12
  export function getSharedImagesDir() {
19
- return dirname(nodeRequire.resolve(IMAGES_RESOLVE_ANCHOR));
13
+ return dirname(fileURLToPath(import.meta.url));
20
14
  }
21
15
 
22
16
  function assertSafeImageBasename(fileName) {
@@ -37,6 +31,16 @@ function assertSafeImageBasename(fileName) {
37
31
  return fileName;
38
32
  }
39
33
 
34
+ function resolveToBasename(ref) {
35
+ if (Object.hasOwn(posterFiles, ref)) {
36
+ return posterFiles[ref];
37
+ }
38
+ if (Object.hasOwn(otherFiles, ref)) {
39
+ return otherFiles[ref];
40
+ }
41
+ return assertSafeImageBasename(ref);
42
+ }
43
+
40
44
  function resolvedPathUnderRoot(rootDir, baseName) {
41
45
  const rootResolved = resolve(rootDir);
42
46
  const resolved = resolve(rootResolved, baseName);
@@ -50,11 +54,9 @@ function resolvedPathUnderRoot(rootDir, baseName) {
50
54
  }
51
55
 
52
56
  export function getSharedImagePath(ref) {
53
- const segment = Object.hasOwn(POSTER_FILE_BY_ID, ref)
54
- ? POSTER_FILE_BY_ID[ref]
55
- : assertSafeImageBasename(ref);
56
- if (!ALLOWED_BASENAMES.has(segment)) {
57
- throw new TypeError(`unknown poster image: ${ref}`);
57
+ const baseName = resolveToBasename(ref);
58
+ if (!ALLOWED_BASENAMES.has(baseName)) {
59
+ throw new TypeError(`unknown shared image: ${ref}`);
58
60
  }
59
- return resolvedPathUnderRoot(getSharedImagesDir(), segment);
61
+ return resolvedPathUnderRoot(getSharedImagesDir(), baseName);
60
62
  }
package/dist/index.cjs CHANGED
@@ -111,6 +111,8 @@ __export(index_exports, {
111
111
  mapBaseResourceTypeToFormData: () => mapBaseResourceTypeToFormData,
112
112
  normalizeUrl: () => normalizeUrl,
113
113
  nzStartOfDay: () => nzStartOfDay,
114
+ otherFiles: () => otherFiles,
115
+ otherImages: () => otherImages,
114
116
  packagingOptions: () => packagingOptions,
115
117
  partnerBasicInfoFields: () => partnerBasicInfoFields,
116
118
  paymentMethodOptions: () => paymentMethodOptions,
@@ -8488,9 +8490,15 @@ var posterFiles = {
8488
8490
  poster2: "poster2.png",
8489
8491
  poster3: "poster3.png"
8490
8492
  };
8493
+ var otherFiles = {
8494
+ cluiTui: "cluiTui.png"
8495
+ };
8491
8496
  var posters = Object.fromEntries(
8492
8497
  Object.entries(posterFiles).map(([key, file]) => [key, `${PKG}/images/${file}`])
8493
8498
  );
8499
+ var otherImages = Object.fromEntries(
8500
+ Object.entries(otherFiles).map(([key, file]) => [key, `${PKG}/images/${file}`])
8501
+ );
8494
8502
 
8495
8503
  // src/storage/index.ts
8496
8504
  var SAVED_PASSWORD_KEY = "savedPassword";
@@ -8636,6 +8644,8 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
8636
8644
  mapBaseResourceTypeToFormData,
8637
8645
  normalizeUrl,
8638
8646
  nzStartOfDay,
8647
+ otherFiles,
8648
+ otherImages,
8639
8649
  packagingOptions,
8640
8650
  partnerBasicInfoFields,
8641
8651
  paymentMethodOptions,