@timber-js/app 0.1.55 → 0.1.57
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/client/index.js +19 -42
- package/dist/client/index.js.map +1 -1
- package/dist/client/navigation-context.d.ts +5 -0
- package/dist/client/navigation-context.d.ts.map +1 -1
- package/dist/client/top-loader.d.ts +58 -0
- package/dist/client/top-loader.d.ts.map +1 -0
- package/dist/client/transition-root.d.ts +3 -1
- package/dist/client/transition-root.d.ts.map +1 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -150
- package/dist/index.js.map +1 -1
- package/dist/plugins/chunks.d.ts +20 -39
- package/dist/plugins/chunks.d.ts.map +1 -1
- package/dist/plugins/entries.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client/browser-entry.ts +1 -1
- package/src/client/navigation-context.ts +16 -47
- package/src/client/top-loader.tsx +196 -0
- package/src/client/transition-root.tsx +11 -3
- package/src/index.ts +27 -2
- package/src/plugins/chunks.ts +20 -195
- package/src/plugins/entries.ts +1 -0
package/dist/client/index.js
CHANGED
|
@@ -93,33 +93,25 @@ function useLinkStatus() {
|
|
|
93
93
|
* that depend on these APIs are safe to call from any environment —
|
|
94
94
|
* they return null or no-op when the APIs aren't available.
|
|
95
95
|
*
|
|
96
|
+
* Singleton guarantee: With the simplified chunking strategy (LOCAL-337),
|
|
97
|
+
* this module lives in exactly one client chunk. The previous globalThis +
|
|
98
|
+
* Symbol.for workaround for cross-chunk duplication is no longer needed.
|
|
99
|
+
* See design/27-chunking-strategy.md.
|
|
100
|
+
*
|
|
96
101
|
* See design/19-client-navigation.md §"NavigationContext"
|
|
97
102
|
*/
|
|
98
103
|
/**
|
|
99
104
|
* The context is created lazily to avoid calling createContext at module
|
|
100
105
|
* level. In the RSC environment, React.createContext doesn't exist —
|
|
101
106
|
* calling it at import time would crash the server.
|
|
102
|
-
*
|
|
103
|
-
* IMPORTANT: Context instances are stored on globalThis, NOT in module-
|
|
104
|
-
* level variables. The RSC client bundler duplicates this module across
|
|
105
|
-
* the browser-entry chunk (index) and client-reference chunk (shared-app)
|
|
106
|
-
* because both entry graphs import it. Module-level variables would create
|
|
107
|
-
* separate singleton instances per chunk — the provider in TransitionRoot
|
|
108
|
-
* (index chunk) would use context A while the consumer in LinkStatusProvider
|
|
109
|
-
* (shared-app chunk) reads from context B. globalThis guarantees a single
|
|
110
|
-
* instance regardless of how many times the module is duplicated.
|
|
111
|
-
*
|
|
112
|
-
* See design/19-client-navigation.md §"Singleton Context Guarantee"
|
|
113
107
|
*/
|
|
114
|
-
var
|
|
115
|
-
var
|
|
108
|
+
var _navCtx;
|
|
109
|
+
var _pendingNavCtx;
|
|
116
110
|
function getOrCreateContext() {
|
|
117
|
-
|
|
118
|
-
if (existing !== void 0) return existing;
|
|
111
|
+
if (_navCtx !== void 0) return _navCtx;
|
|
119
112
|
if (typeof React.createContext === "function") {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return ctx;
|
|
113
|
+
_navCtx = React.createContext(null);
|
|
114
|
+
return _navCtx;
|
|
123
115
|
}
|
|
124
116
|
}
|
|
125
117
|
/**
|
|
@@ -152,42 +144,27 @@ function NavigationProvider({ value, children }) {
|
|
|
152
144
|
* NavigationProvider with the correct params/pathname.
|
|
153
145
|
*
|
|
154
146
|
* This is NOT used by hooks directly — hooks read from React context.
|
|
155
|
-
*
|
|
156
|
-
* Stored on globalThis (like the context instances above) because the
|
|
157
|
-
* router lives in the shared-app chunk while renderRoot lives in the
|
|
158
|
-
* index chunk. Module-level variables would be separate per chunk.
|
|
159
147
|
*/
|
|
160
|
-
var
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
params: {},
|
|
165
|
-
pathname: "/"
|
|
166
|
-
} };
|
|
167
|
-
return g[NAV_STATE_KEY];
|
|
168
|
-
}
|
|
148
|
+
var _navState = {
|
|
149
|
+
params: {},
|
|
150
|
+
pathname: "/"
|
|
151
|
+
};
|
|
169
152
|
function setNavigationState(state) {
|
|
170
|
-
|
|
153
|
+
_navState = state;
|
|
171
154
|
}
|
|
172
155
|
function getNavigationState() {
|
|
173
|
-
return
|
|
156
|
+
return _navState;
|
|
174
157
|
}
|
|
175
158
|
/**
|
|
176
159
|
* Separate context for the in-flight navigation URL. Provided by
|
|
177
160
|
* TransitionRoot (urgent useState), consumed by LinkStatusProvider
|
|
178
161
|
* and useNavigationPending.
|
|
179
|
-
*
|
|
180
|
-
* Uses globalThis via Symbol.for for the same reason as NavigationContext
|
|
181
|
-
* above — the bundler duplicates this module across chunks, and module-
|
|
182
|
-
* level variables would create separate context instances.
|
|
183
162
|
*/
|
|
184
163
|
function getOrCreatePendingContext() {
|
|
185
|
-
|
|
186
|
-
if (existing !== void 0) return existing;
|
|
164
|
+
if (_pendingNavCtx !== void 0) return _pendingNavCtx;
|
|
187
165
|
if (typeof React.createContext === "function") {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return ctx;
|
|
166
|
+
_pendingNavCtx = React.createContext(null);
|
|
167
|
+
return _pendingNavCtx;
|
|
191
168
|
}
|
|
192
169
|
}
|
|
193
170
|
/**
|