@bleedingdev/modern-js-image 3.9.0-ultramodern.2 → 3.9.0-ultramodern.21
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
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppTools, CliPlugin } from '@modern-js/app-tools';
|
|
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;
|
|
6
|
+
}
|
|
7
|
+
export declare const imagePlugin: (options?: ImagePluginOptions) => CliPlugin<AppTools>;
|
|
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
|
-
|
|
40
|
-
|
|
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)(
|
|
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,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bleedingdev/modern-js-image",
|
|
3
|
-
"version": "3.9.0-ultramodern.
|
|
3
|
+
"version": "3.9.0-ultramodern.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
|
-
"types": "./dist/
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"types": "./dist/
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
10
|
"default": "./dist/index.cjs"
|
|
11
11
|
},
|
|
12
12
|
"./runtime": {
|
|
13
|
-
"types": "./dist/
|
|
13
|
+
"types": "./dist/runtime.d.ts",
|
|
14
14
|
"default": "./dist/runtime.js"
|
|
15
15
|
},
|
|
16
16
|
"./types": {
|
|
17
|
-
"types": "./dist/types
|
|
17
|
+
"types": "./dist/types.d.ts"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"typesVersions": {
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@rsbuild-image/core": "
|
|
37
|
+
"@rsbuild-image/core": "0.0.1-next.36",
|
|
38
38
|
"@rsbuild-image/react": "0.0.1-next.36",
|
|
39
|
-
"ipx": "
|
|
39
|
+
"ipx": "^4.0.0-beta.1",
|
|
40
40
|
"sharp": "^0.35.4"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.
|
|
44
|
-
"@rslib/core": "1.0.
|
|
45
|
-
"@types/node": "^26.
|
|
43
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.21",
|
|
44
|
+
"@rslib/core": "1.0.2",
|
|
45
|
+
"@types/node": "^26.6.2",
|
|
46
46
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
47
|
-
"react": "^19.
|
|
48
|
-
"react-dom": "^19.
|
|
47
|
+
"react": "^19.3.0",
|
|
48
|
+
"react-dom": "^19.3.0",
|
|
49
49
|
"typescript": "^7.0.2"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
package/dist/types/cli.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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 {
|
|
4
|
-
}
|
|
5
|
-
export declare const imagePlugin: (options?: ImagePluginOptions) => CliPlugin<AppTools>;
|
|
6
|
-
export default imagePlugin;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|