porffor 0.57.9 → 0.57.10

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.
@@ -9,18 +9,31 @@ export const importedFuncs = {};
9
9
  Object.defineProperty(importedFuncs, 'length', { configurable: true, writable: true, value: 0 });
10
10
 
11
11
  export const createImport = (name, params, returns, js = null, c = null) => {
12
- if (name in importedFuncs) return false;
12
+ const lazy = () => {
13
+ if (typeof params === 'function') params = params();
14
+ if (typeof returns === 'function') returns = returns();
15
+ if (typeof params === 'number') params = new Array(params).fill(valtypeBinary);
16
+ if (typeof returns === 'number') returns = new Array(returns).fill(valtypeBinary);
17
+ };
18
+
19
+ if (name in importedFuncs) {
20
+ // overwrite existing import
21
+ const existing = importedFuncs[name];
22
+ lazy();
23
+
24
+ existing.params = params;
25
+ existing.returns = returns;
26
+ existing.js = js;
27
+ existing.c = c;
28
+ return;
29
+ }
13
30
 
14
31
  const call = importedFuncs.length;
15
32
  const ident = String.fromCharCode(97 + importedFuncs.length);
16
33
  let obj;
17
34
  const get = () => {
18
35
  if (obj) return obj;
19
-
20
- if (typeof params === 'function') params = params();
21
- if (typeof returns === 'function') returns = returns();
22
- if (typeof params === 'number') params = new Array(params).fill(valtypeBinary);
23
- if (typeof returns === 'number') returns = new Array(returns).fill(valtypeBinary);
36
+ lazy();
24
37
 
25
38
  obj = new Number(call);
26
39
  obj.name = name;
package/compiler/wrap.js CHANGED
@@ -383,21 +383,6 @@ export default (source, module = undefined, customImports = {}, print = str => p
383
383
 
384
384
  for (const x in customImports) {
385
385
  const custom = customImports[x];
386
-
387
- if (x in importedFuncs) {
388
- // overwrite with user custom import
389
- const existing = importedFuncs[x];
390
- if (typeof custom === 'function') {
391
- existing.js = custom;
392
- } else {
393
- existing.params = custom.params;
394
- existing.returns = custom.returns;
395
- existing.js = custom.js;
396
- existing.c = custom.c;
397
- }
398
- continue;
399
- }
400
-
401
386
  // todo: make a simpler api for just js functions at some point using function.length etc
402
387
  createImport(x, custom.params, custom.returns, custom.js, custom.c);
403
388
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "An ahead-of-time JavaScript compiler",
4
- "version": "0.57.9",
4
+ "version": "0.57.10",
5
5
  "author": "Oliver Medhurst <honk@goose.icu>",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runtime/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.57.9';
3
+ globalThis.version = '0.57.10';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {