vike 0.4.189 → 0.4.191

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.
@@ -53,7 +53,8 @@ function distFileNames() {
53
53
  }
54
54
  // Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
55
55
  if (id.endsWith('.css')) {
56
- if ((0, utils_js_1.isFilePathAbsolute)(id)) {
56
+ const userRootDir = config.root;
57
+ if (id.startsWith(userRootDir)) {
57
58
  (0, utils_js_1.assertPosixPath)(id);
58
59
  (0, getFilePath_js_1.assertModuleId)(id);
59
60
  let name;
@@ -65,10 +66,10 @@ function distFileNames() {
65
66
  const filePath = (0, getFilePath_js_1.getModuleFilePathAbsolute)(id, config);
66
67
  name = filePath;
67
68
  name = name.split('.').slice(0, -1).join('.'); // remove file extension
68
- name = name.split('/').join('_');
69
+ name = name.split('/').filter(Boolean).join('_');
69
70
  }
70
71
  // Make fileHash the same between local development and CI
71
- const idStable = path_1.default.posix.relative(config.root, id);
72
+ const idStable = path_1.default.posix.relative(userRootDir, id);
72
73
  // Don't remove `?` queries because each `id` should belong to a unique bundle.
73
74
  const hash = getIdHash(idStable);
74
75
  return `${name}-${hash}`;
@@ -76,13 +77,18 @@ function distFileNames() {
76
77
  else {
77
78
  let name;
78
79
  const isVirtualModule = id.match(/virtual:([^:]+):/);
79
- if (!isVirtualModule) {
80
- name = 'style';
81
- }
82
- else {
80
+ if (isVirtualModule) {
83
81
  name = isVirtualModule[1];
84
82
  (0, utils_js_1.assert)(name);
85
83
  }
84
+ else if (
85
+ // https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
86
+ id.startsWith('/__uno')) {
87
+ name = 'uno';
88
+ }
89
+ else {
90
+ name = 'style';
91
+ }
86
92
  const hash = getIdHash(id);
87
93
  return `${name}-${hash}`;
88
94
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPageContext = void 0;
3
+ exports.providePageContext = exports.getPageContext = void 0;
4
4
  var executeHook_js_1 = require("./hooks/executeHook.js");
5
5
  Object.defineProperty(exports, "getPageContext", { enumerable: true, get: function () { return executeHook_js_1.getPageContext; } });
6
+ Object.defineProperty(exports, "providePageContext", { enumerable: true, get: function () { return executeHook_js_1.providePageContext; } });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isUserHookError = exports.getPageContext = exports.executeHook = void 0;
3
+ exports.isUserHookError = exports.providePageContext = exports.getPageContext = exports.executeHook = void 0;
4
4
  const assert_js_1 = require("../../utils/assert.js");
5
5
  const getGlobalObject_js_1 = require("../../utils/getGlobalObject.js");
6
6
  const humanizeTime_js_1 = require("../../utils/humanizeTime.js");
@@ -72,6 +72,11 @@ function getPageContext() {
72
72
  return globalObject.pageContext;
73
73
  }
74
74
  exports.getPageContext = getPageContext;
75
+ /**
76
+ * Provide `pageContext` for universal hooks.
77
+ *
78
+ * https://vike.dev/getPageContext
79
+ */
75
80
  function providePageContext(pageContext) {
76
81
  globalObject.pageContext = pageContext;
77
82
  // Promise.resolve() is quicker than process.nextTick() and setImmediate()
@@ -80,3 +85,4 @@ function providePageContext(pageContext) {
80
85
  globalObject.pageContext = null;
81
86
  });
82
87
  }
88
+ exports.providePageContext = providePageContext;
@@ -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.189';
5
+ exports.PROJECT_VERSION = '0.4.191';
@@ -2,7 +2,7 @@ export { distFileNames };
2
2
  // Attempt to preserve file structure of `.page.js` files:
3
3
  // - https://github.com/vikejs/vike/commit/11a4c49e5403aa7c37c8020c462b499425b41854
4
4
  // - Blocker: https://github.com/rollup/rollup/issues/4724
5
- import { assertPosixPath, assert, assertUsage, isArray, isCallable, isFilePathAbsolute } from '../utils.js';
5
+ import { assertPosixPath, assert, assertUsage, isArray, isCallable } from '../utils.js';
6
6
  import path from 'path';
7
7
  import crypto from 'crypto';
8
8
  import { getAssetsDir } from '../shared/getAssetsDir.js';
@@ -48,7 +48,8 @@ function distFileNames() {
48
48
  }
49
49
  // Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
50
50
  if (id.endsWith('.css')) {
51
- if (isFilePathAbsolute(id)) {
51
+ const userRootDir = config.root;
52
+ if (id.startsWith(userRootDir)) {
52
53
  assertPosixPath(id);
53
54
  assertModuleId(id);
54
55
  let name;
@@ -60,10 +61,10 @@ function distFileNames() {
60
61
  const filePath = getModuleFilePathAbsolute(id, config);
61
62
  name = filePath;
62
63
  name = name.split('.').slice(0, -1).join('.'); // remove file extension
63
- name = name.split('/').join('_');
64
+ name = name.split('/').filter(Boolean).join('_');
64
65
  }
65
66
  // Make fileHash the same between local development and CI
66
- const idStable = path.posix.relative(config.root, id);
67
+ const idStable = path.posix.relative(userRootDir, id);
67
68
  // Don't remove `?` queries because each `id` should belong to a unique bundle.
68
69
  const hash = getIdHash(idStable);
69
70
  return `${name}-${hash}`;
@@ -71,13 +72,18 @@ function distFileNames() {
71
72
  else {
72
73
  let name;
73
74
  const isVirtualModule = id.match(/virtual:([^:]+):/);
74
- if (!isVirtualModule) {
75
- name = 'style';
76
- }
77
- else {
75
+ if (isVirtualModule) {
78
76
  name = isVirtualModule[1];
79
77
  assert(name);
80
78
  }
79
+ else if (
80
+ // https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
81
+ id.startsWith('/__uno')) {
82
+ name = 'uno';
83
+ }
84
+ else {
85
+ name = 'style';
86
+ }
81
87
  const hash = getIdHash(id);
82
88
  return `${name}-${hash}`;
83
89
  }
@@ -1 +1 @@
1
- export { getPageContext } from './hooks/executeHook.js';
1
+ export { getPageContext, providePageContext } from './hooks/executeHook.js';
@@ -1 +1 @@
1
- export { getPageContext } from './hooks/executeHook.js';
1
+ export { getPageContext, providePageContext } from './hooks/executeHook.js';
@@ -1,5 +1,6 @@
1
1
  export { executeHook };
2
2
  export { getPageContext };
3
+ export { providePageContext };
3
4
  export { isUserHookError };
4
5
  import type { PageContextClient, PageContextServer } from '../types.js';
5
6
  import type { Hook, HookLoc } from './getHook.js';
@@ -12,3 +13,9 @@ declare function executeHook<T = unknown>(hookFnCaller: () => T, hook: Omit<Hook
12
13
  * https://vike.dev/getPageContext
13
14
  */
14
15
  declare function getPageContext<PageContext = PageContextClient | PageContextServer>(): null | PageContext;
16
+ /**
17
+ * Provide `pageContext` for universal hooks.
18
+ *
19
+ * https://vike.dev/getPageContext
20
+ */
21
+ declare function providePageContext(pageContext: PageContextUnknown): void;
@@ -1,5 +1,6 @@
1
1
  export { executeHook };
2
2
  export { getPageContext };
3
+ export { providePageContext };
3
4
  export { isUserHookError };
4
5
  import { getProjectError, assertWarning } from '../../utils/assert.js';
5
6
  import { getGlobalObject } from '../../utils/getGlobalObject.js';
@@ -69,6 +70,11 @@ function isNotDisabled(timeout) {
69
70
  function getPageContext() {
70
71
  return globalObject.pageContext;
71
72
  }
73
+ /**
74
+ * Provide `pageContext` for universal hooks.
75
+ *
76
+ * https://vike.dev/getPageContext
77
+ */
72
78
  function providePageContext(pageContext) {
73
79
  globalObject.pageContext = pageContext;
74
80
  // Promise.resolve() is quicker than process.nextTick() and setImmediate()
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.189";
1
+ export declare const PROJECT_VERSION: "0.4.191";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.189';
2
+ export const PROJECT_VERSION = '0.4.191';
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.189";
3
+ projectVersion: "0.4.191";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.189",
3
+ "version": "0.4.191",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",