@leeoohoo/ui-apps-devkit 0.1.0 → 0.1.2
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/README.md +75 -60
- package/bin/chatos-uiapp.js +4 -4
- package/package.json +26 -20
- package/src/cli.js +53 -53
- package/src/commands/dev.js +14 -14
- package/src/commands/init.js +131 -129
- package/src/commands/install.js +47 -46
- package/src/commands/pack.js +72 -72
- package/src/commands/validate.js +138 -80
- package/src/lib/args.js +49 -49
- package/src/lib/config.js +29 -29
- package/src/lib/fs.js +78 -78
- package/src/lib/path-boundary.js +16 -16
- package/src/lib/plugin.js +45 -45
- package/src/lib/state-constants.js +2 -0
- package/src/lib/template.js +172 -168
- package/src/sandbox/server.js +1957 -692
- package/templates/basic/README.md +78 -54
- package/templates/basic/chatos.config.json +5 -5
- package/templates/basic/docs/CHATOS_UI_APPS_AI_CONTRIBUTIONS.md +214 -181
- package/templates/basic/docs/CHATOS_UI_APPS_BACKEND_PROTOCOL.md +75 -74
- package/templates/basic/docs/CHATOS_UI_APPS_HOST_API.md +136 -123
- package/templates/basic/docs/CHATOS_UI_APPS_OVERVIEW.md +112 -107
- package/templates/basic/docs/CHATOS_UI_APPS_PLUGIN_MANIFEST.md +242 -227
- package/templates/basic/docs/CHATOS_UI_APPS_STYLE_GUIDE.md +95 -0
- package/templates/basic/docs/CHATOS_UI_APPS_TROUBLESHOOTING.md +45 -0
- package/templates/basic/docs/CHATOS_UI_PROMPTS_PROTOCOL.md +392 -392
- package/templates/basic/plugin/apps/app/compact.mjs +41 -0
- package/templates/basic/plugin/apps/app/index.mjs +287 -263
- package/templates/basic/plugin/apps/app/mcp-prompt.en.md +7 -7
- package/templates/basic/plugin/apps/app/mcp-prompt.zh.md +7 -7
- package/templates/basic/plugin/apps/app/mcp-server.mjs +15 -15
- package/templates/basic/plugin/backend/index.mjs +37 -37
- package/templates/basic/template.json +7 -7
- package/templates/notepad/README.md +55 -24
- package/templates/notepad/chatos.config.json +4 -4
- package/templates/notepad/docs/CHATOS_UI_APPS_AI_CONTRIBUTIONS.md +214 -181
- package/templates/notepad/docs/CHATOS_UI_APPS_BACKEND_PROTOCOL.md +75 -74
- package/templates/notepad/docs/CHATOS_UI_APPS_HOST_API.md +136 -123
- package/templates/notepad/docs/CHATOS_UI_APPS_OVERVIEW.md +112 -107
- package/templates/notepad/docs/CHATOS_UI_APPS_PLUGIN_MANIFEST.md +242 -227
- package/templates/notepad/docs/CHATOS_UI_APPS_STYLE_GUIDE.md +95 -0
- package/templates/notepad/docs/CHATOS_UI_APPS_TROUBLESHOOTING.md +45 -0
- package/templates/notepad/docs/CHATOS_UI_PROMPTS_PROTOCOL.md +392 -392
- package/templates/notepad/plugin/apps/app/api.mjs +30 -30
- package/templates/notepad/plugin/apps/app/compact.mjs +41 -0
- package/templates/notepad/plugin/apps/app/dom.mjs +14 -14
- package/templates/notepad/plugin/apps/app/ds-tree.mjs +35 -35
- package/templates/notepad/plugin/apps/app/index.mjs +1056 -1056
- package/templates/notepad/plugin/apps/app/layers.mjs +338 -338
- package/templates/notepad/plugin/apps/app/markdown.mjs +120 -120
- package/templates/notepad/plugin/apps/app/mcp-prompt.en.md +22 -22
- package/templates/notepad/plugin/apps/app/mcp-prompt.zh.md +22 -22
- package/templates/notepad/plugin/apps/app/mcp-server.mjs +206 -199
- package/templates/notepad/plugin/apps/app/styles.mjs +355 -355
- package/templates/notepad/plugin/apps/app/tags.mjs +21 -21
- package/templates/notepad/plugin/apps/app/ui.mjs +280 -280
- package/templates/notepad/plugin/backend/index.mjs +99 -99
- package/templates/notepad/plugin/plugin.json +23 -23
- package/templates/notepad/plugin/shared/notepad-paths.mjs +59 -41
- package/templates/notepad/plugin/shared/notepad-store.mjs +765 -765
- package/templates/notepad/template.json +8 -8
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
function ensureBridgeAvailable(bridgeEnabled) {
|
|
2
|
-
if (!bridgeEnabled) {
|
|
3
|
-
throw new Error('Host bridge not available (backend.invoke disabled)');
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function createNotesApi({ host, bridgeEnabled }) {
|
|
8
|
-
if (!host || typeof host !== 'object') throw new Error('host is required');
|
|
9
|
-
|
|
10
|
-
const invoke = async (method, params) => {
|
|
11
|
-
ensureBridgeAvailable(bridgeEnabled);
|
|
12
|
-
return await host.backend.invoke(method, params);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
init: async () => await invoke('notes.init'),
|
|
17
|
-
listFolders: async () => await invoke('notes.listFolders'),
|
|
18
|
-
createFolder: async (params) => await invoke('notes.createFolder', params),
|
|
19
|
-
renameFolder: async (params) => await invoke('notes.renameFolder', params),
|
|
20
|
-
deleteFolder: async (params) => await invoke('notes.deleteFolder', params),
|
|
21
|
-
listNotes: async (params) => await invoke('notes.listNotes', params),
|
|
22
|
-
createNote: async (params) => await invoke('notes.createNote', params),
|
|
23
|
-
getNote: async (params) => await invoke('notes.getNote', params),
|
|
24
|
-
updateNote: async (params) => await invoke('notes.updateNote', params),
|
|
25
|
-
deleteNote: async (params) => await invoke('notes.deleteNote', params),
|
|
26
|
-
listTags: async () => await invoke('notes.listTags'),
|
|
27
|
-
searchNotes: async (params) => await invoke('notes.searchNotes', params),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
1
|
+
function ensureBridgeAvailable(bridgeEnabled) {
|
|
2
|
+
if (!bridgeEnabled) {
|
|
3
|
+
throw new Error('Host bridge not available (backend.invoke disabled)');
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function createNotesApi({ host, bridgeEnabled }) {
|
|
8
|
+
if (!host || typeof host !== 'object') throw new Error('host is required');
|
|
9
|
+
|
|
10
|
+
const invoke = async (method, params) => {
|
|
11
|
+
ensureBridgeAvailable(bridgeEnabled);
|
|
12
|
+
return await host.backend.invoke(method, params);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
init: async () => await invoke('notes.init'),
|
|
17
|
+
listFolders: async () => await invoke('notes.listFolders'),
|
|
18
|
+
createFolder: async (params) => await invoke('notes.createFolder', params),
|
|
19
|
+
renameFolder: async (params) => await invoke('notes.renameFolder', params),
|
|
20
|
+
deleteFolder: async (params) => await invoke('notes.deleteFolder', params),
|
|
21
|
+
listNotes: async (params) => await invoke('notes.listNotes', params),
|
|
22
|
+
createNote: async (params) => await invoke('notes.createNote', params),
|
|
23
|
+
getNote: async (params) => await invoke('notes.getNote', params),
|
|
24
|
+
updateNote: async (params) => await invoke('notes.updateNote', params),
|
|
25
|
+
deleteNote: async (params) => await invoke('notes.deleteNote', params),
|
|
26
|
+
listTags: async () => await invoke('notes.listTags'),
|
|
27
|
+
searchNotes: async (params) => await invoke('notes.searchNotes', params),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function mount({ container, host }) {
|
|
2
|
+
if (!container) throw new Error('container is required');
|
|
3
|
+
|
|
4
|
+
const ctx = typeof host?.context?.get === 'function' ? host.context.get() : {};
|
|
5
|
+
const root = document.createElement('div');
|
|
6
|
+
root.style.height = '100%';
|
|
7
|
+
root.style.boxSizing = 'border-box';
|
|
8
|
+
root.style.padding = '16px';
|
|
9
|
+
root.style.display = 'flex';
|
|
10
|
+
root.style.flexDirection = 'column';
|
|
11
|
+
root.style.gap = '10px';
|
|
12
|
+
|
|
13
|
+
const title = document.createElement('div');
|
|
14
|
+
title.textContent = 'Notepad (Compact)';
|
|
15
|
+
title.style.fontWeight = '700';
|
|
16
|
+
title.style.fontSize = '15px';
|
|
17
|
+
|
|
18
|
+
const meta = document.createElement('div');
|
|
19
|
+
meta.style.fontSize = '12px';
|
|
20
|
+
meta.style.opacity = '0.72';
|
|
21
|
+
meta.textContent = `${ctx?.pluginId || ''}:${ctx?.appId || ''} · compact`;
|
|
22
|
+
|
|
23
|
+
const desc = document.createElement('div');
|
|
24
|
+
desc.style.fontSize = '13px';
|
|
25
|
+
desc.style.opacity = '0.82';
|
|
26
|
+
desc.textContent = 'Render a streamlined list or quick actions for compact surfaces.';
|
|
27
|
+
|
|
28
|
+
root.appendChild(title);
|
|
29
|
+
root.appendChild(meta);
|
|
30
|
+
root.appendChild(desc);
|
|
31
|
+
|
|
32
|
+
container.appendChild(root);
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
try {
|
|
36
|
+
container.textContent = '';
|
|
37
|
+
} catch {
|
|
38
|
+
// ignore
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export function normalizeString(value) {
|
|
2
|
-
return typeof value === 'string' ? value.trim() : '';
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function isElement(node) {
|
|
6
|
-
return node && typeof node === 'object' && typeof node.appendChild === 'function';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function setButtonEnabled(btn, enabled) {
|
|
10
|
-
if (!btn) return;
|
|
11
|
-
btn.disabled = !enabled;
|
|
12
|
-
btn.dataset.disabled = enabled ? '0' : '1';
|
|
13
|
-
}
|
|
14
|
-
|
|
1
|
+
export function normalizeString(value) {
|
|
2
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function isElement(node) {
|
|
6
|
+
return node && typeof node === 'object' && typeof node.appendChild === 'function';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function setButtonEnabled(btn, enabled) {
|
|
10
|
+
if (!btn) return;
|
|
11
|
+
btn.disabled = !enabled;
|
|
12
|
+
btn.dataset.disabled = enabled ? '0' : '1';
|
|
13
|
+
}
|
|
14
|
+
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
async function importFirst(candidates) {
|
|
2
|
-
const list = Array.isArray(candidates) ? candidates : [];
|
|
3
|
-
let lastError = null;
|
|
4
|
-
for (const candidate of list) {
|
|
5
|
-
if (!candidate) continue;
|
|
6
|
-
try {
|
|
7
|
-
return await import(candidate);
|
|
8
|
-
} catch (err) {
|
|
9
|
-
lastError = err;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const hint = list.filter(Boolean).join('\n - ');
|
|
13
|
-
const message = `Failed to load ds-tree modules. Tried:\n - ${hint}`;
|
|
14
|
-
const error = new Error(message);
|
|
15
|
-
error.cause = lastError;
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function makeCandidates(relativePath) {
|
|
20
|
-
const rel = typeof relativePath === 'string' ? relativePath.trim() : '';
|
|
21
|
-
if (!rel) return [];
|
|
22
|
-
return [
|
|
23
|
-
new URL(`../../common/ui/${rel}`, import.meta.url).toString(),
|
|
24
|
-
new URL(`../../../../../common/ui/${rel}`, import.meta.url).toString(),
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const [treeView, treeStyles] = await Promise.all([
|
|
29
|
-
importFirst(makeCandidates('ds-tree-view.mjs')),
|
|
30
|
-
importFirst(makeCandidates('ds-tree-styles.mjs')),
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
|
-
export const createDsPathTreeView = treeView.createDsPathTreeView;
|
|
34
|
-
export const DS_TREE_STYLES = treeStyles.DS_TREE_STYLES;
|
|
35
|
-
|
|
1
|
+
async function importFirst(candidates) {
|
|
2
|
+
const list = Array.isArray(candidates) ? candidates : [];
|
|
3
|
+
let lastError = null;
|
|
4
|
+
for (const candidate of list) {
|
|
5
|
+
if (!candidate) continue;
|
|
6
|
+
try {
|
|
7
|
+
return await import(candidate);
|
|
8
|
+
} catch (err) {
|
|
9
|
+
lastError = err;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const hint = list.filter(Boolean).join('\n - ');
|
|
13
|
+
const message = `Failed to load ds-tree modules. Tried:\n - ${hint}`;
|
|
14
|
+
const error = new Error(message);
|
|
15
|
+
error.cause = lastError;
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function makeCandidates(relativePath) {
|
|
20
|
+
const rel = typeof relativePath === 'string' ? relativePath.trim() : '';
|
|
21
|
+
if (!rel) return [];
|
|
22
|
+
return [
|
|
23
|
+
new URL(`../../common/ui/${rel}`, import.meta.url).toString(),
|
|
24
|
+
new URL(`../../../../../common/ui/${rel}`, import.meta.url).toString(),
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const [treeView, treeStyles] = await Promise.all([
|
|
29
|
+
importFirst(makeCandidates('ds-tree-view.mjs')),
|
|
30
|
+
importFirst(makeCandidates('ds-tree-styles.mjs')),
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
export const createDsPathTreeView = treeView.createDsPathTreeView;
|
|
34
|
+
export const DS_TREE_STYLES = treeStyles.DS_TREE_STYLES;
|
|
35
|
+
|