@modern-js/runtime 2.60.2 → 2.60.4

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.
@@ -110,10 +110,15 @@ class LoadableCollector {
110
110
  nonce,
111
111
  ...scriptLoadingAtr
112
112
  }));
113
+ const jsScriptRegExp = /<script .*?src="([^"]+)".*?>/g;
114
+ const matchs = template.matchAll(jsScriptRegExp);
115
+ const existedScript = [];
116
+ for (const match of matchs) {
117
+ existedScript.push(match[1]);
118
+ }
113
119
  const scripts = await Promise.all(chunks.filter((chunk) => {
114
120
  var _this_existsAssets;
115
- const jsChunkReg = new RegExp(`<script .*src="${chunk.url}".*>`);
116
- return !jsChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
121
+ return !existedScript.includes(chunk.url) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
117
122
  }).map(async (chunk) => {
118
123
  const script = `<script${attributes} src="${chunk.url}"></script>`;
119
124
  if ((0, import_utils.checkIsNode)() && checkIsInline(chunk, enableInlineScripts)) {
@@ -130,10 +135,15 @@ class LoadableCollector {
130
135
  const { template, chunkSet, config } = this.options;
131
136
  const { enableInlineStyles } = config;
132
137
  const atrributes = (0, import_utils.attributesToString)(this.generateAttributes());
138
+ const linkRegExp = /<link .*?href="([^"]+)".*?>/g;
139
+ const matchs = template.matchAll(linkRegExp);
140
+ const existedLinks = [];
141
+ for (const match of matchs) {
142
+ existedLinks.push(match[1]);
143
+ }
133
144
  const css = await Promise.all(chunks.filter((chunk) => {
134
145
  var _this_existsAssets;
135
- const cssChunkReg = new RegExp(`<link .*href="${chunk.url}".*>`);
136
- return !cssChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
146
+ return !existedLinks.includes(chunk.url) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
137
147
  }).map(async (chunk) => {
138
148
  const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
139
149
  if ((0, import_utils.checkIsNode)() && checkIsInline(chunk, enableInlineStyles)) {
@@ -133,7 +133,7 @@ var LoadableCollector = /* @__PURE__ */ function() {
133
133
  _proto.emitScriptAssets = function emitScriptAssets(chunks) {
134
134
  var _this = this;
135
135
  return _async_to_generator(function() {
136
- var _this_options, template, nonce, chunkSet, config, _config_scriptLoading, scriptLoading, enableInlineScripts, scriptLoadingAtr, attributes, scripts;
136
+ var _this_options, template, nonce, chunkSet, config, _config_scriptLoading, scriptLoading, enableInlineScripts, scriptLoadingAtr, attributes, jsScriptRegExp, matchs, existedScript, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, match, scripts;
137
137
  return _ts_generator(this, function(_state) {
138
138
  switch (_state.label) {
139
139
  case 0:
@@ -147,12 +147,34 @@ var LoadableCollector = /* @__PURE__ */ function() {
147
147
  attributes = attributesToString(_this.generateAttributes(_object_spread({
148
148
  nonce
149
149
  }, scriptLoadingAtr)));
150
+ jsScriptRegExp = /<script .*?src="([^"]+)".*?>/g;
151
+ matchs = template.matchAll(jsScriptRegExp);
152
+ existedScript = [];
153
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
154
+ try {
155
+ for (_iterator = matchs[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
156
+ match = _step.value;
157
+ existedScript.push(match[1]);
158
+ }
159
+ } catch (err) {
160
+ _didIteratorError = true;
161
+ _iteratorError = err;
162
+ } finally {
163
+ try {
164
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
165
+ _iterator.return();
166
+ }
167
+ } finally {
168
+ if (_didIteratorError) {
169
+ throw _iteratorError;
170
+ }
171
+ }
172
+ }
150
173
  return [
151
174
  4,
152
175
  Promise.all(chunks.filter(function(chunk) {
153
176
  var _this_existsAssets;
154
- var jsChunkReg = new RegExp('<script .*src="'.concat(chunk.url, '".*>'));
155
- return !jsChunkReg.test(template) && !((_this_existsAssets = _this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
177
+ return !existedScript.includes(chunk.url) && !((_this_existsAssets = _this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
156
178
  }).map(function() {
157
179
  var _ref = _async_to_generator(function(chunk) {
158
180
  var script;
@@ -198,19 +220,41 @@ var LoadableCollector = /* @__PURE__ */ function() {
198
220
  _proto.emitStyleAssets = function emitStyleAssets(chunks) {
199
221
  var _this = this;
200
222
  return _async_to_generator(function() {
201
- var _this_options, template, chunkSet, config, enableInlineStyles, atrributes, css;
223
+ var _this_options, template, chunkSet, config, enableInlineStyles, atrributes, linkRegExp, matchs, existedLinks, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, match, css;
202
224
  return _ts_generator(this, function(_state) {
203
225
  switch (_state.label) {
204
226
  case 0:
205
227
  _this_options = _this.options, template = _this_options.template, chunkSet = _this_options.chunkSet, config = _this_options.config;
206
228
  enableInlineStyles = config.enableInlineStyles;
207
229
  atrributes = attributesToString(_this.generateAttributes());
230
+ linkRegExp = /<link .*?href="([^"]+)".*?>/g;
231
+ matchs = template.matchAll(linkRegExp);
232
+ existedLinks = [];
233
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
234
+ try {
235
+ for (_iterator = matchs[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
236
+ match = _step.value;
237
+ existedLinks.push(match[1]);
238
+ }
239
+ } catch (err) {
240
+ _didIteratorError = true;
241
+ _iteratorError = err;
242
+ } finally {
243
+ try {
244
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
245
+ _iterator.return();
246
+ }
247
+ } finally {
248
+ if (_didIteratorError) {
249
+ throw _iteratorError;
250
+ }
251
+ }
252
+ }
208
253
  return [
209
254
  4,
210
255
  Promise.all(chunks.filter(function(chunk) {
211
256
  var _this_existsAssets;
212
- var cssChunkReg = new RegExp('<link .*href="'.concat(chunk.url, '".*>'));
213
- return !cssChunkReg.test(template) && !((_this_existsAssets = _this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
257
+ return !existedLinks.includes(chunk.url) && !((_this_existsAssets = _this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
214
258
  }).map(function() {
215
259
  var _ref = _async_to_generator(function(chunk) {
216
260
  var link;
@@ -77,10 +77,15 @@ class LoadableCollector {
77
77
  nonce,
78
78
  ...scriptLoadingAtr
79
79
  }));
80
+ const jsScriptRegExp = /<script .*?src="([^"]+)".*?>/g;
81
+ const matchs = template.matchAll(jsScriptRegExp);
82
+ const existedScript = [];
83
+ for (const match of matchs) {
84
+ existedScript.push(match[1]);
85
+ }
80
86
  const scripts = await Promise.all(chunks.filter((chunk) => {
81
87
  var _this_existsAssets;
82
- const jsChunkReg = new RegExp(`<script .*src="${chunk.url}".*>`);
83
- return !jsChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
88
+ return !existedScript.includes(chunk.url) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
84
89
  }).map(async (chunk) => {
85
90
  const script = `<script${attributes} src="${chunk.url}"></script>`;
86
91
  if (checkIsNode() && checkIsInline(chunk, enableInlineScripts)) {
@@ -97,10 +102,15 @@ class LoadableCollector {
97
102
  const { template, chunkSet, config } = this.options;
98
103
  const { enableInlineStyles } = config;
99
104
  const atrributes = attributesToString(this.generateAttributes());
105
+ const linkRegExp = /<link .*?href="([^"]+)".*?>/g;
106
+ const matchs = template.matchAll(linkRegExp);
107
+ const existedLinks = [];
108
+ for (const match of matchs) {
109
+ existedLinks.push(match[1]);
110
+ }
100
111
  const css = await Promise.all(chunks.filter((chunk) => {
101
112
  var _this_existsAssets;
102
- const cssChunkReg = new RegExp(`<link .*href="${chunk.url}".*>`);
103
- return !cssChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
113
+ return !existedLinks.includes(chunk.url) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
104
114
  }).map(async (chunk) => {
105
115
  const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
106
116
  if (checkIsNode() && checkIsInline(chunk, enableInlineStyles)) {
@@ -11,7 +11,7 @@ export type CreateAppOptions = {
11
11
  runtime?: typeof runtime;
12
12
  props?: any;
13
13
  };
14
- export declare const createApp: ({ plugins, runtime, props: globalProps, }: CreateAppOptions) => (App?: React.ComponentType<any>) => (props: any) => JSX.Element;
14
+ export declare const createApp: ({ plugins, runtime, props: globalProps, }: CreateAppOptions) => (App?: React.ComponentType<any>) => (props: any) => React.JSX.Element;
15
15
  type BootStrap<T = unknown> = (App: React.ComponentType, id: string | HTMLElement | RuntimeContext, root?: any, ReactDOM?: {
16
16
  render?: Renderer;
17
17
  hydrate?: Renderer;
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare const NoSSRCache: () => JSX.Element;
1
+ import React from 'react';
2
+ export declare const NoSSRCache: () => React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare function Body(props: React.DOMAttributes<HTMLBodyElement>): JSX.Element;
2
+ export declare function Body(props: React.DOMAttributes<HTMLBodyElement>): React.JSX.Element;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  export declare function Comment(props: {
3
3
  comment?: string;
4
4
  children?: string;
5
- }): JSX.Element;
5
+ }): React.JSX.Element;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  export declare function Head(props: {
3
3
  children?: any;
4
- }): JSX.Element;
5
- export declare function DefaultHead(): JSX.Element;
4
+ }): React.JSX.Element;
5
+ export declare function DefaultHead(): React.JSX.Element;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  export declare function Html(props: {
3
3
  children: any[];
4
- } & React.HtmlHTMLAttributes<HTMLHtmlElement>): JSX.Element;
4
+ } & React.HtmlHTMLAttributes<HTMLHtmlElement>): React.JSX.Element;
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare function Links(): JSX.Element;
1
+ import React from 'react';
2
+ export declare function Links(): React.JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  export declare function Root(props: {
3
3
  rootId?: string;
4
- } & React.DOMAttributes<HTMLDivElement>): JSX.Element;
4
+ } & React.DOMAttributes<HTMLDivElement>): React.JSX.Element;
5
5
  export declare function DefaultRoot(props: {
6
6
  children?: any;
7
- }): JSX.Element;
7
+ }): React.JSX.Element;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  export declare function Script(props: {
3
3
  content: () => void;
4
- }): JSX.Element;
4
+ }): React.JSX.Element;
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare function Scripts(): JSX.Element;
1
+ import React from 'react';
2
+ export declare function Scripts(): React.JSX.Element;
@@ -2,4 +2,4 @@ import React from 'react';
2
2
  export declare function Style(props: {
3
3
  children?: string;
4
4
  content?: string;
5
- } & React.DOMAttributes<HTMLStyleElement>): JSX.Element;
5
+ } & React.DOMAttributes<HTMLStyleElement>): React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  /// <reference types="react" />
2
- export declare function Title(): JSX.Element;
2
+ export declare function Title(): import("react").JSX.Element;
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare const DefaultNotFound: () => JSX.Element;
1
+ import React from 'react';
2
+ export declare const DefaultNotFound: () => React.JSX.Element;
@@ -7,5 +7,5 @@ import type { StaticHandlerContext } from '@modern-js/runtime-utils/remix-router
7
7
  declare const DeferredDataScripts: (props?: {
8
8
  nonce?: string;
9
9
  context: StaticHandlerContext;
10
- }) => JSX.Element | null;
10
+ }) => import("react").JSX.Element | null;
11
11
  export default DeferredDataScripts;
@@ -7,4 +7,4 @@ export interface WithRouterProps<Params extends {
7
7
  params: Params;
8
8
  navigate: ReturnType<typeof useNavigate>;
9
9
  }
10
- export declare const withRouter: <Props extends WithRouterProps<{}>>(Component: React.ComponentType<Props>) => (props: Omit<Props, keyof WithRouterProps<{}>>) => JSX.Element;
10
+ export declare const withRouter: <Props extends WithRouterProps<{}>>(Component: React.ComponentType<Props>) => (props: Omit<Props, keyof WithRouterProps<{}>>) => React.JSX.Element;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.60.2",
18
+ "version": "2.60.4",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -190,7 +190,7 @@
190
190
  "@types/loadable__component": "^5.13.4",
191
191
  "@types/react-helmet": "^6.1.2",
192
192
  "@types/styled-components": "^5.1.14",
193
- "cookie": "0.5.0",
193
+ "cookie": "0.7.2",
194
194
  "es-module-lexer": "^1.1.0",
195
195
  "esbuild": "0.17.19",
196
196
  "invariant": "^2.2.4",
@@ -199,11 +199,11 @@
199
199
  "react-is": "^18",
200
200
  "react-side-effect": "^2.1.1",
201
201
  "styled-components": "^5.3.1",
202
- "@modern-js/plugin-data-loader": "2.60.2",
203
- "@modern-js/plugin": "2.60.2",
204
- "@modern-js/runtime-utils": "2.60.2",
205
- "@modern-js/utils": "2.60.2",
206
- "@modern-js/types": "2.60.2"
202
+ "@modern-js/plugin": "2.60.4",
203
+ "@modern-js/plugin-data-loader": "2.60.4",
204
+ "@modern-js/runtime-utils": "2.60.4",
205
+ "@modern-js/types": "2.60.4",
206
+ "@modern-js/utils": "2.60.4"
207
207
  },
208
208
  "peerDependencies": {
209
209
  "react": ">=17",
@@ -211,7 +211,7 @@
211
211
  },
212
212
  "devDependencies": {
213
213
  "@remix-run/web-fetch": "^4.1.3",
214
- "@rsbuild/core": "1.0.7",
214
+ "@rsbuild/core": "~1.0.11",
215
215
  "@testing-library/react": "^13.4.0",
216
216
  "@types/cookie": "0.6.0",
217
217
  "@types/invariant": "^2.2.30",
@@ -225,11 +225,11 @@
225
225
  "react-dom": "^18",
226
226
  "ts-jest": "^29.1.0",
227
227
  "typescript": "^5",
228
- "webpack": "^5.94.0",
229
- "@modern-js/core": "2.60.2",
230
- "@scripts/jest-config": "2.60.2",
231
- "@scripts/build": "2.60.2",
232
- "@modern-js/app-tools": "2.60.2"
228
+ "webpack": "^5.95.0",
229
+ "@modern-js/app-tools": "2.60.4",
230
+ "@scripts/build": "2.60.4",
231
+ "@modern-js/core": "2.60.4",
232
+ "@scripts/jest-config": "2.60.4"
233
233
  },
234
234
  "sideEffects": false,
235
235
  "publishConfig": {