@bleedingdev/modern-js-image 3.9.0-ultramodern.9 → 3.9.3-ultramodern.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/cli.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { AppTools, CliPlugin } from '@modern-js/app-tools';
2
- import { type PluginImageOptions as BuilderPluginImageOptions } from '@rsbuild-image/core';
3
- export interface ImagePluginOptions extends BuilderPluginImageOptions {
2
+ import { type PluginImageOptions as BuilderPluginImageOptions, type ExtendedIPXOptions } from '@rsbuild-image/core';
3
+ export interface ImagePluginOptions extends Omit<BuilderPluginImageOptions, 'ipx'> {
4
+ /** Options for the dev server's IPX route, `/_modern/ipx` by default. */
5
+ ipx?: ExtendedIPXOptions;
4
6
  }
5
7
  export declare const imagePlugin: (options?: ImagePluginOptions) => CliPlugin<AppTools>;
6
8
  export default imagePlugin;
package/dist/index.cjs CHANGED
@@ -1,5 +1,14 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
3
12
  (()=>{
4
13
  __webpack_require__.d = (exports1, getters, values)=>{
5
14
  var define = (defs, kind)=>{
@@ -31,16 +40,64 @@ __webpack_require__.d(__webpack_exports__, {
31
40
  default: ()=>cli,
32
41
  imagePlugin: ()=>imagePlugin
33
42
  });
43
+ const external_node_path_namespaceObject = require("node:path");
44
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
34
45
  const core_namespaceObject = require("@rsbuild-image/core");
35
46
  const imagePlugin = (options = {})=>({
36
47
  name: '@modern-js/image',
37
48
  setup: (api)=>{
38
- const { ...builderPluginOptions } = options;
39
- builderPluginOptions.ipx ||= {};
40
- builderPluginOptions.ipx.assetPrefix ??= '/_modern/ipx';
49
+ const { ipx = {}, ...builderPluginOptions } = options;
50
+ const { assetPrefix = '/_modern/ipx', ...ipxOptions } = ipx;
51
+ const route = `${assetPrefix.replace(/\/+$/, '')}/`;
52
+ let web;
53
+ api.onAfterCreateCompiler(({ compiler })=>{
54
+ const all = 'compilers' in compiler ? compiler.compilers : [
55
+ compiler
56
+ ];
57
+ web = all.find((item)=>'web' === item.name) ?? all[0];
58
+ });
59
+ const output = (method, id)=>new Promise((resolve, reject)=>{
60
+ const outputFileSystem = web?.outputFileSystem;
61
+ const read = outputFileSystem?.[method];
62
+ if (!web || !read) return reject(new Error('No web compiler output'));
63
+ const file = external_node_path_default().resolve(web.outputPath, `.${external_node_path_default().sep}${id}`);
64
+ const inside = external_node_path_default().relative(web.outputPath, file);
65
+ if ('..' === inside || inside.startsWith(`..${external_node_path_default().sep}`) || external_node_path_default().isAbsolute(inside)) return reject(new Error(`IPX source outside the dev output: ${id}`));
66
+ read.call(outputFileSystem, file, (error, value)=>error ? reject(error) : resolve(value));
67
+ });
68
+ let handler;
69
+ const serveIPX = ()=>handler ??= import("ipx").then(({ createIPX, createIPXNodeHandler })=>createIPXNodeHandler(createIPX({
70
+ storage: {
71
+ name: '@modern-js/image:dev-output',
72
+ getMeta: async (id)=>({
73
+ mtime: (await output('stat', id)).mtime
74
+ }),
75
+ getData: (id)=>output('readFile', id)
76
+ },
77
+ ...ipxOptions
78
+ })));
41
79
  api.config(()=>({
80
+ source: {
81
+ define: {
82
+ __RSBUILD_IMAGE_IPX_ASSET_PREFIX__: JSON.stringify(assetPrefix)
83
+ }
84
+ },
85
+ dev: {
86
+ setupMiddlewares: [
87
+ (middlewares)=>{
88
+ middlewares.push((req, res, next)=>{
89
+ if (!req.url?.startsWith(route)) return next();
90
+ req.url = req.url.slice(route.length - 1);
91
+ serveIPX().then((serve)=>serve(req, res)).catch(next);
92
+ });
93
+ }
94
+ ]
95
+ },
42
96
  builderPlugins: [
43
- (0, core_namespaceObject.pluginImage)(builderPluginOptions)
97
+ (0, core_namespaceObject.pluginImage)({
98
+ ...builderPluginOptions,
99
+ loader: builderPluginOptions.loader ?? ('dev' === api.getAppContext().command ? require.resolve('@rsbuild-image/core/image-loader') : void 0)
100
+ })
44
101
  ]
45
102
  }));
46
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bleedingdev/modern-js-image",
3
- "version": "3.9.0-ultramodern.9",
3
+ "version": "3.9.3-ultramodern.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.ts",
@@ -34,33 +34,35 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@rsbuild-image/core": "npm:@bleedingdev/rsbuild-image-core@0.1.0",
37
+ "@rsbuild-image/core": "0.0.1-next.36",
38
38
  "@rsbuild-image/react": "0.0.1-next.36",
39
- "ipx": "npm:@bleedingdev/ipx@3.2.1",
40
- "sharp": "^0.35.4"
39
+ "ipx": "^4.0.0-beta.1",
40
+ "sharp": "^0.35.5"
41
41
  },
42
42
  "devDependencies": {
43
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.9",
44
- "@rslib/core": "1.0.0",
45
- "@types/node": "^26.4.1",
46
- "@typescript/native-preview": "7.0.0-dev.20260707.2",
47
- "react": "^19.2.8",
48
- "react-dom": "^19.2.8",
49
- "typescript": "^7.0.2"
43
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.3-ultramodern.2",
44
+ "@rslib/core": "1.0.3",
45
+ "@types/node": "^26.6.3",
46
+ "react": "^19.3.0",
47
+ "react-dom": "^19.3.0",
48
+ "typescript": "7.0.2"
50
49
  },
51
50
  "scripts": {
52
51
  "build": "rslib build",
53
52
  "dev": "rslib build --watch"
54
53
  },
55
- "homepage": "https://github.com/BleedingDev/ultramodern.js#readme",
54
+ "homepage": "https://github.com/ultramodernjs/ultramodern.js#readme",
56
55
  "bugs": {
57
- "url": "https://github.com/BleedingDev/ultramodern.js/issues"
56
+ "url": "https://github.com/ultramodernjs/ultramodern.js/issues"
58
57
  },
59
58
  "repository": {
60
59
  "type": "git",
61
- "url": "git+https://github.com/BleedingDev/ultramodern.js.git"
60
+ "url": "git+https://github.com/ultramodernjs/ultramodern.js.git"
62
61
  },
63
62
  "publishConfig": {
64
63
  "access": "public"
64
+ },
65
+ "ultramodern": {
66
+ "sourceName": "@modern-js/image"
65
67
  }
66
68
  }