@feedmepos/mf-common 1.29.32 → 1.29.35

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,6 +1,4 @@
1
- import { type CountryCode } from "libphonenumber-js";
2
- export declare const DEFAULT_COUNTRY_CODE = "MY";
3
- export declare function getCountryByPhoneNumber(phoneNumber: string): CountryCode;
1
+ export { DEFAULT_COUNTRY_CODE, getCountryByPhoneNumber, toSupportedCountry } from "./supportedCountry";
4
2
  export declare function useCountry(): {
5
3
  countryOptions: import("vue").ComputedRef<{
6
4
  code: string;
@@ -1 +1 @@
1
- {"version":3,"file":"country.d.ts","sourceRoot":"","sources":["../../../src/utils/country.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAK7F,eAAO,MAAM,oBAAoB,OAAO,CAAA;AAExC,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,eAU1D;AAED,wBAAgB,UAAU;;;;;;EAwBzB"}
1
+ {"version":3,"file":"country.d.ts","sourceRoot":"","sources":["../../../src/utils/country.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAE3B,wBAAgB,UAAU;;;;;;EAwBzB"}
@@ -0,0 +1,12 @@
1
+ import { type CountryCode } from "libphonenumber-js";
2
+ import { F_COUNTRY } from "@feedmepos/core/entity";
3
+ export declare const DEFAULT_COUNTRY_CODE = "MY";
4
+ /**
5
+ * Normalize a country code against the list of countries where the portal
6
+ * service is deployed (the `enabledCountries` from the `portal_supported_country`
7
+ * flag). Countries without a deployed backend (e.g. CN) fall back to the default
8
+ * country (MY) so requests never target a missing backend region.
9
+ */
10
+ export declare function toSupportedCountry(country: string | null | undefined, supportedCountries: readonly F_COUNTRY[]): F_COUNTRY;
11
+ export declare function getCountryByPhoneNumber(phoneNumber: string): CountryCode;
12
+ //# sourceMappingURL=supportedCountry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supportedCountry.d.ts","sourceRoot":"","sources":["../../../src/utils/supportedCountry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEtE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD,eAAO,MAAM,oBAAoB,OAAO,CAAA;AAExC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,kBAAkB,EAAE,SAAS,SAAS,EAAE,GACvC,SAAS,CAMX;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,eAU1D"}
@@ -39,10 +39,11 @@ export interface FmmfPresentOptions {
39
39
  * Map of package names to custom CDN URLs to override default jsdelivr CDN.
40
40
  *
41
41
  * Useful for testing local builds or using different CDN sources. Keys must start with
42
- * '@feedmepos/mf-' or be '@feedmepos/ui-library'. This only affects your local build.
42
+ * '@feedmepos/mf-' or be one of the UI library packages ('@feedmepos/ui-library',
43
+ * '@feedmepos/ui-library-v2'). This only affects your local build.
43
44
  *
44
45
  * @example { '@feedmepos/mf-menu': 'http://localhost:5173/dist/app.js' }
45
- * @throws Error if keys don't start with '@feedmepos/mf-' or '@feedmepos/ui-library'
46
+ * @throws Error if keys don't start with '@feedmepos/mf-' and are not a UI library package
46
47
  */
47
48
  replaceFmmfPackages?: Record<string, string>;
48
49
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"vite-preset.d.ts","sourceRoot":"","sources":["../vite-preset.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAwB,UAAU,EAAE,MAAM,MAAM,CAAA;AAKvE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;OAQG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAE9B;;;;;;;OAOG;I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;GAWG;AACH,eAAO,MAAM,eAAe,WAClB,UAAU,qBACC,SAAS,YACnB,kBAAkB,KAC1B,QAAQ,UAAU,CA+NpB,CAAA"}
@@ -1,12 +1,12 @@
1
- import { readFileSync as y } from "fs";
2
- import { resolve as v } from "path";
3
- const z = (l) => {
1
+ import { readFileSync as O } from "fs";
2
+ import { resolve as y } from "path";
3
+ const D = (l) => {
4
4
  const p = l.join("|");
5
5
  return new RegExp(`^(${p})(\\/.*)?$`);
6
- }, O = ({
6
+ }, k = ({
7
7
  externals: l
8
8
  }) => {
9
- const p = z(l);
9
+ const p = D(l);
10
10
  return {
11
11
  name: "externalize",
12
12
  setup(e) {
@@ -18,7 +18,7 @@ const z = (l) => {
18
18
  }));
19
19
  }
20
20
  };
21
- }, D = (l) => {
21
+ }, E = (l) => {
22
22
  const p = "/@id/", e = new RegExp(
23
23
  `${p}(${l.join("|")})`,
24
24
  "g"
@@ -27,10 +27,10 @@ const z = (l) => {
27
27
  name: "vite-plugin-remove-prefix",
28
28
  transform: (t) => e.test(t) ? t.replace(
29
29
  e,
30
- (n, c) => c
30
+ (n, o) => o
31
31
  ) : t
32
32
  };
33
- }, k = (l) => {
33
+ }, P = (l) => {
34
34
  const { externals: p } = l;
35
35
  return {
36
36
  name: "vite-plugin-externalize",
@@ -40,18 +40,18 @@ const z = (l) => {
40
40
  var t;
41
41
  const n = { ...e };
42
42
  return n.optimizeDeps && n.optimizeDeps.esbuildOptions && ((t = n.optimizeDeps.esbuildOptions).plugins ?? (t.plugins = []), n.optimizeDeps.esbuildOptions.plugins.push(
43
- O({ externals: p })
43
+ k({ externals: p })
44
44
  )), n;
45
45
  },
46
46
  configResolved: (e) => {
47
47
  if (e.optimizeDeps && e.optimizeDeps.include) {
48
48
  const n = e.optimizeDeps.include.filter(
49
- (c) => !p.includes(c)
49
+ (o) => !p.includes(o)
50
50
  );
51
51
  e.optimizeDeps.include = n;
52
52
  }
53
53
  e.optimizeDeps && (e.optimizeDeps.exclude = e.optimizeDeps.exclude || [], e.optimizeDeps.exclude.push(...p));
54
- const t = D(p);
54
+ const t = E(p);
55
55
  e.plugins.push(t);
56
56
  },
57
57
  // Supresses the following warning:
@@ -62,18 +62,23 @@ const z = (l) => {
62
62
  // [dependency] (imported by [sourceFile])
63
63
  load: (e) => p.includes(e) ? "export default {};" : null
64
64
  };
65
- }, E = "@feedmepos/mf-", F = async (l, { command: p, mode: e }, t = {}) => {
66
- var f, j, x, h, b;
65
+ }, u = "@feedmepos/mf-", g = [
66
+ "@feedmepos/ui-library",
67
+ "@feedmepos/ui-library-v2"
68
+ ], F = async (l, { command: p, mode: e }, t = {}) => {
69
+ var j, b, v, h, x;
67
70
  const n = JSON.parse(
68
- y(v(process.cwd(), "package.json"), "utf-8")
69
- ), c = Object.keys(n.dependencies).filter((s) => s.startsWith(E)).reduce((s, i) => (s[i] = n.dependencies[i], s), {});
70
- (f = t.includeFmmfPackages) == null || f.forEach((s) => {
71
- c[s] = n.dependencies[s] ?? "latest";
72
- }), (j = t.excludeFmmfPackages) == null || j.forEach((s) => {
73
- delete c[s];
71
+ O(y(process.cwd(), "package.json"), "utf-8")
72
+ ), o = Object.keys(n.dependencies).filter((s) => s.startsWith(u)).reduce((s, i) => (s[i] = n.dependencies[i], s), {});
73
+ (j = t.includeFmmfPackages) == null || j.forEach((s) => {
74
+ o[s] = n.dependencies[s] ?? "latest";
75
+ }), (b = t.excludeFmmfPackages) == null || b.forEach((s) => {
76
+ delete o[s];
74
77
  });
75
- const m = {
78
+ const a = {
76
79
  "@feedmepos/ui-library": "https://cdn.jsdelivr.net/npm/@feedmepos/ui-library@latest/dist/feedmepos-ui-library.js",
80
+ // v2 is a prerelease: `latest` does not track it, the `alpha` dist-tag does.
81
+ "@feedmepos/ui-library-v2": "https://cdn.jsdelivr.net/npm/@feedmepos/ui-library-v2@alpha/dist/feedmepos-ui-library-v2.js",
77
82
  // Conditionally externalize core packages to share business logic
78
83
  ...t.externalizeCore ? {
79
84
  "@feedmepos/core": "https://cdn.jsdelivr.net/npm/@feedmepos/core@latest/es/index.js",
@@ -81,65 +86,69 @@ const z = (l) => {
81
86
  "@feedmepos/core/entity": "https://cdn.jsdelivr.net/npm/@feedmepos/core@latest/es/entity.js",
82
87
  "@feedmepos/core/modules": "https://cdn.jsdelivr.net/npm/@feedmepos/core@latest/es/modules.js"
83
88
  } : {}
84
- }, o = {
89
+ }, c = {
85
90
  "@vue/devtools-api": "6.5.0/lib/esm/index.js",
86
91
  vue: "3.5.16/dist/vue.esm-browser.prod.min.js",
87
92
  "vue-router": "4.2.5/dist/vue-router.esm-browser.min.js",
88
93
  pinia: "2.1.7/+esm"
89
94
  };
90
- let a = [
91
- ...Object.keys(o),
95
+ let m = [
92
96
  ...Object.keys(c),
93
- ...Object.keys(m)
97
+ ...Object.keys(o),
98
+ ...Object.keys(a)
94
99
  ];
95
100
  const r = { ...l };
96
- if (p == "build" && e.startsWith("fmmf") && (a = [
97
- ...Object.keys(c),
101
+ if (p == "build" && e.startsWith("fmmf") && (m = [
98
102
  ...Object.keys(o),
99
- ...Object.keys(m)
103
+ ...Object.keys(c),
104
+ ...Object.keys(a)
100
105
  ], r.build = {
101
106
  emptyOutDir: !0,
102
107
  lib: {
103
108
  entry: {
104
- app: v(process.cwd(), "src/app.ts")
109
+ app: y(process.cwd(), "src/app.ts")
105
110
  // Entry must export routers, FmApp, etc.
106
111
  },
107
112
  formats: ["es"]
108
113
  // ES module format for native browser import
109
114
  }
110
115
  }), r.plugins ?? (r.plugins = []), t.externalize) {
111
- const s = t.externalize === !0 ? a : t.externalize;
112
- r.plugins.push(k({ externals: s }));
116
+ const s = t.externalize === !0 ? m : t.externalize;
117
+ r.plugins.push(P({ externals: s }));
113
118
  }
114
- r.optimizeDeps ?? (r.optimizeDeps = {}), (x = r.optimizeDeps).esbuildOptions ?? (x.esbuildOptions = {}), (h = r.optimizeDeps.esbuildOptions).keepNames ?? (h.keepNames = !0), r.build ?? (r.build = {}), (b = r.build).rollupOptions ?? (b.rollupOptions = {}), r.build.rollupOptions.external = a.concat(
119
+ r.optimizeDeps ?? (r.optimizeDeps = {}), (v = r.optimizeDeps).esbuildOptions ?? (v.esbuildOptions = {}), (h = r.optimizeDeps.esbuildOptions).keepNames ?? (h.keepNames = !0), r.build ?? (r.build = {}), (x = r.build).rollupOptions ?? (x.rollupOptions = {}), r.build.rollupOptions.external = m.concat(
115
120
  ...r.build.rollupOptions.external ?? []
116
121
  );
117
- const d = c;
122
+ const d = o;
118
123
  await Promise.all(
119
124
  Object.keys(d).map(async (s) => {
120
125
  const i = "latest";
121
126
  return d[s] = `https://cdn.jsdelivr.net/npm/${s}@${i}/dist/app.js`;
122
127
  })
123
128
  );
124
- const u = {
129
+ const f = {
125
130
  imports: {
126
131
  // Microfrontend applications
127
132
  ...d,
128
133
  // Common dependencies (Vue ecosystem)
129
- ...Object.keys(o).reduce((s, i) => (s[i] = `https://cdn.jsdelivr.net/npm/${i}@${o[i]}`, s), {}),
134
+ ...Object.keys(c).reduce((s, i) => (s[i] = `https://cdn.jsdelivr.net/npm/${i}@${c[i]}`, s), {}),
130
135
  // Specific external packages (UI library, core packages)
131
- ...m
136
+ ...a
132
137
  },
133
138
  // Scopes allow different module resolution in specific contexts
134
139
  scopes: t.importMapScopes ?? {}
135
140
  };
136
141
  t.replaceFmmfPackages && Object.entries(t.replaceFmmfPackages).forEach(([s, i]) => {
137
- if (s.startsWith("@feedmepos/mf-") || s === "@feedmepos/ui-library")
138
- u.imports[s] = i;
142
+ if (s.startsWith(u) || g.includes(
143
+ s
144
+ ))
145
+ f.imports[s] = i;
139
146
  else
140
- throw new Error(`Invalid replaceFmmfPackages key: ${s}, must start with @feedmepos/mf-`);
147
+ throw new Error(
148
+ `Invalid replaceFmmfPackages key: ${s}, must start with ${u} or be one of ${g.join(", ")}`
149
+ );
141
150
  });
142
- const g = {
151
+ const z = {
143
152
  name: "vite-plugin-feedme-microfrontend",
144
153
  enforce: "pre",
145
154
  // Run before other plugins
@@ -159,7 +168,7 @@ const z = (l) => {
159
168
  type: "importmap"
160
169
  // Special script type for ES module imports
161
170
  },
162
- children: JSON.stringify(u, null, 2),
171
+ children: JSON.stringify(f, null, 2),
163
172
  injectTo: "head-prepend"
164
173
  // Add at the beginning of <head>
165
174
  },
@@ -177,7 +186,7 @@ const z = (l) => {
177
186
  }
178
187
  }
179
188
  };
180
- return r.plugins.push(g), r;
189
+ return r.plugins.push(z), r;
181
190
  };
182
191
  export {
183
192
  F as fmmfVitePresent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedmepos/mf-common",
3
- "version": "1.29.32",
3
+ "version": "1.29.35",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"