@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.
Files changed (62) hide show
  1. package/README.md +75 -60
  2. package/bin/chatos-uiapp.js +4 -4
  3. package/package.json +26 -20
  4. package/src/cli.js +53 -53
  5. package/src/commands/dev.js +14 -14
  6. package/src/commands/init.js +131 -129
  7. package/src/commands/install.js +47 -46
  8. package/src/commands/pack.js +72 -72
  9. package/src/commands/validate.js +138 -80
  10. package/src/lib/args.js +49 -49
  11. package/src/lib/config.js +29 -29
  12. package/src/lib/fs.js +78 -78
  13. package/src/lib/path-boundary.js +16 -16
  14. package/src/lib/plugin.js +45 -45
  15. package/src/lib/state-constants.js +2 -0
  16. package/src/lib/template.js +172 -168
  17. package/src/sandbox/server.js +1957 -692
  18. package/templates/basic/README.md +78 -54
  19. package/templates/basic/chatos.config.json +5 -5
  20. package/templates/basic/docs/CHATOS_UI_APPS_AI_CONTRIBUTIONS.md +214 -181
  21. package/templates/basic/docs/CHATOS_UI_APPS_BACKEND_PROTOCOL.md +75 -74
  22. package/templates/basic/docs/CHATOS_UI_APPS_HOST_API.md +136 -123
  23. package/templates/basic/docs/CHATOS_UI_APPS_OVERVIEW.md +112 -107
  24. package/templates/basic/docs/CHATOS_UI_APPS_PLUGIN_MANIFEST.md +242 -227
  25. package/templates/basic/docs/CHATOS_UI_APPS_STYLE_GUIDE.md +95 -0
  26. package/templates/basic/docs/CHATOS_UI_APPS_TROUBLESHOOTING.md +45 -0
  27. package/templates/basic/docs/CHATOS_UI_PROMPTS_PROTOCOL.md +392 -392
  28. package/templates/basic/plugin/apps/app/compact.mjs +41 -0
  29. package/templates/basic/plugin/apps/app/index.mjs +287 -263
  30. package/templates/basic/plugin/apps/app/mcp-prompt.en.md +7 -7
  31. package/templates/basic/plugin/apps/app/mcp-prompt.zh.md +7 -7
  32. package/templates/basic/plugin/apps/app/mcp-server.mjs +15 -15
  33. package/templates/basic/plugin/backend/index.mjs +37 -37
  34. package/templates/basic/template.json +7 -7
  35. package/templates/notepad/README.md +55 -24
  36. package/templates/notepad/chatos.config.json +4 -4
  37. package/templates/notepad/docs/CHATOS_UI_APPS_AI_CONTRIBUTIONS.md +214 -181
  38. package/templates/notepad/docs/CHATOS_UI_APPS_BACKEND_PROTOCOL.md +75 -74
  39. package/templates/notepad/docs/CHATOS_UI_APPS_HOST_API.md +136 -123
  40. package/templates/notepad/docs/CHATOS_UI_APPS_OVERVIEW.md +112 -107
  41. package/templates/notepad/docs/CHATOS_UI_APPS_PLUGIN_MANIFEST.md +242 -227
  42. package/templates/notepad/docs/CHATOS_UI_APPS_STYLE_GUIDE.md +95 -0
  43. package/templates/notepad/docs/CHATOS_UI_APPS_TROUBLESHOOTING.md +45 -0
  44. package/templates/notepad/docs/CHATOS_UI_PROMPTS_PROTOCOL.md +392 -392
  45. package/templates/notepad/plugin/apps/app/api.mjs +30 -30
  46. package/templates/notepad/plugin/apps/app/compact.mjs +41 -0
  47. package/templates/notepad/plugin/apps/app/dom.mjs +14 -14
  48. package/templates/notepad/plugin/apps/app/ds-tree.mjs +35 -35
  49. package/templates/notepad/plugin/apps/app/index.mjs +1056 -1056
  50. package/templates/notepad/plugin/apps/app/layers.mjs +338 -338
  51. package/templates/notepad/plugin/apps/app/markdown.mjs +120 -120
  52. package/templates/notepad/plugin/apps/app/mcp-prompt.en.md +22 -22
  53. package/templates/notepad/plugin/apps/app/mcp-prompt.zh.md +22 -22
  54. package/templates/notepad/plugin/apps/app/mcp-server.mjs +206 -199
  55. package/templates/notepad/plugin/apps/app/styles.mjs +355 -355
  56. package/templates/notepad/plugin/apps/app/tags.mjs +21 -21
  57. package/templates/notepad/plugin/apps/app/ui.mjs +280 -280
  58. package/templates/notepad/plugin/backend/index.mjs +99 -99
  59. package/templates/notepad/plugin/plugin.json +23 -23
  60. package/templates/notepad/plugin/shared/notepad-paths.mjs +59 -41
  61. package/templates/notepad/plugin/shared/notepad-store.mjs +765 -765
  62. 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
+