@ubean/shared 0.6.4 → 0.6.6
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/index.d.ts +33 -0
- package/dist/index.js +21 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -593,4 +593,37 @@ export declare function matchAnyGlob(route: string, patterns: string[]): boolean
|
|
|
593
593
|
*/
|
|
594
594
|
export declare function capitalize(str: string): string;
|
|
595
595
|
//#endregion
|
|
596
|
+
//#region src/first-paint.d.ts
|
|
597
|
+
/**
|
|
598
|
+
* 首帧主题脚本的归属判据。
|
|
599
|
+
*
|
|
600
|
+
* 两个消费者必须得到**同一个答案**,否则 `<head>` 里会同时出现两份互相抵消的脚本
|
|
601
|
+
* (ubean 写 `.dark-mode`,`@vean/theme` 写 `.dark`,UnoCSS 只认后者):
|
|
602
|
+
*
|
|
603
|
+
* - `@ubean/integrations/ui` 的 `ubeanUiPlugin()` —— 为真时 `registerHeadScript()`
|
|
604
|
+
* - `@ubean/config` 的 `resolveColorModeOwnership()` —— 为真时把 `colorMode` 置 `false`
|
|
605
|
+
*
|
|
606
|
+
* 放在 `@ubean/shared`(两侧都已有的依赖,且浏览器安全)而不是任一侧:
|
|
607
|
+
* `@ubean/config` 不能依赖 `@ubean/build`(`./ui` 子路径静态 import 它),
|
|
608
|
+
* 而 `@ubean/build` 又不该知道 vean 的存在。
|
|
609
|
+
*/
|
|
610
|
+
/** 判定只看 `ui` 字段,避免把整个 `ResolvedConfig` 拖进类型依赖。 */
|
|
611
|
+
export interface FirstPaintOwnerConfig {
|
|
612
|
+
ui?: boolean | {
|
|
613
|
+
disabled?: boolean;
|
|
614
|
+
theme?: false | {
|
|
615
|
+
initScript?: boolean;
|
|
616
|
+
};
|
|
617
|
+
} | undefined;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* `ui` 是否接管首帧主题脚本。
|
|
621
|
+
*
|
|
622
|
+
* 默认接管(`ui: true` / `ui: {}` / `ui: { css: false }` 都算)。只有三种情况让位:
|
|
623
|
+
* - `ui` 未启用(`false` / `undefined`)
|
|
624
|
+
* - `ui.disabled === true`
|
|
625
|
+
* - `ui.theme === false` 或 `ui.theme.initScript === false`(显式手动注入)
|
|
626
|
+
*/
|
|
627
|
+
export declare function integrationOwnsFirstPaintScript(config: FirstPaintOwnerConfig): boolean;
|
|
628
|
+
//#endregion
|
|
596
629
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -556,4 +556,24 @@ function matchAnyGlob(route, patterns) {
|
|
|
556
556
|
return patterns.some((p) => matchGlob(route, p));
|
|
557
557
|
}
|
|
558
558
|
//#endregion
|
|
559
|
-
|
|
559
|
+
//#region src/first-paint.ts
|
|
560
|
+
/**
|
|
561
|
+
* `ui` 是否接管首帧主题脚本。
|
|
562
|
+
*
|
|
563
|
+
* 默认接管(`ui: true` / `ui: {}` / `ui: { css: false }` 都算)。只有三种情况让位:
|
|
564
|
+
* - `ui` 未启用(`false` / `undefined`)
|
|
565
|
+
* - `ui.disabled === true`
|
|
566
|
+
* - `ui.theme === false` 或 `ui.theme.initScript === false`(显式手动注入)
|
|
567
|
+
*/
|
|
568
|
+
function integrationOwnsFirstPaintScript(config) {
|
|
569
|
+
const ui = config.ui;
|
|
570
|
+
if (ui === false || ui === void 0) return false;
|
|
571
|
+
if (ui === true) return true;
|
|
572
|
+
const options = ui;
|
|
573
|
+
if (options.disabled === true) return false;
|
|
574
|
+
if (options.theme === false) return false;
|
|
575
|
+
if (typeof options.theme === "object" && options.theme !== null && options.theme.initScript === false) return false;
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
//#endregion
|
|
579
|
+
export { ACTION_BRAND, ActionError, UbeanError, capitalize, createError, defineEnv, envField, errorToResponse, fail, getBasename, getDirname, getExtension, getStem, integrationOwnsFirstPaintScript, isActionFailure, isEnvFieldMeta, isNodeRuntime, isServerAction, isUbeanError, matchAnyGlob, matchGlob, normalizeEnvSchema, normalizePath, pathToTitle, resolveEnvSchema, setRuntimeEnv, useRuntimeEnv };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubean/shared",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "Shared protocol types, errors, env and universal utilities for ubean",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"hono": "4.13.13",
|
|
33
33
|
"pathe": "^2.0.3",
|
|
34
34
|
"scule": "^1.3.0",
|
|
35
|
-
"tslog": "^5.
|
|
35
|
+
"tslog": "^5.4.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^26.6.5",
|