File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
3+ import { useContext } from "react" ;
4+ import { replexicaContext } from "./context" ;
5+ import { ReplexicaChunkGetterArgs , ReplexicaChunkProps } from "../types" ;
6+
7+ export function ReplexicaClientChunk ( props : ReplexicaChunkProps ) {
8+ const r = useContext ( replexicaContext ) ! ;
9+
10+ const result = getReplexicaChunkContent ( {
11+ data : r . data ,
12+ selector : props ,
13+ } ) ;
14+
15+ return result ;
16+ }
17+
18+ export function getReplexicaChunkContent ( args : ReplexicaChunkGetterArgs ) {
19+ const fileData = args . data ?. [ args . selector . fileId ] ;
20+ const scopeData = fileData ?. [ args . selector . scopeId ] ;
21+ const chunkData = scopeData ?. [ args . selector . chunkId ] ;
22+
23+ const fallback = `chunk#${ args . selector . fileId } :${ args . selector . scopeId } .${ args . selector . chunkId } ` ;
24+
25+ const result = chunkData || fallback ;
26+
27+ return result ;
28+ }
Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
3+ import { createContext } from "react" ;
4+
5+ export type ReplexicaIntlContext = {
6+ data : any ;
7+ } ;
8+
9+ export const replexicaContext = createContext < ReplexicaIntlContext | null > ( null ) ;
Original file line number Diff line number Diff line change 1+ export * from './provider' ;
2+ export * from './chunk' ;
3+ export * from './proxy' ;
Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
3+ import { useMemo } from "react" ;
4+ import { replexicaContext } from './context' ;
5+
6+ export type ReplexicaIntlProviderProps = {
7+ data : any ;
8+ children ?: React . ReactNode ;
9+ } ;
10+
11+ export function ReplexicaIntlProvider ( props : ReplexicaIntlProviderProps ) {
12+ const value = useMemo ( getReplexicaValue , [ props . data ] ) ;
13+ return (
14+ < replexicaContext . Provider value = { value } >
15+ { props . children }
16+ </ replexicaContext . Provider >
17+ ) ;
18+
19+ function getReplexicaValue ( ) {
20+ return {
21+ data : props . data ,
22+ } ;
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
3+ import { createElement , useContext } from "react" ;
4+ import { ReplexicaChunkSelector , ReplexicaProxyProps } from "../types" ;
5+ import { replexicaContext } from "./context" ;
6+ import { getReplexicaChunkContent } from "./chunk" ;
7+
8+ export function ReplexicaClientProxy < P extends { } > ( props : ReplexicaProxyProps < P > ) {
9+ // const r = useContext(replexicaContext)!;
10+ // const data = r.data;
11+
12+ // const propsPatch: Partial<P> = Object
13+ // .entries(props.attributes || {})
14+ // .reduce((acc, [key, value]) => {
15+ // const result = getReplexicaChunkContent({
16+ // data: data,
17+ // selector: value as ReplexicaChunkSelector,
18+ // });
19+
20+ // return {
21+ // ...acc,
22+ // [key]: result,
23+ // };
24+ // }, {});
25+
26+ // const modifiedProps: P = {
27+ // ...props.targetProps,
28+ // ...propsPatch,
29+ // };
30+
31+ // return createElement(
32+ // props.target,
33+ // modifiedProps,
34+ // );
35+ return null ;
36+ }
Original file line number Diff line number Diff line change 1+ export const value = 42 ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ export type ReplexicaChunkSelector = {
2+ fileId : string ;
3+ scopeId : string ;
4+ chunkId : string ;
5+ } ;
6+
7+ export type ReplexicaChunkProps = ReplexicaChunkSelector ;
8+
9+ export type ReplexicaChunkGetterArgs = {
10+ data : any ;
11+ selector : ReplexicaChunkSelector ;
12+ } ;
13+
14+ export type ReplexicaProxyProps < P extends { } > = P & {
15+ __ReplexixcaComponent : string | React . ComponentType < P > ;
16+ __ReplexicaAttributes : Record < keyof P , ReplexicaChunkSelector > ;
17+ } ;
You can’t perform that action at this time.
0 commit comments