@web-widget/react 1.52.1 → 1.53.1

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/vite.d.ts CHANGED
@@ -2,6 +2,7 @@ import * as vite from 'vite';
2
2
  import { WebWidgetUserConfig } from '@web-widget/vite-plugin';
3
3
 
4
4
  interface ReactWebWidgetPluginOptions extends Partial<WebWidgetUserConfig> {
5
+ workspace?: string;
5
6
  }
6
7
  declare function reactWebWidgetPlugin(options?: ReactWebWidgetPluginOptions): vite.Plugin<any>[];
7
8
 
package/dist/vite.js CHANGED
@@ -1,22 +1,40 @@
1
1
  // src/vite.ts
2
2
  import { webWidgetPlugin } from "@web-widget/vite-plugin";
3
+ import { posix } from "path";
4
+ import { normalizePath } from "@rollup/pluginutils";
5
+ function escapeRegExp(path) {
6
+ return path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7
+ }
8
+ function appendSlash(path) {
9
+ return path.endsWith(posix.sep) ? path : `${path}${posix.sep}`;
10
+ }
3
11
  function reactWebWidgetPlugin(options) {
4
12
  const {
5
13
  provide = "@web-widget/react",
14
+ workspace = "",
6
15
  export: exportWidget = {},
7
16
  import: importWidget = {},
8
17
  manifest
9
18
  } = options != null ? options : {};
19
+ const workspacePattern = workspace ? escapeRegExp(normalizePath(appendSlash(workspace))) : workspace;
20
+ const widgetPattern = `[.@]widget`;
21
+ const modulesPattern = `[.@](?:route|widget)`;
22
+ const extensionPattern = `\\.(?:tsx|jsx)`;
10
23
  return webWidgetPlugin({
11
24
  manifest,
12
25
  provide,
13
26
  export: {
14
- include: /[.@](?:route|widget)\.(?:tsx|jsx)(?:\?as=.+)?$/,
27
+ include: new RegExp(
28
+ `^${workspacePattern}[^?]*${modulesPattern}${extensionPattern}$`
29
+ ),
15
30
  ...exportWidget
16
31
  },
17
32
  import: {
18
- include: /[.@]widget\.[^?]*(?:\?as=.+)?$/,
19
- includeImporter: /\.(?:tsx|jsx)(?:\?as=.+)?$/,
33
+ include: new RegExp(`^[^?]*${widgetPattern}\\.[^?]*$`),
34
+ includeImporter: new RegExp(
35
+ // NOTE: Should not match this: app.vue?vue&type=script&lang.jsx
36
+ `^${workspacePattern}[^?]*${extensionPattern}$`
37
+ ),
20
38
  ...importWidget
21
39
  }
22
40
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@web-widget/react",
3
3
  "description": "React adapter",
4
- "version": "1.52.1",
4
+ "version": "1.53.1",
5
5
  "homepage": "https://github.com/web-widget/web-widget#readme",
6
6
  "repository": {
7
7
  "type": "git",
@@ -13,10 +13,11 @@
13
13
  },
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@web-widget/helpers": "1.52.1",
17
- "@web-widget/schema": "1.52.1",
18
- "@web-widget/vite-plugin": "1.52.1",
19
- "@web-widget/web-widget": "1.52.1"
16
+ "@rollup/pluginutils": "^5.1.4",
17
+ "@web-widget/helpers": "1.53.1",
18
+ "@web-widget/schema": "1.53.1",
19
+ "@web-widget/vite-plugin": "1.53.1",
20
+ "@web-widget/web-widget": "1.53.1"
20
21
  },
21
22
  "devDependencies": {
22
23
  "@types/react": "^19.0.10",