@gridspace/raster-path 1.0.4 โ†’ 1.0.5

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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@gridspace/raster-path",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "private": false,
5
5
  "description": "Terrain and Tool Raster Path Finder using WebGPU",
6
6
  "type": "module",
7
7
  "main": "build/raster-path.js",
8
8
  "exports": {
9
9
  ".": "./build/raster-path.js",
10
- "./worker": "./build/webgpu-worker.js"
10
+ "./worker": "./build/raster-worker.js"
11
11
  },
12
12
  "files": [
13
13
  "build/**/*",
@@ -29,18 +29,22 @@
29
29
  "postinstall": "npm run build",
30
30
  "build": "npm run clean && npm run build:web && npm run build:shaders",
31
31
  "build:shaders": "node scripts/build-shaders.js",
32
- "build:web": "mkdir -p build && cp src/web/*.html src/web/*.css src/web/*.js build/ && cp src/index.js build/raster-path.js && cp src/etc/serve.json build/",
32
+ "build:web": "mkdir -p build && cp src/web/*.html src/web/*.css src/web/*.js build/ && cp src/core/raster-path.js build/raster-path.js && cp src/etc/serve.json build/",
33
33
  "clean": "rm -rf build/",
34
34
  "dev": "npm run build && npm run serve",
35
35
  "serve": "npx serve build --config serve.json --listen 9090",
36
+ "publish": "npm publish --access public",
36
37
  "test": "npm run test:planar && npm run test:radial",
37
38
  "test:planar": "npm run build && npx electron src/test/planar-test.cjs",
38
39
  "test:planar-tiling": "npm run build && npx electron src/test/planar-tiling-test.cjs",
39
40
  "test:radial": "npm run build && npx electron src/test/radial-test.cjs",
41
+ "test:calibrate": "npm run build && npx electron src/test/calibrate-test.cjs",
40
42
  "test:batch-divisor": "npm run build && npx electron src/test/batch-divisor-benchmark.cjs",
41
43
  "test:work-estimation": "npm run build && npx electron src/test/work-estimation-profile.cjs",
42
44
  "test:workload-calibration": "npm run build && npx electron src/test/workload-calibration.cjs",
43
- "test:lathe-cylinder-2-debug": "npm run build && npx electron src/test/lathe-cylinder-2-debug.cjs"
45
+ "test:lathe-cylinder-2-debug": "npm run build && npx electron src/test/lathe-cylinder-2-debug.cjs",
46
+ "test:extreme-work": "npm run build && npx electron src/test/extreme-work-test.cjs",
47
+ "test:radial-thread-limit": "npm run build && npx electron src/test/radial-thread-limit-test.cjs"
44
48
  },
45
49
  "keywords": [
46
50
  "cnc",
@@ -1,27 +1,47 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Build script: Injects shader code into webgpu-worker.js
3
+ * Build script: Bundle worker modules with esbuild, then inject shader code
4
4
  *
5
- * Replaces placeholders like SHADER-radial-cull with shader file contents
5
+ * 1. Bundle all worker modules (raster-worker.js + imports) into single file
6
+ * 2. Replace shader placeholders like 'SHADER:radial-raster' with shader file contents
6
7
  */
7
8
 
8
9
  import fs from 'fs';
9
10
  import path from 'path';
10
11
  import { fileURLToPath } from 'url';
12
+ import * as esbuild from 'esbuild';
11
13
 
12
14
  const __filename = fileURLToPath(import.meta.url);
13
15
  const __dirname = path.dirname(__filename);
14
16
 
15
17
  const SHADER_DIR = path.join(__dirname, '../src/shaders');
16
- const WORKER_SRC = path.join(__dirname, '../src/web/webgpu-worker.js');
18
+ const WORKER_SRC = path.join(__dirname, '../src/core/raster-worker.js');
17
19
  const BUILD_DIR = path.join(__dirname, '../build');
18
- const WORKER_DEST = path.join(BUILD_DIR, 'webgpu-worker.js');
20
+ const WORKER_BUNDLED = path.join(BUILD_DIR, 'raster-worker.bundled.js');
21
+ const WORKER_DEST = path.join(BUILD_DIR, 'raster-worker.js');
19
22
 
20
- // Read worker source
21
- let workerCode = fs.readFileSync(WORKER_SRC, 'utf8');
23
+ // Ensure build directory exists
24
+ if (!fs.existsSync(BUILD_DIR)) {
25
+ fs.mkdirSync(BUILD_DIR, { recursive: true });
26
+ }
22
27
 
23
- // Find all shader placeholders
24
- const shaderRegex = /'SHADER:([a-z0-9-]+)'/g;
28
+ // Step 1: Bundle worker modules with esbuild
29
+ console.log('๐Ÿ“ฆ Bundling worker modules with esbuild...');
30
+ await esbuild.build({
31
+ entryPoints: [WORKER_SRC],
32
+ bundle: true,
33
+ format: 'esm',
34
+ outfile: WORKER_BUNDLED,
35
+ platform: 'browser',
36
+ target: 'es2020',
37
+ });
38
+ console.log(`โœ… Bundled: ${WORKER_BUNDLED}`);
39
+
40
+ // Step 2: Read bundled code and inject shaders
41
+ let workerCode = fs.readFileSync(WORKER_BUNDLED, 'utf8');
42
+
43
+ // Find all shader placeholders (handle both single and double quotes)
44
+ const shaderRegex = /['"]SHADER:([a-z0-9-]+)['"]/g;
25
45
  let match;
26
46
  const replacements = [];
27
47
 
@@ -63,3 +83,7 @@ console.log(`๐Ÿ”จ Build ID: ${buildId}`);
63
83
  // Write output
64
84
  fs.writeFileSync(WORKER_DEST, workerCode, 'utf8');
65
85
  console.log(`โœ… Built: ${WORKER_DEST}`);
86
+
87
+ // Clean up intermediate bundled file
88
+ fs.unlinkSync(WORKER_BUNDLED);
89
+ console.log('๐Ÿงน Cleaned up intermediate bundle');