@orbit-work/oem-sdk 0.1.9 → 0.1.10
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/audit-brand.js +28 -7
- package/dist/audit-brand.js.map +1 -1
- package/dist/audit.d.ts +2 -2
- package/dist/audit.js +28 -7
- package/dist/audit.js.map +1 -1
- package/dist/{chunk-I3RBZK2G.js → chunk-PVX4DQMJ.js} +25 -5
- package/dist/chunk-PVX4DQMJ.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/manifest.d.ts +2 -2
- package/dist/manifest.js +1 -1
- package/dist/runtime.js +1 -1
- package/package.json +2 -2
- package/schema/orbit-brand.schema.json +57 -0
- package/dist/chunk-I3RBZK2G.js.map +0 -1
package/dist/audit.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { realpath, readFile, stat } from 'fs/promises';
|
|
2
2
|
import { resolve, extname, sep, dirname } from 'path';
|
|
3
3
|
import { gzipSync, inflateSync } from 'zlib';
|
|
4
|
+
import { CHAT_MARK_ASSET_KEYS, UNIFIED_NEUTRAL_TOKENS, BRAND_ACTION_TOKENS, BRAND_LOGIN_TOKENS, ds2ContrastRatio, checkOemPrimary, isOrbitworkFontScale, ORBITWORK_FONT_SCALES } from '@orbit-work/ui/appearance';
|
|
4
5
|
import { init, parse } from 'es-module-lexer';
|
|
5
6
|
import { transform } from 'esbuild';
|
|
6
7
|
import { validateDictionary } from '@orbit-work/ui/locale';
|
|
7
|
-
import { UNIFIED_NEUTRAL_TOKENS, BRAND_ACTION_TOKENS, ds2ContrastRatio, checkOemPrimary, isOrbitworkFontScale, ORBITWORK_FONT_SCALES } from '@orbit-work/ui/appearance';
|
|
8
8
|
import { WORKBENCH_SLOT_DECLARATIONS, WORKBENCH_KEYED_SLOT_KEYS } from '@orbit-work/ui/slot/core';
|
|
9
9
|
|
|
10
10
|
// src/audit-brand.ts
|
|
@@ -49,7 +49,7 @@ var ROOT_KEYS = /* @__PURE__ */ new Set([
|
|
|
49
49
|
"contributes"
|
|
50
50
|
]);
|
|
51
51
|
var IDENTITY_KEYS = /* @__PURE__ */ new Set(["productName", "appId", "versionChannel", "protocolScheme", "userDataNamespace"]);
|
|
52
|
-
var ASSET_KEYS = /* @__PURE__ */ new Set(["appIcon", "tray", "trayVariants", "logo", "loginKV"]);
|
|
52
|
+
var ASSET_KEYS = /* @__PURE__ */ new Set(["appIcon", "tray", "trayVariants", "logo", "loginKV", ...CHAT_MARK_ASSET_KEYS]);
|
|
53
53
|
var MODE_KEYS = /* @__PURE__ */ new Set(["light", "dark"]);
|
|
54
54
|
var THEME_KEYS = /* @__PURE__ */ new Set(["primary", "signal", "allowDangerHue"]);
|
|
55
55
|
var HEX6 = /^#[0-9a-f]{6}$/i;
|
|
@@ -61,7 +61,7 @@ var APPEARANCE_KEYS = /* @__PURE__ */ new Set(["homeBackdrop", "login"]);
|
|
|
61
61
|
var LOGIN_APPEARANCE_KEYS = /* @__PURE__ */ new Set(["claimColor", "claimNoteColor", "accentColor", "scrim"]);
|
|
62
62
|
var BRANDING_KEYS = /* @__PURE__ */ new Set(["productName", "companyName", "claim", "claimHighlight", "claimNote", "slogan"]);
|
|
63
63
|
var SLOT_COMMON_KEYS = /* @__PURE__ */ new Set(["name"]);
|
|
64
|
-
var BRAND_TOKEN_NAMES = /* @__PURE__ */ new Set([...UNIFIED_NEUTRAL_TOKENS, ...BRAND_ACTION_TOKENS]);
|
|
64
|
+
var BRAND_TOKEN_NAMES = /* @__PURE__ */ new Set([...UNIFIED_NEUTRAL_TOKENS, ...BRAND_ACTION_TOKENS, ...BRAND_LOGIN_TOKENS]);
|
|
65
65
|
var SLOT_DECLARATIONS = WORKBENCH_SLOT_DECLARATIONS;
|
|
66
66
|
var HEX = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
67
67
|
var KEBAB_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -185,6 +185,23 @@ function parseIdentity(value, id, platform) {
|
|
|
185
185
|
throw new Error("Platform environment must be stable, debug, or oem-dev");
|
|
186
186
|
return { productName, appId, versionChannel, protocolScheme, ...userDataNamespace ? { userDataNamespace } : {} };
|
|
187
187
|
}
|
|
188
|
+
function parseChatMarkAssets(value, partial = false) {
|
|
189
|
+
const result = {};
|
|
190
|
+
for (const key of CHAT_MARK_ASSET_KEYS) {
|
|
191
|
+
if (value[key] !== void 0) result[key] = relativePath(value[key], `assets.${key}`);
|
|
192
|
+
}
|
|
193
|
+
if (!partial) {
|
|
194
|
+
const light = CHAT_MARK_ASSET_KEYS.slice(0, 3);
|
|
195
|
+
const dark = CHAT_MARK_ASSET_KEYS.slice(3);
|
|
196
|
+
for (const group of [light, dark]) {
|
|
197
|
+
if (group.some((key) => result[key]) && group.some((key) => !result[key]))
|
|
198
|
+
throw new Error(`assets chat mark group is incomplete: ${group.join(", ")}`);
|
|
199
|
+
}
|
|
200
|
+
if (dark.some((key) => result[key]) && !result.chatThinkingOrbit)
|
|
201
|
+
throw new Error("assets dark chat marks require the light chat mark group");
|
|
202
|
+
}
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
188
205
|
function parseAssets(value) {
|
|
189
206
|
if (!isRecord(value)) throw new Error("assets must be an object");
|
|
190
207
|
assertKnownKeys(value, ASSET_KEYS, "assets");
|
|
@@ -195,6 +212,7 @@ function parseAssets(value) {
|
|
|
195
212
|
}
|
|
196
213
|
const loginKV = value.loginKV === void 0 ? void 0 : relativePath(value.loginKV, "assets.loginKV");
|
|
197
214
|
return {
|
|
215
|
+
...parseChatMarkAssets(value),
|
|
198
216
|
appIcon: relativePath(value.appIcon, "assets.appIcon"),
|
|
199
217
|
...tray ? { tray } : {},
|
|
200
218
|
...trayVariants ? { trayVariants } : {},
|
|
@@ -631,7 +649,7 @@ async function assertAsset(packageRoot, relative, kind) {
|
|
|
631
649
|
if (!info.isFile()) throw new Error(`assets.${kind} must point to a file`);
|
|
632
650
|
if (info.size > ASSET_BUDGET) throw new Error(`assets.${kind} exceeds 5 MiB`);
|
|
633
651
|
const extension = extname(file).toLowerCase();
|
|
634
|
-
const allowed = kind === "loginKV" ? /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".webp"]) : kind === "logo" ? /* @__PURE__ */ new Set([".svg", ".png", ".webp", ".jpg", ".jpeg"]) : /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg"]);
|
|
652
|
+
const allowed = kind === "loginKV" ? /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".webp"]) : kind === "logo" || CHAT_MARK_ASSET_KEYS.includes(kind) ? /* @__PURE__ */ new Set([".svg", ".png", ".webp", ".jpg", ".jpeg"]) : /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg"]);
|
|
635
653
|
if (!allowed.has(extension)) throw new Error(`assets.${kind} has unsupported extension: ${extension}`);
|
|
636
654
|
if (kind === "appIcon" || kind === "tray") {
|
|
637
655
|
const bytes = await readFile(file);
|
|
@@ -670,12 +688,14 @@ function strictPngDimensions(bytes) {
|
|
|
670
688
|
const end = offset + 12 + length;
|
|
671
689
|
if (end > bytes.length) return null;
|
|
672
690
|
const kind = bytes.toString("ascii", offset + 4, offset + 8);
|
|
673
|
-
if (pngCrc32(bytes.subarray(offset + 4, offset + 8 + length)) !== bytes.readUInt32BE(offset + 8 + length))
|
|
691
|
+
if (pngCrc32(bytes.subarray(offset + 4, offset + 8 + length)) !== bytes.readUInt32BE(offset + 8 + length))
|
|
692
|
+
return null;
|
|
674
693
|
if (!dimensions) {
|
|
675
694
|
if (kind !== "IHDR" || length !== 13) return null;
|
|
676
695
|
const width = bytes.readUInt32BE(offset + 8);
|
|
677
696
|
const height = bytes.readUInt32BE(offset + 12);
|
|
678
|
-
if (!width || !height || bytes[offset + 18] !== 0 || bytes[offset + 19] !== 0 || bytes[offset + 20] > 1)
|
|
697
|
+
if (!width || !height || bytes[offset + 18] !== 0 || bytes[offset + 19] !== 0 || bytes[offset + 20] > 1)
|
|
698
|
+
return null;
|
|
679
699
|
dimensions = { width, height };
|
|
680
700
|
} else if (kind === "IDAT") {
|
|
681
701
|
idat.push(bytes.subarray(offset + 8, offset + 8 + length));
|
|
@@ -703,7 +723,8 @@ async function assertTrayVariants(packageRoot, variants) {
|
|
|
703
723
|
try {
|
|
704
724
|
file = await resolvePackageFile(packageRoot, relative, field);
|
|
705
725
|
} catch (error) {
|
|
706
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
726
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
727
|
+
throw new Error(`${field} file is missing: ${relative}`);
|
|
707
728
|
throw error;
|
|
708
729
|
}
|
|
709
730
|
const info = await stat(file);
|