@mxpicture/build-api 0.2.105 → 0.2.106

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.
@@ -1,3 +1,4 @@
1
+ import type { ExportNode } from "../types/types.exports.js";
1
2
  export declare const exportsRegex: RegExp;
2
3
  /**
3
4
  * Copy known keys from a source struct to a target struct.
@@ -7,5 +8,8 @@ export declare const exportsRegex: RegExp;
7
8
  * @param keys - Property keys to transfer.
8
9
  */
9
10
  export declare const enrichStruct: <T>(src: T, tar: T, keys: (keyof T)[]) => void;
10
- export declare const extractExportsString: (...code: string[]) => string[];
11
+ export declare const extractExportsString: (p: {
12
+ source: string;
13
+ code: string | string[];
14
+ }) => ExportNode[];
11
15
  //# sourceMappingURL=exports.common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.common.d.ts","sourceRoot":"","sources":["../../src/exp/exports.common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,QACsE,CAAC;AAEhG;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAG,IAEnE,CAAC;AAwBF,eAAO,MAAM,oBAAoB,GAAI,GAAG,MAAM,MAAM,EAAE,KAAG,MAAM,EAS9D,CAAC"}
1
+ {"version":3,"file":"exports.common.d.ts","sourceRoot":"","sources":["../../src/exp/exports.common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,eAAO,MAAM,YAAY,QACwE,CAAC;AAElG;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAG,IAEnE,CAAC;AAuBF,eAAO,MAAM,oBAAoB,GAAI,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB,KAAG,UAAU,EAeb,CAAC"}
@@ -1,4 +1,4 @@
1
- export const exportsRegex = /export\s+(?:const|let|var|function|class|interface|type|enum)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;
1
+ export const exportsRegex = /export\s+((?:const|let|var|function|class|interface|type|enum))\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;
2
2
  /**
3
3
  * Copy known keys from a source struct to a target struct.
4
4
  *
@@ -27,14 +27,17 @@ const enrichStructKey = (src, tar, key) => {
27
27
  throw new Error(`Type "${typeof src[key]}" is not supported`);
28
28
  }
29
29
  };
30
- // todo extend by type
31
- export const extractExportsString = (...code) => {
32
- const regResults = exportsRegex.exec(code.join(" "));
30
+ export const extractExportsString = (p) => {
31
+ const regResults = exportsRegex.exec(Array.isArray(p.code) ? p.code.join(" ") : p.code);
33
32
  if (!regResults)
34
33
  return [];
35
- const results = [];
36
- for (let i = 1; i < regResults.length; i += 2)
37
- results.push(regResults.at(i));
38
- return results;
34
+ const nodes = [];
35
+ for (let i = 1; i < regResults.length; i += 3)
36
+ nodes.push({
37
+ name: regResults.at(i + 1),
38
+ kind: regResults.at(i),
39
+ source: p.source,
40
+ });
41
+ return nodes;
39
42
  };
40
43
  //# sourceMappingURL=exports.common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.common.js","sourceRoot":"","sources":["../../src/exp/exports.common.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GACvB,6FAA6F,CAAC;AAEhG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,GAAM,EAAE,GAAM,EAAE,IAAiB,EAAQ,EAAE;IACzE,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAI,GAAM,EAAE,GAAM,EAAE,GAAY,EAAQ,EAAE;IAChE,QAAQ,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,QAAQ;YACV,GAAG,CAAC,GAAG,CAAa,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9C,MAAM;QAER,KAAK,QAAQ;YACV,GAAG,CAAC,GAAG,CAAa,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAClD,MAAM;QAER,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACX,GAAG,CAAC,GAAG,CAAa,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACjC,MAAM;QAER;YACE,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAClE,CAAC;AACH,CAAC,CAAC;AAEF,sBAAsB;AACtB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAG,IAAc,EAAY,EAAE;IAClE,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAE3B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["export const exportsRegex =\n /export\\s+(?:const|let|var|function|class|interface|type|enum)\\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;\n\n/**\n * Copy known keys from a source struct to a target struct.\n *\n * @param src - Source object.\n * @param tar - Target object (mutated in place).\n * @param keys - Property keys to transfer.\n */\nexport const enrichStruct = <T>(src: T, tar: T, keys: (keyof T)[]): void => {\n for (const key of keys) enrichStructKey(src, tar, key);\n};\n\nconst enrichStructKey = <T>(src: T, tar: T, key: keyof T): void => {\n switch (typeof src[key]) {\n case \"string\":\n (tar[key] as unknown) = src[key].substring(0);\n break;\n\n case \"object\":\n (tar[key] as unknown) = structuredClone(src[key]);\n break;\n\n case \"bigint\":\n case \"number\":\n case \"boolean\":\n (tar[key] as unknown) = src[key];\n break;\n\n default:\n throw new Error(`Type \"${typeof src[key]}\" is not supported`);\n }\n};\n\n// todo extend by type\nexport const extractExportsString = (...code: string[]): string[] => {\n const regResults = exportsRegex.exec(code.join(\" \"));\n if (!regResults) return [];\n\n const results: string[] = [];\n for (let i = 1; i < regResults.length; i += 2)\n results.push(regResults.at(i)!);\n\n return results;\n};\n"]}
1
+ {"version":3,"file":"exports.common.js","sourceRoot":"","sources":["../../src/exp/exports.common.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GACvB,+FAA+F,CAAC;AAElG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,GAAM,EAAE,GAAM,EAAE,IAAiB,EAAQ,EAAE;IACzE,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAI,GAAM,EAAE,GAAM,EAAE,GAAY,EAAQ,EAAE;IAChE,QAAQ,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,QAAQ;YACV,GAAG,CAAC,GAAG,CAAa,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9C,MAAM;QAER,KAAK,QAAQ;YACV,GAAG,CAAC,GAAG,CAAa,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAClD,MAAM;QAER,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACX,GAAG,CAAC,GAAG,CAAa,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACjC,MAAM;QAER;YACE,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAClE,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAGpC,EAAgB,EAAE;IACjB,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAClC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAClD,CAAC;IACF,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAE3B,MAAM,KAAK,GAAiB,EAAE,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;QAC3C,KAAK,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAE;YAC3B,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,CAAE;YACvB,MAAM,EAAE,CAAC,CAAC,MAAM;SACjB,CAAC,CAAC;IAEL,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import type { ExportNode } from \"../types/types.exports.js\";\n\nexport const exportsRegex =\n /export\\s+((?:const|let|var|function|class|interface|type|enum))\\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;\n\n/**\n * Copy known keys from a source struct to a target struct.\n *\n * @param src - Source object.\n * @param tar - Target object (mutated in place).\n * @param keys - Property keys to transfer.\n */\nexport const enrichStruct = <T>(src: T, tar: T, keys: (keyof T)[]): void => {\n for (const key of keys) enrichStructKey(src, tar, key);\n};\n\nconst enrichStructKey = <T>(src: T, tar: T, key: keyof T): void => {\n switch (typeof src[key]) {\n case \"string\":\n (tar[key] as unknown) = src[key].substring(0);\n break;\n\n case \"object\":\n (tar[key] as unknown) = structuredClone(src[key]);\n break;\n\n case \"bigint\":\n case \"number\":\n case \"boolean\":\n (tar[key] as unknown) = src[key];\n break;\n\n default:\n throw new Error(`Type \"${typeof src[key]}\" is not supported`);\n }\n};\n\nexport const extractExportsString = (p: {\n source: string;\n code: string | string[];\n}): ExportNode[] => {\n const regResults = exportsRegex.exec(\n Array.isArray(p.code) ? p.code.join(\" \") : p.code,\n );\n if (!regResults) return [];\n\n const nodes: ExportNode[] = [];\n for (let i = 1; i < regResults.length; i += 3)\n nodes.push({\n name: regResults.at(i + 1)!,\n kind: regResults.at(i)!,\n source: p.source,\n });\n\n return nodes;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/build-api",
3
- "version": "0.2.105",
3
+ "version": "0.2.106",
4
4
  "description": "Build utilities API",
5
5
  "type": "module",
6
6
  "author": "MXPicture",