@fictjs/runtime 0.0.14 → 0.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.
Files changed (40) hide show
  1. package/dist/advanced.cjs +8 -8
  2. package/dist/advanced.js +3 -3
  3. package/dist/{chunk-PMF6MWEV.cjs → chunk-7WAGAQLT.cjs} +45 -24
  4. package/dist/chunk-7WAGAQLT.cjs.map +1 -0
  5. package/dist/{chunk-RY4WDS6R.js → chunk-BWZFJXUI.js} +32 -11
  6. package/dist/chunk-BWZFJXUI.js.map +1 -0
  7. package/dist/{chunk-F3AIYQB7.js → chunk-CF3OHML2.js} +3 -3
  8. package/dist/chunk-CF3OHML2.js.map +1 -0
  9. package/dist/{chunk-GJTYOFMO.cjs → chunk-Q4EN6BXV.cjs} +16 -16
  10. package/dist/{chunk-GJTYOFMO.cjs.map → chunk-Q4EN6BXV.cjs.map} +1 -1
  11. package/dist/{chunk-IUZXKAAY.js → chunk-V62XZLDU.js} +2 -2
  12. package/dist/{chunk-624QY53A.cjs → chunk-YQ4IB7NC.cjs} +7 -7
  13. package/dist/chunk-YQ4IB7NC.cjs.map +1 -0
  14. package/dist/index.cjs +44 -44
  15. package/dist/index.d.cts +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.dev.js +30 -9
  18. package/dist/index.dev.js.map +1 -1
  19. package/dist/index.js +2 -2
  20. package/dist/internal.cjs +44 -35
  21. package/dist/internal.cjs.map +1 -1
  22. package/dist/internal.d.cts +6 -1
  23. package/dist/internal.d.ts +6 -1
  24. package/dist/internal.js +12 -3
  25. package/dist/internal.js.map +1 -1
  26. package/dist/{props-ES0Ag_Wd.d.ts → props-BBi8Tkks.d.ts} +9 -2
  27. package/dist/{props-CrOMYbLv.d.cts → props-BfmSLuyp.d.cts} +9 -2
  28. package/package.json +1 -1
  29. package/src/binding.ts +4 -3
  30. package/src/constants.ts +2 -3
  31. package/src/dev-entry.ts +22 -0
  32. package/src/lifecycle.ts +11 -3
  33. package/src/list-helpers.ts +14 -3
  34. package/src/props.ts +29 -3
  35. package/src/scope.ts +1 -1
  36. package/dist/chunk-624QY53A.cjs.map +0 -1
  37. package/dist/chunk-F3AIYQB7.js.map +0 -1
  38. package/dist/chunk-PMF6MWEV.cjs.map +0 -1
  39. package/dist/chunk-RY4WDS6R.js.map +0 -1
  40. /package/dist/{chunk-IUZXKAAY.js.map → chunk-V62XZLDU.js.map} +0 -0
@@ -213,8 +213,7 @@ function getPropAlias(prop2, tagName) {
213
213
  return a;
214
214
  }
215
215
  var $$EVENTS = "_$FICT_DELEGATE";
216
- var delegatedEvents = isDev ? DelegatedEventNames : [];
217
- var DelegatedEvents = new Set(delegatedEvents);
216
+ var DelegatedEvents = new Set(DelegatedEventNames);
218
217
  var svgElements = isDev ? [
219
218
  "altGlyph",
220
219
  "altGlyphDef",
@@ -512,7 +511,7 @@ var currentRoot;
512
511
  var currentEffectCleanups;
513
512
  var globalErrorHandlers = /* @__PURE__ */ new WeakMap();
514
513
  var globalSuspenseHandlers = /* @__PURE__ */ new WeakMap();
515
- function createRootContext(parent = currentRoot) {
514
+ function createRootContext(parent) {
516
515
  return { parent, cleanups: [], destroyCallbacks: [] };
517
516
  }
518
517
  function pushRoot(root) {
@@ -588,8 +587,9 @@ function destroyRoot(root) {
588
587
  globalSuspenseHandlers.delete(root);
589
588
  }
590
589
  }
591
- function createRoot(fn) {
592
- const root = createRootContext();
590
+ function createRoot(fn, options) {
591
+ const parent = options?.inherit ? currentRoot : void 0;
592
+ const root = createRootContext(parent);
593
593
  const prev = pushRoot(root);
594
594
  let value;
595
595
  try {
@@ -2205,7 +2205,8 @@ function bindEvent(el, eventName, handler, options) {
2205
2205
  if (handler == null) return () => {
2206
2206
  };
2207
2207
  const rootRef = getCurrentRoot();
2208
- if (isDev5 && DelegatedEvents.has(eventName) && !options) {
2208
+ const shouldDelegate = options == null && DelegatedEvents.has(eventName);
2209
+ if (shouldDelegate) {
2209
2210
  const key = `$$${eventName}`;
2210
2211
  delegateEvents([eventName]);
2211
2212
  const resolveHandler = isReactive(handler) ? handler : () => handler;
@@ -2352,7 +2353,7 @@ function assignProp(node, prop2, value, prev, isSVG, skipRef, props) {
2352
2353
  }
2353
2354
  if (prop2.slice(0, 2) === "on") {
2354
2355
  const eventName = prop2.slice(2).toLowerCase();
2355
- const shouldDelegate = isDev5 && DelegatedEvents.has(eventName);
2356
+ const shouldDelegate = DelegatedEvents.has(eventName);
2356
2357
  if (!shouldDelegate && prev) {
2357
2358
  const handler = Array.isArray(prev) ? prev[0] : prev;
2358
2359
  node.removeEventListener(eventName, handler);
@@ -2656,17 +2657,27 @@ function __fictRender(ctx, fn) {
2656
2657
  }
2657
2658
 
2658
2659
  // src/props.ts
2660
+ var PROP_GETTER_MARKER = Symbol.for("fict:prop-getter");
2659
2661
  var propGetters = /* @__PURE__ */ new WeakSet();
2660
2662
  var rawToProxy = /* @__PURE__ */ new WeakMap();
2661
2663
  var proxyToRaw = /* @__PURE__ */ new WeakMap();
2662
2664
  function __fictProp(getter) {
2663
2665
  if (typeof getter === "function" && getter.length === 0) {
2664
2666
  propGetters.add(getter);
2667
+ if (Object.isExtensible(getter)) {
2668
+ try {
2669
+ ;
2670
+ getter[PROP_GETTER_MARKER] = true;
2671
+ } catch {
2672
+ }
2673
+ }
2665
2674
  }
2666
2675
  return getter;
2667
2676
  }
2668
2677
  function isPropGetter(value) {
2669
- return typeof value === "function" && propGetters.has(value);
2678
+ if (typeof value !== "function") return false;
2679
+ const fn = value;
2680
+ return propGetters.has(fn) || fn[PROP_GETTER_MARKER] === true;
2670
2681
  }
2671
2682
  function createPropsProxy(props) {
2672
2683
  if (!props || typeof props !== "object") {
@@ -2790,11 +2801,21 @@ function mergeProps(...sources) {
2790
2801
  }
2791
2802
  });
2792
2803
  }
2793
- function prop(getter) {
2804
+ function prop(getter, options) {
2794
2805
  if (isPropGetter(getter)) {
2795
2806
  return getter;
2796
2807
  }
2797
- return __fictProp(createMemo(getter));
2808
+ const fn = getter;
2809
+ const unwrap2 = options?.unwrap !== false;
2810
+ return __fictProp(
2811
+ createMemo(() => {
2812
+ const value = fn();
2813
+ if (unwrap2 && isPropGetter(value)) {
2814
+ return value();
2815
+ }
2816
+ return value;
2817
+ })
2818
+ );
2798
2819
  }
2799
2820
 
2800
2821
  // src/dom.ts
@@ -3298,4 +3319,4 @@ export {
3298
3319
  createElement,
3299
3320
  template
3300
3321
  };
3301
- //# sourceMappingURL=chunk-RY4WDS6R.js.map
3322
+ //# sourceMappingURL=chunk-BWZFJXUI.js.map