@farm.js/federation 0.1.0-beta.0 → 0.1.0-beta.2

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.
package/dist/config.js CHANGED
@@ -127,7 +127,7 @@ function normalizeRemoteAlias(value) {
127
127
  function normalizeRemoteEntry(value, alias) {
128
128
  const entry = nonEmptyString(value, `Federation remote ${alias} entry`);
129
129
  if (entry.startsWith("/")) {
130
- if (entry.startsWith("//") || entry.includes("\\")) {
130
+ if (entry.startsWith("//") || entry.includes("\\") || !hasBrowserStablePathname(entry)) {
131
131
  throw new TypeError(`Federation remote ${alias} entry must be a root-relative URL, not a network-path URL`);
132
132
  }
133
133
  return entry;
@@ -177,7 +177,7 @@ function normalizeOutputFile(value) {
177
177
  if (value.includes("\\") ||
178
178
  value.includes("?") ||
179
179
  value.includes("#") ||
180
- segments.some((segment) => !segment || segment === "." || segment === "..") ||
180
+ segments.some((segment) => !isBrowserStablePathSegment(segment)) ||
181
181
  !/\.m?js$/i.test(filename)) {
182
182
  throw new TypeError("Federation filename must be a safe relative .js or .mjs path");
183
183
  }
@@ -190,7 +190,9 @@ function optionalPublicPath(value) {
190
190
  if (publicPath === "auto")
191
191
  return publicPath;
192
192
  if (publicPath.startsWith("/")) {
193
- if (publicPath.startsWith("//") || publicPath.includes("\\")) {
193
+ if (publicPath.startsWith("//") ||
194
+ publicPath.includes("\\") ||
195
+ !hasBrowserStablePathname(publicPath)) {
194
196
  throw new TypeError("Federation publicPath must be a root-relative URL, not a network-path URL");
195
197
  }
196
198
  return publicPath;
@@ -212,6 +214,26 @@ function optionalPublicPath(value) {
212
214
  }
213
215
  return parsed.href;
214
216
  }
217
+ function hasBrowserStablePathname(value) {
218
+ const pathname = value.split(/[?#]/, 1)[0] || "/";
219
+ return pathname.split("/").every((segment) => !segment || isBrowserStablePathSegment(segment));
220
+ }
221
+ function isBrowserStablePathSegment(segment) {
222
+ if (!segment)
223
+ return false;
224
+ let decoded = segment;
225
+ try {
226
+ decoded = decodeURIComponent(segment);
227
+ }
228
+ catch {
229
+ // Malformed escapes remain literal in browser pathnames.
230
+ }
231
+ return (decoded !== "." &&
232
+ decoded !== ".." &&
233
+ !decoded.includes("/") &&
234
+ !decoded.includes("\\") &&
235
+ !hasControlCharacter(decoded));
236
+ }
215
237
  function booleanOption(value, label) {
216
238
  if (value !== undefined && typeof value !== "boolean") {
217
239
  throw new TypeError(`Federation ${label} must be a boolean`);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type FederationOptions, type FederationRemote, type FederationSharedOptions, type FederationSharedPackage, type FederationSharedPackages } from "./config.js";
2
2
  export type { FederationOptions, FederationRemote, FederationSharedOptions, FederationSharedPackage, FederationSharedPackages, };
3
3
  /** Publish and consume independently deployed browser modules from a Farm application. */
4
- export declare function federation(options: FederationOptions): import("@farm.js/core/plugin").FarmPlugin<undefined, Record<string, never>, unknown, undefined, unknown, false>;
4
+ export declare function federation(options: FederationOptions): import("@farm.js/core/plugin").FarmPlugin<undefined, Record<string, never>, unknown, undefined, unknown, false, import("@farm.js/core/plugin").PluginRoutes>;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC9B,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,GACzB,CAAC;AAEF,0FAA0F;AAC1F,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,mHAyBpD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC9B,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,GACzB,CAAC;AAEF,0FAA0F;AAC1F,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,gKAyBpD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/federation",
3
- "version": "0.1.0-beta.0",
3
+ "version": "0.1.0-beta.2",
4
4
  "description": "Client-side Module Federation for Farm.js applications",
5
5
  "keywords": [
6
6
  "farm.js",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@module-federation/runtime": "^2.9.0",
39
39
  "@module-federation/vite": "^1.21.6",
40
- "@farm.js/core": "0.1.0-beta.92"
40
+ "@farm.js/core": "0.1.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^20.10.5",