@remix-run/router 0.0.0-experimental-cffa549a1 → 0.0.0-experimental-9ffbba722
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/index.d.ts +1 -1
- package/dist/router.cjs.js +52 -9
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +2 -1
- package/dist/router.js +49 -10
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +52 -9
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +11 -1
- package/index.ts +1 -0
- package/package.json +1 -1
- package/router.ts +45 -3
- package/utils.ts +23 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, AgnosticRouteObject, DataStrategyFunction as unstable_DataStrategyFunction, DataStrategyFunctionArgs as unstable_DataStrategyFunctionArgs, DataStrategyMatch as unstable_DataStrategyMatch, ErrorResponse, FormEncType, FormMethod, HandlerResult as unstable_HandlerResult, HTMLFormMethod, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, AgnosticPatchRoutesOnMissFunction as unstable_AgnosticPatchRoutesOnMissFunction, PathMatch, PathParam, PathPattern, RedirectFunction, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, TrackedPromise, UIMatch, V7_FormMethod, } from "./utils";
|
|
2
|
-
export { AbortedDeferredError, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, redirectDocument, replace, resolvePath, resolveTo, stripBasename, } from "./utils";
|
|
2
|
+
export { AbortedDeferredError, data as unstable_data, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, redirectDocument, replace, resolvePath, resolveTo, stripBasename, } from "./utils";
|
|
3
3
|
export type { BrowserHistory, BrowserHistoryOptions, HashHistory, HashHistoryOptions, History, InitialEntry, Location, MemoryHistory, MemoryHistoryOptions, Path, To, } from "./history";
|
|
4
4
|
export { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, parsePath, } from "./history";
|
|
5
5
|
export * from "./router";
|
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-9ffbba722
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1327,6 +1327,23 @@ const json = function json(data, init) {
|
|
|
1327
1327
|
headers
|
|
1328
1328
|
}));
|
|
1329
1329
|
};
|
|
1330
|
+
class DataWithResponseInit {
|
|
1331
|
+
constructor(data, init) {
|
|
1332
|
+
this.type = "DataWithResponseInit";
|
|
1333
|
+
this.data = data;
|
|
1334
|
+
this.init = init || null;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* Create "responses" that contain `status`/`headers` without forcing
|
|
1340
|
+
* serialization into an actual `Response` - used by Remix single fetch
|
|
1341
|
+
*/
|
|
1342
|
+
function data(data, init) {
|
|
1343
|
+
return new DataWithResponseInit(data, typeof init === "number" ? {
|
|
1344
|
+
status: init
|
|
1345
|
+
} : init);
|
|
1346
|
+
}
|
|
1330
1347
|
class AbortedDeferredError extends Error {}
|
|
1331
1348
|
class DeferredData {
|
|
1332
1349
|
constructor(data, responseInit) {
|
|
@@ -4739,8 +4756,7 @@ async function callLoaderOrAction(type, request, match, manifest, mapRouteProper
|
|
|
4739
4756
|
async function convertHandlerResultToDataResult(handlerResult) {
|
|
4740
4757
|
let {
|
|
4741
4758
|
result,
|
|
4742
|
-
type
|
|
4743
|
-
status
|
|
4759
|
+
type
|
|
4744
4760
|
} = handlerResult;
|
|
4745
4761
|
if (isResponse(result)) {
|
|
4746
4762
|
let data;
|
|
@@ -4779,25 +4795,47 @@ async function convertHandlerResultToDataResult(handlerResult) {
|
|
|
4779
4795
|
};
|
|
4780
4796
|
}
|
|
4781
4797
|
if (type === ResultType.error) {
|
|
4798
|
+
if (isDataWithResponseInit(result)) {
|
|
4799
|
+
var _result$init2;
|
|
4800
|
+
if (result.data instanceof Error) {
|
|
4801
|
+
var _result$init;
|
|
4802
|
+
return {
|
|
4803
|
+
type: ResultType.error,
|
|
4804
|
+
error: result.data,
|
|
4805
|
+
statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status
|
|
4806
|
+
};
|
|
4807
|
+
}
|
|
4808
|
+
|
|
4809
|
+
// Convert thrown unstable_data() to ErrorResponse instances
|
|
4810
|
+
result = new ErrorResponseImpl(((_result$init2 = result.init) == null ? void 0 : _result$init2.status) || 500, undefined, result.data);
|
|
4811
|
+
}
|
|
4782
4812
|
return {
|
|
4783
4813
|
type: ResultType.error,
|
|
4784
4814
|
error: result,
|
|
4785
|
-
statusCode: isRouteErrorResponse(result) ? result.status :
|
|
4815
|
+
statusCode: isRouteErrorResponse(result) ? result.status : undefined
|
|
4786
4816
|
};
|
|
4787
4817
|
}
|
|
4788
4818
|
if (isDeferredData(result)) {
|
|
4789
|
-
var _result$
|
|
4819
|
+
var _result$init3, _result$init4;
|
|
4790
4820
|
return {
|
|
4791
4821
|
type: ResultType.deferred,
|
|
4792
4822
|
deferredData: result,
|
|
4793
|
-
statusCode: (_result$
|
|
4794
|
-
headers: ((_result$
|
|
4823
|
+
statusCode: (_result$init3 = result.init) == null ? void 0 : _result$init3.status,
|
|
4824
|
+
headers: ((_result$init4 = result.init) == null ? void 0 : _result$init4.headers) && new Headers(result.init.headers)
|
|
4825
|
+
};
|
|
4826
|
+
}
|
|
4827
|
+
if (isDataWithResponseInit(result)) {
|
|
4828
|
+
var _result$init5, _result$init6;
|
|
4829
|
+
return {
|
|
4830
|
+
type: ResultType.data,
|
|
4831
|
+
data: result.data,
|
|
4832
|
+
statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status,
|
|
4833
|
+
headers: (_result$init6 = result.init) != null && _result$init6.headers ? new Headers(result.init.headers) : undefined
|
|
4795
4834
|
};
|
|
4796
4835
|
}
|
|
4797
4836
|
return {
|
|
4798
4837
|
type: ResultType.data,
|
|
4799
|
-
data: result
|
|
4800
|
-
statusCode: status
|
|
4838
|
+
data: result
|
|
4801
4839
|
};
|
|
4802
4840
|
}
|
|
4803
4841
|
|
|
@@ -5160,6 +5198,9 @@ function isErrorResult(result) {
|
|
|
5160
5198
|
function isRedirectResult(result) {
|
|
5161
5199
|
return (result && result.type) === ResultType.redirect;
|
|
5162
5200
|
}
|
|
5201
|
+
function isDataWithResponseInit(value) {
|
|
5202
|
+
return typeof value === "object" && value != null && "type" in value && "data" in value && "init" in value && value.type === "DataWithResponseInit";
|
|
5203
|
+
}
|
|
5163
5204
|
function isDeferredData(value) {
|
|
5164
5205
|
let deferred = value;
|
|
5165
5206
|
return deferred && typeof deferred === "object" && typeof deferred.data === "object" && typeof deferred.subscribe === "function" && typeof deferred.cancel === "function" && typeof deferred.resolveData === "function";
|
|
@@ -5436,6 +5477,7 @@ exports.defer = defer;
|
|
|
5436
5477
|
exports.generatePath = generatePath;
|
|
5437
5478
|
exports.getStaticContextFromError = getStaticContextFromError;
|
|
5438
5479
|
exports.getToPathname = getToPathname;
|
|
5480
|
+
exports.isDataWithResponseInit = isDataWithResponseInit;
|
|
5439
5481
|
exports.isDeferredData = isDeferredData;
|
|
5440
5482
|
exports.isRouteErrorResponse = isRouteErrorResponse;
|
|
5441
5483
|
exports.joinPaths = joinPaths;
|
|
@@ -5450,4 +5492,5 @@ exports.replace = replace;
|
|
|
5450
5492
|
exports.resolvePath = resolvePath;
|
|
5451
5493
|
exports.resolveTo = resolveTo;
|
|
5452
5494
|
exports.stripBasename = stripBasename;
|
|
5495
|
+
exports.unstable_data = data;
|
|
5453
5496
|
//# sourceMappingURL=router.cjs.js.map
|