@codepress/codepress-engine 0.7.11 → 0.8.0-dev.jsmap.20251204072058
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/CPRefreshProvider.d.ts +44 -0
- package/dist/CPRefreshProvider.js +69 -0
- package/dist/CPRefreshProvider.js.map +1 -0
- package/dist/esbuild-plugin.d.ts +5 -2
- package/dist/esbuild-plugin.js +8 -62
- package/dist/esbuild-plugin.js.map +1 -1
- package/dist/types.d.ts +44 -0
- package/package.json +17 -2
- package/swc/codepress_engine.v0_82_87.wasm +0 -0
- package/swc/codepress_engine.v26.wasm +0 -0
- package/swc/codepress_engine.v42.wasm +0 -0
- package/swc/codepress_engine.v48.wasm +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CPRefreshProvider - Root-level refresh provider for CodePress HMR
|
|
3
|
+
*
|
|
4
|
+
* NOTE: By default, you don't need to manually add this provider.
|
|
5
|
+
* The CodePress SWC/Babel plugin automatically injects it at app entry points:
|
|
6
|
+
* - Next.js Pages Router: pages/_app.tsx
|
|
7
|
+
* - Next.js App Router: app/layout.tsx
|
|
8
|
+
* - Vite/CRA: src/main.tsx or src/index.tsx
|
|
9
|
+
*
|
|
10
|
+
* When `window.__CP_triggerRefresh()` is called, all components under this provider will re-render.
|
|
11
|
+
*
|
|
12
|
+
* To disable auto-injection, set `autoInjectRefreshProvider: false` in the plugin config:
|
|
13
|
+
* ```js
|
|
14
|
+
* // next.config.js
|
|
15
|
+
* experimental: {
|
|
16
|
+
* swcPlugins: [['@codepress/codepress-engine/swc', { autoInjectRefreshProvider: false }]]
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Then manually add the provider:
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { CPRefreshProvider } from '@codepress/codepress-engine/refresh-provider';
|
|
23
|
+
*
|
|
24
|
+
* export default function App({ children }) {
|
|
25
|
+
* return <CPRefreshProvider>{children}</CPRefreshProvider>;
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import React, { ReactNode } from 'react';
|
|
30
|
+
export declare const CPRefreshContext: React.Context<number>;
|
|
31
|
+
interface CPRefreshProviderProps {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Root-level provider that triggers re-renders when CP_PREVIEW_REFRESH event fires.
|
|
36
|
+
* Only one instance of this provider is needed at the app root.
|
|
37
|
+
*/
|
|
38
|
+
export declare function CPRefreshProvider({ children }: CPRefreshProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
declare global {
|
|
40
|
+
interface Window {
|
|
41
|
+
__CP_triggerRefresh?: () => void;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export default CPRefreshProvider;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CPRefreshContext = void 0;
|
|
4
|
+
exports.CPRefreshProvider = CPRefreshProvider;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
/**
|
|
7
|
+
* CPRefreshProvider - Root-level refresh provider for CodePress HMR
|
|
8
|
+
*
|
|
9
|
+
* NOTE: By default, you don't need to manually add this provider.
|
|
10
|
+
* The CodePress SWC/Babel plugin automatically injects it at app entry points:
|
|
11
|
+
* - Next.js Pages Router: pages/_app.tsx
|
|
12
|
+
* - Next.js App Router: app/layout.tsx
|
|
13
|
+
* - Vite/CRA: src/main.tsx or src/index.tsx
|
|
14
|
+
*
|
|
15
|
+
* When `window.__CP_triggerRefresh()` is called, all components under this provider will re-render.
|
|
16
|
+
*
|
|
17
|
+
* To disable auto-injection, set `autoInjectRefreshProvider: false` in the plugin config:
|
|
18
|
+
* ```js
|
|
19
|
+
* // next.config.js
|
|
20
|
+
* experimental: {
|
|
21
|
+
* swcPlugins: [['@codepress/codepress-engine/swc', { autoInjectRefreshProvider: false }]]
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Then manually add the provider:
|
|
26
|
+
* ```tsx
|
|
27
|
+
* import { CPRefreshProvider } from '@codepress/codepress-engine/refresh-provider';
|
|
28
|
+
*
|
|
29
|
+
* export default function App({ children }) {
|
|
30
|
+
* return <CPRefreshProvider>{children}</CPRefreshProvider>;
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
const react_1 = require("react");
|
|
35
|
+
// Module-level version counter that persists across renders
|
|
36
|
+
let __cpVersion = 0;
|
|
37
|
+
// Context for components that want to subscribe to refresh events
|
|
38
|
+
exports.CPRefreshContext = (0, react_1.createContext)(0);
|
|
39
|
+
/**
|
|
40
|
+
* Root-level provider that triggers re-renders when CP_PREVIEW_REFRESH event fires.
|
|
41
|
+
* Only one instance of this provider is needed at the app root.
|
|
42
|
+
*/
|
|
43
|
+
function CPRefreshProvider({ children }) {
|
|
44
|
+
const version = (0, react_1.useSyncExternalStore)((callback) => {
|
|
45
|
+
if (typeof window === 'undefined') {
|
|
46
|
+
return () => { };
|
|
47
|
+
}
|
|
48
|
+
const handler = () => {
|
|
49
|
+
__cpVersion = __cpVersion + 1;
|
|
50
|
+
callback();
|
|
51
|
+
};
|
|
52
|
+
window.addEventListener('CP_PREVIEW_REFRESH', handler);
|
|
53
|
+
// Also expose the trigger function globally
|
|
54
|
+
if (!window.__CP_triggerRefresh) {
|
|
55
|
+
window.__CP_triggerRefresh = () => {
|
|
56
|
+
window.dispatchEvent(new CustomEvent('CP_PREVIEW_REFRESH'));
|
|
57
|
+
};
|
|
58
|
+
// Mark that this function dispatches the preview event
|
|
59
|
+
window.__CP_triggerRefresh.__cp_dispatches_preview = true;
|
|
60
|
+
}
|
|
61
|
+
return () => {
|
|
62
|
+
window.removeEventListener('CP_PREVIEW_REFRESH', handler);
|
|
63
|
+
};
|
|
64
|
+
}, () => __cpVersion, () => 0 // Server snapshot
|
|
65
|
+
);
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)(exports.CPRefreshContext.Provider, { value: version, children: children }));
|
|
67
|
+
}
|
|
68
|
+
exports.default = CPRefreshProvider;
|
|
69
|
+
//# sourceMappingURL=CPRefreshProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CPRefreshProvider.js","sourceRoot":"","sources":["../src/CPRefreshProvider.tsx"],"names":[],"mappings":";;;AA6CA,8CAoCC;;AAjFD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,iCAA8E;AAE9E,4DAA4D;AAC5D,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB,kEAAkE;AACrD,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAAS,CAAC,CAAC,CAAC;AAMzD;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAA0B;IACpE,MAAM,OAAO,GAAG,IAAA,4BAAoB,EAClC,CAAC,QAAoB,EAAE,EAAE;QACvB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAClC,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,WAAW,GAAG,WAAW,GAAG,CAAC,CAAC;YAC9B,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAEvD,4CAA4C;QAC5C,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAChC,MAAM,CAAC,mBAAmB,GAAG,GAAG,EAAE;gBAChC,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC;YACF,uDAAuD;YACtD,MAAM,CAAC,mBAA2B,CAAC,uBAAuB,GAAG,IAAI,CAAC;QACrE,CAAC;QAED,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC5D,CAAC,CAAC;IACJ,CAAC,EACD,GAAG,EAAE,CAAC,WAAW,EACjB,GAAG,EAAE,CAAC,CAAC,CAAC,kBAAkB;KAC3B,CAAC;IAEF,OAAO,CACL,uBAAC,wBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YACtC,QAAQ,GACiB,CAC7B,CAAC;AACJ,CAAC;AASD,kBAAe,iBAAiB,CAAC"}
|
package/dist/esbuild-plugin.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CodePress esbuild plugin - Injects tracking attributes
|
|
3
|
-
*
|
|
2
|
+
* CodePress esbuild plugin - Injects tracking attributes into JSX
|
|
3
|
+
*
|
|
4
|
+
* This plugin adds codepress-data-fp attributes to JSX elements for element identification.
|
|
5
|
+
* HMR is handled separately by a single root-level provider (CPRefreshProvider) that users
|
|
6
|
+
* add to their app entry point, rather than wrapping every component.
|
|
4
7
|
*/
|
|
5
8
|
import type { Plugin } from 'esbuild';
|
|
6
9
|
interface CodePressPluginOptions {
|
package/dist/esbuild-plugin.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* CodePress esbuild plugin - Injects tracking attributes
|
|
4
|
-
*
|
|
3
|
+
* CodePress esbuild plugin - Injects tracking attributes into JSX
|
|
4
|
+
*
|
|
5
|
+
* This plugin adds codepress-data-fp attributes to JSX elements for element identification.
|
|
6
|
+
* HMR is handled separately by a single root-level provider (CPRefreshProvider) that users
|
|
7
|
+
* add to their app entry point, rather than wrapping every component.
|
|
5
8
|
*/
|
|
6
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
10
|
if (k2 === undefined) k2 = k;
|
|
@@ -95,60 +98,6 @@ function injectJSXAttributes(source, encoded, repoName, branchName) {
|
|
|
95
98
|
}
|
|
96
99
|
return output.join('\n');
|
|
97
100
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Wrap exported components with __CPProvider
|
|
100
|
-
*/
|
|
101
|
-
function wrapWithProvider(source) {
|
|
102
|
-
var _a;
|
|
103
|
-
// Find default export component
|
|
104
|
-
const defaultExportMatch = source.match(/export\s+default\s+function\s+(\w+)/);
|
|
105
|
-
if (!defaultExportMatch) {
|
|
106
|
-
// Try: export default ComponentName;
|
|
107
|
-
const namedMatch = source.match(/export\s+default\s+(\w+);/);
|
|
108
|
-
if (!namedMatch)
|
|
109
|
-
return source;
|
|
110
|
-
}
|
|
111
|
-
const componentName = (defaultExportMatch === null || defaultExportMatch === void 0 ? void 0 : defaultExportMatch[1]) || ((_a = source.match(/export\s+default\s+(\w+);/)) === null || _a === void 0 ? void 0 : _a[1]);
|
|
112
|
-
if (!componentName)
|
|
113
|
-
return source;
|
|
114
|
-
// Inject provider wrapper code at the top
|
|
115
|
-
const providerCode = `
|
|
116
|
-
import { useSyncExternalStore } from 'react';
|
|
117
|
-
|
|
118
|
-
// Module-level version counter for HMR
|
|
119
|
-
let __cpvVersion = 0;
|
|
120
|
-
|
|
121
|
-
// Provider component that wraps the default export
|
|
122
|
-
function __CPProvider({ value, children }: { value?: any; children: React.ReactNode }) {
|
|
123
|
-
const __cpv = useSyncExternalStore(
|
|
124
|
-
(cb) => {
|
|
125
|
-
const h = () => {
|
|
126
|
-
__cpvVersion = __cpvVersion + 1;
|
|
127
|
-
cb();
|
|
128
|
-
};
|
|
129
|
-
if (typeof window !== 'undefined') {
|
|
130
|
-
window.addEventListener("CP_PREVIEW_REFRESH", h);
|
|
131
|
-
return () => { window.removeEventListener("CP_PREVIEW_REFRESH", h); };
|
|
132
|
-
}
|
|
133
|
-
return () => {};
|
|
134
|
-
},
|
|
135
|
-
() => __cpvVersion,
|
|
136
|
-
() => 0
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
return <CPX.Provider value={value} key={__cpv}>{children}</CPX.Provider>;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Context for passing data through provider
|
|
143
|
-
const CPX = { Provider: ({ value, children }: any) => children };
|
|
144
|
-
`;
|
|
145
|
-
// Wrap the default export
|
|
146
|
-
const wrappedSource = source.replace(new RegExp(`export\\s+default\\s+${componentName}`), `const __Original${componentName} = ${componentName};
|
|
147
|
-
export default function ${componentName}(props: any) {
|
|
148
|
-
return <__CPProvider><__Original${componentName} {...props} /></__CPProvider>;
|
|
149
|
-
}`);
|
|
150
|
-
return providerCode + '\n' + wrappedSource;
|
|
151
|
-
}
|
|
152
101
|
function createCodePressPlugin(options = {}) {
|
|
153
102
|
const { repo_name = '', branch_name = '', repo_root = process.cwd(), } = options;
|
|
154
103
|
return {
|
|
@@ -167,12 +116,9 @@ function createCodePressPlugin(options = {}) {
|
|
|
167
116
|
if (!encoded) {
|
|
168
117
|
return { contents: source, loader: 'tsx' };
|
|
169
118
|
}
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (transformed.includes('export default')) {
|
|
174
|
-
transformed = wrapWithProvider(transformed);
|
|
175
|
-
}
|
|
119
|
+
// Inject JSX attributes (codepress-data-fp)
|
|
120
|
+
// HMR is handled by a root-level CPRefreshProvider, not per-component wrapping
|
|
121
|
+
const transformed = injectJSXAttributes(source, encoded, repo_name, branch_name);
|
|
176
122
|
return {
|
|
177
123
|
contents: transformed,
|
|
178
124
|
loader: 'tsx',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-plugin.js","sourceRoot":"","sources":["../src/esbuild-plugin.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"esbuild-plugin.js","sourceRoot":"","sources":["../src/esbuild-plugin.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFH,sDAyCC;AAvHD,uCAAyB;AACzB,2CAA6B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AA0B;YAC1B,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACnD,IAAI,CAAC;oBACH,oBAAoB;oBACpB,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;wBACvC,OAAO,IAAI,CAAC;oBACd,CAAC;oBAED,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;oBAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;oBACpD,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;oBAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;wBACb,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;oBAC7C,CAAC;oBAED,4CAA4C;oBAC5C,+EAA+E;oBAC/E,MAAM,WAAW,GAAG,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;oBAEjF,OAAO;wBACL,QAAQ,EAAE,WAAW;wBACrB,MAAM,EAAE,KAAK;qBACd,CAAC;gBACJ,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;oBACvE,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAED,kBAAe,qBAAqB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,4 +14,48 @@ export interface CodePressPluginOptions {
|
|
|
14
14
|
* Used by CodePress HMR to substitute env vars in dynamically built modules.
|
|
15
15
|
*/
|
|
16
16
|
env_vars?: Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Store metadata in window.__CODEPRESS_MAP__ instead of DOM attributes.
|
|
19
|
+
* When true, only codepress-data-fp attribute is added to DOM.
|
|
20
|
+
* This avoids React reconciliation issues and keeps DOM clean.
|
|
21
|
+
* Defaults to true.
|
|
22
|
+
*/
|
|
23
|
+
useJsMetadataMap?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Automatically inject the refresh provider at detected app entry points.
|
|
26
|
+
* Defaults to true.
|
|
27
|
+
*
|
|
28
|
+
* When enabled, the plugin detects and wraps these entry points:
|
|
29
|
+
* - Next.js Pages Router: pages/_app.tsx
|
|
30
|
+
* - Next.js App Router: app/layout.tsx (root layout)
|
|
31
|
+
* - Vite/CRA: src/main.tsx or src/index.tsx
|
|
32
|
+
*
|
|
33
|
+
* Set to false to disable auto-injection. You'll need to manually add
|
|
34
|
+
* the refresh provider:
|
|
35
|
+
*
|
|
36
|
+
* ```tsx
|
|
37
|
+
* import { CPRefreshProvider } from '@codepress/codepress-engine/refresh-provider';
|
|
38
|
+
*
|
|
39
|
+
* export default function App({ children }) {
|
|
40
|
+
* return <CPRefreshProvider>{children}</CPRefreshProvider>;
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Reasons to disable:
|
|
45
|
+
* - Monorepos with library packages that match entry point patterns
|
|
46
|
+
* - Custom entry points not detected automatically
|
|
47
|
+
* - Full control over where the provider is placed
|
|
48
|
+
*/
|
|
49
|
+
autoInjectRefreshProvider?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Skip wrapping custom components with __CPProvider.
|
|
52
|
+
* When useJsMetadataMap is true (the default), this is automatically set to true.
|
|
53
|
+
* @deprecated This is now automatically determined by useJsMetadataMap
|
|
54
|
+
*/
|
|
55
|
+
skipProviderWrap?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Skip wrapping custom components with <codepress-marker>.
|
|
58
|
+
* Only used when useJsMetadataMap is false.
|
|
59
|
+
*/
|
|
60
|
+
skipMarkerWrap?: boolean;
|
|
17
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codepress/codepress-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-dev.jsmap.20251204072058",
|
|
4
4
|
"packageManager": "pnpm@10.22.0",
|
|
5
5
|
"description": "CodePress engine - Babel and SWC plug-ins",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,6 +41,11 @@
|
|
|
41
41
|
"require": "./dist/webpack-plugin.js",
|
|
42
42
|
"default": "./dist/webpack-plugin.js"
|
|
43
43
|
},
|
|
44
|
+
"./refresh-provider": {
|
|
45
|
+
"types": "./dist/CPRefreshProvider.d.ts",
|
|
46
|
+
"require": "./dist/CPRefreshProvider.js",
|
|
47
|
+
"default": "./dist/CPRefreshProvider.js"
|
|
48
|
+
},
|
|
44
49
|
"./swc/wasm": "./swc/codepress_engine.v42.wasm",
|
|
45
50
|
"./swc/wasm-v42": "./swc/codepress_engine.v42.wasm",
|
|
46
51
|
"./swc/wasm-v26": "./swc/codepress_engine.v26.wasm",
|
|
@@ -89,7 +94,16 @@
|
|
|
89
94
|
"access": "public"
|
|
90
95
|
},
|
|
91
96
|
"peerDependencies": {
|
|
92
|
-
"@babel/core": "^7.0.0"
|
|
97
|
+
"@babel/core": "^7.0.0",
|
|
98
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
99
|
+
},
|
|
100
|
+
"peerDependenciesMeta": {
|
|
101
|
+
"@babel/core": {
|
|
102
|
+
"optional": true
|
|
103
|
+
},
|
|
104
|
+
"react": {
|
|
105
|
+
"optional": true
|
|
106
|
+
}
|
|
93
107
|
},
|
|
94
108
|
"devDependencies": {
|
|
95
109
|
"@babel/cli": "^7.26.0",
|
|
@@ -105,6 +119,7 @@
|
|
|
105
119
|
"@types/babel__core": "^7.20.5",
|
|
106
120
|
"@types/jest": "^30.0.0",
|
|
107
121
|
"@types/node": "^22.9.0",
|
|
122
|
+
"@types/react": "^19.0.0",
|
|
108
123
|
"@types/node-fetch": "^2.6.11",
|
|
109
124
|
"@types/webpack": "^5.28.5",
|
|
110
125
|
"babel-jest": "^30.2.0",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|