@atproto/lex-builder 0.0.23 → 0.1.0-next.0

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/dist/util.js CHANGED
@@ -1,18 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.memoize = memoize;
4
- exports.startsWithLower = startsWithLower;
5
- exports.ucFirst = ucFirst;
6
- exports.lcFirst = lcFirst;
7
- exports.toPascalCase = toPascalCase;
8
- exports.toCamelCase = toCamelCase;
9
- exports.toConstantCase = toConstantCase;
10
- exports.toLowerCase = toLowerCase;
11
- exports.toUpperCase = toUpperCase;
12
- exports.asRelativePath = asRelativePath;
13
- exports.startsWithDigit = startsWithDigit;
14
- const node_path_1 = require("node:path");
15
- function memoize(fn) {
1
+ import { relative } from 'node:path';
2
+ export function memoize(fn) {
16
3
  const cache = new Map();
17
4
  return ((arg) => {
18
5
  const cached = cache.get(arg);
@@ -23,29 +10,29 @@ function memoize(fn) {
23
10
  return result;
24
11
  });
25
12
  }
26
- function startsWithLower(str) {
13
+ export function startsWithLower(str) {
27
14
  const code = str.charCodeAt(0);
28
15
  return code >= 97 && code <= 122; // 'a' to 'z'
29
16
  }
30
- function ucFirst(str) {
17
+ export function ucFirst(str) {
31
18
  return str.charAt(0).toUpperCase() + str.slice(1);
32
19
  }
33
- function lcFirst(str) {
20
+ export function lcFirst(str) {
34
21
  return str.charAt(0).toLowerCase() + str.slice(1);
35
22
  }
36
- function toPascalCase(str) {
23
+ export function toPascalCase(str) {
37
24
  return extractWords(str).map(toLowerCase).map(ucFirst).join('');
38
25
  }
39
- function toCamelCase(str) {
26
+ export function toCamelCase(str) {
40
27
  return lcFirst(toPascalCase(str));
41
28
  }
42
- function toConstantCase(str) {
29
+ export function toConstantCase(str) {
43
30
  return extractWords(str).map(toUpperCase).join('_');
44
31
  }
45
- function toLowerCase(str) {
32
+ export function toLowerCase(str) {
46
33
  return str.toLowerCase();
47
34
  }
48
- function toUpperCase(str) {
35
+ export function toUpperCase(str) {
49
36
  return str.toUpperCase();
50
37
  }
51
38
  function extractWords(str) {
@@ -59,13 +46,13 @@ function extractWords(str) {
59
46
  ? processedStr.split(/\s+/) // split by spaces
60
47
  : []; // Avoid returning [''] for empty strings
61
48
  }
62
- function asRelativePath(from, to) {
63
- const relPath = (0, node_path_1.relative)(from, to);
49
+ export function asRelativePath(from, to) {
50
+ const relPath = relative(from, to);
64
51
  return relPath.startsWith('./') || relPath.startsWith('../')
65
52
  ? relPath
66
53
  : `./${relPath}`;
67
54
  }
68
- function startsWithDigit(str) {
55
+ export function startsWithDigit(str) {
69
56
  const code = str.charCodeAt(0);
70
57
  return code >= 48 && code <= 57; // '0' to '9'
71
58
  }
package/dist/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAEA,0BAWC;AAED,0CAGC;AAED,0BAEC;AAED,0BAEC;AAED,oCAEC;AAED,kCAEC;AAED,wCAEC;AAED,kCAEC;AAED,kCAEC;AAeD,wCAKC;AAED,0CAGC;AAvED,yCAAoC;AAEpC,SAAgB,OAAO,CACrB,EAAK;IAEL,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuC,CAAA;IAC5D,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;QACtB,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC7B,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAA;QACvC,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;QACtB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACtB,OAAO,MAAM,CAAA;IACf,CAAC,CAAM,CAAA;AACT,CAAC;AAED,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IAC9B,OA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AAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,sCAAsC;SACrE,IAAI,EAAE,CAAA,CAAC,+BAA+B;IAEzC,OAAO,YAAY;QACjB,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,kBAAkB;QAC9C,CAAC,CAAC,EAAE,CAAA,CAAC,yCAAyC;AAClD,CAAC;AAED,SAAgB,cAAc,CAAC,IAAY,EAAE,EAAU;IACrD,MAAM,OAAO,GAAG,IAAA,oBAAQ,EAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IAClC,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;QAC1D,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,KAAK,OAAO,EAAE,CAAA;AACpB,CAAC;AAED,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IAC9B,OAAO,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAA,CAAC,aAAa;AAC/C,CAAC","sourcesContent":["import { relative } from 'node:path'\n\nexport function memoize<T extends (arg: string) => NonNullable<unknown> | null>(\n fn: T,\n): T {\n const cache = new Map<string, NonNullable<unknown> | null>()\n return ((arg: string) => {\n const cached = cache.get(arg)\n if (cached !== undefined) return cached\n const result = fn(arg)\n cache.set(arg, result)\n return result\n }) as T\n}\n\nexport function startsWithLower(str: string) {\n const code = str.charCodeAt(0)\n return code >= 97 && code <= 122 // 'a' to 'z'\n}\n\nexport function ucFirst(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nexport function lcFirst(str: string) {\n return str.charAt(0).toLowerCase() + str.slice(1)\n}\n\nexport function toPascalCase(str: string): string {\n return extractWords(str).map(toLowerCase).map(ucFirst).join('')\n}\n\nexport function toCamelCase(str: string): string {\n return lcFirst(toPascalCase(str))\n}\n\nexport function toConstantCase(str: string): string {\n return extractWords(str).map(toUpperCase).join('_')\n}\n\nexport function toLowerCase(str: string): string {\n return str.toLowerCase()\n}\n\nexport function toUpperCase(str: string): string {\n return str.toUpperCase()\n}\n\nfunction extractWords(str: string): string[] {\n const processedStr = str\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2') // split camelCase\n .replace(/([A-Z])([A-Z][a-z])/g, '$1 $2') // split ALLCAPSWords\n .replace(/([0-9])([A-Za-z])/g, '$1 $2') // split number followed by letter\n .replace(/[^a-zA-Z0-9]+/g, ' ') // replace non-alphanumeric with space\n .trim() // trim leading/trailing spaces\n\n return processedStr\n ? processedStr.split(/\\s+/) // split by spaces\n : [] // Avoid returning [''] for empty strings\n}\n\nexport function asRelativePath(from: string, to: string) {\n const relPath = relative(from, to)\n return relPath.startsWith('./') || relPath.startsWith('../')\n ? relPath\n : `./${relPath}`\n}\n\nexport function startsWithDigit(str: string) {\n const code = str.charCodeAt(0)\n return code >= 48 && code <= 57 // '0' to '9'\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,UAAU,OAAO,CACrB,EAAK;IAEL,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuC,CAAA;IAC5D,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;QACtB,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC7B,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAA;QACvC,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;QACtB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACtB,OAAO,MAAM,CAAA;IACf,CAAC,CAAM,CAAA;AACT,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,C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CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,kCAAkC;SACzE,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,sCAAsC;SACrE,IAAI,EAAE,CAAA,CAAC,+BAA+B;IAEzC,OAAO,YAAY;QACjB,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,kBAAkB;QAC9C,CAAC,CAAC,EAAE,CAAA,CAAC,yCAAyC;AAClD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,EAAU;IACrD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IAClC,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;QAC1D,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,KAAK,OAAO,EAAE,CAAA;AACpB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IAC9B,OAAO,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAA,CAAC,aAAa;AAC/C,CAAC","sourcesContent":["import { relative } from 'node:path'\n\nexport function memoize<T extends (arg: string) => NonNullable<unknown> | null>(\n fn: T,\n): T {\n const cache = new Map<string, NonNullable<unknown> | null>()\n return ((arg: string) => {\n const cached = cache.get(arg)\n if (cached !== undefined) return cached\n const result = fn(arg)\n cache.set(arg, result)\n return result\n }) as T\n}\n\nexport function startsWithLower(str: string) {\n const code = str.charCodeAt(0)\n return code >= 97 && code <= 122 // 'a' to 'z'\n}\n\nexport function ucFirst(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nexport function lcFirst(str: string) {\n return str.charAt(0).toLowerCase() + str.slice(1)\n}\n\nexport function toPascalCase(str: string): string {\n return extractWords(str).map(toLowerCase).map(ucFirst).join('')\n}\n\nexport function toCamelCase(str: string): string {\n return lcFirst(toPascalCase(str))\n}\n\nexport function toConstantCase(str: string): string {\n return extractWords(str).map(toUpperCase).join('_')\n}\n\nexport function toLowerCase(str: string): string {\n return str.toLowerCase()\n}\n\nexport function toUpperCase(str: string): string {\n return str.toUpperCase()\n}\n\nfunction extractWords(str: string): string[] {\n const processedStr = str\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2') // split camelCase\n .replace(/([A-Z])([A-Z][a-z])/g, '$1 $2') // split ALLCAPSWords\n .replace(/([0-9])([A-Za-z])/g, '$1 $2') // split number followed by letter\n .replace(/[^a-zA-Z0-9]+/g, ' ') // replace non-alphanumeric with space\n .trim() // trim leading/trailing spaces\n\n return processedStr\n ? processedStr.split(/\\s+/) // split by spaces\n : [] // Avoid returning [''] for empty strings\n}\n\nexport function asRelativePath(from: string, to: string) {\n const relPath = relative(from, to)\n return relPath.startsWith('./') || relPath.startsWith('../')\n ? relPath\n : `./${relPath}`\n}\n\nexport function startsWithDigit(str: string) {\n const code = str.charCodeAt(0)\n return code >= 48 && code <= 57 // '0' to '9'\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@atproto/lex-builder",
3
- "version": "0.0.23",
3
+ "version": "0.1.0-next.0",
4
+ "engines": {
5
+ "node": ">=22"
6
+ },
4
7
  "license": "MIT",
5
8
  "description": "TypeScript schema builder for AT Lexicons",
6
9
  "keywords": [
@@ -24,23 +27,19 @@
24
27
  "./CHANGELOG.md"
25
28
  ],
26
29
  "sideEffects": false,
27
- "type": "commonjs",
28
- "main": "./dist/index.js",
29
- "types": "./dist/index.d.ts",
30
+ "type": "module",
30
31
  "exports": {
31
32
  ".": {
32
33
  "types": "./dist/index.d.ts",
33
- "browser": "./dist/index.js",
34
- "require": "./dist/index.js",
35
- "import": "./dist/index.js"
34
+ "default": "./dist/index.js"
36
35
  }
37
36
  },
38
37
  "dependencies": {
39
38
  "prettier": "^3.2.5",
40
39
  "ts-morph": "^27.0.0",
41
40
  "tslib": "^2.8.1",
42
- "@atproto/lex-document": "^0.0.21",
43
- "@atproto/lex-schema": "^0.0.20"
41
+ "@atproto/lex-schema": "^0.1.0-next.0",
42
+ "@atproto/lex-document": "^0.1.0-next.0"
44
43
  },
45
44
  "devDependencies": {
46
45
  "@ts-morph/common": "^0.28.0",
@@ -223,7 +223,7 @@ export class LexBuilder {
223
223
 
224
224
  // @NOTE Individual exports exports from the defs file might conflict with
225
225
  // child namespaces. For this reason, we also add a namespace export for the
226
- // defs (export * as $defs from './xyz.defs'). This is an escape hatch
226
+ // defs (export * as $defs from './xyz.defs.js'). This is an escape hatch
227
227
  // allowing to still access the definitions if a hash get shadowed by a
228
228
  // child namespace.
229
229
  file.addExportDeclaration({
@@ -239,7 +239,7 @@ export class RefResolver {
239
239
  // > "Cannot use namespace '<nsIdentifier>' as a type."
240
240
 
241
241
  // Instead the generated code should look like:
242
- // import { "<unsafeTypeName>" as <safeIdentifier> } from './<moduleSpecifier>'
242
+ // import { "<unsafeTypeName>" as <safeIdentifier> } from './<moduleSpecifier>.js'
243
243
 
244
244
  // Because it requires more complex management of local variables names,
245
245
  // and we don't expect this to actually happen with properly designed
@@ -250,7 +250,7 @@ export class RefResolver {
250
250
  )
251
251
  }
252
252
 
253
- // import * as <nsIdentifier> from './<moduleSpecifier>'
253
+ // import * as <nsIdentifier> from './<moduleSpecifier>.js'
254
254
  const nsIdentifier = this.getNsIdentifier(nsid, moduleSpecifier)
255
255
 
256
256
  return {