@modern-js/plugin-data-loader 0.0.0-next-1686216166331 → 0.0.0-next-1686226316243

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/CHANGELOG.md CHANGED
@@ -1,15 +1,18 @@
1
1
  # @modern-js/plugin-data-loader
2
2
 
3
- ## 0.0.0-next-1686216166331
3
+ ## 0.0.0-next-1686226316243
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 1da359d893: chore: publishConfig add provenance config
7
+ - 7e6fb5fc1: chore: publishConfig add provenance config
8
8
 
9
9
  chore: publishConfig 增加 provenance 配置
10
10
 
11
- - Updated dependencies [1da359d893]
12
- - @modern-js/utils@0.0.0-next-1686216166331
11
+ - a7a7ad779: chore: move some public code to the utils package
12
+ chore: 移动一些公共的代码到 utils 包
13
+ - Updated dependencies [7e6fb5fc1]
14
+ - Updated dependencies [a7a7ad779]
15
+ - @modern-js/utils@0.0.0-next-1686226316243
13
16
 
14
17
  ## 2.22.1
15
18
 
@@ -24,8 +24,8 @@ const _node = require("@remix-run/node");
24
24
  const _remixrouter = require("@modern-js/utils/runtime/remix-router");
25
25
  const _nestedroutes = require("@modern-js/utils/runtime/nested-routes");
26
26
  const _lodash = require("@modern-js/utils/lodash");
27
+ const _runtimenode = require("@modern-js/utils/runtime-node");
27
28
  const _constants = require("../common/constants");
28
- const _utils = require("../common/utils");
29
29
  const _response = require("./response");
30
30
  (0, _node.installGlobals)();
31
31
  const redirectStatusCodes = /* @__PURE__ */ new Set([
@@ -95,7 +95,7 @@ const sendLoaderResponse = async (res, nodeResponse) => {
95
95
  const handleRequest = async ({ context, serverRoutes, routes: routesConfig }) => {
96
96
  const { method, query } = context;
97
97
  const routeId = query[_constants.LOADER_ID_PARAM];
98
- const entry = (0, _utils.matchEntry)(context.path, serverRoutes);
98
+ const entry = (0, _runtimenode.matchEntry)(context.path, serverRoutes);
99
99
  if (!routeId || !entry) {
100
100
  return;
101
101
  }
@@ -13,13 +13,13 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
13
13
  const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
14
14
  const _fs = /* @__PURE__ */ _interop_require_default._(require("fs"));
15
15
  const _utils = require("@modern-js/utils");
16
- const _utils1 = require("../common/utils");
16
+ const _runtimenode = require("@modern-js/utils/runtime-node");
17
17
  const _default = () => ({
18
18
  name: "@modern-js/plugin-data-loader",
19
19
  setup: () => ({
20
20
  prepareLoaderHandler({ serverRoutes, distDir }) {
21
21
  return async (context) => {
22
- const entry = (0, _utils1.matchEntry)(context.path, serverRoutes);
22
+ const entry = (0, _runtimenode.matchEntry)(context.path, serverRoutes);
23
23
  if (!entry) {
24
24
  return;
25
25
  }
@@ -6,8 +6,8 @@ import { installGlobals, writeReadableStreamToWritable, Response as NodeResponse
6
6
  import { createStaticHandler, ErrorResponse, UNSAFE_DEFERRED_SYMBOL as DEFERRED_SYMBOL } from "@modern-js/utils/runtime/remix-router";
7
7
  import { transformNestedRoutes } from "@modern-js/utils/runtime/nested-routes";
8
8
  import { isPlainObject } from "@modern-js/utils/lodash";
9
+ import { matchEntry } from "@modern-js/utils/runtime-node";
9
10
  import { CONTENT_TYPE_DEFERRED, LOADER_ID_PARAM } from "../common/constants";
10
- import { matchEntry } from "../common/utils";
11
11
  import { createDeferredReadableStream } from "./response";
12
12
  installGlobals();
13
13
  var redirectStatusCodes = /* @__PURE__ */ new Set([
@@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "path";
4
4
  import fs from "fs";
5
5
  import { MAIN_ENTRY_NAME, SERVER_BUNDLE_DIRECTORY } from "@modern-js/utils";
6
- import { matchEntry } from "../common/utils";
6
+ import { matchEntry } from "@modern-js/utils/runtime-node";
7
7
  export default function() {
8
8
  return {
9
9
  name: "@modern-js/plugin-data-loader",
@@ -2,8 +2,8 @@ import { installGlobals, writeReadableStreamToWritable, Response as NodeResponse
2
2
  import { createStaticHandler, ErrorResponse, UNSAFE_DEFERRED_SYMBOL as DEFERRED_SYMBOL } from "@modern-js/utils/runtime/remix-router";
3
3
  import { transformNestedRoutes } from "@modern-js/utils/runtime/nested-routes";
4
4
  import { isPlainObject } from "@modern-js/utils/lodash";
5
+ import { matchEntry } from "@modern-js/utils/runtime-node";
5
6
  import { CONTENT_TYPE_DEFERRED, LOADER_ID_PARAM } from "../common/constants";
6
- import { matchEntry } from "../common/utils";
7
7
  import { createDeferredReadableStream } from "./response";
8
8
  installGlobals();
9
9
  const redirectStatusCodes = /* @__PURE__ */ new Set([
@@ -1,7 +1,7 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
3
  import { MAIN_ENTRY_NAME, SERVER_BUNDLE_DIRECTORY } from "@modern-js/utils";
4
- import { matchEntry } from "../common/utils";
4
+ import { matchEntry } from "@modern-js/utils/runtime-node";
5
5
  export default () => ({
6
6
  name: "@modern-js/plugin-data-loader",
7
7
  setup: () => ({
@@ -1,6 +1,6 @@
1
1
  import type { NestedRoute, ServerRoute } from '@modern-js/types';
2
2
  import { Response as NodeResponse } from '@remix-run/node';
3
- import { ServerContext } from '../common/utils';
3
+ import { ServerContext } from '@modern-js/utils/runtime-node';
4
4
  export declare function isRedirectResponse(status: number): boolean;
5
5
  export declare function isResponse(value: any): value is NodeResponse;
6
6
  export declare const handleRequest: ({
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-next-1686216166331",
18
+ "version": "0.0.0-next-1686226316243",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -59,7 +59,7 @@
59
59
  "path-to-regexp": "^6.2.0",
60
60
  "react-router-dom": "^6.8.1",
61
61
  "@swc/helpers": "0.5.1",
62
- "@modern-js/utils": "0.0.0-next-1686216166331"
62
+ "@modern-js/utils": "0.0.0-next-1686226316243"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@types/babel__core": "^7.20.0",
@@ -77,11 +77,11 @@
77
77
  "react": "^18",
78
78
  "react-dom": "^18",
79
79
  "react-router-dom": "^6.8.1",
80
- "@modern-js/types": "0.0.0-next-1686216166331",
81
- "@modern-js/server-core": "0.0.0-next-1686216166331",
82
- "@modern-js/core": "0.0.0-next-1686216166331",
83
- "@scripts/jest-config": "0.0.0-next-1686216166331",
84
- "@scripts/build": "0.0.0-next-1686216166331"
80
+ "@modern-js/server-core": "0.0.0-next-1686226316243",
81
+ "@modern-js/types": "0.0.0-next-1686226316243",
82
+ "@scripts/build": "0.0.0-next-1686226316243",
83
+ "@modern-js/core": "0.0.0-next-1686226316243",
84
+ "@scripts/jest-config": "0.0.0-next-1686226316243"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "react": ">=17.0.0",
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "matchEntry", {
6
- enumerable: true,
7
- get: function() {
8
- return matchEntry;
9
- }
10
- });
11
- function sortByUrlPath(entries) {
12
- entries.sort(function(a, b) {
13
- const length1 = a.urlPath.length;
14
- const length2 = b.urlPath.length;
15
- if (length1 < length2) {
16
- return 1;
17
- }
18
- if (length1 > length2) {
19
- return -1;
20
- }
21
- return 0;
22
- });
23
- return entries;
24
- }
25
- const matchEntry = (pathname, entries) => {
26
- sortByUrlPath(entries);
27
- return entries.find((entry) => pathname.startsWith(entry.urlPath));
28
- };
@@ -1,20 +0,0 @@
1
- function sortByUrlPath(entries) {
2
- entries.sort(function(a, b) {
3
- var length1 = a.urlPath.length;
4
- var length2 = b.urlPath.length;
5
- if (length1 < length2) {
6
- return 1;
7
- }
8
- if (length1 > length2) {
9
- return -1;
10
- }
11
- return 0;
12
- });
13
- return entries;
14
- }
15
- export var matchEntry = function(pathname, entries) {
16
- sortByUrlPath(entries);
17
- return entries.find(function(entry) {
18
- return pathname.startsWith(entry.urlPath);
19
- });
20
- };
@@ -1,18 +0,0 @@
1
- function sortByUrlPath(entries) {
2
- entries.sort(function(a, b) {
3
- const length1 = a.urlPath.length;
4
- const length2 = b.urlPath.length;
5
- if (length1 < length2) {
6
- return 1;
7
- }
8
- if (length1 > length2) {
9
- return -1;
10
- }
11
- return 0;
12
- });
13
- return entries;
14
- }
15
- export const matchEntry = (pathname, entries) => {
16
- sortByUrlPath(entries);
17
- return entries.find((entry) => pathname.startsWith(entry.urlPath));
18
- };
@@ -1,3 +0,0 @@
1
- import { ModernServerContext, ServerRoute } from '@modern-js/types';
2
- export type ServerContext = Pick<ModernServerContext, 'logger' | 'req' | 'res' | 'params' | 'headers' | 'method' | 'url' | 'host' | 'protocol' | 'origin' | 'href' | 'path' | 'query'>;
3
- export declare const matchEntry: (pathname: string, entries: ServerRoute[]) => ServerRoute | undefined;