@feedmepos/mf-common 1.18.0-beta.1 → 1.18.0-beta.3

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,12 +4,12 @@
4
4
  export declare const FM_POST_MESSAGE_REQUEST = "fm-post-message-request";
5
5
  export declare const FM_POST_MESSAGE_RESPONSE = "fm-post-message-response";
6
6
  export type PostMessageMethodCallParams = {
7
- window: Window;
7
+ targetWindow: Window;
8
8
  methodName: string;
9
9
  params?: Object[];
10
10
  timeout?: number;
11
11
  };
12
- export declare function callMethodOnWindow({ window, methodName, params, timeout }: PostMessageMethodCallParams): Promise<any>;
12
+ export declare function callMethodOnWindow({ targetWindow, methodName, params, timeout }: PostMessageMethodCallParams): Promise<any>;
13
13
  export declare function registerPostMessageMethod(methodName: string, method: (...args: any[]) => Promise<any>): void;
14
14
  export declare function installPostMessageMethodCall(): void;
15
15
  export declare function uninstallPostMessageMethodCall(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"postMessageMethodCall.d.ts","sourceRoot":"","sources":["../../../src/utils/postMessageMethodCall.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,uBAAuB,4BAA4B,CAAA;AAChE,eAAO,MAAM,wBAAwB,6BAA6B,CAAA;AAElE,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,UAAU,EACV,MAAW,EACX,OAAO,EACR,EAAE,2BAA2B,GAAG,OAAO,CAAC,GAAG,CAAC,CAmC5C;AA4BD,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,QAGzC;AAGD,wBAAgB,4BAA4B,SAM3C;AAED,wBAAgB,8BAA8B,SAG7C"}
1
+ {"version":3,"file":"postMessageMethodCall.d.ts","sourceRoot":"","sources":["../../../src/utils/postMessageMethodCall.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,uBAAuB,4BAA4B,CAAA;AAChE,eAAO,MAAM,wBAAwB,6BAA6B,CAAA;AAElE,MAAM,MAAM,2BAA2B,GAAG;IACxC,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,wBAAgB,kBAAkB,CAAC,EACjC,YAAY,EACZ,UAAU,EACV,MAAW,EACX,OAAO,EACR,EAAE,2BAA2B,GAAG,OAAO,CAAC,GAAG,CAAC,CAmC5C;AA4BD,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,QAGzC;AAGD,wBAAgB,4BAA4B,SAM3C;AAED,wBAAgB,8BAA8B,SAG7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"vite-preset.d.ts","sourceRoot":"","sources":["../vite-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAwB,UAAU,EAAE,MAAM,MAAM,CAAA;AAMvE,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC9B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,OAAO,CAAA;IAIf,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAChC,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,eAAO,MAAM,eAAe,WAClB,UAAU,qBACC,SAAS,YACnB,kBAAkB,KAC1B,QAAQ,UAAU,CA0JpB,CAAA"}
1
+ {"version":3,"file":"vite-preset.d.ts","sourceRoot":"","sources":["../vite-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAwB,UAAU,EAAE,MAAM,MAAM,CAAA;AAMvE,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC9B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,OAAO,CAAA;IAIf,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAChC,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,eAAO,MAAM,eAAe,WAClB,UAAU,qBACC,SAAS,YACnB,kBAAkB,KAC1B,QAAQ,UAAU,CAkJpB,CAAA"}
@@ -1,16 +1,170 @@
1
- import "path";
2
- import "fs";
3
- import { f as b } from "./vite-preset-62104d2c.js";
4
- import "node:http";
5
- import "node:https";
6
- import "node:zlib";
7
- import "node:stream";
8
- import "node:buffer";
9
- import "node:util";
10
- import "node:url";
11
- import "node:net";
12
- import "node:fs";
13
- import "node:path";
1
+ import { resolve as h } from "path";
2
+ import { readFileSync as b } from "fs";
3
+ const g = (l) => {
4
+ const r = l.join("|");
5
+ return new RegExp(`^(${r})(\\/.*)?$`);
6
+ }, y = ({
7
+ externals: l
8
+ }) => {
9
+ const r = g(l);
10
+ return {
11
+ name: "externalize",
12
+ setup(e) {
13
+ e.onResolve({ filter: r }, (t) => ({
14
+ path: t.path,
15
+ namespace: "externalize"
16
+ })), e.onLoad({ filter: r }, () => ({
17
+ contents: ""
18
+ }));
19
+ }
20
+ };
21
+ }, z = (l) => {
22
+ const r = "/@id/", e = new RegExp(
23
+ `${r}(${l.join("|")})`,
24
+ "g"
25
+ );
26
+ return {
27
+ name: "vite-plugin-remove-prefix",
28
+ transform: (t) => e.test(t) ? t.replace(
29
+ e,
30
+ (p, c) => c
31
+ ) : t
32
+ };
33
+ }, O = (l) => {
34
+ const { externals: r } = l;
35
+ return {
36
+ name: "vite-plugin-externalize",
37
+ enforce: "pre",
38
+ apply: "serve",
39
+ config: (e) => {
40
+ var t;
41
+ const p = { ...e };
42
+ return p.optimizeDeps && p.optimizeDeps.esbuildOptions && ((t = p.optimizeDeps.esbuildOptions).plugins ?? (t.plugins = []), p.optimizeDeps.esbuildOptions.plugins.push(
43
+ y({ externals: r })
44
+ )), p;
45
+ },
46
+ configResolved: (e) => {
47
+ if (e.optimizeDeps && e.optimizeDeps.include) {
48
+ const p = e.optimizeDeps.include.filter(
49
+ (c) => !r.includes(c)
50
+ );
51
+ e.optimizeDeps.include = p;
52
+ }
53
+ e.optimizeDeps && (e.optimizeDeps.exclude = e.optimizeDeps.exclude || [], e.optimizeDeps.exclude.push(...r));
54
+ const t = z(r);
55
+ e.plugins.push(t);
56
+ },
57
+ // Supresses the following warning:
58
+ // Failed to resolve import [dependency] from [sourceFile]. Does the file exist?
59
+ resolveId: (e) => r.includes(e) ? { id: e, external: !0 } : null,
60
+ // Supresses the following warning:
61
+ // The following dependencies are imported but could not be resolved:
62
+ // [dependency] (imported by [sourceFile])
63
+ load: (e) => r.includes(e) ? "export default {};" : null
64
+ };
65
+ }, k = "@feedmepos/mf-", P = async (l, { command: r, mode: e }, t = {}) => {
66
+ var f, j, x;
67
+ const p = JSON.parse(
68
+ b(h(process.cwd(), "package.json"), "utf-8")
69
+ ), c = Object.keys(p.dependencies).filter((s) => s.startsWith(k)).reduce((s, i) => (s[i] = p.dependencies[i], s), {});
70
+ (f = t.includeFmmfPackages) == null || f.forEach((s) => {
71
+ c[s] = p.dependencies[s] ?? "latest";
72
+ }), (j = t.excludeFmmfPackages) == null || j.forEach((s) => {
73
+ delete c[s];
74
+ });
75
+ const a = {
76
+ "@feedmepos/ui-library": "https://cdn.jsdelivr.net/npm/@feedmepos/ui-library@latest/dist/feedmepos-ui-library.js",
77
+ ...t.externalizeCore ? {
78
+ "@feedmepos/core": "https://cdn.jsdelivr.net/npm/@feedmepos/core@latest/es/index.js",
79
+ "@feedmepos/core/fn": "https://cdn.jsdelivr.net/npm/@feedmepos/core@latest/es/fn.js",
80
+ "@feedmepos/core/entity": "https://cdn.jsdelivr.net/npm/@feedmepos/core@latest/es/entity.js",
81
+ "@feedmepos/core/modules": "https://cdn.jsdelivr.net/npm/@feedmepos/core@latest/es/modules.js"
82
+ } : {}
83
+ }, o = {
84
+ "@vue/devtools-api": "6.5.0/lib/esm/index.js",
85
+ vue: "3.5.13/dist/vue.esm-browser.prod.min.js",
86
+ "vue-router": "4.2.5/dist/vue-router.esm-browser.min.js",
87
+ pinia: "2.1.7/+esm"
88
+ };
89
+ let m = [
90
+ ...Object.keys(o),
91
+ ...Object.keys(c),
92
+ ...Object.keys(a)
93
+ ];
94
+ const n = { ...l };
95
+ if (r == "build" && e.startsWith("fmmf") && (m = [
96
+ ...Object.keys(c),
97
+ ...Object.keys(o),
98
+ ...Object.keys(a)
99
+ ], n.build = {
100
+ emptyOutDir: !0,
101
+ lib: {
102
+ entry: {
103
+ app: h(process.cwd(), "src/app.ts")
104
+ },
105
+ formats: ["es"]
106
+ }
107
+ }), n.plugins ?? (n.plugins = []), t.externalize) {
108
+ const s = t.externalize === !0 ? m : t.externalize;
109
+ n.plugins.push(O({ externals: s }));
110
+ }
111
+ n.build ?? (n.build = {}), (x = n.build).rollupOptions ?? (x.rollupOptions = {}), n.build.rollupOptions.external = m.concat(
112
+ ...n.build.rollupOptions.external ?? []
113
+ );
114
+ const d = c;
115
+ await Promise.all(
116
+ Object.keys(d).map(async (s) => {
117
+ const i = "latest";
118
+ return d[s] = `https://cdn.jsdelivr.net/npm/${s}@${i}/dist/app.js`;
119
+ })
120
+ );
121
+ const u = {
122
+ imports: {
123
+ ...d,
124
+ ...Object.keys(o).reduce((s, i) => (s[i] = `https://cdn.jsdelivr.net/npm/${i}@${o[i]}`, s), {}),
125
+ ...a
126
+ },
127
+ scopes: t.importMapScopes ?? {}
128
+ };
129
+ t.replaceFmmfPackages && Object.entries(t.replaceFmmfPackages).forEach(([s, i]) => {
130
+ if (s.startsWith("@feedmepos/mf-") || s === "@feedmepos/ui-library")
131
+ u.imports[s] = i;
132
+ else
133
+ throw new Error(`Invalid replaceFmmfPackages key: ${s}, must start with @feedmepos/mf-`);
134
+ });
135
+ const v = {
136
+ name: "vite-plugin-feedme-microfrontend",
137
+ enforce: "pre",
138
+ config: async () => {
139
+ },
140
+ transformIndexHtml: {
141
+ enforce: "pre",
142
+ transform(s) {
143
+ return {
144
+ html: s,
145
+ tags: [
146
+ {
147
+ tag: "script",
148
+ attrs: {
149
+ type: "importmap"
150
+ },
151
+ children: JSON.stringify(u, null, 2),
152
+ injectTo: "head-prepend"
153
+ },
154
+ {
155
+ tag: "script",
156
+ attrs: {
157
+ src: "https://cdn.jsdelivr.net/npm/es-module-shims@1.8.0/dist/es-module-shims.min.js"
158
+ },
159
+ injectTo: "head-prepend"
160
+ }
161
+ ]
162
+ };
163
+ }
164
+ }
165
+ };
166
+ return n.plugins.push(v), n;
167
+ };
14
168
  export {
15
- b as fmmfVitePresent
169
+ P as fmmfVitePresent
16
170
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedmepos/mf-common",
3
- "version": "1.18.0-beta.1",
3
+ "version": "1.18.0-beta.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -1,207 +0,0 @@
1
- import "node:fs";
2
- import "node:path";
3
- import { F as k, a as U } from "./vite-preset-62104d2c.js";
4
- import "path";
5
- import "fs";
6
- import "node:http";
7
- import "node:https";
8
- import "node:zlib";
9
- import "node:stream";
10
- import "node:buffer";
11
- import "node:util";
12
- import "node:url";
13
- import "node:net";
14
- let f = 0;
15
- const t = {
16
- START_BOUNDARY: f++,
17
- HEADER_FIELD_START: f++,
18
- HEADER_FIELD: f++,
19
- HEADER_VALUE_START: f++,
20
- HEADER_VALUE: f++,
21
- HEADER_VALUE_ALMOST_DONE: f++,
22
- HEADERS_ALMOST_DONE: f++,
23
- PART_DATA_START: f++,
24
- PART_DATA: f++,
25
- END: f++
26
- };
27
- let F = 1;
28
- const _ = {
29
- PART_BOUNDARY: F,
30
- LAST_BOUNDARY: F *= 2
31
- }, O = 10, g = 13, w = 32, P = 45, B = 58, V = 97, Y = 122, x = (u) => u | 32, R = () => {
32
- };
33
- class C {
34
- /**
35
- * @param {string} boundary
36
- */
37
- constructor(o) {
38
- this.index = 0, this.flags = 0, this.onHeaderEnd = R, this.onHeaderField = R, this.onHeadersEnd = R, this.onHeaderValue = R, this.onPartBegin = R, this.onPartData = R, this.onPartEnd = R, this.boundaryChars = {}, o = `\r
39
- --` + o;
40
- const n = new Uint8Array(o.length);
41
- for (let r = 0; r < o.length; r++)
42
- n[r] = o.charCodeAt(r), this.boundaryChars[n[r]] = !0;
43
- this.boundary = n, this.lookbehind = new Uint8Array(this.boundary.length + 8), this.state = t.START_BOUNDARY;
44
- }
45
- /**
46
- * @param {Uint8Array} data
47
- */
48
- write(o) {
49
- let n = 0;
50
- const r = o.length;
51
- let E = this.index, { lookbehind: l, boundary: d, boundaryChars: p, index: e, state: i, flags: A } = this;
52
- const m = this.boundary.length, S = m - 1, N = o.length;
53
- let a, b;
54
- const h = (c) => {
55
- this[c + "Mark"] = n;
56
- }, s = (c) => {
57
- delete this[c + "Mark"];
58
- }, D = (c, L, T, y) => {
59
- (L === void 0 || L !== T) && this[c](y && y.subarray(L, T));
60
- }, H = (c, L) => {
61
- const T = c + "Mark";
62
- T in this && (L ? (D(c, this[T], n, o), delete this[T]) : (D(c, this[T], o.length, o), this[T] = 0));
63
- };
64
- for (n = 0; n < r; n++)
65
- switch (a = o[n], i) {
66
- case t.START_BOUNDARY:
67
- if (e === d.length - 2) {
68
- if (a === P)
69
- A |= _.LAST_BOUNDARY;
70
- else if (a !== g)
71
- return;
72
- e++;
73
- break;
74
- } else if (e - 1 === d.length - 2) {
75
- if (A & _.LAST_BOUNDARY && a === P)
76
- i = t.END, A = 0;
77
- else if (!(A & _.LAST_BOUNDARY) && a === O)
78
- e = 0, D("onPartBegin"), i = t.HEADER_FIELD_START;
79
- else
80
- return;
81
- break;
82
- }
83
- a !== d[e + 2] && (e = -2), a === d[e + 2] && e++;
84
- break;
85
- case t.HEADER_FIELD_START:
86
- i = t.HEADER_FIELD, h("onHeaderField"), e = 0;
87
- case t.HEADER_FIELD:
88
- if (a === g) {
89
- s("onHeaderField"), i = t.HEADERS_ALMOST_DONE;
90
- break;
91
- }
92
- if (e++, a === P)
93
- break;
94
- if (a === B) {
95
- if (e === 1)
96
- return;
97
- H("onHeaderField", !0), i = t.HEADER_VALUE_START;
98
- break;
99
- }
100
- if (b = x(a), b < V || b > Y)
101
- return;
102
- break;
103
- case t.HEADER_VALUE_START:
104
- if (a === w)
105
- break;
106
- h("onHeaderValue"), i = t.HEADER_VALUE;
107
- case t.HEADER_VALUE:
108
- a === g && (H("onHeaderValue", !0), D("onHeaderEnd"), i = t.HEADER_VALUE_ALMOST_DONE);
109
- break;
110
- case t.HEADER_VALUE_ALMOST_DONE:
111
- if (a !== O)
112
- return;
113
- i = t.HEADER_FIELD_START;
114
- break;
115
- case t.HEADERS_ALMOST_DONE:
116
- if (a !== O)
117
- return;
118
- D("onHeadersEnd"), i = t.PART_DATA_START;
119
- break;
120
- case t.PART_DATA_START:
121
- i = t.PART_DATA, h("onPartData");
122
- case t.PART_DATA:
123
- if (E = e, e === 0) {
124
- for (n += S; n < N && !(o[n] in p); )
125
- n += m;
126
- n -= S, a = o[n];
127
- }
128
- if (e < d.length)
129
- d[e] === a ? (e === 0 && H("onPartData", !0), e++) : e = 0;
130
- else if (e === d.length)
131
- e++, a === g ? A |= _.PART_BOUNDARY : a === P ? A |= _.LAST_BOUNDARY : e = 0;
132
- else if (e - 1 === d.length)
133
- if (A & _.PART_BOUNDARY) {
134
- if (e = 0, a === O) {
135
- A &= ~_.PART_BOUNDARY, D("onPartEnd"), D("onPartBegin"), i = t.HEADER_FIELD_START;
136
- break;
137
- }
138
- } else
139
- A & _.LAST_BOUNDARY && a === P ? (D("onPartEnd"), i = t.END, A = 0) : e = 0;
140
- if (e > 0)
141
- l[e - 1] = a;
142
- else if (E > 0) {
143
- const c = new Uint8Array(l.buffer, l.byteOffset, l.byteLength);
144
- D("onPartData", 0, E, c), E = 0, h("onPartData"), n--;
145
- }
146
- break;
147
- case t.END:
148
- break;
149
- default:
150
- throw new Error(`Unexpected state entered: ${i}`);
151
- }
152
- H("onHeaderField"), H("onHeaderValue"), H("onPartData"), this.index = e, this.state = i, this.flags = A;
153
- }
154
- end() {
155
- if (this.state === t.HEADER_FIELD_START && this.index === 0 || this.state === t.PART_DATA && this.index === this.boundary.length)
156
- this.onPartEnd();
157
- else if (this.state !== t.END)
158
- throw new Error("MultipartParser.end(): stream ended unexpectedly");
159
- }
160
- }
161
- function I(u) {
162
- const o = u.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
163
- if (!o)
164
- return;
165
- const n = o[2] || o[3] || "";
166
- let r = n.slice(n.lastIndexOf("\\") + 1);
167
- return r = r.replace(/%22/g, '"'), r = r.replace(/&#(\d{4});/g, (E, l) => String.fromCharCode(l)), r;
168
- }
169
- async function ee(u, o) {
170
- if (!/multipart/i.test(o))
171
- throw new TypeError("Failed to fetch");
172
- const n = o.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
173
- if (!n)
174
- throw new TypeError("no or bad content-type header, no multipart boundary");
175
- const r = new C(n[1] || n[2]);
176
- let E, l, d, p, e, i;
177
- const A = [], m = new k(), S = (s) => {
178
- d += h.decode(s, { stream: !0 });
179
- }, N = (s) => {
180
- A.push(s);
181
- }, a = () => {
182
- const s = new U(A, i, { type: e });
183
- m.append(p, s);
184
- }, b = () => {
185
- m.append(p, d);
186
- }, h = new TextDecoder("utf-8");
187
- h.decode(), r.onPartBegin = function() {
188
- r.onPartData = S, r.onPartEnd = b, E = "", l = "", d = "", p = "", e = "", i = null, A.length = 0;
189
- }, r.onHeaderField = function(s) {
190
- E += h.decode(s, { stream: !0 });
191
- }, r.onHeaderValue = function(s) {
192
- l += h.decode(s, { stream: !0 });
193
- }, r.onHeaderEnd = function() {
194
- if (l += h.decode(), E = E.toLowerCase(), E === "content-disposition") {
195
- const s = l.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
196
- s && (p = s[2] || s[3] || ""), i = I(l), i && (r.onPartData = N, r.onPartEnd = a);
197
- } else
198
- E === "content-type" && (e = l);
199
- l = "", E = "";
200
- };
201
- for await (const s of u)
202
- r.write(s);
203
- return r.end(), m;
204
- }
205
- export {
206
- ee as toFormData
207
- };