zudoku 0.80.0 → 0.80.1

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.
@@ -1,5 +1,6 @@
1
1
  import { getCurrentConfig } from "../config/loader.js";
2
2
  export type { ConfigEnv, Plugin, PluginOption, UserConfig } from "vite";
3
3
  export { defineConfig, mergeConfig } from "vite";
4
+ export { joinUrl } from "../lib/util/joinUrl.js";
4
5
  export { getCurrentConfig as getZudokuConfig };
5
6
  export declare const getPluginConfigs: <V>(name: string) => V[];
@@ -0,0 +1,87 @@
1
+ // src/config/loader.ts
2
+ import colors from "picocolors";
3
+ import {
4
+ runnerImport,
5
+ loadEnv as viteLoadEnv
6
+ } from "vite";
7
+
8
+ // src/lib/util/invariant.ts
9
+ function invariant(condition, message, options) {
10
+ if (condition) {
11
+ return;
12
+ }
13
+ const provided = typeof message === "function" ? message() : message;
14
+ throw new ZudokuError(provided ?? "Invariant failed", options);
15
+ }
16
+ var ZudokuError = class extends Error {
17
+ developerHint;
18
+ title;
19
+ constructor(message, { developerHint, title, cause } = {}) {
20
+ super(message, { cause });
21
+ this.name = "ZudokuError";
22
+ this.title = title;
23
+ this.developerHint = developerHint;
24
+ }
25
+ };
26
+
27
+ // src/lib/util/joinUrl.ts
28
+ var defaultUrlRegExp = /^(\w+:\/\/[^/?]+)?([^?]*)(\?.*)?$/;
29
+ var normalizeParts = (parts) => parts.filter(
30
+ (part) => part !== null && part !== void 0 && part !== false && (typeof part === "string" || typeof part === "number")
31
+ ).map((part) => `${part}`).filter((part) => part);
32
+ var parseParts = (parts) => {
33
+ const partsStr = parts.join("/");
34
+ const [, prefix = "", pathname = "", query = ""] = partsStr.match(defaultUrlRegExp) ?? [];
35
+ return {
36
+ prefix,
37
+ pathname: pathname.split("/").filter((part) => part !== ""),
38
+ query
39
+ };
40
+ };
41
+ var buildUrl = (parsedParts) => {
42
+ const { prefix, pathname, query } = parsedParts;
43
+ let url = prefix;
44
+ if (pathname.length > 0) {
45
+ if (url) {
46
+ url += "/";
47
+ } else {
48
+ url = "/";
49
+ }
50
+ url += pathname.join("/");
51
+ } else if (!url) {
52
+ url = "/";
53
+ }
54
+ return url + query;
55
+ };
56
+ var joinUrl = (...parts) => {
57
+ const normalizedParts = normalizeParts(parts);
58
+ const parsedParts = parseParts(normalizedParts);
59
+ return buildUrl(parsedParts);
60
+ };
61
+
62
+ // src/config/loader.ts
63
+ var configStore = globalThis;
64
+ var getConfig = () => configStore.__zudokuConfig;
65
+ var getCurrentConfig = () => {
66
+ const config = getConfig();
67
+ invariant(config, "Config not loaded");
68
+ return config;
69
+ };
70
+
71
+ // src/lib/core/plugin-config.ts
72
+ var PLUGIN_CONFIG = /* @__PURE__ */ Symbol.for("zudoku.pluginConfig");
73
+ var selectPluginConfigs = (plugins, name) => plugins.flatMap((plugin) => {
74
+ const tag = plugin && typeof plugin === "object" ? plugin[PLUGIN_CONFIG] : void 0;
75
+ return tag?.name === name ? [tag.config] : [];
76
+ });
77
+
78
+ // src/vite/index.ts
79
+ import { defineConfig, mergeConfig } from "vite";
80
+ var getPluginConfigs = (name) => selectPluginConfigs(getCurrentConfig().plugins ?? [], name);
81
+ export {
82
+ defineConfig,
83
+ getPluginConfigs,
84
+ getCurrentConfig as getZudokuConfig,
85
+ joinUrl,
86
+ mergeConfig
87
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.80.0",
3
+ "version": "0.80.1",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -124,7 +124,8 @@
124
124
  },
125
125
  "./vite": {
126
126
  "types": "./dist/declarations/vite/index.d.ts",
127
- "default": "./src/vite/index.ts"
127
+ "import": "./dist/vite/index.js",
128
+ "default": "./dist/vite/index.js"
128
129
  },
129
130
  "./server": {
130
131
  "types": "./dist/declarations/app/entry.server.d.ts",
@@ -344,7 +345,7 @@
344
345
  }
345
346
  },
346
347
  "scripts": {
347
- "build": "esbuild src/cli/cli.ts src/vite/prerender/worker.ts --outdir=dist/cli --entry-names=[name] --bundle --format=esm --packages=external --target=node20 --platform=node --log-level=error",
348
+ "build": "tsx scripts/build.ts",
348
349
  "postbuild": "tsx scripts/check-external-deps.ts",
349
350
  "typecheck": "tsc --project tsconfig.app.json --noEmit",
350
351
  "generate:types": "tsx scripts/generate-types.js && tsx scripts/generate-flat-config.js",
package/src/vite/index.ts CHANGED
@@ -3,6 +3,7 @@ import { selectPluginConfigs } from "../lib/core/plugin-config.js";
3
3
 
4
4
  export type { ConfigEnv, Plugin, PluginOption, UserConfig } from "vite";
5
5
  export { defineConfig, mergeConfig } from "vite";
6
+ export { joinUrl } from "../lib/util/joinUrl.js";
6
7
  export { getCurrentConfig as getZudokuConfig };
7
8
 
8
9
  // Read configs of all plugins registered with `createPlugin(name, ...)`. Used by