-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added tests for existing functionality * work on tests * added tests for defer * fixed handle example * work on handle * added support for handle * skipped hydratefallback test * support root exports * work on links function * support for links functions * removed debugger * added reoking of route when exportNames change --------- Co-authored-by: Nadav Abrahami <[email protected]>
- Loading branch information
Showing
7 changed files
with
515 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-argument */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-return */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export const createHandleProxy = () => { | ||
const lastLoadedHandleRef: { current: any } = { current: null }; | ||
const handle = new Proxy({}, { | ||
get: (_, prop) => { | ||
return lastLoadedHandleRef.current?.[prop] as unknown; | ||
}, | ||
apply(_, thisArg, argArray) { | ||
return lastLoadedHandleRef.current?.apply(thisArg, argArray); | ||
}, | ||
construct(_, argArray) { | ||
return new lastLoadedHandleRef.current(...argArray); | ||
}, | ||
defineProperty(_, property, attributes) { | ||
return Object.defineProperty(lastLoadedHandleRef.current, property, attributes); | ||
}, | ||
deleteProperty(_, p) { | ||
return delete lastLoadedHandleRef.current[p]; | ||
}, | ||
getOwnPropertyDescriptor(_, p) { | ||
return Object.getOwnPropertyDescriptor(lastLoadedHandleRef.current, p); | ||
}, | ||
getPrototypeOf(_) { | ||
return Object.getPrototypeOf(lastLoadedHandleRef.current); | ||
}, | ||
has(_, p) { | ||
return p in lastLoadedHandleRef.current; | ||
}, | ||
isExtensible(_) { | ||
return Object.isExtensible(lastLoadedHandleRef.current); | ||
}, | ||
ownKeys(_) { | ||
return Object.keys(lastLoadedHandleRef.current) | ||
}, | ||
preventExtensions(_) { | ||
return Object.preventExtensions(lastLoadedHandleRef.current); | ||
}, | ||
set(_, p, newValue) { | ||
lastLoadedHandleRef.current[p] = newValue; | ||
return true; | ||
}, | ||
setPrototypeOf(_, v) { | ||
return Object.setPrototypeOf(lastLoadedHandleRef.current, v); | ||
}, | ||
|
||
|
||
}); | ||
return { | ||
handle, | ||
setHandle: (handle: any) => { | ||
lastLoadedHandleRef.current = handle; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { LinksFunction } from "@remix-run/node"; | ||
|
||
export const createLinksProxy = () => { | ||
const lastLoadedLinks: { current: null | LinksFunction } = { current: null }; | ||
const linksWrapper = ()=>{ | ||
if(lastLoadedLinks.current){ | ||
return lastLoadedLinks.current(); | ||
} | ||
return []; | ||
} | ||
return { | ||
linksWrapper, | ||
setLinks: (linksFunction: LinksFunction) => { | ||
lastLoadedLinks.current = linksFunction; | ||
} | ||
}; | ||
} |
Oops, something went wrong.