breeze-bindgen 1.1.3 → 1.1.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.
@@ -0,0 +1,18 @@
1
+ export interface CTypeNode {
2
+ function: boolean;
3
+ template: boolean;
4
+ type: string;
5
+ argsTemplate: CTypeNode[];
6
+ argsFunc: CTypeNode[];
7
+ }
8
+ export declare class CTypeParser {
9
+ tokens: string[];
10
+ cursor: number;
11
+ lex(str: string): void;
12
+ parse(str?: string | null, typeTransformer?: (orig: string) => string): CTypeNode;
13
+ eat(token: any, force?: boolean): boolean;
14
+ next(token?: string | null): string | false;
15
+ formatToC(node: CTypeNode): string;
16
+ formatToTypeScript(node: CTypeNode, namespace?: string): string;
17
+ }
18
+ export declare const cTypeToTypeScript: (str: string, namespace: string) => string;
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/cli.mjs CHANGED
@@ -6,20 +6,21 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  throw Error('Dynamic require of "' + x + '" is not supported');
7
7
  });
8
8
 
9
- // cli.ts
9
+ // src/cli.ts
10
10
  import log2 from "fancy-log";
11
11
 
12
- // core.ts
12
+ // src/core.ts
13
13
  import log from "fancy-log";
14
14
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
15
- import { join, dirname, resolve as resolvePath } from "node:path";
16
- import { fileURLToPath } from "node:url";
15
+ import { join, resolve as resolvePath } from "node:path";
17
16
  import { spawnSync } from "node:child_process";
18
17
 
19
- // c-type-parser.ts
18
+ // src/c-type-parser.ts
20
19
  var CTypeParser = class {
21
- tokens = [];
22
- cursor = 0;
20
+ constructor() {
21
+ this.tokens = [];
22
+ this.cursor = 0;
23
+ }
23
24
  lex(str) {
24
25
  this.tokens = [];
25
26
  let current = "";
@@ -143,7 +144,7 @@ var cTypeToTypeScript = (str, namespace) => {
143
144
  return parser2.formatToTypeScript(res, namespace);
144
145
  };
145
146
 
146
- // core.ts
147
+ // src/core.ts
147
148
  var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
148
149
  var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
149
150
  var DEFAULT_NAME_FILTER = "breeze::js::";
@@ -441,8 +442,6 @@ function generateBindingsAndDefinitions(config) {
441
442
  } = config;
442
443
  const absoluteCppFilePath = resolvePath(cppFilePath);
443
444
  const absoluteOutputDir = resolvePath(outputDir);
444
- const currentFilePath = fileURLToPath(import.meta.url);
445
- const bindgenDir = dirname(currentFilePath);
446
445
  const clangArgs = [
447
446
  "-Xclang",
448
447
  "-ast-dump=json",
@@ -496,7 +495,7 @@ ${clangProcess.stderr}`);
496
495
  log(`Bindings generated successfully in ${absoluteOutputDir}`);
497
496
  }
498
497
 
499
- // cli.ts
498
+ // src/cli.ts
500
499
  import { resolve as resolvePath2, join as joinPath, dirname as dirname4 } from "node:path";
501
500
 
502
501
  // node_modules/yargs/lib/platform-shims/esm.mjs
@@ -810,7 +809,7 @@ function sync_default(start, callback) {
810
809
  // node_modules/yargs/lib/platform-shims/esm.mjs
811
810
  import { format as format3, inspect } from "util";
812
811
  import { readFileSync as readFileSync4 } from "fs";
813
- import { fileURLToPath as fileURLToPath2 } from "url";
812
+ import { fileURLToPath } from "url";
814
813
 
815
814
  // node_modules/yargs-parser/build/lib/index.js
816
815
  import { format } from "util";
@@ -2010,8 +2009,8 @@ var y18n_default = y18n2;
2010
2009
  // node_modules/yargs/lib/platform-shims/esm.mjs
2011
2010
  var REQUIRE_ERROR = "require is not supported by ESM";
2012
2011
  var REQUIRE_DIRECTORY_ERROR = "loading a directory of commands is not supported yet for ESM";
2013
- var mainFilename = fileURLToPath2(import.meta.url).split("node_modules")[0];
2014
- var __dirname = fileURLToPath2(import.meta.url);
2012
+ var mainFilename = fileURLToPath(import.meta.url).split("node_modules")[0];
2013
+ var __dirname = fileURLToPath(import.meta.url);
2015
2014
  var esm_default = {
2016
2015
  assert: {
2017
2016
  notStrictEqual,
@@ -5167,7 +5166,7 @@ function isYargsInstance(y) {
5167
5166
  var Yargs = YargsFactory(esm_default);
5168
5167
  var yargs_default = Yargs;
5169
5168
 
5170
- // cli.ts
5169
+ // src/cli.ts
5171
5170
  import { readFileSync as readFileSync5 } from "node:fs";
5172
5171
  async function main() {
5173
5172
  const argv = await yargs_default(hideBin(process.argv)).option("input", {
package/dist/core.cjs CHANGED
@@ -214,7 +214,7 @@ var require_fancy_log = __commonJS({
214
214
  }
215
215
  });
216
216
 
217
- // core.ts
217
+ // src/core.ts
218
218
  var core_exports = {};
219
219
  __export(core_exports, {
220
220
  generateBindingsAndDefinitions: () => generateBindingsAndDefinitions
@@ -223,13 +223,14 @@ module.exports = __toCommonJS(core_exports);
223
223
  var import_fancy_log = __toESM(require_fancy_log());
224
224
  var import_node_fs = require("node:fs");
225
225
  var import_node_path = require("node:path");
226
- var import_node_url = require("node:url");
227
226
  var import_node_child_process = require("node:child_process");
228
227
 
229
- // c-type-parser.ts
228
+ // src/c-type-parser.ts
230
229
  var CTypeParser = class {
231
- tokens = [];
232
- cursor = 0;
230
+ constructor() {
231
+ this.tokens = [];
232
+ this.cursor = 0;
233
+ }
233
234
  lex(str) {
234
235
  this.tokens = [];
235
236
  let current = "";
@@ -353,8 +354,7 @@ var cTypeToTypeScript = (str, namespace) => {
353
354
  return parser.formatToTypeScript(res, namespace);
354
355
  };
355
356
 
356
- // core.ts
357
- var import_meta = {};
357
+ // src/core.ts
358
358
  var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
359
359
  var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
360
360
  var DEFAULT_NAME_FILTER = "breeze::js::";
@@ -652,8 +652,6 @@ function generateBindingsAndDefinitions(config) {
652
652
  } = config;
653
653
  const absoluteCppFilePath = (0, import_node_path.resolve)(cppFilePath);
654
654
  const absoluteOutputDir = (0, import_node_path.resolve)(outputDir);
655
- const currentFilePath = (0, import_node_url.fileURLToPath)(import_meta.url);
656
- const bindgenDir = (0, import_node_path.dirname)(currentFilePath);
657
655
  const clangArgs = [
658
656
  "-Xclang",
659
657
  "-ast-dump=json",
package/dist/core.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ interface BindgenConfig {
2
+ cppFilePath: string;
3
+ outputDir: string;
4
+ clangPath?: string;
5
+ cppBindingOutputFile?: string;
6
+ tsDefinitionOutputFile?: string;
7
+ additionalTypes?: string;
8
+ tsModuleName?: string;
9
+ nameFilter?: string;
10
+ }
11
+ export declare function generateBindingsAndDefinitions(config: BindgenConfig): void;
12
+ export {};
package/dist/core.mjs CHANGED
@@ -215,17 +215,18 @@ var require_fancy_log = __commonJS({
215
215
  }
216
216
  });
217
217
 
218
- // core.ts
218
+ // src/core.ts
219
219
  var import_fancy_log = __toESM(require_fancy_log());
220
220
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
221
- import { join, dirname, resolve as resolvePath } from "node:path";
222
- import { fileURLToPath } from "node:url";
221
+ import { join, resolve as resolvePath } from "node:path";
223
222
  import { spawnSync } from "node:child_process";
224
223
 
225
- // c-type-parser.ts
224
+ // src/c-type-parser.ts
226
225
  var CTypeParser = class {
227
- tokens = [];
228
- cursor = 0;
226
+ constructor() {
227
+ this.tokens = [];
228
+ this.cursor = 0;
229
+ }
229
230
  lex(str) {
230
231
  this.tokens = [];
231
232
  let current = "";
@@ -349,7 +350,7 @@ var cTypeToTypeScript = (str, namespace) => {
349
350
  return parser.formatToTypeScript(res, namespace);
350
351
  };
351
352
 
352
- // core.ts
353
+ // src/core.ts
353
354
  var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
354
355
  var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
355
356
  var DEFAULT_NAME_FILTER = "breeze::js::";
@@ -647,8 +648,6 @@ function generateBindingsAndDefinitions(config) {
647
648
  } = config;
648
649
  const absoluteCppFilePath = resolvePath(cppFilePath);
649
650
  const absoluteOutputDir = resolvePath(outputDir);
650
- const currentFilePath = fileURLToPath(import.meta.url);
651
- const bindgenDir = dirname(currentFilePath);
652
651
  const clangArgs = [
653
652
  "-Xclang",
654
653
  "-ast-dump=json",
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
3
3
  "name": "breeze-bindgen",
4
- "version": "1.1.3",
5
- "main": "dist/index.cjs",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
4
+ "version": "1.1.5",
5
+ "main": "dist/core.cjs",
6
+ "module": "dist/core.mjs",
7
+ "types": "dist/core.d.ts",
8
8
  "bin": {
9
9
  "breeze-bindgen": "./dist/cli.mjs"
10
10
  },
@@ -24,11 +24,12 @@
24
24
  "yargs": "17.1.1"
25
25
  },
26
26
  "scripts": {
27
- "build": "esbuild core.ts --bundle --outfile=dist/core.cjs --platform=node --format=cjs && esbuild core.ts --bundle --outfile=dist/core.mjs --platform=node --format=esm && esbuild cli.ts --bundle --outfile=dist/cli.mjs --platform=node --format=esm --banner:js=\"#!/usr/bin/env node\" --external:fancy-log --external:util",
27
+ "build": "esbuild src/core.ts --bundle --outfile=dist/core.cjs --platform=node --format=cjs && esbuild src/core.ts --bundle --outfile=dist/core.mjs --platform=node --format=esm && esbuild src/cli.ts --bundle --outfile=dist/cli.mjs --platform=node --format=esm --banner:js=\"#!/usr/bin/env node\" --external:fancy-log --external:util && yarn build-types",
28
28
  "prepublishOnly": "yarn build",
29
- "build:cli": "esbuild cli.ts --bundle --outfile=cli.js --platform=node --format=esm --banner:js='#!/usr/bin/env node'",
30
- "cli": "node -r esbuild-register cli.ts",
31
- "typegen": "node -r esbuild-register typegen.ts",
32
- "parser-test": "node -r esbuild-register c-type-parser.ts"
29
+ "build:cli": "esbuild src/cli.ts --bundle --outfile=cli.js --platform=node --format=esm --banner:js='#!/usr/bin/env node'",
30
+ "cli": "node -r esbuild-register src/cli.ts",
31
+ "typegen": "node -r esbuild-register src/typegen.ts",
32
+ "parser-test": "node -r esbuild-register src/c-type-parser.ts",
33
+ "build-types": "tsc -p ./tsconfig.json --emitDeclarationOnly --declaration --outdir dist"
33
34
  }
34
35
  }