@timardex/cluemart-shared 1.5.528 → 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.
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/images/index.ts
21
+ var images_exports = {};
22
+ __export(images_exports, {
23
+ otherFiles: () => otherFiles,
24
+ otherImages: () => otherImages,
25
+ posterFiles: () => posterFiles,
26
+ posters: () => posters
27
+ });
28
+ module.exports = __toCommonJS(images_exports);
29
+ var PKG = "@timardex/cluemart-shared";
30
+ var posterFiles = {
31
+ poster1: "poster1.png",
32
+ poster2: "poster2.png",
33
+ poster3: "poster3.png"
34
+ };
35
+ var otherFiles = {
36
+ cluiTui: "cluiTui.png"
37
+ };
38
+ var posters = Object.fromEntries(
39
+ Object.entries(posterFiles).map(([key, file]) => [key, `${PKG}/images/${file}`])
40
+ );
41
+ var otherImages = Object.fromEntries(
42
+ Object.entries(otherFiles).map(([key, file]) => [key, `${PKG}/images/${file}`])
43
+ );
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ otherFiles,
47
+ otherImages,
48
+ posterFiles,
49
+ posters
50
+ });
51
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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 * `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":[]}
@@ -0,0 +1,40 @@
1
+ declare const PKG: "@timardex/cluemart-shared";
2
+ /**
3
+ * Basenames under the shared images directory — use with `getSharedImagePath` from `@timardex/cluemart-shared/images/node` (Express / Node).
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
+ * `images/node` reads this at runtime for `getSharedImagePath` allow-listing.
6
+ */
7
+ declare const posterFiles: {
8
+ readonly poster1: "poster1.png";
9
+ readonly poster2: "poster2.png";
10
+ readonly poster3: "poster3.png";
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
+ };
19
+ /**
20
+ * Module specifiers for each poster (not resolved file URLs). Use a static import or require with these paths
21
+ * so your bundler resolves the file, e.g.
22
+ * `import poster1 from "@timardex/cluemart-shared/images/poster1.png"`
23
+ * or `require("@timardex/cluemart-shared/images/poster1.png")` (React Native / Metro).
24
+ *
25
+ * Derived from `posterFiles` so keys and filenames stay aligned.
26
+ */
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]}`; };
33
+ type PosterAssetId = keyof typeof posters;
34
+ /** A single filename under the shared images directory (values of `posterFiles`). */
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];
39
+
40
+ export { type OtherImageBasename, type OtherImageId, type PosterAssetId, type PosterImageBasename, otherFiles, otherImages, posterFiles, posters };
@@ -0,0 +1,40 @@
1
+ declare const PKG: "@timardex/cluemart-shared";
2
+ /**
3
+ * Basenames under the shared images directory — use with `getSharedImagePath` from `@timardex/cluemart-shared/images/node` (Express / Node).
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
+ * `images/node` reads this at runtime for `getSharedImagePath` allow-listing.
6
+ */
7
+ declare const posterFiles: {
8
+ readonly poster1: "poster1.png";
9
+ readonly poster2: "poster2.png";
10
+ readonly poster3: "poster3.png";
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
+ };
19
+ /**
20
+ * Module specifiers for each poster (not resolved file URLs). Use a static import or require with these paths
21
+ * so your bundler resolves the file, e.g.
22
+ * `import poster1 from "@timardex/cluemart-shared/images/poster1.png"`
23
+ * or `require("@timardex/cluemart-shared/images/poster1.png")` (React Native / Metro).
24
+ *
25
+ * Derived from `posterFiles` so keys and filenames stay aligned.
26
+ */
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]}`; };
33
+ type PosterAssetId = keyof typeof posters;
34
+ /** A single filename under the shared images directory (values of `posterFiles`). */
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];
39
+
40
+ export { type OtherImageBasename, type OtherImageId, type PosterAssetId, type PosterImageBasename, otherFiles, otherImages, posterFiles, posters };
@@ -0,0 +1,13 @@
1
+ import {
2
+ otherFiles,
3
+ otherImages,
4
+ posterFiles,
5
+ posters
6
+ } from "../chunk-4PJQMQVX.mjs";
7
+ export {
8
+ otherFiles,
9
+ otherImages,
10
+ posterFiles,
11
+ posters
12
+ };
13
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ const path = require("node:path");
4
+
5
+ const { basename, resolve, sep } = path;
6
+
7
+ const { otherFiles, posterFiles } = require("./index.cjs");
8
+
9
+ const ALLOWED_BASENAMES = new Set([
10
+ ...Object.values(posterFiles),
11
+ ...Object.values(otherFiles),
12
+ ]);
13
+
14
+ /** Directory containing this module and the shipped PNGs (`dist/images/` in the published package). */
15
+ function getSharedImagesDir() {
16
+ return __dirname;
17
+ }
18
+
19
+ /**
20
+ * @param {string} fileName
21
+ * @returns {string}
22
+ */
23
+ function assertSafeImageBasename(fileName) {
24
+ if (typeof fileName !== "string" || fileName.length === 0) {
25
+ throw new TypeError("fileName must be a non-empty string");
26
+ }
27
+ if (fileName !== basename(fileName)) {
28
+ throw new TypeError(
29
+ "fileName must be a basename (no path separators or .. segments)",
30
+ );
31
+ }
32
+ if (fileName === "." || fileName === "..") {
33
+ throw new TypeError("invalid fileName");
34
+ }
35
+ if (fileName.includes("\0")) {
36
+ throw new TypeError("invalid fileName");
37
+ }
38
+ return fileName;
39
+ }
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
+
55
+ /**
56
+ * @param {string} rootDir
57
+ * @param {string} baseName
58
+ * @returns {string}
59
+ */
60
+ function resolvedPathUnderRoot(rootDir, baseName) {
61
+ const rootResolved = resolve(rootDir);
62
+ const resolved = resolve(rootResolved, baseName);
63
+ const prefix = rootResolved.endsWith(sep) ? rootResolved : rootResolved + sep;
64
+ if (resolved !== rootResolved && !resolved.startsWith(prefix)) {
65
+ throw new TypeError(
66
+ "resolved path must stay under the shared images directory",
67
+ );
68
+ }
69
+ return resolved;
70
+ }
71
+
72
+ function getSharedImagePath(ref) {
73
+ const baseName = resolveToBasename(ref);
74
+ if (!ALLOWED_BASENAMES.has(baseName)) {
75
+ throw new TypeError(`unknown shared image: ${ref}`);
76
+ }
77
+ return resolvedPathUnderRoot(getSharedImagesDir(), baseName);
78
+ }
79
+
80
+ module.exports = { getSharedImagePath, getSharedImagesDir };
@@ -0,0 +1,25 @@
1
+ import type {
2
+ OtherImageBasename,
3
+ OtherImageId,
4
+ PosterAssetId,
5
+ PosterImageBasename,
6
+ } from "./index.js";
7
+
8
+ export type {
9
+ OtherImageBasename,
10
+ OtherImageId,
11
+ PosterAssetId,
12
+ PosterImageBasename,
13
+ } from "./index.js";
14
+
15
+ /** Absolute path to `dist/images/` (directory of the shipped `node` entry and PNGs). */
16
+ export function getSharedImagesDir(): string;
17
+
18
+ /**
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.
22
+ */
23
+ export function getSharedImagePath(
24
+ ref: PosterAssetId | PosterImageBasename | OtherImageId | OtherImageBasename,
25
+ ): string;
@@ -0,0 +1,62 @@
1
+ import { basename, dirname, resolve, sep } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+
4
+ import { otherFiles, posterFiles } from "./index.mjs";
5
+
6
+ const ALLOWED_BASENAMES = new Set([
7
+ ...Object.values(posterFiles),
8
+ ...Object.values(otherFiles),
9
+ ]);
10
+
11
+ /** Directory containing this module and the shipped PNGs (`dist/images/` in the published package). */
12
+ export function getSharedImagesDir() {
13
+ return dirname(fileURLToPath(import.meta.url));
14
+ }
15
+
16
+ function assertSafeImageBasename(fileName) {
17
+ if (typeof fileName !== "string" || fileName.length === 0) {
18
+ throw new TypeError("fileName must be a non-empty string");
19
+ }
20
+ if (fileName !== basename(fileName)) {
21
+ throw new TypeError(
22
+ "fileName must be a basename (no path separators or .. segments)",
23
+ );
24
+ }
25
+ if (fileName === "." || fileName === "..") {
26
+ throw new TypeError("invalid fileName");
27
+ }
28
+ if (fileName.includes("\0")) {
29
+ throw new TypeError("invalid fileName");
30
+ }
31
+ return fileName;
32
+ }
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
+
44
+ function resolvedPathUnderRoot(rootDir, baseName) {
45
+ const rootResolved = resolve(rootDir);
46
+ const resolved = resolve(rootResolved, baseName);
47
+ const prefix = rootResolved.endsWith(sep) ? rootResolved : rootResolved + sep;
48
+ if (resolved !== rootResolved && !resolved.startsWith(prefix)) {
49
+ throw new TypeError(
50
+ "resolved path must stay under the shared images directory",
51
+ );
52
+ }
53
+ return resolved;
54
+ }
55
+
56
+ export function getSharedImagePath(ref) {
57
+ const baseName = resolveToBasename(ref);
58
+ if (!ALLOWED_BASENAMES.has(baseName)) {
59
+ throw new TypeError(`unknown shared image: ${ref}`);
60
+ }
61
+ return resolvedPathUnderRoot(getSharedImagesDir(), baseName);
62
+ }
Binary file
@@ -0,0 +1,2 @@
1
+ declare const src: string | number;
2
+ export default src;
Binary file
@@ -0,0 +1,2 @@
1
+ declare const src: string | number;
2
+ export default src;
Binary file
@@ -0,0 +1,2 @@
1
+ declare const src: string | number;
2
+ export default src;
package/dist/index.cjs CHANGED
@@ -111,9 +111,13 @@ __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,
119
+ posterFiles: () => posterFiles,
120
+ posters: () => posters,
117
121
  priceUnits: () => priceUnits,
118
122
  producedIngOptions: () => producedIngOptions,
119
123
  productLabelGroups: () => productLabelGroups,
@@ -8479,6 +8483,23 @@ function useSchoolForm(data) {
8479
8483
  };
8480
8484
  }
8481
8485
 
8486
+ // src/images/index.ts
8487
+ var PKG = "@timardex/cluemart-shared";
8488
+ var posterFiles = {
8489
+ poster1: "poster1.png",
8490
+ poster2: "poster2.png",
8491
+ poster3: "poster3.png"
8492
+ };
8493
+ var otherFiles = {
8494
+ cluiTui: "cluiTui.png"
8495
+ };
8496
+ var posters = Object.fromEntries(
8497
+ Object.entries(posterFiles).map(([key, file]) => [key, `${PKG}/images/${file}`])
8498
+ );
8499
+ var otherImages = Object.fromEntries(
8500
+ Object.entries(otherFiles).map(([key, file]) => [key, `${PKG}/images/${file}`])
8501
+ );
8502
+
8482
8503
  // src/storage/index.ts
8483
8504
  var SAVED_PASSWORD_KEY = "savedPassword";
8484
8505
  var SAVED_EMAIL_KEY = "savedEmail";
@@ -8623,9 +8644,13 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
8623
8644
  mapBaseResourceTypeToFormData,
8624
8645
  normalizeUrl,
8625
8646
  nzStartOfDay,
8647
+ otherFiles,
8648
+ otherImages,
8626
8649
  packagingOptions,
8627
8650
  partnerBasicInfoFields,
8628
8651
  paymentMethodOptions,
8652
+ posterFiles,
8653
+ posters,
8629
8654
  priceUnits,
8630
8655
  producedIngOptions,
8631
8656
  productLabelGroups,