vike 0.4.229-commit-c3526d6 → 0.4.229-commit-847f1b6

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.
@@ -19,14 +19,13 @@ function getTrapGet(obj, objName, skipOnInternalProp, fallback) {
19
19
  return function (_, prop) {
20
20
  const propStr = String(prop);
21
21
  if (prop === '_isProxyObject')
22
- return { target: obj };
22
+ return true;
23
23
  if (!skipOnInternalProp)
24
24
  onInternalProp(propStr, objName);
25
- if (fallback) {
25
+ if (fallback && !(prop in obj)) {
26
26
  // Rudimentary flat pageContext implementation https://github.com/vikejs/vike/issues/1268
27
27
  // Failed full-fledged implementation: https://github.com/vikejs/vike/pull/2458
28
- if (!(prop in obj))
29
- return fallback(prop);
28
+ return fallback(prop);
30
29
  }
31
30
  const val = obj[prop];
32
31
  onNotSerializable(propStr, val, objName);
@@ -115,7 +115,7 @@ function execHookAsync(hookFnCaller, hook, pageContextForPublicUsage) {
115
115
  }, timeoutErr);
116
116
  (async () => {
117
117
  try {
118
- providePageContext(pageContextForPublicUsage);
118
+ providePageContextInternal(pageContextForPublicUsage);
119
119
  const ret = await hookFnCaller();
120
120
  resolve(ret);
121
121
  }
@@ -130,7 +130,7 @@ function execHookAsync(hookFnCaller, hook, pageContextForPublicUsage) {
130
130
  }
131
131
  function execHookSync(hook, pageContext, preparePageContextForPublicUsage) {
132
132
  const pageContextForPublicUsage = preparePageContextForPublicUsage(pageContext);
133
- providePageContext(pageContextForPublicUsage);
133
+ providePageContextInternal(pageContextForPublicUsage);
134
134
  const hookReturn = hook.hookFn(pageContextForPublicUsage);
135
135
  return { hookReturn };
136
136
  }
@@ -145,8 +145,11 @@ function isNotDisabled(timeout) {
145
145
  function getPageContext() {
146
146
  const { pageContext } = globalObject;
147
147
  if (!pageContext)
148
- return pageContext;
149
- const pageContextForPublicUsage = (0, preparePageContextForPublicUsage_js_1.preparePageContextForPublicUsage)(pageContext);
148
+ return null;
149
+ const pageContextForPublicUsage = pageContext._isProxyObject
150
+ ? // providePageContext() is called on the user-land (e.g. it's called by `vike-{react,vue,solid}`) thus it's already a proxy
151
+ pageContext
152
+ : (0, preparePageContextForPublicUsage_js_1.preparePageContextForPublicUsage)(pageContext);
150
153
  return pageContextForPublicUsage;
151
154
  }
152
155
  /**
@@ -155,9 +158,9 @@ function getPageContext() {
155
158
  * https://vike.dev/getPageContext
156
159
  */
157
160
  function providePageContext(pageContext) {
158
- // providePageContext() can be called in the user-land (e.g. it's called by `vike-{react,vue,solid}`) thus we need to unwrap the proxy.
159
- if (pageContext?._isProxyObject)
160
- pageContext = pageContext._isProxyObject.target;
161
+ providePageContextInternal(pageContext);
162
+ }
163
+ function providePageContextInternal(pageContext) {
161
164
  globalObject.pageContext = pageContext;
162
165
  // Promise.resolve() is quicker than process.nextTick() and setImmediate()
163
166
  // https://stackoverflow.com/questions/67949576/process-nexttick-before-promise-resolve-then
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = void 0;
4
4
  // Automatically updated by @brillout/release-me
5
- exports.PROJECT_VERSION = '0.4.229-commit-c3526d6';
5
+ exports.PROJECT_VERSION = '0.4.229-commit-847f1b6';
@@ -17,14 +17,13 @@ function getTrapGet(obj, objName, skipOnInternalProp, fallback) {
17
17
  return function (_, prop) {
18
18
  const propStr = String(prop);
19
19
  if (prop === '_isProxyObject')
20
- return { target: obj };
20
+ return true;
21
21
  if (!skipOnInternalProp)
22
22
  onInternalProp(propStr, objName);
23
- if (fallback) {
23
+ if (fallback && !(prop in obj)) {
24
24
  // Rudimentary flat pageContext implementation https://github.com/vikejs/vike/issues/1268
25
25
  // Failed full-fledged implementation: https://github.com/vikejs/vike/pull/2458
26
- if (!(prop in obj))
27
- return fallback(prop);
26
+ return fallback(prop);
28
27
  }
29
28
  const val = obj[prop];
30
29
  onNotSerializable(propStr, val, objName);
@@ -60,4 +60,4 @@ declare function getPageContext<PageContext = PageContextClient | PageContextSer
60
60
  *
61
61
  * https://vike.dev/getPageContext
62
62
  */
63
- declare function providePageContext(pageContext: null | PageContextPrepareMinimum): void;
63
+ declare function providePageContext(pageContext: null | PageContextClient | PageContextServer): void;
@@ -113,7 +113,7 @@ function execHookAsync(hookFnCaller, hook, pageContextForPublicUsage) {
113
113
  }, timeoutErr);
114
114
  (async () => {
115
115
  try {
116
- providePageContext(pageContextForPublicUsage);
116
+ providePageContextInternal(pageContextForPublicUsage);
117
117
  const ret = await hookFnCaller();
118
118
  resolve(ret);
119
119
  }
@@ -128,7 +128,7 @@ function execHookAsync(hookFnCaller, hook, pageContextForPublicUsage) {
128
128
  }
129
129
  function execHookSync(hook, pageContext, preparePageContextForPublicUsage) {
130
130
  const pageContextForPublicUsage = preparePageContextForPublicUsage(pageContext);
131
- providePageContext(pageContextForPublicUsage);
131
+ providePageContextInternal(pageContextForPublicUsage);
132
132
  const hookReturn = hook.hookFn(pageContextForPublicUsage);
133
133
  return { hookReturn };
134
134
  }
@@ -143,8 +143,11 @@ function isNotDisabled(timeout) {
143
143
  function getPageContext() {
144
144
  const { pageContext } = globalObject;
145
145
  if (!pageContext)
146
- return pageContext;
147
- const pageContextForPublicUsage = preparePageContextForPublicUsage(pageContext);
146
+ return null;
147
+ const pageContextForPublicUsage = pageContext._isProxyObject
148
+ ? // providePageContext() is called on the user-land (e.g. it's called by `vike-{react,vue,solid}`) thus it's already a proxy
149
+ pageContext
150
+ : preparePageContextForPublicUsage(pageContext);
148
151
  return pageContextForPublicUsage;
149
152
  }
150
153
  /**
@@ -153,9 +156,9 @@ function getPageContext() {
153
156
  * https://vike.dev/getPageContext
154
157
  */
155
158
  function providePageContext(pageContext) {
156
- // providePageContext() can be called in the user-land (e.g. it's called by `vike-{react,vue,solid}`) thus we need to unwrap the proxy.
157
- if (pageContext?._isProxyObject)
158
- pageContext = pageContext._isProxyObject.target;
159
+ providePageContextInternal(pageContext);
160
+ }
161
+ function providePageContextInternal(pageContext) {
159
162
  globalObject.pageContext = pageContext;
160
163
  // Promise.resolve() is quicker than process.nextTick() and setImmediate()
161
164
  // https://stackoverflow.com/questions/67949576/process-nexttick-before-promise-resolve-then
@@ -6,9 +6,6 @@ type PageContextPrepareMinimum = {
6
6
  _isOriginalObject: true;
7
7
  isPageContext: true;
8
8
  _globalContext: GlobalContextPrepareMinimum;
9
- _isProxyObject?: {
10
- target: PageContextPrepareMinimum;
11
- };
12
9
  };
13
10
  declare function preparePageContextForPublicUsage<PageContext extends PageContextPrepareMinimum>(pageContext: PageContext): PageContext;
14
11
  declare function assertPropertyGetters(pageContext: Record<string, unknown>): void;
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.229-commit-c3526d6";
1
+ export declare const PROJECT_VERSION: "0.4.229-commit-847f1b6";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.229-commit-c3526d6';
2
+ export const PROJECT_VERSION = '0.4.229-commit-847f1b6';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.229-commit-c3526d6",
3
+ "version": "0.4.229-commit-847f1b6",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {