agentic-zi-ui 0.0.1 → 0.0.3
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/RELEASE.md +2 -0
- package/VERSIONING.md +20 -0
- package/dist/UiRenderer.d.ts +1 -1
- package/dist/UiRenderer.d.ts.map +1 -1
- package/dist/UiRenderer.js +1 -1
- package/dist/actions.d.ts +1 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/autoStyles.d.ts +2 -0
- package/dist/autoStyles.d.ts.map +1 -0
- package/dist/autoStyles.js +51 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +76 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/package.json +11 -6
package/RELEASE.md
CHANGED
package/VERSIONING.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Versioning policy (agentic-zi-ui)
|
|
2
|
+
|
|
3
|
+
## No breaking changes
|
|
4
|
+
Use patch/minor if the external contract stays the same:
|
|
5
|
+
- No new tags, events, actions, or state model changes
|
|
6
|
+
- No schema changes that affect validation
|
|
7
|
+
- Internal refactors, bug fixes, performance improvements
|
|
8
|
+
|
|
9
|
+
Suggested bumps:
|
|
10
|
+
- Patch: fixes only (0.0.1 -> 0.0.2)
|
|
11
|
+
- Minor: additive, backwards-compatible exports or optional features
|
|
12
|
+
|
|
13
|
+
## Breaking changes
|
|
14
|
+
Use major if any of the following change:
|
|
15
|
+
- Allowed tags/props/events/actions behavior
|
|
16
|
+
- Template schema or validation rules
|
|
17
|
+
- State binding or interpolation semantics
|
|
18
|
+
- Required prop changes for `ZijusCustomWidget`
|
|
19
|
+
|
|
20
|
+
Rule of thumb: if existing templates could render differently or fail, bump major.
|
package/dist/UiRenderer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UiNode, UiTemplate, UiActionType, WidgetDefinition } from "
|
|
1
|
+
import type { UiNode, UiTemplate, UiActionType, WidgetDefinition } from "agentic-zi-ui-schema";
|
|
2
2
|
export type RenderPolicy = {
|
|
3
3
|
allowedTags?: string[];
|
|
4
4
|
allowedProps?: string[];
|
package/dist/UiRenderer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiRenderer.d.ts","sourceRoot":"","sources":["../src/UiRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EAEV,YAAY,EACZ,gBAAgB,EACjB,MAAM,
|
|
1
|
+
{"version":3,"file":"UiRenderer.d.ts","sourceRoot":"","sources":["../src/UiRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EAEV,YAAY,EACZ,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAc9B,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,UAAU,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACvE,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;IAC/C,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AA8QF,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,aAAa,EACb,KAAK,EACL,MAAM,GACP,EAAE,eAAe,2CAkPjB"}
|
package/dist/UiRenderer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
3
|
import React, { useMemo, useReducer, useEffect, useState } from "react";
|
|
4
|
-
import { UI_ALLOWED_TAGS, UI_ALLOWED_PROPS, UiActionTypeSchema, } from "
|
|
4
|
+
import { UI_ALLOWED_TAGS, UI_ALLOWED_PROPS, UiActionTypeSchema, } from "agentic-zi-ui-schema";
|
|
5
5
|
import { runAction } from "./actions";
|
|
6
6
|
const BASE_ALLOWED_TAGS = new Set(UI_ALLOWED_TAGS);
|
|
7
7
|
const BASE_ALLOWED_PROPS = new Set(UI_ALLOWED_PROPS);
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UiAction, UiActionType } from "
|
|
1
|
+
import type { UiAction, UiActionType } from "agentic-zi-ui-schema";
|
|
2
2
|
export type ActionContext = {
|
|
3
3
|
sendFlowEvent: (name: string, payload?: Record<string, unknown>) => void;
|
|
4
4
|
patchState: (key: string, value: unknown) => void;
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACzE,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACnC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC,CAAC;AAWF,wBAAsB,SAAS,CAC7B,MAAM,EAAE,QAAQ,EAChB,GAAG,EAAE,aAAa,EAClB,EAAE,CAAC,EAAE,OAAO,EACZ,cAAc,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC,CAuDf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoStyles.d.ts","sourceRoot":"","sources":["../src/autoStyles.ts"],"names":[],"mappings":"AAwCA,wBAAsB,yBAAyB,CAC7C,SAAS,GAAE,MAA2B,GACrC,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const DEFAULT_CONFIG_URL = "/agentic-zi-ui.config.json";
|
|
2
|
+
let loadPromise = null;
|
|
3
|
+
function isBrowser() {
|
|
4
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
5
|
+
}
|
|
6
|
+
function getGlobalConfig() {
|
|
7
|
+
const anyGlobal = globalThis;
|
|
8
|
+
return anyGlobal.__AGENTIC_ZI_UI_CONFIG__ ?? null;
|
|
9
|
+
}
|
|
10
|
+
async function fetchConfig(url) {
|
|
11
|
+
try {
|
|
12
|
+
const res = await fetch(url, { headers: { "Accept": "application/json" } });
|
|
13
|
+
if (!res.ok)
|
|
14
|
+
return null;
|
|
15
|
+
const json = (await res.json());
|
|
16
|
+
if (!json?.baseUrl || !Array.isArray(json.botIdList))
|
|
17
|
+
return null;
|
|
18
|
+
return json;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function ensureLink(href) {
|
|
25
|
+
const existing = document.querySelector(`link[data-agentic-zi-ui="${href}"]`);
|
|
26
|
+
if (existing)
|
|
27
|
+
return;
|
|
28
|
+
const link = document.createElement("link");
|
|
29
|
+
link.rel = "stylesheet";
|
|
30
|
+
link.href = href;
|
|
31
|
+
link.setAttribute("data-agentic-zi-ui", href);
|
|
32
|
+
document.head.appendChild(link);
|
|
33
|
+
}
|
|
34
|
+
export async function ensureAgenticStylesLoaded(configUrl = DEFAULT_CONFIG_URL) {
|
|
35
|
+
if (!isBrowser())
|
|
36
|
+
return;
|
|
37
|
+
if (loadPromise)
|
|
38
|
+
return loadPromise;
|
|
39
|
+
loadPromise = (async () => {
|
|
40
|
+
const config = getGlobalConfig() ?? (await fetchConfig(configUrl));
|
|
41
|
+
if (!config)
|
|
42
|
+
return;
|
|
43
|
+
const baseUrl = config.cssBaseUrl ?? config.baseUrl;
|
|
44
|
+
const botIds = Array.isArray(config.botIdList) ? config.botIdList : [];
|
|
45
|
+
for (const botId of botIds) {
|
|
46
|
+
const href = `${baseUrl.replace(/\/$/, "")}/safelist/current/${encodeURIComponent(botId)}.css`;
|
|
47
|
+
ensureLink(href);
|
|
48
|
+
}
|
|
49
|
+
})();
|
|
50
|
+
return loadPromise;
|
|
51
|
+
}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
const CONFIG_NAME = "agentic-zi-ui.config.json";
|
|
5
|
+
function readConfig(cwd) {
|
|
6
|
+
const configPath = path.resolve(cwd, CONFIG_NAME);
|
|
7
|
+
if (!fs.existsSync(configPath)) {
|
|
8
|
+
throw new Error(`Missing ${CONFIG_NAME} in ${cwd}`);
|
|
9
|
+
}
|
|
10
|
+
const raw = fs.readFileSync(configPath, "utf8");
|
|
11
|
+
const json = JSON.parse(raw);
|
|
12
|
+
if (!json.baseUrl || typeof json.baseUrl !== "string") {
|
|
13
|
+
throw new Error("config.baseUrl is required");
|
|
14
|
+
}
|
|
15
|
+
if (!Array.isArray(json.botIdList) || json.botIdList.length === 0) {
|
|
16
|
+
throw new Error("config.botIdList must be a non-empty array");
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
baseUrl: json.baseUrl.replace(/\/$/, ""),
|
|
20
|
+
botIdList: json.botIdList,
|
|
21
|
+
outputPath: json.outputPath,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function parseTokens(payload) {
|
|
25
|
+
if (Array.isArray(payload)) {
|
|
26
|
+
return payload.map(String).filter(Boolean);
|
|
27
|
+
}
|
|
28
|
+
if (payload && typeof payload === "object") {
|
|
29
|
+
const obj = payload;
|
|
30
|
+
const tokens = obj.tokens ?? obj.safelist ?? obj.classes ?? obj.classNames ?? null;
|
|
31
|
+
if (Array.isArray(tokens)) {
|
|
32
|
+
return tokens.map(String).filter(Boolean);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (typeof payload === "string") {
|
|
36
|
+
return payload
|
|
37
|
+
.split(/\s+/)
|
|
38
|
+
.map((t) => t.trim())
|
|
39
|
+
.filter(Boolean);
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
async function fetchSafelist(baseUrl, botId) {
|
|
44
|
+
const url = `${baseUrl}/safelist/current/${encodeURIComponent(botId)}`;
|
|
45
|
+
const res = await fetch(url, { headers: { "Accept": "application/json" } });
|
|
46
|
+
if (!res.ok) {
|
|
47
|
+
const text = await res.text();
|
|
48
|
+
throw new Error(`Failed ${res.status} ${url}: ${text}`);
|
|
49
|
+
}
|
|
50
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
51
|
+
if (contentType.includes("application/json")) {
|
|
52
|
+
const json = await res.json();
|
|
53
|
+
return parseTokens(json);
|
|
54
|
+
}
|
|
55
|
+
const text = await res.text();
|
|
56
|
+
return parseTokens(text);
|
|
57
|
+
}
|
|
58
|
+
async function main() {
|
|
59
|
+
const cwd = process.cwd();
|
|
60
|
+
const config = readConfig(cwd);
|
|
61
|
+
const outputPath = path.resolve(cwd, config.outputPath ?? "apps/client/src/ui/tailwindSafelist.txt");
|
|
62
|
+
const tokens = new Set();
|
|
63
|
+
for (const botId of config.botIdList) {
|
|
64
|
+
const list = await fetchSafelist(config.baseUrl, botId);
|
|
65
|
+
for (const token of list)
|
|
66
|
+
tokens.add(token);
|
|
67
|
+
}
|
|
68
|
+
const output = Array.from(tokens).sort().join("\n");
|
|
69
|
+
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
70
|
+
fs.writeFileSync(outputPath, `${output}\n`, "utf8");
|
|
71
|
+
console.log(`Safelist updated: ${outputPath} (${tokens.size} classes) from ${config.botIdList.length} bot(s).`);
|
|
72
|
+
}
|
|
73
|
+
main().catch((err) => {
|
|
74
|
+
console.error(err?.message ?? err);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { UiRendererProps } from "./UiRenderer";
|
|
2
|
+
import { ensureAgenticStylesLoaded } from "./autoStyles";
|
|
2
3
|
export type { UiRendererProps, RenderPolicy } from "./UiRenderer";
|
|
3
4
|
export type { UiRendererProps as ZijusCustomWidgetProps } from "./UiRenderer";
|
|
4
5
|
export declare function ZijusCustomWidget(props: UiRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export { ensureAgenticStylesLoaded };
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAElE,YAAY,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE9E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAElE,YAAY,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE9E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,2CAKvD;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { UiRenderer } from "./UiRenderer";
|
|
4
|
+
import { ensureAgenticStylesLoaded } from "./autoStyles";
|
|
3
5
|
export function ZijusCustomWidget(props) {
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
ensureAgenticStylesLoaded();
|
|
8
|
+
}, []);
|
|
4
9
|
return _jsx(UiRenderer, { ...props });
|
|
5
10
|
}
|
|
11
|
+
export { ensureAgenticStylesLoaded };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-zi-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"private": false,
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"agentic-zi-ui-safelist": "./dist/cli.js"
|
|
16
|
+
},
|
|
14
17
|
"scripts": {
|
|
15
18
|
"dev": "tsc -w",
|
|
16
19
|
"build": "tsc",
|
|
@@ -18,16 +21,18 @@
|
|
|
18
21
|
"release:patch": "npm version patch -m \"chore(release): %s\"",
|
|
19
22
|
"release:minor": "npm version minor -m \"chore(release): %s\"",
|
|
20
23
|
"release:major": "npm version major -m \"chore(release): %s\"",
|
|
21
|
-
"publish:public": "npm publish --access public"
|
|
22
|
-
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@acme/ui-schema": "workspace:*"
|
|
24
|
+
"publish:public": "npm publish --access public",
|
|
25
|
+
"safelist:pull": "agentic-zi-ui-safelist"
|
|
25
26
|
},
|
|
27
|
+
"dependencies": {},
|
|
26
28
|
"peerDependencies": {
|
|
27
|
-
"react": "^18 || ^19"
|
|
29
|
+
"react": "^18 || ^19",
|
|
30
|
+
"agentic-zi-ui-schema": "^0.0.1"
|
|
28
31
|
},
|
|
29
32
|
"devDependencies": {
|
|
30
33
|
"@types/react": "^19.2.5",
|
|
34
|
+
"@types/node": "^24.10.1",
|
|
35
|
+
"agentic-zi-ui-schema": "^0.0.1",
|
|
31
36
|
"typescript": "~5.9.3"
|
|
32
37
|
}
|
|
33
38
|
}
|