@jxsuite/runtime 4.0.2 → 4.1.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Kevin Shenk
3
+ Copyright (c) 2026 Avunu LLC and Jx Suite contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/runtime.js CHANGED
@@ -3036,7 +3036,9 @@ function evaluateAttrTemplate(str, state) {
3036
3036
  }
3037
3037
  var _moduleCache = new Map;
3038
3038
  var _moduleLoaders = new Map;
3039
+ var _hostSeeded = new Set;
3039
3040
  function preloadModule(specifier, mod) {
3041
+ _hostSeeded.add(specifier);
3040
3042
  if (typeof mod === "function") {
3041
3043
  _moduleCache.delete(specifier);
3042
3044
  _moduleLoaders.set(specifier, mod);
@@ -4290,32 +4292,32 @@ async function resolveViaDevProxy(def, state, key, base) {
4290
4292
  }
4291
4293
  return s;
4292
4294
  }
4295
+ function latestServerCall(s, invoke, label) {
4296
+ let seq = 0;
4297
+ return (args) => {
4298
+ seq += 1;
4299
+ const n = seq;
4300
+ new Promise((settle) => {
4301
+ settle(invoke(args));
4302
+ }).then((result) => {
4303
+ if (n === seq) {
4304
+ s.value = result;
4305
+ }
4306
+ }).catch((error) => {
4307
+ if (n === seq) {
4308
+ console.error(label, error);
4309
+ }
4310
+ });
4311
+ };
4312
+ }
4293
4313
  async function resolveServerFunction(def, state, key, base) {
4294
4314
  const src = def.$src;
4295
4315
  const exportName = def.$export;
4296
- let mod;
4297
- const seeded = seededModule(src);
4298
- if (seeded instanceof Promise) {
4299
- mod = await seeded;
4300
- } else if (seeded) {
4301
- mod = seeded;
4302
- } else {
4303
- try {
4304
- mod = await import(src);
4305
- } catch {
4306
- if (base) {
4307
- try {
4308
- const resolvedSrc = new URL(src, base).href;
4309
- mod = await import(resolvedSrc);
4310
- } catch {
4311
- return resolveServerFunctionViaProxy(def, state, key, base);
4312
- }
4313
- } else {
4314
- return resolveServerFunctionViaProxy(def, state, key, base);
4315
- }
4316
- }
4317
- _moduleCache.set(src, mod);
4316
+ const seeded = _hostSeeded.has(src) ? seededModule(src) : undefined;
4317
+ if (!seeded) {
4318
+ return resolveServerFunctionViaProxy(def, state, key, base);
4318
4319
  }
4320
+ const mod = seeded instanceof Promise ? await seeded : seeded;
4319
4321
  const candidate = mod[exportName] ?? mod.default?.[exportName];
4320
4322
  if (!candidate) {
4321
4323
  throw new Error(`Jx: export "${exportName}" not found in "${src}" for "${key}"`);
@@ -4335,12 +4337,11 @@ async function resolveServerFunction(def, state, key, base) {
4335
4337
  };
4336
4338
  const s = ref(null);
4337
4339
  if (hasReactiveArg) {
4340
+ const call = latestServerCall(s, fn, "Jx server function:");
4338
4341
  effect(() => {
4339
4342
  const args = resolveArgs();
4340
4343
  onEffectCleanup(() => {});
4341
- fn(args).then((result) => {
4342
- s.value = result;
4343
- }).catch(() => {});
4344
+ call(args);
4344
4345
  });
4345
4346
  } else {
4346
4347
  s.value = await fn(resolveArgs());
@@ -4373,18 +4374,15 @@ async function resolveServerFunctionViaProxy(def, state, key, base) {
4373
4374
  return r.json();
4374
4375
  });
4375
4376
  const s = ref(null);
4377
+ const call = latestServerCall(s, doResolve, "Jx server proxy:");
4376
4378
  if (hasReactiveArg) {
4377
4379
  effect(() => {
4378
4380
  const args = resolveArgs();
4379
4381
  onEffectCleanup(() => {});
4380
- doResolve(args).then((result) => {
4381
- s.value = result;
4382
- }).catch((error) => console.error("Jx server proxy:", error));
4382
+ call(args);
4383
4383
  });
4384
4384
  } else {
4385
- doResolve(resolveArgs()).then((result) => {
4386
- s.value = result;
4387
- }).catch((error) => console.error("Jx server proxy:", error));
4385
+ call(resolveArgs());
4388
4386
  }
4389
4387
  return s;
4390
4388
  }
@@ -4941,5 +4939,5 @@ export {
4941
4939
  transposeCanvasUnits
4942
4940
  };
4943
4941
 
4944
- //# debugId=AA34AE79F7363B3164756E2164756E21
4942
+ //# debugId=9BAF2C3B31911D4B64756E2164756E21
4945
4943
  //# sourceMappingURL=runtime.js.map