This commit is contained in:
babayaga 2026-01-27 08:55:42 +01:00
parent 8f22bad4f2
commit c3e4a54bfa
71 changed files with 80992 additions and 60 deletions

View File

@ -1,6 +1,6 @@
import { SolidworkOptions } from '../types.js';
export declare const convertFile: (src: any, target: any, view: string, onNode: (data: any) => void, options: SolidworkOptions, configuration: string) => Promise<any>;
export declare function convertFiles(file: any, targets: string[], view: any, onNode: (data: any) => void, options: SolidworkOptions): Promise<any>;
export declare function convertFiles(file: any, targets: string[], view: any, onNode: (data: any) => void, options: SolidworkOptions): Promise<void | any[]>;
export declare const report: (data: any, dst: string) => any;
export declare const targets: (f: string, options: SolidworkOptions) => any[];
export declare function convert(options: SolidworkOptions): Promise<any>;
export declare function convert(options: SolidworkOptions): Promise<(void | any[])[]>;

View File

@ -1,3 +1,3 @@
import { SolidworkOptions } from '../types.js';
export declare function packFile(file: any, onNode: (data: any) => void, options: SolidworkOptions): Promise<any>;
export declare function pack(options: SolidworkOptions): Promise<any>;
export declare function pack(options: SolidworkOptions): Promise<any[]>;

View File

@ -1,10 +1,10 @@
export declare const dirname: () => any;
export declare const dirname: () => string;
export declare const swProcMessage: (log: string) => {
logLevel: string;
message: string;
} | null;
export declare const fileAsBuffer: (path: string) => any;
export declare const getSWBin: (argv: string) => any;
export declare const fileAsBuffer: (path: string) => Buffer<ArrayBufferLike>;
export declare const getSWBin: (argv: string) => string;
export declare function closeAppByName(appName: string): void;
export declare function removeEmptyValues(obj: any): any;
export declare const equalFiles: (pathA: any, pathB: any) => boolean;

View File

@ -4,8 +4,9 @@ export * from './cad/sw-lib.js';
export * from './_cli.js';
export * from './sw_argv.js';
export * from './lib/geometry/dxf.js';
export declare function createLogger(name: string, options?: any): any;
export declare const defaultLogger: any;
import { Logger } from "tslog";
export declare function createLogger(name: string, options?: any): Logger;
export declare const defaultLogger: Logger;
export { MODULE_NAME } from './constants.js';
export declare const logger: any;
export declare const substitute: any;
export declare const logger: Logger;
export declare const substitute: (path: string, alt?: boolean, vars?: Record<string, string>, keep?: boolean) => any;

View File

@ -1,9 +1,9 @@
import { SlicerOptions } from '../types.js';
export declare const fileAsBuffer: (path: string) => any;
export declare const getSlicrDir: (options: SlicerOptions) => any;
export declare const getBin: (options: SlicerOptions) => any;
export declare const fileAsBuffer: (path: string) => Buffer<ArrayBufferLike>;
export declare const getSlicrDir: (options: SlicerOptions) => string;
export declare const getBin: (options: SlicerOptions) => string;
export declare const convertFile: (file: any, target: any, onNode: (data: any) => void, options: SlicerOptions) => Promise<any>;
export declare function convertFiles(file: any, targets: string[], onNode: (data: any) => void, options: SlicerOptions): Promise<any>;
export declare function convertFiles(file: any, targets: string[], onNode: (data: any) => void, options: SlicerOptions): Promise<void | any[]>;
export declare const report: (data: any, dst: string) => any;
export declare const targets: (f: string, options: SlicerOptions) => any[];
export declare function convert(options: SlicerOptions): Promise<void>;

1
packages/cad/dist-in/report/csv.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare const reportCSV: (data: any) => string;

300
packages/cad/dist/350.main_node.js vendored Normal file
View File

@ -0,0 +1,300 @@
#!/usr/bin/env node
"use strict";
exports.id = 350;
exports.ids = [350];
exports.modules = {
/***/ 3350
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ pMap)
/* harmony export */ });
/* unused harmony exports pMapIterable, pMapSkip */
async function pMap(
iterable,
mapper,
{
concurrency = Number.POSITIVE_INFINITY,
stopOnError = true,
signal,
} = {},
) {
return new Promise((resolve_, reject_) => {
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
}
if (typeof mapper !== 'function') {
throw new TypeError('Mapper function is required');
}
if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
}
const result = [];
const errors = [];
const skippedIndexesMap = new Map();
let isRejected = false;
let isResolved = false;
let isIterableDone = false;
let resolvingCount = 0;
let currentIndex = 0;
const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
const signalListener = () => {
reject(signal.reason);
};
const cleanup = () => {
signal?.removeEventListener('abort', signalListener);
};
const resolve = value => {
resolve_(value);
cleanup();
};
const reject = reason => {
isRejected = true;
isResolved = true;
reject_(reason);
cleanup();
};
if (signal) {
if (signal.aborted) {
reject(signal.reason);
}
signal.addEventListener('abort', signalListener, {once: true});
}
const next = async () => {
if (isResolved) {
return;
}
const nextItem = await iterator.next();
const index = currentIndex;
currentIndex++;
// Note: `iterator.next()` can be called many times in parallel.
// This can cause multiple calls to this `next()` function to
// receive a `nextItem` with `done === true`.
// The shutdown logic that rejects/resolves must be protected
// so it runs only one time as the `skippedIndex` logic is
// non-idempotent.
if (nextItem.done) {
isIterableDone = true;
if (resolvingCount === 0 && !isResolved) {
if (!stopOnError && errors.length > 0) {
reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
return;
}
isResolved = true;
if (skippedIndexesMap.size === 0) {
resolve(result);
return;
}
const pureResult = [];
// Support multiple `pMapSkip`'s.
for (const [index, value] of result.entries()) {
if (skippedIndexesMap.get(index) === pMapSkip) {
continue;
}
pureResult.push(value);
}
resolve(pureResult);
}
return;
}
resolvingCount++;
// Intentionally detached
(async () => {
try {
const element = await nextItem.value;
if (isResolved) {
return;
}
const value = await mapper(element, index);
// Use Map to stage the index of the element.
if (value === pMapSkip) {
skippedIndexesMap.set(index, value);
}
result[index] = value;
resolvingCount--;
await next();
} catch (error) {
if (stopOnError) {
reject(error);
} else {
errors.push(error);
resolvingCount--;
// In that case we can't really continue regardless of `stopOnError` state
// since an iterable is likely to continue throwing after it throws once.
// If we continue calling `next()` indefinitely we will likely end up
// in an infinite loop of failed iteration.
try {
await next();
} catch (error) {
reject(error);
}
}
}
})();
};
// Create the concurrent runners in a detached (non-awaited)
// promise. We need this so we can await the `next()` calls
// to stop creating runners before hitting the concurrency limit
// if the iterable has already been marked as done.
// NOTE: We *must* do this for async iterators otherwise we'll spin up
// infinite `next()` calls by default and never start the event loop.
(async () => {
for (let index = 0; index < concurrency; index++) {
try {
// eslint-disable-next-line no-await-in-loop
await next();
} catch (error) {
reject(error);
break;
}
if (isIterableDone || isRejected) {
break;
}
}
})();
});
}
function pMapIterable(
iterable,
mapper,
{
concurrency = Number.POSITIVE_INFINITY,
backpressure = concurrency,
} = {},
) {
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
}
if (typeof mapper !== 'function') {
throw new TypeError('Mapper function is required');
}
if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
}
if (!((Number.isSafeInteger(backpressure) && backpressure >= concurrency) || backpressure === Number.POSITIVE_INFINITY)) {
throw new TypeError(`Expected \`backpressure\` to be an integer from \`concurrency\` (${concurrency}) and up or \`Infinity\`, got \`${backpressure}\` (${typeof backpressure})`);
}
return {
async * [Symbol.asyncIterator]() {
const iterator = iterable[Symbol.asyncIterator] === undefined ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
const promises = [];
let runningMappersCount = 0;
let isDone = false;
let index = 0;
function trySpawn() {
if (isDone || !(runningMappersCount < concurrency && promises.length < backpressure)) {
return;
}
const promise = (async () => {
const {done, value} = await iterator.next();
if (done) {
return {done: true};
}
runningMappersCount++;
// Spawn if still below concurrency and backpressure limit
trySpawn();
try {
const returnValue = await mapper(await value, index++);
runningMappersCount--;
if (returnValue === pMapSkip) {
const index = promises.indexOf(promise);
if (index > 0) {
promises.splice(index, 1);
}
}
// Spawn if still below backpressure limit and just dropped below concurrency limit
trySpawn();
return {done: false, value: returnValue};
} catch (error) {
isDone = true;
return {error};
}
})();
promises.push(promise);
}
trySpawn();
while (promises.length > 0) {
const {error, done, value} = await promises[0]; // eslint-disable-line no-await-in-loop
promises.shift();
if (error) {
throw error;
}
if (done) {
return;
}
// Spawn if just dropped below backpressure limit and below the concurrency limit
trySpawn();
if (value === pMapSkip) {
continue;
}
yield value;
}
},
};
}
const pMapSkip = Symbol('skip');
/***/ }
};
;

View File

@ -1 +0,0 @@
export declare const noop: () => void;

View File

@ -1,2 +0,0 @@
export const noop = () => { };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2xvZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQUMsTUFBTSxJQUFJLEdBQUcsR0FBRyxFQUFFLEdBQUUsQ0FBQyxDQUFBIn0=

72475
packages/cad/dist/main_node.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
export declare const reportCSV: (data: any) => any;

8062
packages/cad/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -41,15 +41,15 @@
},
"license": "ISC",
"bugs": {
"url": "https://git.osr-plastic.org/osr-plastic/cad/issues"
"url": "https://git.polymech.info/mono/cad/issues"
},
"homepage": "https://git.osr-plastic.org/osr-plastic/cad#readme",
"homepage": "https://git.polymech.info/mono/cad#readme",
"dependencies": {
"@polymech/cache": "link:..\\cache",
"@polymech/commons": "link:..\\commons",
"@polymech/core": "link:..\\core",
"@polymech/fs": "link:..\\fs",
"@polymech/log": "link:..\\log",
"@polymech/cache": "file:..\\cache",
"@polymech/commons": "file:..\\commons",
"@polymech/core": "file:..\\core",
"@polymech/fs": "file:..\\fs",
"@polymech/log": "file:..\\log",
"add": "^2.0.6",
"csv-stringify": "^6.5.2",
"dxf-parser": "^1.1.2",
@ -65,7 +65,7 @@
"tslog": "^3.3.3",
"which": "^2.0.2",
"yargs": "^17.7.2",
"zod": "^3.24.1"
"zod": "^4.3.6"
},
"devDependencies": {
"@types/js-yaml": "^4.0.9",

View File

@ -0,0 +1,94 @@
// nexe.js - Compile pm-media to Windows executable using nexe Node.js API
import { compile } from 'nexe';
import path from 'path';
import fs from 'fs';
async function buildExecutable() {
const outputDir = './dist/win-64';
const outputFile = 'kbot.exe';
const entryPoint = './dist/main_node.cjs';
const nexeTemp = '../../nexe-24';
const nodeVersion = '24.5.0';
// Ensure output directory exists
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
console.log(`📁 Created output directory: ${outputDir}`);
}
// Ensure nexe temp directory exists
if (!fs.existsSync(nexeTemp)) {
fs.mkdirSync(nexeTemp, { recursive: true });
console.log(`📁 Created temp directory: ${nexeTemp}`);
}
// Check if entry point exists
if (!fs.existsSync(entryPoint)) {
console.log(`❌ Entry point ${entryPoint} not found. Please run 'npm run build' first.`);
process.exit(1);
}
const outputPath = path.join(outputDir, outputFile);
console.log('📦 Compiling with nexe...');
console.log(` Entry: ${entryPoint}`);
console.log(` Output: ${outputPath}`);
console.log(` Temp: ${nexeTemp}`);
console.log(` Target: windows-x64-${nodeVersion}`);
try {
await compile({
input: entryPoint,
output: outputPath,
target: `windows-x64-${nodeVersion}`,
build: true, // Build from source for native modules like sharp
temp: nexeTemp,
clean: false,
name: 'pm-media',
configure: ['--with-intl=full-icu'], // Full ICU support
make: ['-j4'], // Parallel build
loglevel: 'verbose',
// Resources - include any additional files if needed
resources: [
// Add any resource patterns here if needed
// './assets/**/*'
],
patches: [
// Patch for better native module support
async (compiler, next) => {
// This patch helps with native modules like sharp
await compiler.replaceInFileAsync(
'lib/internal/bootstrap/pre_execution.js',
'process.dlopen = function(',
`
// Nexe patch for native modules
const originalDlopen = process.dlopen;
process.dlopen = function(`
);
return next();
}
]
});
console.log(`✅ Successfully compiled to ${outputPath}`);
// Show file size
if (fs.existsSync(outputPath)) {
const stats = fs.statSync(outputPath);
const fileSizeInMB = (stats.size / (1024 * 1024)).toFixed(2);
console.log(`📊 Executable size: ${fileSizeInMB} MB`);
}
console.log('🎉 Build complete!');
} catch (error) {
console.error('❌ Compilation failed:', error.message);
if (error.stack) {
console.error(error.stack);
}
process.exit(1);
}
}
// Run the build
buildExecutable().catch(console.error);

View File

@ -0,0 +1,5 @@
npm run webpack
cp ./dist/main_node.js ./dist/main_node.cjs
node scripts/nexe.js
#mkdir -p dist/win-64/dist
#cp dist/win-64/*.wasm dist/win-64/dist/

View File

@ -11,8 +11,7 @@
"strictNullChecks": false,
"allowJs": true,
"baseUrl": ".",
"declarationDir": "./dist",
"outDir": "./dist",
"outDir": "./dist-in",
"inlineSourceMap": true,
"preserveConstEnums": true,
"allowSyntheticDefaultImports": true,

View File

@ -1,26 +1,25 @@
const path = require('path')
const webpack = require('webpack')
const Visualizer = require('webpack-visualizer-plugin2');
module.exports = {
devtool:false,
import path from 'path';
import { fileURLToPath } from 'url';
import webpack from 'webpack';
const __dirname = fileURLToPath(new URL('.', import.meta.url));
export default {
devtool: false,
plugins: [
new webpack.BannerPlugin({ banner: "#!/usr/bin/env node", raw: true }),
new Visualizer({
filename: path.join('stats', 'statistics.html'),
throwOnError: true
}),
new webpack.BannerPlugin({ banner: "#!/usr/bin/env node", raw: true })
],
entry: './dist/main.js',
entry: './dist-in/main.js',
target: 'node',
mode:'production',
mode: 'production',
module: {
rules: []
},
optimization: {
minimize: true
minimize: false
},
resolve: {
extensions: ['.js']
extensions: ['.js', '.ts']
},
output: {
filename: 'main_node.js',