close to final version added the subtaskand comment working section

This commit is contained in:
tusuii
2026-02-16 19:50:23 +05:30
parent 6aec1445e9
commit 1788e364f1
28 changed files with 5867 additions and 133 deletions

5
temp_spin/temp/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
node_modules
dist
target
.spin/
build/

14
temp_spin/temp/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "starlingmonkey",
"request": "launch",
"name": "Debug StarlingMonkey component",
"component": "${workspaceFolder}/dist/temp.wasm",
"program": "${workspaceFolder}/src/index.js",
"stopOnEntry": false,
"trace": true
}
]
}

12
temp_spin/temp/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,12 @@
{
"starlingmonkey": {
"componentRuntime": {
"executable": "spin",
"options": [
"up",
"-f",
"${workspaceFolder}",
],
}
}
}

39
temp_spin/temp/README.md Normal file
View File

@@ -0,0 +1,39 @@
# `http-js` Template
A starter template for building JavaScript HTTP applications with Spin.
## Getting Started
Build the App
```bash
spin build
```
## Run the App
```bash
spin up
```
## Using Spin Interfaces
To use additional Spin interfaces, install the corresponding packages:
| Interface | Package |
|---------------|---------------------------------|
| Key-Value | `@spinframework/spin-kv` |
| LLM | `@spinframework/spin-llm` |
| MQTT | `@spinframework/spin-mqtt` |
| MySQL | `@spinframework/spin-mysql` |
| PostgreSQL | `@spinframework/spin-postgres` |
| Redis | `@spinframework/spin-redis` |
| SQLite | `@spinframework/spin-sqlite` |
| Variables | `@spinframework/spin-variables` |
## Using the StarlingMonkey Debugger for VS Code
1. First install the [StarlingMonkey Debugger](https://marketplace.visualstudio.com/items?itemName=BytecodeAlliance.starlingmonkey-debugger) extension.
2. Build the component using the debug command `npm run build:debug`.
3. Uncomment `tcp://127.0.0.1:*` in the `allowed_outbound_hosts` field in the `spin.toml`.
4. Start the debugger in VS Code which should start Spin and attach the debugger. The debugger needs to be restarted for each http call.

42
temp_spin/temp/build.mjs Normal file
View File

@@ -0,0 +1,42 @@
// build.mjs
import { build } from 'esbuild';
import path from 'path';
import { SpinEsbuildPlugin } from "@spinframework/build-tools/plugins/esbuild/index.js";
import fs from 'fs';
const spinPlugin = await SpinEsbuildPlugin();
// plugin to handle vendor files in node_modules that may not be bundled.
// Instead of generating a real source map for these files, it appends a minimal
// inline source map pointing to an empty source. This avoids errors and ensures
// source maps exist even for unbundled vendor code.
let SourceMapPlugin = {
name: 'excludeVendorFromSourceMap',
setup(build) {
build.onLoad({ filter: /node_modules/ }, args => {
return {
contents: fs.readFileSync(args.path, 'utf8')
+ '\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==',
loader: 'default',
}
})
},
}
await build({
entryPoints: ['./src/index.js'],
outfile: './build/bundle.js',
bundle: true,
format: 'esm',
platform: 'node',
sourcemap: true,
minify: false,
plugins: [spinPlugin, SourceMapPlugin],
logLevel: 'error',
loader: {
'.ts': 'ts',
'.tsx': 'tsx',
},
resolveExtensions: ['.ts', '.tsx', '.js'],
sourceRoot: path.resolve(process.cwd(), 'src'),
});

1710
temp_spin/temp/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
{
"name": "temp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "node build.mjs && mkdirp dist && j2w -i build/bundle.js --initLocation http://temp.localhost -o dist/temp.wasm",
"build:debug": "node build.mjs && mkdirp dist && j2w -d -i build/bundle.js --initLocation http://temp.localhost -o dist/temp.wasm",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"mkdirp": "^3.0.1",
"esbuild": "^0.25.8"
},
"dependencies": {
"itty-router": "^5.0.18",
"@spinframework/build-tools": "^1.0.4",
"@spinframework/wasi-http-proxy": "^1.0.0"
}
}

21
temp_spin/temp/spin.toml Normal file
View File

@@ -0,0 +1,21 @@
spin_manifest_version = 2
[application]
authors = ["tusuii <tusuii764@gmail.com>"]
description = ""
name = "temp"
version = "0.1.0"
[[trigger.http]]
route = "/..."
component = "temp"
[component.temp]
source = "dist/temp.wasm"
exclude_files = ["**/node_modules"]
allowed_outbound_hosts = [
# "tcp://127.0.0.1:*", # Uncomment this line to while using the StarlingMonkey Debugger
]
[component.temp.build]
command = ["npm install", "npm run build"]
watch = ["src/**/*.js"]

View File

@@ -0,0 +1,17 @@
// For AutoRouter documentation refer to https://itty.dev/itty-router/routers/autorouter
import { AutoRouter } from 'itty-router';
let router = AutoRouter();
// Route ordering matters, the first route that matches will be used
// Any route that does not return will be treated as a middleware
// Any unmatched route will return a 404
router
.get('/', () => new Response('Hello, Spin!'))
.get('/hello/:name', ({ name }) => `Hello, ${name}!`)
addEventListener('fetch', (event) => {
event.respondWith(router.fetch(event.request));
});