@w3kits-com/plugin-opendesign 0.1.10 → 0.1.12

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 (125) hide show
  1. package/dist/404/index.html +1 -1
  2. package/dist/404.html +1 -1
  3. package/dist/__next.$oc$slug.__PAGE__.txt +1 -1
  4. package/dist/__next.$oc$slug.txt +1 -1
  5. package/dist/__next._full.txt +1 -1
  6. package/dist/__next._head.txt +1 -1
  7. package/dist/__next._index.txt +1 -1
  8. package/dist/__next._tree.txt +1 -1
  9. package/dist/__w3kits/webcontainer-runtime/package.json +6 -1
  10. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/browser-vfs/dist/index.d.ts +108 -0
  11. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/browser-vfs/dist/index.d.ts.map +1 -0
  12. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/browser-vfs/dist/index.mjs +413 -0
  13. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/browser-vfs/package.json +12 -0
  14. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/analytics/artifact-id.d.ts +5 -0
  15. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/analytics/artifact-id.d.ts.map +1 -0
  16. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/analytics/events.d.ts +250 -0
  17. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/analytics/events.d.ts.map +1 -0
  18. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/analytics/index.d.ts +4 -0
  19. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/analytics/index.d.ts.map +1 -0
  20. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/analytics/index.mjs +186 -0
  21. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/analytics/public-params.d.ts +26 -0
  22. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/analytics/public-params.d.ts.map +1 -0
  23. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/app-config.d.ts +44 -0
  24. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/app-config.d.ts.map +1 -0
  25. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/artifacts.d.ts +34 -0
  26. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/artifacts.d.ts.map +1 -0
  27. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/chat.d.ts +158 -0
  28. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/chat.d.ts.map +1 -0
  29. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/comments.d.ts +65 -0
  30. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/comments.d.ts.map +1 -0
  31. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/connectionTest.d.ts +49 -0
  32. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/connectionTest.d.ts.map +1 -0
  33. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/connectionTest.mjs +83 -0
  34. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/connectors.d.ts +133 -0
  35. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/connectors.d.ts.map +1 -0
  36. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/files.d.ts +43 -0
  37. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/files.d.ts.map +1 -0
  38. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/finalize.d.ts +50 -0
  39. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/finalize.d.ts.map +1 -0
  40. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/finalize.mjs +5 -0
  41. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/live-artifacts.d.ts +151 -0
  42. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/live-artifacts.d.ts.map +1 -0
  43. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/mcp.d.ts +117 -0
  44. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/mcp.d.ts.map +1 -0
  45. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/memory.d.ts +233 -0
  46. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/memory.d.ts.map +1 -0
  47. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/orbit.d.ts +22 -0
  48. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/orbit.d.ts.map +1 -0
  49. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/orbit.mjs +0 -0
  50. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/projects.d.ts +286 -0
  51. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/projects.d.ts.map +1 -0
  52. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/providerModels.d.ts +19 -0
  53. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/providerModels.d.ts.map +1 -0
  54. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/providerModels.mjs +0 -0
  55. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/proxy.d.ts +24 -0
  56. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/proxy.d.ts.map +1 -0
  57. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/registry.d.ts +156 -0
  58. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/registry.d.ts.map +1 -0
  59. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/research.d.ts +35 -0
  60. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/research.d.ts.map +1 -0
  61. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/research.mjs +9 -0
  62. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/routines.d.ts +104 -0
  63. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/routines.d.ts.map +1 -0
  64. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/version.d.ts +11 -0
  65. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/api/version.d.ts.map +1 -0
  66. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/common.d.ts +33 -0
  67. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/common.d.ts.map +1 -0
  68. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/critique.d.ts +344 -0
  69. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/critique.d.ts.map +1 -0
  70. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/critique.mjs +182 -0
  71. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/errors.d.ts +40 -0
  72. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/errors.d.ts.map +1 -0
  73. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/examples.d.ts +20 -0
  74. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/examples.d.ts.map +1 -0
  75. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/index.d.ts +31 -0
  76. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/index.d.ts.map +1 -0
  77. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/index.mjs +2072 -0
  78. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/deck-framework.d.ts +39 -0
  79. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/deck-framework.d.ts.map +1 -0
  80. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/directions.d.ts +69 -0
  81. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/directions.d.ts.map +1 -0
  82. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/discovery.d.ts +2 -0
  83. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/discovery.d.ts.map +1 -0
  84. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/media-contract.d.ts +2 -0
  85. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/media-contract.d.ts.map +1 -0
  86. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/official-system.d.ts +12 -0
  87. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/official-system.d.ts.map +1 -0
  88. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/system.d.ts +58 -0
  89. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/prompts/system.d.ts.map +1 -0
  90. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/sse/chat.d.ts +96 -0
  91. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/sse/chat.d.ts.map +1 -0
  92. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/sse/common.d.ts +8 -0
  93. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/sse/common.d.ts.map +1 -0
  94. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/sse/proxy.d.ts +6 -0
  95. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/sse/proxy.d.ts.map +1 -0
  96. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/tasks.d.ts +12 -0
  97. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/dist/tasks.d.ts.map +1 -0
  98. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/contracts/package.json +40 -0
  99. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/platform/dist/index.d.ts +68 -0
  100. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/platform/dist/index.d.ts.map +1 -0
  101. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/platform/dist/index.mjs +397 -0
  102. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/platform/package.json +12 -0
  103. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/sidecar/dist/index.d.ts +144 -0
  104. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/sidecar/dist/index.d.ts.map +1 -0
  105. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/sidecar/dist/index.mjs +412 -0
  106. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/sidecar/package.json +12 -0
  107. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/sidecar-proto/dist/index.d.ts +291 -0
  108. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/sidecar-proto/dist/index.d.ts.map +1 -0
  109. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/sidecar-proto/dist/index.mjs +315 -0
  110. package/dist/__w3kits/webcontainer-runtime/workspace-packages/@open-design/sidecar-proto/package.json +12 -0
  111. package/dist/_not-found/__next._full.txt +1 -1
  112. package/dist/_not-found/__next._head.txt +1 -1
  113. package/dist/_not-found/__next._index.txt +1 -1
  114. package/dist/_not-found/__next._not-found.__PAGE__.txt +1 -1
  115. package/dist/_not-found/__next._not-found.txt +1 -1
  116. package/dist/_not-found/__next._tree.txt +1 -1
  117. package/dist/_not-found/index.html +1 -1
  118. package/dist/_not-found/index.txt +1 -1
  119. package/dist/browser-daemon.js +20 -0
  120. package/dist/index.html +1 -1
  121. package/dist/index.txt +1 -1
  122. package/package.json +1 -1
  123. /package/dist/_next/static/{zDhAhlvmD2uhNsdWY6CQB → 5BA5jEbmoqCfBPFzdjNtN}/_buildManifest.js +0 -0
  124. /package/dist/_next/static/{zDhAhlvmD2uhNsdWY6CQB → 5BA5jEbmoqCfBPFzdjNtN}/_clientMiddlewareManifest.js +0 -0
  125. /package/dist/_next/static/{zDhAhlvmD2uhNsdWY6CQB → 5BA5jEbmoqCfBPFzdjNtN}/_ssgManifest.js +0 -0
@@ -0,0 +1,413 @@
1
+ // src/index.ts
2
+ var TEXT_ENCODER = new TextEncoder();
3
+ var TEXT_DECODER = new TextDecoder();
4
+ var BrowserVfsError = class extends Error {
5
+ constructor(code, message) {
6
+ super(message);
7
+ this.code = code;
8
+ this.name = "BrowserVfsError";
9
+ }
10
+ code;
11
+ };
12
+ function splitPath(path) {
13
+ return path.split("/").filter(Boolean);
14
+ }
15
+ function normalizeWorkspacePath(input) {
16
+ const trimmed = input.trim();
17
+ if (!trimmed) throw new BrowserVfsError("invalid_path", "Workspace path is required");
18
+ if (trimmed === "/") return "/";
19
+ if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) throw new BrowserVfsError("invalid_path", "Workspace path must not be a URL");
20
+ if (trimmed.includes("\\")) throw new BrowserVfsError("invalid_path", "Workspace path must use forward slashes");
21
+ const segments = splitPath(trimmed);
22
+ if (segments.length === 0) throw new BrowserVfsError("invalid_path", "Workspace path is required");
23
+ for (const segment of segments) {
24
+ if (segment === "." || segment === "..") throw new BrowserVfsError("path_traversal", "Workspace path must not traverse directories");
25
+ if (!/^[A-Za-z0-9._@=,+~ -]+$/.test(segment)) throw new BrowserVfsError("invalid_path", "Workspace path contains unsupported characters");
26
+ }
27
+ return "/" + segments.join("/");
28
+ }
29
+ function projectWorkspaceRoot(projectId) {
30
+ const normalized = normalizeWorkspacePath("/projects/" + projectId);
31
+ const segments = splitPath(normalized);
32
+ if (segments.length !== 2 || segments[0] !== "projects") throw new BrowserVfsError("invalid_project_id", "Project id must be a single safe path segment");
33
+ return normalized;
34
+ }
35
+ function pathWithinPrefix(path, prefix) {
36
+ return path === prefix || path.startsWith(prefix.endsWith("/") ? prefix : prefix + "/");
37
+ }
38
+ async function sha256Hex(data) {
39
+ const buffer = new ArrayBuffer(data.byteLength);
40
+ new Uint8Array(buffer).set(data);
41
+ try {
42
+ const digest = await crypto.subtle.digest("SHA-256", buffer);
43
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
44
+ } catch {
45
+ let hash = 2166136261;
46
+ for (const byte of data) {
47
+ hash ^= byte;
48
+ hash = Math.imul(hash, 16777619) >>> 0;
49
+ }
50
+ return hash.toString(16).padStart(8, "0");
51
+ }
52
+ }
53
+ function toBytes(data) {
54
+ return typeof data === "string" ? TEXT_ENCODER.encode(data) : data;
55
+ }
56
+ function bytesToBase64(data) {
57
+ let binary = "";
58
+ for (const byte of data) binary += String.fromCharCode(byte);
59
+ return btoa(binary);
60
+ }
61
+ function base64ToBytes(data) {
62
+ const binary = atob(data);
63
+ const bytes = new Uint8Array(binary.length);
64
+ for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);
65
+ return bytes;
66
+ }
67
+ function fileStat(path, data, options = {}) {
68
+ return sha256Hex(data).then((etag) => {
69
+ const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
70
+ return {
71
+ path,
72
+ size: data.byteLength,
73
+ etag,
74
+ revision: updatedAt + "-" + etag.slice(0, 12),
75
+ updatedAt,
76
+ ...options.contentType ? { contentType: options.contentType } : {}
77
+ };
78
+ });
79
+ }
80
+ function directoryEntriesFor(files, prefix) {
81
+ const directories = /* @__PURE__ */ new Set();
82
+ const root = prefix === "/" ? "/" : prefix.replace(/\/$/, "");
83
+ for (const file of files) {
84
+ if (!pathWithinPrefix(file.path, root)) continue;
85
+ const relative = root === "/" ? file.path.slice(1) : file.path.slice(root.length + 1);
86
+ const [first] = relative.split("/");
87
+ if (first && relative.includes("/")) directories.add((root === "/" ? "" : root) + "/" + first);
88
+ }
89
+ const updatedAt = (/* @__PURE__ */ new Date(0)).toISOString();
90
+ return Array.from(directories, (path) => ({ kind: "directory", path, size: 0, etag: "", revision: "", updatedAt })).sort((a, b) => a.path.localeCompare(b.path));
91
+ }
92
+ var MemoryWorkspaceBackend = class {
93
+ files = /* @__PURE__ */ new Map();
94
+ async stat(path) {
95
+ return this.files.get(normalizeWorkspacePath(path))?.metadata ?? null;
96
+ }
97
+ async readFile(path) {
98
+ const file = this.files.get(normalizeWorkspacePath(path));
99
+ return file ? new Uint8Array(file.body) : null;
100
+ }
101
+ async writeFile(path, data, options = {}) {
102
+ const normalized = normalizeWorkspacePath(path);
103
+ if (normalized === "/") throw new BrowserVfsError("invalid_path", "Workspace file path must not be root");
104
+ const body = new Uint8Array(data);
105
+ const metadata = await fileStat(normalized, body, options);
106
+ this.files.set(normalized, { body, metadata });
107
+ return metadata;
108
+ }
109
+ async deleteFile(path) {
110
+ return this.files.delete(normalizeWorkspacePath(path));
111
+ }
112
+ async listFiles(prefix = "/") {
113
+ const normalized = normalizeWorkspacePath(prefix);
114
+ const files = Array.from(this.files.values(), (file) => ({ ...file.metadata, kind: "file" }));
115
+ const directFiles = files.filter((file) => {
116
+ if (!pathWithinPrefix(file.path, normalized)) return false;
117
+ const relative = normalized === "/" ? file.path.slice(1) : file.path.slice(normalized.length + 1);
118
+ return relative.length > 0 && !relative.includes("/");
119
+ });
120
+ return [...directoryEntriesFor(files, normalized), ...directFiles].sort((a, b) => a.path.localeCompare(b.path));
121
+ }
122
+ async clear() {
123
+ this.files.clear();
124
+ }
125
+ };
126
+ var OpfsWorkspaceBackend = class _OpfsWorkspaceBackend {
127
+ constructor(root) {
128
+ this.root = root;
129
+ }
130
+ root;
131
+ index = null;
132
+ static async create(options = {}) {
133
+ const scope = options.globalScope ?? globalThis;
134
+ const getDirectory = scope.navigator?.storage?.getDirectory;
135
+ if (typeof getDirectory !== "function") throw new BrowserVfsError("opfs_unavailable", "OPFS is not available");
136
+ const storageRoot = await getDirectory.call(scope.navigator.storage);
137
+ const namespaceRoot = await storageRoot.getDirectoryHandle(options.namespace ?? "default", { create: true });
138
+ return new _OpfsWorkspaceBackend(namespaceRoot);
139
+ }
140
+ async filesDirectory() {
141
+ return this.root.getDirectoryHandle("files", { create: true });
142
+ }
143
+ async readIndex() {
144
+ if (this.index) return this.index;
145
+ try {
146
+ const handle = await this.root.getFileHandle("index.json");
147
+ const file = await handle.getFile();
148
+ const json = TEXT_DECODER.decode(await file.arrayBuffer());
149
+ const records = JSON.parse(json);
150
+ this.index = new Map(records.map((record) => [record.path, record]));
151
+ } catch {
152
+ this.index = /* @__PURE__ */ new Map();
153
+ }
154
+ return this.index;
155
+ }
156
+ async writeIndex() {
157
+ const index = await this.readIndex();
158
+ const handle = await this.root.getFileHandle("index.json", { create: true });
159
+ const writable = await handle.createWritable();
160
+ await writable.write(TEXT_ENCODER.encode(JSON.stringify(Array.from(index.values()).sort((a, b) => a.path.localeCompare(b.path)))));
161
+ await writable.close();
162
+ }
163
+ fileName(path) {
164
+ return encodeURIComponent(path);
165
+ }
166
+ async stat(path) {
167
+ return (await this.readIndex()).get(normalizeWorkspacePath(path)) ?? null;
168
+ }
169
+ async readFile(path) {
170
+ const normalized = normalizeWorkspacePath(path);
171
+ if (!(await this.readIndex()).has(normalized)) return null;
172
+ try {
173
+ const handle = await (await this.filesDirectory()).getFileHandle(this.fileName(normalized));
174
+ const file = await handle.getFile();
175
+ return new Uint8Array(await file.arrayBuffer());
176
+ } catch {
177
+ return null;
178
+ }
179
+ }
180
+ async writeFile(path, data, options = {}) {
181
+ const normalized = normalizeWorkspacePath(path);
182
+ if (normalized === "/") throw new BrowserVfsError("invalid_path", "Workspace file path must not be root");
183
+ const body = new Uint8Array(data);
184
+ const metadata = await fileStat(normalized, body, options);
185
+ const handle = await (await this.filesDirectory()).getFileHandle(this.fileName(normalized), { create: true });
186
+ const writable = await handle.createWritable();
187
+ await writable.write(body);
188
+ await writable.close();
189
+ (await this.readIndex()).set(normalized, metadata);
190
+ await this.writeIndex();
191
+ return metadata;
192
+ }
193
+ async deleteFile(path) {
194
+ const normalized = normalizeWorkspacePath(path);
195
+ const index = await this.readIndex();
196
+ const existed = index.delete(normalized);
197
+ if (!existed) return false;
198
+ await (await this.filesDirectory()).removeEntry?.(this.fileName(normalized));
199
+ await this.writeIndex();
200
+ return true;
201
+ }
202
+ async listFiles(prefix = "/") {
203
+ const normalized = normalizeWorkspacePath(prefix);
204
+ const files = Array.from((await this.readIndex()).values(), (file) => ({ ...file, kind: "file" }));
205
+ const directFiles = files.filter((file) => {
206
+ if (!pathWithinPrefix(file.path, normalized)) return false;
207
+ const relative = normalized === "/" ? file.path.slice(1) : file.path.slice(normalized.length + 1);
208
+ return relative.length > 0 && !relative.includes("/");
209
+ });
210
+ return [...directoryEntriesFor(files, normalized), ...directFiles].sort((a, b) => a.path.localeCompare(b.path));
211
+ }
212
+ async clear() {
213
+ const paths = Array.from((await this.readIndex()).keys());
214
+ for (const path of paths) await (await this.filesDirectory()).removeEntry?.(this.fileName(path));
215
+ this.index = /* @__PURE__ */ new Map();
216
+ await this.writeIndex();
217
+ }
218
+ };
219
+ function requestResult(request) {
220
+ return new Promise((resolve, reject) => {
221
+ request.onsuccess = () => resolve(request.result);
222
+ request.onerror = () => reject(request.error ?? new BrowserVfsError("indexeddb_error", "IndexedDB request failed"));
223
+ });
224
+ }
225
+ function transactionDone(transaction) {
226
+ return new Promise((resolve, reject) => {
227
+ transaction.oncomplete = () => resolve();
228
+ transaction.onabort = () => reject(transaction.error ?? new BrowserVfsError("indexeddb_aborted", "IndexedDB transaction aborted"));
229
+ transaction.onerror = () => reject(transaction.error ?? new BrowserVfsError("indexeddb_error", "IndexedDB transaction failed"));
230
+ });
231
+ }
232
+ var IndexedDbWorkspaceBackend = class _IndexedDbWorkspaceBackend {
233
+ constructor(db) {
234
+ this.db = db;
235
+ }
236
+ db;
237
+ static async create(options = {}) {
238
+ const scope = options.globalScope ?? globalThis;
239
+ const indexedDB = scope.indexedDB;
240
+ if (typeof indexedDB?.open !== "function") throw new BrowserVfsError("indexeddb_unavailable", "IndexedDB is not available");
241
+ const request = indexedDB.open("w3kits-browser-vfs:" + (options.namespace ?? "default"), 1);
242
+ request.onupgradeneeded = () => {
243
+ const db = request.result;
244
+ if (!db.objectStoreNames.contains("files")) db.createObjectStore("files", { keyPath: "path" });
245
+ };
246
+ return new _IndexedDbWorkspaceBackend(await requestResult(request));
247
+ }
248
+ store(mode) {
249
+ const transaction = this.db.transaction("files", mode);
250
+ return { store: transaction.objectStore("files"), done: transactionDone(transaction) };
251
+ }
252
+ async stat(path) {
253
+ const { store } = this.store("readonly");
254
+ const record = await requestResult(store.get(normalizeWorkspacePath(path)));
255
+ return record?.metadata ?? null;
256
+ }
257
+ async readFile(path) {
258
+ const { store } = this.store("readonly");
259
+ const record = await requestResult(store.get(normalizeWorkspacePath(path)));
260
+ return record ? new Uint8Array(record.body) : null;
261
+ }
262
+ async writeFile(path, data, options = {}) {
263
+ const normalized = normalizeWorkspacePath(path);
264
+ if (normalized === "/") throw new BrowserVfsError("invalid_path", "Workspace file path must not be root");
265
+ const body = new Uint8Array(data);
266
+ const metadata = await fileStat(normalized, body, options);
267
+ const { store, done } = this.store("readwrite");
268
+ const buffer = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
269
+ await requestResult(store.put({ path: normalized, body: buffer, metadata }));
270
+ await done;
271
+ return metadata;
272
+ }
273
+ async deleteFile(path) {
274
+ const normalized = normalizeWorkspacePath(path);
275
+ const existing = await this.stat(normalized);
276
+ if (!existing) return false;
277
+ const { store, done } = this.store("readwrite");
278
+ await requestResult(store.delete(normalized));
279
+ await done;
280
+ return true;
281
+ }
282
+ async listFiles(prefix = "/") {
283
+ const normalized = normalizeWorkspacePath(prefix);
284
+ const { store } = this.store("readonly");
285
+ const records = await requestResult(store.getAll());
286
+ const files = records.map((record) => ({ ...record.metadata, kind: "file" }));
287
+ const directFiles = files.filter((file) => {
288
+ if (!pathWithinPrefix(file.path, normalized)) return false;
289
+ const relative = normalized === "/" ? file.path.slice(1) : file.path.slice(normalized.length + 1);
290
+ return relative.length > 0 && !relative.includes("/");
291
+ });
292
+ return [...directoryEntriesFor(files, normalized), ...directFiles].sort((a, b) => a.path.localeCompare(b.path));
293
+ }
294
+ async clear() {
295
+ const { store, done } = this.store("readwrite");
296
+ await requestResult(store.clear());
297
+ await done;
298
+ }
299
+ };
300
+ async function createPersistentBrowserWorkspaceBackend(options = {}) {
301
+ if (isOpfsAvailable(options.globalScope ?? globalThis)) {
302
+ try {
303
+ return await OpfsWorkspaceBackend.create(options);
304
+ } catch {
305
+ }
306
+ }
307
+ if (isIndexedDbAvailable(options.globalScope ?? globalThis)) {
308
+ try {
309
+ return await IndexedDbWorkspaceBackend.create(options);
310
+ } catch {
311
+ }
312
+ }
313
+ return new MemoryWorkspaceBackend();
314
+ }
315
+ async function createPersistentBrowserWorkspace(options = {}) {
316
+ return createBrowserWorkspace(await createPersistentBrowserWorkspaceBackend(options));
317
+ }
318
+ function createBrowserWorkspace(backend = new MemoryWorkspaceBackend()) {
319
+ const dirty = /* @__PURE__ */ new Set();
320
+ return {
321
+ async readFile(path) {
322
+ return backend.readFile(path);
323
+ },
324
+ async readText(path) {
325
+ const bytes = await backend.readFile(path);
326
+ return bytes ? TEXT_DECODER.decode(bytes) : null;
327
+ },
328
+ async writeFile(path, data, options) {
329
+ const metadata = await backend.writeFile(path, toBytes(data), options);
330
+ dirty.add(metadata.path);
331
+ return metadata;
332
+ },
333
+ async deleteFile(path) {
334
+ const normalized = normalizeWorkspacePath(path);
335
+ const deleted = await backend.deleteFile(normalized);
336
+ if (deleted) dirty.add(normalized);
337
+ return deleted;
338
+ },
339
+ stat(path) {
340
+ return backend.stat(path);
341
+ },
342
+ listFiles(prefix) {
343
+ return backend.listFiles(prefix);
344
+ },
345
+ dirtyPaths() {
346
+ return Array.from(dirty).sort();
347
+ },
348
+ markClean(paths) {
349
+ if (!paths) {
350
+ dirty.clear();
351
+ return;
352
+ }
353
+ for (const path of paths) dirty.delete(normalizeWorkspacePath(path));
354
+ },
355
+ async exportSnapshot() {
356
+ const entries = await backend.listFiles("/");
357
+ const allFiles = await collectFilesRecursive(backend, entries);
358
+ const files = [];
359
+ for (const entry of allFiles) {
360
+ const body = await backend.readFile(entry.path);
361
+ if (!body) continue;
362
+ files.push({
363
+ path: entry.path,
364
+ contentBase64: bytesToBase64(body),
365
+ ...entry.contentType ? { contentType: entry.contentType } : {},
366
+ updatedAt: entry.updatedAt
367
+ });
368
+ }
369
+ return TEXT_ENCODER.encode(JSON.stringify({ version: 1, files }));
370
+ },
371
+ async importSnapshot(data, options = {}) {
372
+ const json = typeof data === "string" ? data : TEXT_DECODER.decode(data);
373
+ const snapshot = JSON.parse(json);
374
+ if (snapshot.version !== 1 || !Array.isArray(snapshot.files)) throw new BrowserVfsError("invalid_snapshot", "Unsupported workspace snapshot");
375
+ await backend.clear();
376
+ dirty.clear();
377
+ for (const file of snapshot.files) {
378
+ const metadata = await backend.writeFile(file.path, base64ToBytes(file.contentBase64), file.contentType ? { contentType: file.contentType } : {});
379
+ if (options.markDirty) dirty.add(metadata.path);
380
+ }
381
+ }
382
+ };
383
+ }
384
+ async function collectFilesRecursive(backend, entries) {
385
+ const files = [];
386
+ for (const entry of entries) {
387
+ if (entry.kind === "file") {
388
+ files.push(entry);
389
+ continue;
390
+ }
391
+ files.push(...await collectFilesRecursive(backend, await backend.listFiles(entry.path)));
392
+ }
393
+ return files.sort((a, b) => a.path.localeCompare(b.path));
394
+ }
395
+ function isOpfsAvailable(globalScope = globalThis) {
396
+ return typeof globalScope.navigator?.storage?.getDirectory === "function";
397
+ }
398
+ function isIndexedDbAvailable(globalScope = globalThis) {
399
+ return typeof globalScope.indexedDB?.open === "function";
400
+ }
401
+ export {
402
+ BrowserVfsError,
403
+ IndexedDbWorkspaceBackend,
404
+ MemoryWorkspaceBackend,
405
+ OpfsWorkspaceBackend,
406
+ createBrowserWorkspace,
407
+ createPersistentBrowserWorkspace,
408
+ createPersistentBrowserWorkspaceBackend,
409
+ isIndexedDbAvailable,
410
+ isOpfsAvailable,
411
+ normalizeWorkspacePath,
412
+ projectWorkspaceRoot
413
+ };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@open-design/browser-vfs",
3
+ "version": "0.7.0",
4
+ "type": "module",
5
+ "main": "./dist/index.mjs",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.mjs"
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,5 @@
1
+ export declare function anonymizeArtifactId(args: {
2
+ projectId: string;
3
+ fileName: string;
4
+ }): string;
5
+ //# sourceMappingURL=artifact-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-id.d.ts","sourceRoot":"","sources":["../../src/analytics/artifact-id.ts"],"names":[],"mappings":"AAmBA,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAQT"}
@@ -0,0 +1,250 @@
1
+ export type AnalyticsEventName = 'app_launch' | 'home_view' | 'home_click' | 'project_create_result' | 'settings_view' | 'settings_click' | 'settings_cli_test_result' | 'settings_byok_test_result' | 'studio_view' | 'studio_click' | 'run_created' | 'run_finished' | 'artifact_export_result';
2
+ export type TrackingProjectKind = 'prototype' | 'slide_deck' | 'template' | 'live_artifact' | 'image' | 'video' | 'audio';
3
+ export type TrackingSourceTab = 'prototype' | 'slide_deck' | 'from_template' | 'live_artifact' | 'image' | 'video' | 'audio';
4
+ export type TrackingFidelity = 'wireframe' | 'high_fidelity' | 'not_applicable';
5
+ export type TrackingExecutionMode = 'local_cli' | 'byok';
6
+ export type TrackingConfiguredProviderType = 'local_cli' | 'byok' | 'both' | 'none' | 'unknown';
7
+ export type TrackingExecutionAvailability = 'available' | 'unavailable' | 'unknown';
8
+ export type TrackingPlatform = 'web' | 'desktop';
9
+ export type TrackingLaunchSource = 'direct' | 'deeplink' | 'reload' | 'unknown';
10
+ export type TrackingTopTabId = 'designs' | 'examples' | 'design_systems' | 'image_templates' | 'video_templates';
11
+ export type TrackingActiveSection = 'execution_model' | 'media_providers' | 'language' | 'appearance' | 'pets' | 'about' | 'connectors' | 'mcp_client' | 'orbit' | 'routines' | 'integrations' | 'skills' | 'design_systems' | 'memory' | 'privacy' | 'notifications';
12
+ export type TrackingCliProviderId = 'claude_code' | 'codex_cli' | 'devin_terminal' | 'gemini_cli' | 'opencode' | 'hermes' | 'kimi_cli' | 'cursor_agent' | 'qwen_code' | 'github_copilot_cli' | 'pi' | 'other';
13
+ export type TrackingArtifactKind = 'html' | 'markdown' | 'image' | 'video' | 'audio' | 'doc' | 'unknown';
14
+ export type TrackingExportFormat = 'pdf' | 'pptx' | 'zip' | 'html' | 'markdown' | 'template' | 'vercel' | 'cloudflare_pages';
15
+ export type TrackingRunResult = 'success' | 'failed' | 'cancelled';
16
+ export type TrackingCreateResult = 'success' | 'failed';
17
+ export type TrackingExportResult = 'success' | 'failed' | 'cancelled';
18
+ export type TrackingTokenCountSource = 'provider_usage' | 'estimated' | 'unknown';
19
+ export interface AppLaunchProps {
20
+ page: 'app';
21
+ launch_source: TrackingLaunchSource;
22
+ platform: TrackingPlatform;
23
+ }
24
+ export interface HomeViewPageProps {
25
+ page: 'home';
26
+ has_available_cli: boolean;
27
+ has_available_byok: boolean;
28
+ configured_provider_type: TrackingConfiguredProviderType;
29
+ execution_availability: TrackingExecutionAvailability;
30
+ }
31
+ export interface HomeViewAssetPanelProps {
32
+ page: 'home';
33
+ area: 'asset_panel';
34
+ element: 'tab_content';
35
+ view_type: 'tab_content';
36
+ target_id: TrackingTopTabId;
37
+ result_count: number;
38
+ is_empty: boolean;
39
+ }
40
+ export interface HomeClickCreateButtonProps {
41
+ page: 'home';
42
+ area: 'create_panel';
43
+ element: 'create_button';
44
+ action: 'create_project';
45
+ source_tab: TrackingSourceTab;
46
+ project_kind: TrackingProjectKind;
47
+ has_project_name: boolean;
48
+ }
49
+ export interface ProjectCreateResultProps {
50
+ page: 'home';
51
+ area: 'create_panel';
52
+ action_source: 'create_button' | 'import_claude_design_zip' | 'open_folder';
53
+ project_id: string | null;
54
+ project_kind: TrackingProjectKind | null;
55
+ creation_source: 'blank' | 'template' | 'zip' | 'folder';
56
+ fidelity: TrackingFidelity;
57
+ result: TrackingCreateResult;
58
+ error_code?: string;
59
+ }
60
+ export interface SettingsViewProps {
61
+ page: 'settings';
62
+ area: 'settings_panel';
63
+ element: 'page';
64
+ view_type: 'page';
65
+ active_section: TrackingActiveSection;
66
+ execution_mode: TrackingExecutionMode;
67
+ has_available_cli: boolean;
68
+ selected_cli_id?: TrackingCliProviderId;
69
+ }
70
+ export interface SettingsClickExecutionModeTabProps {
71
+ page: 'settings';
72
+ area: 'execution_model';
73
+ element: 'execution_mode_tab';
74
+ action: 'switch_execution_mode';
75
+ mode_before: TrackingExecutionMode;
76
+ mode_after: TrackingExecutionMode;
77
+ byok_protocol_after?: 'anthropic' | 'openai';
78
+ }
79
+ export interface SettingsClickCliProviderCardProps {
80
+ page: 'settings';
81
+ area: 'execution_model';
82
+ element: 'cli_provider_card';
83
+ action: 'select_cli_provider';
84
+ cli_provider_id: TrackingCliProviderId;
85
+ install_status: 'installed' | 'not_installed' | 'unknown';
86
+ is_selected: boolean;
87
+ }
88
+ export interface SettingsClickByokProviderOptionProps {
89
+ page: 'settings';
90
+ area: 'execution_model';
91
+ element: 'byok_provider_option';
92
+ action: 'select_byok_provider';
93
+ provider_id: 'anthropic' | 'openai' | 'azure' | 'ollama' | 'google';
94
+ is_selected: boolean;
95
+ }
96
+ export interface SettingsClickByokFieldProps {
97
+ page: 'settings';
98
+ area: 'execution_model';
99
+ element: 'byok_field';
100
+ action: 'focus_byok_field';
101
+ field_id: 'api_key' | 'base_url' | 'model';
102
+ provider_id: 'anthropic' | 'openai' | 'azure' | 'ollama' | 'google';
103
+ has_value: boolean;
104
+ }
105
+ export interface SettingsCliTestResultProps {
106
+ page: 'settings';
107
+ area: 'execution_model';
108
+ cli_provider_id: TrackingCliProviderId;
109
+ result: 'success' | 'failed' | 'timeout';
110
+ error_code?: string;
111
+ duration_ms: number;
112
+ }
113
+ export interface SettingsByokTestResultProps {
114
+ page: 'settings';
115
+ area: 'execution_model';
116
+ provider_id: 'anthropic' | 'openai' | 'azure' | 'ollama' | 'google';
117
+ result: 'success' | 'failed' | 'timeout';
118
+ error_code?: string;
119
+ duration_ms: number;
120
+ }
121
+ export interface StudioViewChatPanelProps {
122
+ page: 'studio';
123
+ area: 'chat_panel';
124
+ element: 'chat_tab';
125
+ view_type: 'panel';
126
+ source: 'create_project' | 'template' | 'open_project';
127
+ conversation_id: string | null;
128
+ }
129
+ export interface StudioClickChatComposerProps {
130
+ page: 'studio';
131
+ area: 'chat_composer';
132
+ element: 'prompt_template_card' | 'chat_composer_input' | 'composer_settings_button' | 'attachment_button' | 'send_button';
133
+ action: 'click_composer_control';
134
+ user_query_tokens: number;
135
+ has_attachment: boolean;
136
+ }
137
+ export interface RunCreatedProps {
138
+ page: 'studio';
139
+ area: 'chat_composer';
140
+ project_id: string;
141
+ conversation_id: string | null;
142
+ run_id: string;
143
+ project_kind: TrackingProjectKind | null;
144
+ design_system_id?: string;
145
+ design_system_source: 'default' | 'user_selected' | 'template_inherited' | 'project_saved' | 'not_applicable' | 'unknown';
146
+ design_system_version?: string;
147
+ has_attachment: boolean;
148
+ user_query_tokens: number;
149
+ model_id: string | null;
150
+ agent_provider_id: string | null;
151
+ skill_id: string | null;
152
+ mcp_id: string | null;
153
+ token_count_source: TrackingTokenCountSource;
154
+ }
155
+ export interface RunFinishedProps extends Omit<RunCreatedProps, 'area'> {
156
+ area: 'chat_panel';
157
+ result: TrackingRunResult;
158
+ error_code?: string;
159
+ artifact_count: number;
160
+ input_tokens?: number;
161
+ output_tokens?: number;
162
+ total_tokens?: number;
163
+ time_to_first_token_ms?: number;
164
+ generation_duration_ms?: number;
165
+ total_duration_ms: number;
166
+ }
167
+ export interface StudioViewArtifactProps {
168
+ page: 'studio';
169
+ area: 'artifact';
170
+ element: 'artifact_view';
171
+ view_type: 'artifact';
172
+ artifact_id: string;
173
+ artifact_kind: TrackingArtifactKind;
174
+ project_id: string;
175
+ project_kind: TrackingProjectKind;
176
+ }
177
+ export interface StudioClickShareOptionProps {
178
+ page: 'studio';
179
+ area: 'app_header';
180
+ artifact_id: string;
181
+ element: 'share_option';
182
+ action: 'select_share_option';
183
+ share_context: 'artifact';
184
+ export_format: TrackingExportFormat;
185
+ project_id: string;
186
+ project_kind: TrackingProjectKind;
187
+ }
188
+ export interface ArtifactExportResultProps {
189
+ page: 'studio';
190
+ area: 'app_header';
191
+ artifact_id: string;
192
+ project_id: string;
193
+ project_kind: TrackingProjectKind;
194
+ export_format: TrackingExportFormat;
195
+ result: TrackingExportResult;
196
+ error_code?: string;
197
+ export_duration_ms: number;
198
+ }
199
+ export type AnalyticsEventPayload = {
200
+ event: 'app_launch';
201
+ props: AppLaunchProps;
202
+ } | {
203
+ event: 'home_view';
204
+ props: HomeViewPageProps | HomeViewAssetPanelProps;
205
+ } | {
206
+ event: 'home_click';
207
+ props: HomeClickCreateButtonProps;
208
+ } | {
209
+ event: 'project_create_result';
210
+ props: ProjectCreateResultProps;
211
+ } | {
212
+ event: 'settings_view';
213
+ props: SettingsViewProps;
214
+ } | {
215
+ event: 'settings_click';
216
+ props: SettingsClickExecutionModeTabProps | SettingsClickCliProviderCardProps | SettingsClickByokProviderOptionProps | SettingsClickByokFieldProps;
217
+ } | {
218
+ event: 'settings_cli_test_result';
219
+ props: SettingsCliTestResultProps;
220
+ } | {
221
+ event: 'settings_byok_test_result';
222
+ props: SettingsByokTestResultProps;
223
+ } | {
224
+ event: 'studio_view';
225
+ props: StudioViewChatPanelProps | StudioViewArtifactProps;
226
+ } | {
227
+ event: 'studio_click';
228
+ props: StudioClickChatComposerProps | StudioClickShareOptionProps;
229
+ } | {
230
+ event: 'run_created';
231
+ props: RunCreatedProps;
232
+ } | {
233
+ event: 'run_finished';
234
+ props: RunFinishedProps;
235
+ } | {
236
+ event: 'artifact_export_result';
237
+ props: ArtifactExportResultProps;
238
+ };
239
+ export declare function projectKindToTracking(kind: string | null | undefined): TrackingProjectKind | null;
240
+ export declare function createTabToTracking(tab: string): TrackingSourceTab;
241
+ export declare function fidelityToTracking(fidelity: string | null | undefined): TrackingFidelity;
242
+ export declare function topTabToTracking(tab: string): TrackingTopTabId;
243
+ export declare function settingsSectionToTracking(section: string): TrackingActiveSection;
244
+ export declare function executionModeToTracking(mode: string | null | undefined): TrackingExecutionMode;
245
+ export declare function agentIdToTracking(agentId: string | null | undefined): TrackingCliProviderId;
246
+ export declare function artifactKindToTracking(args: {
247
+ rendererId?: string | null;
248
+ fileKind?: string | null;
249
+ }): TrackingArtifactKind;
250
+ //# sourceMappingURL=events.d.ts.map