@eighty4/c2 0.0.5-0 → 0.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/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  - ???
6
6
 
7
+ ## [v0.0.5] - 2026-02-21
8
+
9
+ ### Fixed
10
+
11
+ - Rewrite code using Bun APIs and npm packages to remove
12
+ package install size and dependency on specific runtime
13
+
7
14
  ## [v0.0.4] - 2025-06-30
8
15
 
9
16
  ### Fixed
@@ -28,7 +35,8 @@
28
35
  - Evaluate env() and file() expressions in user data
29
36
  - Merge multiple user data into a MIME multipart message
30
37
 
31
- [Unreleased]: https://github.com/eighty4/c2/compare/v0.0.4...HEAD
38
+ [Unreleased]: https://github.com/eighty4/c2/compare/v0.0.5...HEAD
39
+ [v0.0.5]: https://github.com/eighty4/c2/compare/v0.0.4...v0.0.5
32
40
  [v0.0.4]: https://github.com/eighty4/c2/compare/v0.0.3...v0.0.4
33
41
  [v0.0.3]: https://github.com/eighty4/c2/compare/v0.0.2...v0.0.3
34
42
  [v0.0.2]: https://github.com/eighty4/c2/releases/tag/v0.0.2
package/lib/expression.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { readFile } from 'node:fs/promises'
2
- import MagicString from 'magic-string'
3
2
 
4
3
  type TemplateExpression = {
5
4
  index: number
@@ -23,15 +22,18 @@ export async function evalTemplateExpressions(
23
22
  if (!expressions.length) {
24
23
  return content
25
24
  }
26
- const ms = new MagicString(content)
25
+ let offset = 0
27
26
  for (const expression of expressions) {
28
- ms.update(
29
- expression.index,
30
- expression.index + expression.outie.length,
31
- await evaluate(expression.innie),
32
- )
27
+ const expressionResult = await evaluate(expression.innie)
28
+ content =
29
+ content.substring(0, expression.index + offset) +
30
+ expressionResult +
31
+ content.substring(
32
+ expression.index + expression.outie.length + offset,
33
+ )
34
+ offset += expressionResult.length - expression.outie.length
33
35
  }
34
- return ms.toString()
36
+ return content
35
37
  }
36
38
 
37
39
  async function evaluate(expression: string): Promise<string> {
@@ -1,5 +1,4 @@
1
1
  import { readFile } from 'node:fs/promises';
2
- import MagicString from 'magic-string';
3
2
  export async function evalTemplateExpressions(content) {
4
3
  const regex = new RegExp(/\${{\s*(.*)\s*}}/g);
5
4
  let match;
@@ -14,11 +13,16 @@ export async function evalTemplateExpressions(content) {
14
13
  if (!expressions.length) {
15
14
  return content;
16
15
  }
17
- const ms = new MagicString(content);
16
+ let offset = 0;
18
17
  for (const expression of expressions) {
19
- ms.update(expression.index, expression.index + expression.outie.length, await evaluate(expression.innie));
18
+ const expressionResult = await evaluate(expression.innie);
19
+ content =
20
+ content.substring(0, expression.index + offset) +
21
+ expressionResult +
22
+ content.substring(expression.index + expression.outie.length + offset);
23
+ offset += expressionResult.length - expression.outie.length;
20
24
  }
21
- return ms.toString();
25
+ return content;
22
26
  }
23
27
  async function evaluate(expression) {
24
28
  let match;
@@ -1 +1 @@
1
- {"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../lib/expression.ts"],"names":[],"mappings":"AASA,wBAAsB,uBAAuB,CACzC,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
1
+ {"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../lib/expression.ts"],"names":[],"mappings":"AAQA,wBAAsB,uBAAuB,CACzC,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CA0BjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eighty4/c2",
3
- "version": "0.0.5-0",
3
+ "version": "0.0.5",
4
4
  "author": "Adam McKee <adam.be.g84d@gmail.com>",
5
5
  "repository": "https://github.com/eighty4/c2",
6
6
  "homepage": "https://github.com/eighty4/c2",
@@ -29,13 +29,10 @@
29
29
  "types": "./lib_types/api.d.ts"
30
30
  }
31
31
  },
32
- "dependencies": {
33
- "magic-string": "0.30.17"
34
- },
35
32
  "devDependencies": {
36
- "@types/node": "^22.14.1",
37
- "prettier": "^3.5.3",
38
- "typescript": "5.8.2"
33
+ "@types/node": "^25.3.0",
34
+ "prettier": "^3.8.1",
35
+ "typescript": "5.9.3"
39
36
  },
40
37
  "files": [
41
38
  "lib/*",