flingit 0.0.9 → 0.0.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.
Files changed (149) hide show
  1. package/dist/cli/commands/admin.d.ts.map +1 -1
  2. package/dist/cli/commands/admin.js +29 -16
  3. package/dist/cli/commands/admin.js.map +1 -1
  4. package/dist/cli/commands/cron.d.ts.map +1 -1
  5. package/dist/cli/commands/cron.js +7 -3
  6. package/dist/cli/commands/cron.js.map +1 -1
  7. package/dist/cli/commands/db.d.ts.map +1 -1
  8. package/dist/cli/commands/db.js +5 -2
  9. package/dist/cli/commands/db.js.map +1 -1
  10. package/dist/cli/commands/feedback.d.ts.map +1 -1
  11. package/dist/cli/commands/feedback.js +6 -1
  12. package/dist/cli/commands/feedback.js.map +1 -1
  13. package/dist/cli/commands/init.d.ts.map +1 -1
  14. package/dist/cli/commands/init.js +5 -20
  15. package/dist/cli/commands/init.js.map +1 -1
  16. package/dist/cli/commands/launch.d.ts.map +1 -1
  17. package/dist/cli/commands/launch.js +5 -59
  18. package/dist/cli/commands/launch.js.map +1 -1
  19. package/dist/cli/commands/login.d.ts.map +1 -1
  20. package/dist/cli/commands/login.js +7 -2
  21. package/dist/cli/commands/login.js.map +1 -1
  22. package/dist/cli/commands/logs.d.ts.map +1 -1
  23. package/dist/cli/commands/logs.js +3 -1
  24. package/dist/cli/commands/logs.js.map +1 -1
  25. package/dist/cli/commands/onboard.js +1 -1
  26. package/dist/cli/commands/plugin.d.ts +8 -0
  27. package/dist/cli/commands/plugin.d.ts.map +1 -0
  28. package/dist/cli/commands/plugin.js +407 -0
  29. package/dist/cli/commands/plugin.js.map +1 -0
  30. package/dist/cli/commands/project.d.ts.map +1 -1
  31. package/dist/cli/commands/project.js +3 -1
  32. package/dist/cli/commands/project.js.map +1 -1
  33. package/dist/cli/commands/push.d.ts.map +1 -1
  34. package/dist/cli/commands/push.js +88 -11
  35. package/dist/cli/commands/push.js.map +1 -1
  36. package/dist/cli/commands/register.d.ts +25 -0
  37. package/dist/cli/commands/register.d.ts.map +1 -1
  38. package/dist/cli/commands/register.js +30 -13
  39. package/dist/cli/commands/register.js.map +1 -1
  40. package/dist/cli/commands/secret.d.ts +4 -0
  41. package/dist/cli/commands/secret.d.ts.map +1 -1
  42. package/dist/cli/commands/secret.js +11 -22
  43. package/dist/cli/commands/secret.js.map +1 -1
  44. package/dist/cli/commands/storage.d.ts +10 -0
  45. package/dist/cli/commands/storage.d.ts.map +1 -0
  46. package/dist/cli/commands/storage.js +459 -0
  47. package/dist/cli/commands/storage.js.map +1 -0
  48. package/dist/cli/commands/tun.d.ts.map +1 -1
  49. package/dist/cli/commands/tun.js +3 -2
  50. package/dist/cli/commands/tun.js.map +1 -1
  51. package/dist/cli/deploy/bundler.d.ts +15 -0
  52. package/dist/cli/deploy/bundler.d.ts.map +1 -1
  53. package/dist/cli/deploy/bundler.js +86 -2
  54. package/dist/cli/deploy/bundler.js.map +1 -1
  55. package/dist/cli/index.js +4 -0
  56. package/dist/cli/index.js.map +1 -1
  57. package/dist/cli/utils/config.d.ts +12 -0
  58. package/dist/cli/utils/config.d.ts.map +1 -1
  59. package/dist/cli/utils/config.js +23 -3
  60. package/dist/cli/utils/config.js.map +1 -1
  61. package/dist/cli/utils/environment.d.ts +12 -0
  62. package/dist/cli/utils/environment.d.ts.map +1 -1
  63. package/dist/cli/utils/environment.js +40 -6
  64. package/dist/cli/utils/environment.js.map +1 -1
  65. package/dist/cli/utils/launch-io-impl.d.ts +13 -0
  66. package/dist/cli/utils/launch-io-impl.d.ts.map +1 -0
  67. package/dist/cli/utils/launch-io-impl.js +51 -0
  68. package/dist/cli/utils/launch-io-impl.js.map +1 -0
  69. package/dist/cli/utils/launch-io.d.ts +42 -0
  70. package/dist/cli/utils/launch-io.d.ts.map +1 -0
  71. package/dist/cli/utils/launch-io.js +8 -0
  72. package/dist/cli/utils/launch-io.js.map +1 -0
  73. package/dist/cli/utils/project-name.d.ts +17 -0
  74. package/dist/cli/utils/project-name.d.ts.map +1 -0
  75. package/dist/cli/utils/project-name.js +33 -0
  76. package/dist/cli/utils/project-name.js.map +1 -0
  77. package/dist/cli/utils/prompt-new-project.d.ts +12 -0
  78. package/dist/cli/utils/prompt-new-project.d.ts.map +1 -0
  79. package/dist/cli/utils/prompt-new-project.js +66 -0
  80. package/dist/cli/utils/prompt-new-project.js.map +1 -0
  81. package/dist/client/assets/index-BqVrS7t9.js +40 -0
  82. package/dist/client/assets/index-DSLUsCtO.css +1 -0
  83. package/dist/client/index.html +14 -0
  84. package/dist/client/vite.svg +1 -0
  85. package/dist/index.d.ts +3 -1
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +2 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/runtime/db.d.ts +5 -0
  90. package/dist/runtime/db.d.ts.map +1 -1
  91. package/dist/runtime/db.js +6 -1
  92. package/dist/runtime/db.js.map +1 -1
  93. package/dist/runtime/discord.d.ts +171 -0
  94. package/dist/runtime/discord.d.ts.map +1 -0
  95. package/dist/runtime/discord.js +192 -0
  96. package/dist/runtime/discord.js.map +1 -0
  97. package/dist/runtime/secrets.d.ts +22 -0
  98. package/dist/runtime/secrets.d.ts.map +1 -1
  99. package/dist/runtime/secrets.js +58 -18
  100. package/dist/runtime/secrets.js.map +1 -1
  101. package/dist/runtime/storage.d.ts +29 -0
  102. package/dist/runtime/storage.d.ts.map +1 -0
  103. package/dist/runtime/storage.js +456 -0
  104. package/dist/runtime/storage.js.map +1 -0
  105. package/dist/shared/constants.d.ts +12 -0
  106. package/dist/shared/constants.d.ts.map +1 -0
  107. package/dist/shared/constants.js +12 -0
  108. package/dist/shared/constants.js.map +1 -0
  109. package/dist/shared/discord-types.d.ts +130 -0
  110. package/dist/shared/discord-types.d.ts.map +1 -0
  111. package/dist/shared/discord-types.js +8 -0
  112. package/dist/shared/discord-types.js.map +1 -0
  113. package/dist/shared/random-code.d.ts +6 -0
  114. package/dist/shared/random-code.d.ts.map +1 -0
  115. package/dist/shared/random-code.js +23 -0
  116. package/dist/shared/random-code.js.map +1 -0
  117. package/dist/types/storage.d.ts +154 -0
  118. package/dist/types/storage.d.ts.map +1 -0
  119. package/dist/types/storage.js +8 -0
  120. package/dist/types/storage.js.map +1 -0
  121. package/dist/worker-runtime/discord.d.ts +61 -0
  122. package/dist/worker-runtime/discord.d.ts.map +1 -0
  123. package/dist/worker-runtime/discord.js +181 -0
  124. package/dist/worker-runtime/discord.js.map +1 -0
  125. package/dist/worker-runtime/index.d.ts +21 -1
  126. package/dist/worker-runtime/index.d.ts.map +1 -1
  127. package/dist/worker-runtime/index.js +102 -0
  128. package/dist/worker-runtime/index.js.map +1 -1
  129. package/package.json +9 -2
  130. package/templates/default/CLAUDE.md +65 -11
  131. package/templates/default/skills/discord/SKILL.md +328 -0
  132. package/templates/default/skills/fling/API.md +208 -0
  133. package/templates/default/skills/fling/SKILL.md +51 -8
  134. package/dist/cli/deploy/worker-entry.d.ts +0 -14
  135. package/dist/cli/deploy/worker-entry.d.ts.map +0 -1
  136. package/dist/cli/deploy/worker-entry.js +0 -60
  137. package/dist/cli/deploy/worker-entry.js.map +0 -1
  138. package/dist/cli/deploy/wrangler-config.d.ts +0 -20
  139. package/dist/cli/deploy/wrangler-config.d.ts.map +0 -1
  140. package/dist/cli/deploy/wrangler-config.js +0 -54
  141. package/dist/cli/deploy/wrangler-config.js.map +0 -1
  142. package/dist/cli/loaders/register-wasm.d.ts +0 -12
  143. package/dist/cli/loaders/register-wasm.d.ts.map +0 -1
  144. package/dist/cli/loaders/register-wasm.js +0 -19
  145. package/dist/cli/loaders/register-wasm.js.map +0 -1
  146. package/dist/cli/loaders/wasm-hooks.d.ts +0 -61
  147. package/dist/cli/loaders/wasm-hooks.d.ts.map +0 -1
  148. package/dist/cli/loaders/wasm-hooks.js +0 -63
  149. package/dist/cli/loaders/wasm-hooks.js.map +0 -1
@@ -4,14 +4,16 @@ You are working on a Fling project - a personal software platform for building a
4
4
 
5
5
  ## Core Concepts
6
6
 
7
- Fling provides six primitives that work identically in local development and production:
7
+ Fling provides seven primitives that work identically in local development and production:
8
8
 
9
9
  1. **HTTP** - Expose endpoints via Hono
10
10
  2. **Database** - SQLite locally, D1 in production
11
11
  3. **Secrets** - Secure credential management
12
12
  4. **Migrations** - Version your database schema
13
13
  5. **Cron** - Scheduled tasks that run on a schedule
14
- 6. **WASM** - WebAssembly modules for compute-intensive tasks
14
+ 6. **Storage** - File system locally, R2 in production
15
+ 7. **Discord** - Chatops integration (slash commands, messages, interactions) — see `.claude/skills/discord/SKILL.md`
16
+ 8. **WASM** - WebAssembly modules for compute-intensive tasks
15
17
 
16
18
  ## Project Structure
17
19
 
@@ -68,6 +70,23 @@ cron("hourly-stats", "0 * * * *", async () => {
68
70
  const stats = await generateStats();
69
71
  return { processed: stats.count }; // Optional return value stored in history
70
72
  });
73
+
74
+ // Storage (local filesystem / R2)
75
+ import { storage } from "flingit";
76
+
77
+ // Store and retrieve files
78
+ await storage.put("images/logo.png", imageBuffer, { contentType: "image/png" });
79
+ const file = await storage.get("images/logo.png");
80
+ if (file) {
81
+ const buffer = await file.arrayBuffer();
82
+ const text = await file.text();
83
+ console.log(file.size, file.uploaded, file.contentType);
84
+ }
85
+
86
+ // Check existence, delete, list
87
+ const meta = await storage.head("images/logo.png");
88
+ await storage.delete("old-file.txt");
89
+ const result = await storage.list({ prefix: "images/", limit: 100 });
71
90
  ```
72
91
 
73
92
  ```typescript
@@ -107,6 +126,11 @@ npm exec fling project slug:set <new-slug> # Change project slug (affects URL)
107
126
  npm exec fling cron list # List registered cron jobs
108
127
  npm exec fling cron history <name> # View invocation history
109
128
  npm exec fling cron trigger <name> # Manually trigger a cron job
129
+ npm exec fling storage list # List storage objects
130
+ npm exec fling storage put <key> <file> # Upload file to storage
131
+ npm exec fling storage get <key> [output] # Download object (stdout if no output)
132
+ npm exec fling storage delete <key> --yes # Delete object
133
+ npm exec fling storage info # Show storage stats
110
134
  ```
111
135
 
112
136
  ### Debugging Cron Jobs in Production
@@ -133,11 +157,13 @@ Commands default to local environment. Use `--prod` for production:
133
157
  npm exec fling secret list # Local secrets
134
158
  npm exec fling logs # Local logs
135
159
  npm exec fling db sql "SELECT 1" # Local SQLite
160
+ npm exec fling storage list # Local storage
136
161
 
137
162
  # Production (requires login)
138
163
  npm exec fling -- --prod secret list # Deployed secrets
139
164
  npm exec fling -- --prod logs # Deployed logs
140
165
  npm exec fling -- --prod db sql "SELECT 1" # Deployed D1
166
+ npm exec fling -- --prod storage list # R2 storage
141
167
  ```
142
168
 
143
169
  **Note:** Production logs have a delay of ~10 seconds or more before they appear.
@@ -174,23 +200,40 @@ When the user's request is complete and working locally, deploy it:
174
200
  - All other paths serve static assets from `dist/client/`
175
201
  - If no asset matches, `index.html` is served (SPA fallback)
176
202
 
203
+ ## Collaborating with Others
204
+
205
+ If the user asks how to collaborate with another user on their Fling project, the best approach is:
206
+
207
+ 1. **Host the project on GitHub** - Push their Fling project to a GitHub repository
208
+ 2. **Set up a GitHub Action** - Automatically deploy to Fling when pushing to main
209
+ 3. **Add collaborators** - Invite other users as collaborators on the GitHub repo
210
+
211
+ This gives collaborators:
212
+ - Full access to the codebase via Git
213
+ - Automatic deployments when changes are merged
214
+ - Standard code review workflow via pull requests
215
+
216
+ **Offer to help set this up.** You can create the GitHub repository, write the GitHub Actions workflow file, and guide them through adding collaborators.
217
+
177
218
  ## Important Constraints
178
219
 
179
220
  1. **Backend code runs in Cloudflare Workers** - This is NOT a Node.js environment. You cannot use Node.js-specific APIs (`fs`, `path`, `child_process`, etc.) or npm packages that depend on them. Only use packages that explicitly support Cloudflare Workers or are pure JavaScript/TypeScript with no Node.js dependencies.
180
221
 
181
222
  2. **Memory limit (~128MB)** - Workers have limited memory. Cannot process large datasets in memory. Use streaming, pagination, or chunked processing for large data.
182
223
 
183
- 3. **Feature scope** - Fling supports frontend, backend, database, and cron jobs. Not yet supported: file/blob storage, websockets. If users need these, encourage feedback via `npm exec fling feedback`.
224
+ 3. **Bundle size limit (10MB)** - Cloudflare Workers have a 10MB bundle size limit. Choose lightweight packages to stay under this limit. For example, use `pdf-lib` for PDF generation instead of heavier alternatives. Avoid packages that bundle large dependencies.
225
+
226
+ 4. **Feature scope** - Fling supports frontend, backend, database, cron jobs, file storage (R2), and Discord integration. Not yet supported: websockets. If users need these, encourage feedback via `npm exec fling feedback`.
184
227
 
185
- 4. **Database operations cannot be at module top-level** - They must be inside route handlers or functions called by them.
228
+ 5. **Database operations cannot be at module top-level** - They must be inside route handlers or functions called by them.
186
229
 
187
- 5. **Secrets throw on missing** - No default values. Use `fling secret set` to configure.
230
+ 6. **Secrets throw on missing** - No default values. Use `fling secret set` to configure.
188
231
 
189
- 6. **Use /api prefix for backend routes** - Required for Vite proxy during development.
232
+ 7. **Use /api prefix for backend routes** - Required for Vite proxy during development.
190
233
 
191
- 7. **Run commands yourself** - You have bash access. Don't ask the user to run `fling push`, `fling dev`, `npm start`, etc. Execute them directly.
234
+ 8. **Run commands yourself** - You have bash access. Don't ask the user to run `fling push`, `fling dev`, `npm start`, etc. Execute them directly.
192
235
 
193
- 8. **Reserved paths (`/__*`)** - Paths starting with `/__` are reserved for internal platform use (e.g., `/__cron` for cron jobs). Do not create routes with these prefixes.
236
+ 9. **Reserved paths (`/__*`)** - Paths starting with `/__` are reserved for internal platform use (e.g., `/__cron` for cron jobs). Do not create routes with these prefixes.
194
237
 
195
238
  **If the user's request might hit platform limitations, warn them early and suggest alternatives.**
196
239
 
@@ -1,14 +0,0 @@
1
- /**
2
- * Generate the _worker.ts entry point for Cloudflare Workers
3
- *
4
- * This creates a wrapper that:
5
- * 1. Initializes the Worker environment (bindings)
6
- * 2. Dynamically imports the user's app code (after env is ready)
7
- * 3. Exports fetch and scheduled handlers
8
- */
9
- /**
10
- * Generate the _worker.ts content for deployment.
11
- * Includes both HTTP fetch and cron scheduled handlers.
12
- */
13
- export declare function generateWorkerEntry(): string;
14
- //# sourceMappingURL=worker-entry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker-entry.d.ts","sourceRoot":"","sources":["../../../src/cli/deploy/worker-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CA8C5C"}
@@ -1,60 +0,0 @@
1
- /**
2
- * Generate the _worker.ts entry point for Cloudflare Workers
3
- *
4
- * This creates a wrapper that:
5
- * 1. Initializes the Worker environment (bindings)
6
- * 2. Dynamically imports the user's app code (after env is ready)
7
- * 3. Exports fetch and scheduled handlers
8
- */
9
- /**
10
- * Generate the _worker.ts content for deployment.
11
- * Includes both HTTP fetch and cron scheduled handlers.
12
- */
13
- export function generateWorkerEntry() {
14
- return `/**
15
- * CLIde Worker Entry Point
16
- * Generated by clide push - do not edit manually
17
- */
18
-
19
- import { __initEnv, __getApp, __getCronHandlers, __runMigrations } from "clide/worker-runtime";
20
-
21
- let initialized = false;
22
-
23
- async function ensureInit(env) {
24
- if (!initialized) {
25
- __initEnv(env);
26
- await import("./src/app.ts");
27
- await __runMigrations();
28
- initialized = true;
29
- }
30
- }
31
-
32
- export default {
33
- async fetch(request, env, ctx) {
34
- await ensureInit(env);
35
- return __getApp().fetch(request, env, ctx);
36
- },
37
-
38
- async scheduled(event, env, ctx) {
39
- await ensureInit(env);
40
- const handlers = __getCronHandlers();
41
-
42
- // Find handler matching this schedule
43
- for (const [name, { schedule, handler }] of handlers) {
44
- if (schedule === event.cron) {
45
- console.log(\`[cron] Running "\${name}" (schedule: \${event.cron})\`);
46
- try {
47
- await handler();
48
- } catch (error) {
49
- console.error(\`[cron:\${name}] Error:\`, error);
50
- }
51
- return;
52
- }
53
- }
54
-
55
- console.warn(\`[cron] No handler found for schedule: \${event.cron}\`);
56
- }
57
- };
58
- `;
59
- }
60
- //# sourceMappingURL=worker-entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker-entry.js","sourceRoot":"","sources":["../../../src/cli/deploy/worker-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CR,CAAC;AACF,CAAC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Generate wrangler.toml configuration for Cloudflare Workers
3
- */
4
- export interface WranglerConfigOptions {
5
- projectDir: string;
6
- accountId?: string | undefined;
7
- compatibilityDate?: string;
8
- d1DatabaseId?: string | undefined;
9
- cronSchedules?: string[];
10
- }
11
- /**
12
- * Generate wrangler.toml content for deployment.
13
- * Includes D1 binding if database ID is provided.
14
- */
15
- export declare function generateWranglerConfig(options: WranglerConfigOptions): string;
16
- /**
17
- * Get the worker name for a project directory.
18
- */
19
- export declare function getWorkerName(projectDir: string): string;
20
- //# sourceMappingURL=wrangler-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrangler-config.d.ts","sourceRoot":"","sources":["../../../src/cli/deploy/wrangler-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAYD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAgC7E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -1,54 +0,0 @@
1
- /**
2
- * Generate wrangler.toml configuration for Cloudflare Workers
3
- */
4
- import { createHash } from "node:crypto";
5
- import { basename } from "node:path";
6
- /**
7
- * Generate a unique worker name from the project directory.
8
- * Uses the directory basename plus a short hash for uniqueness.
9
- */
10
- function generateWorkerName(projectDir) {
11
- const base = basename(projectDir).toLowerCase().replace(/[^a-z0-9-]/g, "-");
12
- const hash = createHash("sha256").update(projectDir).digest("hex").slice(0, 6);
13
- return `clide-${base}-${hash}`;
14
- }
15
- /**
16
- * Generate wrangler.toml content for deployment.
17
- * Includes D1 binding if database ID is provided.
18
- */
19
- export function generateWranglerConfig(options) {
20
- const workerName = generateWorkerName(options.projectDir);
21
- const compatibilityDate = options.compatibilityDate ?? "2024-01-01";
22
- const accountLine = options.accountId ? `account_id = "${options.accountId}"\n` : "";
23
- let config = `# CLIde Wrangler Configuration
24
- # Generated by clide push - do not edit manually
25
-
26
- name = "${workerName}"
27
- ${accountLine}main = "_worker.ts"
28
- compatibility_date = "${compatibilityDate}"
29
- compatibility_flags = ["nodejs_compat"]
30
- `;
31
- if (options.d1DatabaseId) {
32
- config += `
33
- [[d1_databases]]
34
- binding = "DB"
35
- database_name = "${workerName}-db"
36
- database_id = "${options.d1DatabaseId}"
37
- `;
38
- }
39
- if (options.cronSchedules && options.cronSchedules.length > 0) {
40
- const schedules = options.cronSchedules.map((s) => `"${s}"`).join(", ");
41
- config += `
42
- [triggers]
43
- crons = [${schedules}]
44
- `;
45
- }
46
- return config;
47
- }
48
- /**
49
- * Get the worker name for a project directory.
50
- */
51
- export function getWorkerName(projectDir) {
52
- return generateWorkerName(projectDir);
53
- }
54
- //# sourceMappingURL=wrangler-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrangler-config.js","sourceRoot":"","sources":["../../../src/cli/deploy/wrangler-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAUrC;;;GAGG;AACH,SAAS,kBAAkB,CAAC,UAAkB;IAC5C,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IAC5E,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/E,OAAO,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA8B;IACnE,MAAM,UAAU,GAAG,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1D,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,YAAY,CAAC;IACpE,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,OAAO,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAErF,IAAI,MAAM,GAAG;;;UAGL,UAAU;EAClB,WAAW;wBACW,iBAAiB;;CAExC,CAAC;IAEA,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACzB,MAAM,IAAI;;;mBAGK,UAAU;iBACZ,OAAO,CAAC,YAAY;CACpC,CAAC;IACA,CAAC;IAED,IAAI,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9D,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxE,MAAM,IAAI;;WAEH,SAAS;CACnB,CAAC;IACA,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,OAAO,kBAAkB,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Registration file for the WASM ESM loader hooks.
3
- *
4
- * This file is used with Node.js --import flag to register the WASM loader
5
- * before any user code runs. It uses the node:module register() API to
6
- * install the custom resolve and load hooks.
7
- *
8
- * Usage:
9
- * node --import ./register-wasm.js script.js
10
- */
11
- export {};
12
- //# sourceMappingURL=register-wasm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-wasm.d.ts","sourceRoot":"","sources":["../../../src/cli/loaders/register-wasm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Registration file for the WASM ESM loader hooks.
3
- *
4
- * This file is used with Node.js --import flag to register the WASM loader
5
- * before any user code runs. It uses the node:module register() API to
6
- * install the custom resolve and load hooks.
7
- *
8
- * Usage:
9
- * node --import ./register-wasm.js script.js
10
- */
11
- import { register } from "node:module";
12
- import { fileURLToPath, pathToFileURL } from "node:url";
13
- import { dirname, join } from "node:path";
14
- const __dirname = dirname(fileURLToPath(import.meta.url));
15
- // The hooks file path - will be .js when compiled to dist/
16
- const hooksPath = join(__dirname, "wasm-hooks.js");
17
- // Register the WASM loader hooks
18
- register(pathToFileURL(hooksPath).href, import.meta.url);
19
- //# sourceMappingURL=register-wasm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-wasm.js","sourceRoot":"","sources":["../../../src/cli/loaders/register-wasm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,2DAA2D;AAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAEnD,iCAAiC;AACjC,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"}
@@ -1,61 +0,0 @@
1
- /**
2
- * Node.js ESM loader hooks for WebAssembly support in development.
3
- *
4
- * This file provides the resolve and load hooks that allow importing .wasm
5
- * files directly in TypeScript/JavaScript code during local development.
6
- *
7
- * Usage in user code (same API works in both local dev and production):
8
- * import wasmBinary from './example.wasm';
9
- * const { instance } = await WebAssembly.instantiate(wasmBinary);
10
- * instance.exports.someFunction();
11
- *
12
- * The import returns:
13
- * - In local dev (Node.js): Uint8Array
14
- * - In production (Cloudflare): WebAssembly.Module
15
- *
16
- * Both types are accepted by WebAssembly.instantiate() and by WASM library
17
- * init functions like @resvg/resvg-wasm's initWasm().
18
- */
19
- interface ResolveContext {
20
- conditions: string[];
21
- importAttributes: Record<string, string>;
22
- parentURL?: string;
23
- }
24
- interface ResolveResult {
25
- format?: string | null;
26
- importAttributes?: Record<string, string>;
27
- shortCircuit?: boolean;
28
- url: string;
29
- }
30
- type NextResolve = (specifier: string, context: ResolveContext) => Promise<ResolveResult>;
31
- interface LoadContext {
32
- conditions: string[];
33
- format?: string | null;
34
- importAttributes: Record<string, string>;
35
- }
36
- interface LoadResult {
37
- format: string;
38
- shortCircuit?: boolean;
39
- source?: string | ArrayBuffer | Uint8Array;
40
- }
41
- type NextLoad = (url: string, context: LoadContext) => Promise<LoadResult>;
42
- /**
43
- * Resolve hook: mark .wasm imports with custom format.
44
- */
45
- export declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): Promise<ResolveResult>;
46
- /**
47
- * Load hook: generate JS module that exports WASM binary as Uint8Array.
48
- *
49
- * We embed the WASM binary as base64 in the generated JS module,
50
- * which then decodes to Uint8Array when imported.
51
- *
52
- * This matches what libraries like @resvg/resvg-wasm expect:
53
- * - In Cloudflare Workers: import returns WebAssembly.Module
54
- * - In Node.js (local dev): import returns Uint8Array
55
- *
56
- * Both types are accepted by WebAssembly.instantiate() and by
57
- * library init functions like initWasm().
58
- */
59
- export declare function load(url: string, context: LoadContext, nextLoad: NextLoad): Promise<LoadResult>;
60
- export {};
61
- //# sourceMappingURL=wasm-hooks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wasm-hooks.d.ts","sourceRoot":"","sources":["../../../src/cli/loaders/wasm-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAQH,UAAU,cAAc;IACtB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,KAAK,WAAW,GAAG,CACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,KACpB,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B,UAAU,WAAW;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;CAC5C;AAED,KAAK,QAAQ,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3E;;GAEG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,aAAa,CAAC,CASxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,UAAU,CAAC,CAkBrB"}
@@ -1,63 +0,0 @@
1
- /**
2
- * Node.js ESM loader hooks for WebAssembly support in development.
3
- *
4
- * This file provides the resolve and load hooks that allow importing .wasm
5
- * files directly in TypeScript/JavaScript code during local development.
6
- *
7
- * Usage in user code (same API works in both local dev and production):
8
- * import wasmBinary from './example.wasm';
9
- * const { instance } = await WebAssembly.instantiate(wasmBinary);
10
- * instance.exports.someFunction();
11
- *
12
- * The import returns:
13
- * - In local dev (Node.js): Uint8Array
14
- * - In production (Cloudflare): WebAssembly.Module
15
- *
16
- * Both types are accepted by WebAssembly.instantiate() and by WASM library
17
- * init functions like @resvg/resvg-wasm's initWasm().
18
- */
19
- import { readFile } from "node:fs/promises";
20
- import { fileURLToPath } from "node:url";
21
- // Custom format identifier for WASM files
22
- const WASM_FORMAT = "wasm-loader";
23
- /**
24
- * Resolve hook: mark .wasm imports with custom format.
25
- */
26
- export async function resolve(specifier, context, nextResolve) {
27
- const resolved = await nextResolve(specifier, context);
28
- // Mark .wasm files with our custom format
29
- if (specifier.endsWith(".wasm")) {
30
- return { ...resolved, format: WASM_FORMAT };
31
- }
32
- return resolved;
33
- }
34
- /**
35
- * Load hook: generate JS module that exports WASM binary as Uint8Array.
36
- *
37
- * We embed the WASM binary as base64 in the generated JS module,
38
- * which then decodes to Uint8Array when imported.
39
- *
40
- * This matches what libraries like @resvg/resvg-wasm expect:
41
- * - In Cloudflare Workers: import returns WebAssembly.Module
42
- * - In Node.js (local dev): import returns Uint8Array
43
- *
44
- * Both types are accepted by WebAssembly.instantiate() and by
45
- * library init functions like initWasm().
46
- */
47
- export async function load(url, context, nextLoad) {
48
- if (context.format === WASM_FORMAT) {
49
- const filePath = fileURLToPath(url);
50
- const wasmBuffer = await readFile(filePath);
51
- const base64 = wasmBuffer.toString("base64");
52
- // Generate JS module that decodes base64 to Uint8Array
53
- // This is compatible with libraries that accept either Uint8Array or WebAssembly.Module
54
- const source = `
55
- const base64 = "${base64}";
56
- const binary = Uint8Array.from(atob(base64), c => c.charCodeAt(0));
57
- export default binary;
58
- `;
59
- return { format: "module", source, shortCircuit: true };
60
- }
61
- return nextLoad(url, context);
62
- }
63
- //# sourceMappingURL=wasm-hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wasm-hooks.js","sourceRoot":"","sources":["../../../src/cli/loaders/wasm-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,0CAA0C;AAC1C,MAAM,WAAW,GAAG,aAAa,CAAC;AAkClC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,SAAiB,EACjB,OAAuB,EACvB,WAAwB;IAExB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEvD,0CAA0C;IAC1C,IAAI,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,GAAW,EACX,OAAoB,EACpB,QAAkB;IAElB,IAAI,OAAO,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE7C,uDAAuD;QACvD,wFAAwF;QACxF,MAAM,MAAM,GAAG;kBACD,MAAM;;;CAGvB,CAAC;QAEE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IAED,OAAO,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC"}