@novely/solid-renderer 0.36.0-experemental → 0.36.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 (2) hide show
  1. package/dist/index.jsx +226 -293
  2. package/package.json +3 -3
package/dist/index.jsx CHANGED
@@ -1,15 +1,25 @@
1
- // ../../node_modules/.pnpm/solid-js@1.8.18/node_modules/solid-js/dist/solid.js
1
+ // ../../node_modules/.pnpm/solid-js@1.8.19/node_modules/solid-js/dist/solid.js
2
2
  var sharedConfig = {
3
3
  context: void 0,
4
- registry: void 0
4
+ registry: void 0,
5
+ getContextId() {
6
+ return getContextId(this.context.count);
7
+ },
8
+ getNextContextId() {
9
+ return getContextId(this.context.count++);
10
+ }
5
11
  };
12
+ function getContextId(count) {
13
+ const num = String(count), len = num.length - 1;
14
+ return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
15
+ }
6
16
  function setHydrateContext(context) {
7
17
  sharedConfig.context = context;
8
18
  }
9
19
  function nextHydrateContext() {
10
20
  return {
11
21
  ...sharedConfig.context,
12
- id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
22
+ id: sharedConfig.getNextContextId(),
13
23
  count: 0
14
24
  };
15
25
  }
@@ -216,7 +226,8 @@ function createContext(defaultValue, options) {
216
226
  };
217
227
  }
218
228
  function useContext(context) {
219
- return Owner && Owner.context && Owner.context[context.id] !== void 0 ? Owner.context[context.id] : context.defaultValue;
229
+ let value;
230
+ return Owner && Owner.context && (value = Owner.context[context.id]) !== void 0 ? value : context.defaultValue;
220
231
  }
221
232
  function children(fn) {
222
233
  const children2 = createMemo(fn);
@@ -310,11 +321,7 @@ function updateComputation(node) {
310
321
  return;
311
322
  cleanNode(node);
312
323
  const time = ExecCount;
313
- runComputation(
314
- node,
315
- Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
316
- time
317
- );
324
+ runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
318
325
  if (Transition && !Transition.running && Transition.sources.has(node)) {
319
326
  queueMicrotask(() => {
320
327
  runUpdates(() => {
@@ -692,16 +699,13 @@ function resolveChildren(children2) {
692
699
  function createProvider(id, options) {
693
700
  return function provider(props) {
694
701
  let res;
695
- createRenderEffect(
696
- () => res = untrack(() => {
697
- Owner.context = {
698
- ...Owner.context,
699
- [id]: props.value
700
- };
701
- return children(() => props.children);
702
- }),
703
- void 0
704
- );
702
+ createRenderEffect(() => res = untrack(() => {
703
+ Owner.context = {
704
+ ...Owner.context,
705
+ [id]: props.value
706
+ };
707
+ return children(() => props.children);
708
+ }), void 0);
705
709
  return res;
706
710
  };
707
711
  }
@@ -727,10 +731,10 @@ function mapArray(list, mapFn, options = {}) {
727
731
  let items = [], mapped = [], disposers = [], len = 0, indexes = mapFn.length > 1 ? [] : null;
728
732
  onCleanup(() => dispose(disposers));
729
733
  return () => {
730
- let newItems = list() || [], i, j;
734
+ let newItems = list() || [], newLen = newItems.length, i, j;
731
735
  newItems[$TRACK];
732
736
  return untrack(() => {
733
- let newLen = newItems.length, newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item;
737
+ let newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item;
734
738
  if (newLen === 0) {
735
739
  if (len !== 0) {
736
740
  dispose(disposers);
@@ -875,31 +879,28 @@ function mergeProps(...sources) {
875
879
  sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
876
880
  }
877
881
  if (proxy) {
878
- return new Proxy(
879
- {
880
- get(property) {
881
- for (let i = sources.length - 1; i >= 0; i--) {
882
- const v = resolveSource(sources[i])[property];
883
- if (v !== void 0)
884
- return v;
885
- }
886
- },
887
- has(property) {
888
- for (let i = sources.length - 1; i >= 0; i--) {
889
- if (property in resolveSource(sources[i]))
890
- return true;
891
- }
892
- return false;
893
- },
894
- keys() {
895
- const keys2 = [];
896
- for (let i = 0; i < sources.length; i++)
897
- keys2.push(...Object.keys(resolveSource(sources[i])));
898
- return [...new Set(keys2)];
882
+ return new Proxy({
883
+ get(property) {
884
+ for (let i = sources.length - 1; i >= 0; i--) {
885
+ const v = resolveSource(sources[i])[property];
886
+ if (v !== void 0)
887
+ return v;
899
888
  }
900
889
  },
901
- propTraps
902
- );
890
+ has(property) {
891
+ for (let i = sources.length - 1; i >= 0; i--) {
892
+ if (property in resolveSource(sources[i]))
893
+ return true;
894
+ }
895
+ return false;
896
+ },
897
+ keys() {
898
+ const keys2 = [];
899
+ for (let i = 0; i < sources.length; i++)
900
+ keys2.push(...Object.keys(resolveSource(sources[i])));
901
+ return [...new Set(keys2)];
902
+ }
903
+ }, propTraps);
903
904
  }
904
905
  const sourcesMap = {};
905
906
  const defined = /* @__PURE__ */ Object.create(null);
@@ -945,37 +946,29 @@ function splitProps(props, ...keys2) {
945
946
  if ($PROXY in props) {
946
947
  const blocked = new Set(keys2.length > 1 ? keys2.flat() : keys2[0]);
947
948
  const res = keys2.map((k) => {
948
- return new Proxy(
949
- {
950
- get(property) {
951
- return k.includes(property) ? props[property] : void 0;
952
- },
953
- has(property) {
954
- return k.includes(property) && property in props;
955
- },
956
- keys() {
957
- return k.filter((property) => property in props);
958
- }
949
+ return new Proxy({
950
+ get(property) {
951
+ return k.includes(property) ? props[property] : void 0;
959
952
  },
960
- propTraps
961
- );
962
- });
963
- res.push(
964
- new Proxy(
965
- {
966
- get(property) {
967
- return blocked.has(property) ? void 0 : props[property];
968
- },
969
- has(property) {
970
- return blocked.has(property) ? false : property in props;
971
- },
972
- keys() {
973
- return Object.keys(props).filter((k) => !blocked.has(k));
974
- }
953
+ has(property) {
954
+ return k.includes(property) && property in props;
975
955
  },
976
- propTraps
977
- )
978
- );
956
+ keys() {
957
+ return k.filter((property) => property in props);
958
+ }
959
+ }, propTraps);
960
+ });
961
+ res.push(new Proxy({
962
+ get(property) {
963
+ return blocked.has(property) ? void 0 : props[property];
964
+ },
965
+ has(property) {
966
+ return blocked.has(property) ? false : property in props;
967
+ },
968
+ keys() {
969
+ return Object.keys(props).filter((k) => !blocked.has(k));
970
+ }
971
+ }, propTraps));
979
972
  return res;
980
973
  }
981
974
  const otherObject = {};
@@ -1001,7 +994,7 @@ function splitProps(props, ...keys2) {
1001
994
  var counter = 0;
1002
995
  function createUniqueId() {
1003
996
  const ctx = sharedConfig.context;
1004
- return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
997
+ return ctx ? sharedConfig.getNextContextId() : `cl-${counter++}`;
1005
998
  }
1006
999
  var narrowedError = (name) => `Stale read from <${name}>.`;
1007
1000
  function For(props) {
@@ -1015,120 +1008,59 @@ function Show(props) {
1015
1008
  const condition = createMemo(() => props.when, void 0, {
1016
1009
  equals: (a, b) => keyed ? a === b : !a === !b
1017
1010
  });
1018
- return createMemo(
1019
- () => {
1020
- const c = condition();
1021
- if (c) {
1022
- const child = props.children;
1023
- const fn = typeof child === "function" && child.length > 0;
1024
- return fn ? untrack(
1025
- () => child(
1026
- keyed ? c : () => {
1027
- if (!untrack(condition))
1028
- throw narrowedError("Show");
1029
- return props.when;
1030
- }
1031
- )
1032
- ) : child;
1033
- }
1034
- return props.fallback;
1035
- },
1036
- void 0,
1037
- void 0
1038
- );
1011
+ return createMemo(() => {
1012
+ const c = condition();
1013
+ if (c) {
1014
+ const child = props.children;
1015
+ const fn = typeof child === "function" && child.length > 0;
1016
+ return fn ? untrack(() => child(keyed ? c : () => {
1017
+ if (!untrack(condition))
1018
+ throw narrowedError("Show");
1019
+ return props.when;
1020
+ })) : child;
1021
+ }
1022
+ return props.fallback;
1023
+ }, void 0, void 0);
1039
1024
  }
1040
1025
  function Switch(props) {
1041
1026
  let keyed = false;
1042
1027
  const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1043
- const conditions = children(() => props.children), evalConditions = createMemo(
1044
- () => {
1045
- let conds = conditions();
1046
- if (!Array.isArray(conds))
1047
- conds = [conds];
1048
- for (let i = 0; i < conds.length; i++) {
1049
- const c = conds[i].when;
1050
- if (c) {
1051
- keyed = !!conds[i].keyed;
1052
- return [i, c, conds[i]];
1053
- }
1028
+ const conditions = children(() => props.children), evalConditions = createMemo(() => {
1029
+ let conds = conditions();
1030
+ if (!Array.isArray(conds))
1031
+ conds = [conds];
1032
+ for (let i = 0; i < conds.length; i++) {
1033
+ const c = conds[i].when;
1034
+ if (c) {
1035
+ keyed = !!conds[i].keyed;
1036
+ return [i, c, conds[i]];
1054
1037
  }
1055
- return [-1];
1056
- },
1057
- void 0,
1058
- {
1059
- equals
1060
1038
  }
1061
- );
1062
- return createMemo(
1063
- () => {
1064
- const [index, when, cond] = evalConditions();
1065
- if (index < 0)
1066
- return props.fallback;
1067
- const c = cond.children;
1068
- const fn = typeof c === "function" && c.length > 0;
1069
- return fn ? untrack(
1070
- () => c(
1071
- keyed ? when : () => {
1072
- if (untrack(evalConditions)[0] !== index)
1073
- throw narrowedError("Match");
1074
- return cond.when;
1075
- }
1076
- )
1077
- ) : c;
1078
- },
1079
- void 0,
1080
- void 0
1081
- );
1039
+ return [-1];
1040
+ }, void 0, {
1041
+ equals
1042
+ });
1043
+ return createMemo(() => {
1044
+ const [index, when, cond] = evalConditions();
1045
+ if (index < 0)
1046
+ return props.fallback;
1047
+ const c = cond.children;
1048
+ const fn = typeof c === "function" && c.length > 0;
1049
+ return fn ? untrack(() => c(keyed ? when : () => {
1050
+ if (untrack(evalConditions)[0] !== index)
1051
+ throw narrowedError("Match");
1052
+ return cond.when;
1053
+ })) : c;
1054
+ }, void 0, void 0);
1082
1055
  }
1083
1056
  function Match(props) {
1084
1057
  return props;
1085
1058
  }
1086
- var SuspenseListContext = createContext();
1087
1059
 
1088
- // ../../node_modules/.pnpm/solid-js@1.8.18/node_modules/solid-js/web/dist/web.js
1089
- var booleans = [
1090
- "allowfullscreen",
1091
- "async",
1092
- "autofocus",
1093
- "autoplay",
1094
- "checked",
1095
- "controls",
1096
- "default",
1097
- "disabled",
1098
- "formnovalidate",
1099
- "hidden",
1100
- "indeterminate",
1101
- "inert",
1102
- "ismap",
1103
- "loop",
1104
- "multiple",
1105
- "muted",
1106
- "nomodule",
1107
- "novalidate",
1108
- "open",
1109
- "playsinline",
1110
- "readonly",
1111
- "required",
1112
- "reversed",
1113
- "seamless",
1114
- "selected"
1115
- ];
1116
- var Properties = /* @__PURE__ */ new Set([
1117
- "className",
1118
- "value",
1119
- "readOnly",
1120
- "formNoValidate",
1121
- "isMap",
1122
- "noModule",
1123
- "playsInline",
1124
- ...booleans
1125
- ]);
1126
- var ChildProperties = /* @__PURE__ */ new Set([
1127
- "innerHTML",
1128
- "textContent",
1129
- "innerText",
1130
- "children"
1131
- ]);
1060
+ // ../../node_modules/.pnpm/solid-js@1.8.19/node_modules/solid-js/web/dist/web.js
1061
+ var booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
1062
+ var Properties = /* @__PURE__ */ new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
1063
+ var ChildProperties = /* @__PURE__ */ new Set(["innerHTML", "textContent", "innerText", "children"]);
1132
1064
  var Aliases = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(null), {
1133
1065
  className: "class",
1134
1066
  htmlFor: "for"
@@ -1162,30 +1094,7 @@ function getPropAlias(prop, tagName) {
1162
1094
  const a = PropAliases[prop];
1163
1095
  return typeof a === "object" ? a[tagName] ? a["$"] : void 0 : a;
1164
1096
  }
1165
- var DelegatedEvents = /* @__PURE__ */ new Set([
1166
- "beforeinput",
1167
- "click",
1168
- "dblclick",
1169
- "contextmenu",
1170
- "focusin",
1171
- "focusout",
1172
- "input",
1173
- "keydown",
1174
- "keyup",
1175
- "mousedown",
1176
- "mousemove",
1177
- "mouseout",
1178
- "mouseover",
1179
- "mouseup",
1180
- "pointerdown",
1181
- "pointermove",
1182
- "pointerout",
1183
- "pointerover",
1184
- "pointerup",
1185
- "touchend",
1186
- "touchmove",
1187
- "touchstart"
1188
- ]);
1097
+ var DelegatedEvents = /* @__PURE__ */ new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
1189
1098
  var SVGNamespace = {
1190
1099
  xlink: "http://www.w3.org/1999/xlink",
1191
1100
  xml: "http://www.w3.org/XML/1998/namespace"
@@ -1361,13 +1270,9 @@ function style(node, value, prev) {
1361
1270
  function spread(node, props = {}, isSVG, skipChildren) {
1362
1271
  const prevProps = {};
1363
1272
  if (!skipChildren) {
1364
- createRenderEffect(
1365
- () => prevProps.children = insertExpression(node, props.children, prevProps.children)
1366
- );
1273
+ createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
1367
1274
  }
1368
- createRenderEffect(
1369
- () => typeof props.ref === "function" ? use(props.ref, node) : props.ref = node
1370
- );
1275
+ createRenderEffect(() => typeof props.ref === "function" && use(props.ref, node));
1371
1276
  createRenderEffect(() => assign(node, props, isSVG, true, prevProps, true));
1372
1277
  return prevProps;
1373
1278
  }
@@ -1604,11 +1509,7 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
1604
1509
  if (unwrap) {
1605
1510
  while (typeof item === "function")
1606
1511
  item = item();
1607
- dynamic = normalizeIncomingArray(
1608
- normalized,
1609
- Array.isArray(item) ? item : [item],
1610
- Array.isArray(prev) ? prev : [prev]
1611
- ) || dynamic;
1512
+ dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item], Array.isArray(prev) ? prev : [prev]) || dynamic;
1612
1513
  } else {
1613
1514
  normalized.push(item);
1614
1515
  dynamic = true;
@@ -1655,41 +1556,39 @@ function createElement(tagName, isSVG = false) {
1655
1556
  return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
1656
1557
  }
1657
1558
  function Portal(props) {
1658
- const { useShadow } = props, marker = document.createTextNode(""), mount = () => props.mount || document.body, owner = getOwner();
1559
+ const {
1560
+ useShadow
1561
+ } = props, marker = document.createTextNode(""), mount = () => props.mount || document.body, owner = getOwner();
1659
1562
  let content;
1660
1563
  let hydrating = !!sharedConfig.context;
1661
- createEffect(
1662
- () => {
1663
- if (hydrating)
1664
- getOwner().user = hydrating = false;
1665
- content || (content = runWithOwner(owner, () => createMemo(() => props.children)));
1666
- const el = mount();
1667
- if (el instanceof HTMLHeadElement) {
1668
- const [clean2, setClean] = createSignal(false);
1669
- const cleanup = () => setClean(true);
1670
- createRoot((dispose2) => insert(el, () => !clean2() ? content() : dispose2(), null));
1671
- onCleanup(cleanup);
1672
- } else {
1673
- const container = createElement(props.isSVG ? "g" : "div", props.isSVG), renderRoot = useShadow && container.attachShadow ? container.attachShadow({
1674
- mode: "open"
1675
- }) : container;
1676
- Object.defineProperty(container, "_$host", {
1677
- get() {
1678
- return marker.parentNode;
1679
- },
1680
- configurable: true
1681
- });
1682
- insert(renderRoot, content);
1683
- el.appendChild(container);
1684
- props.ref && props.ref(container);
1685
- onCleanup(() => el.removeChild(container));
1686
- }
1687
- },
1688
- void 0,
1689
- {
1690
- render: !hydrating
1564
+ createEffect(() => {
1565
+ if (hydrating)
1566
+ getOwner().user = hydrating = false;
1567
+ content || (content = runWithOwner(owner, () => createMemo(() => props.children)));
1568
+ const el = mount();
1569
+ if (el instanceof HTMLHeadElement) {
1570
+ const [clean2, setClean] = createSignal(false);
1571
+ const cleanup = () => setClean(true);
1572
+ createRoot((dispose2) => insert(el, () => !clean2() ? content() : dispose2(), null));
1573
+ onCleanup(cleanup);
1574
+ } else {
1575
+ const container = createElement(props.isSVG ? "g" : "div", props.isSVG), renderRoot = useShadow && container.attachShadow ? container.attachShadow({
1576
+ mode: "open"
1577
+ }) : container;
1578
+ Object.defineProperty(container, "_$host", {
1579
+ get() {
1580
+ return marker.parentNode;
1581
+ },
1582
+ configurable: true
1583
+ });
1584
+ insert(renderRoot, content);
1585
+ el.appendChild(container);
1586
+ props.ref && props.ref(container);
1587
+ onCleanup(() => el.removeChild(container));
1691
1588
  }
1692
- );
1589
+ }, void 0, {
1590
+ render: !hydrating
1591
+ });
1693
1592
  return marker;
1694
1593
  }
1695
1594
 
@@ -2176,7 +2075,7 @@ function validateConcurrency(concurrency) {
2176
2075
  }
2177
2076
  }
2178
2077
 
2179
- // ../../node_modules/.pnpm/simple-web-audio@0.6.0_postcss@8.4.32/node_modules/simple-web-audio/dist/index.mjs
2078
+ // ../../node_modules/.pnpm/simple-web-audio@0.7.0_postcss@8.4.32/node_modules/simple-web-audio/dist/index.mjs
2180
2079
  var waitForInteraction = (() => {
2181
2080
  const { promise, resolve } = Promise.withResolvers();
2182
2081
  const onUserInteraction = () => {
@@ -2216,14 +2115,22 @@ addEventListener("blur", function(event) {
2216
2115
  }
2217
2116
  }
2218
2117
  });
2219
- var createQueue = (queue) => {
2118
+ var createQueue = (queue, stopped = false) => {
2220
2119
  const limit = pLimit(1);
2221
2120
  const run = async () => {
2222
2121
  const items = queue.slice();
2223
2122
  for await (const item of items) {
2224
- await item();
2123
+ if (stopped)
2124
+ break;
2125
+ try {
2126
+ await item();
2127
+ } catch (error) {
2128
+ console.error(error);
2129
+ stopped = true;
2130
+ }
2225
2131
  }
2226
2132
  queue = queue.filter((item) => !items.includes(item));
2133
+ stopped = false;
2227
2134
  };
2228
2135
  return {
2229
2136
  get queue() {
@@ -2232,6 +2139,9 @@ var createQueue = (queue) => {
2232
2139
  set queue(value) {
2233
2140
  queue = value;
2234
2141
  },
2142
+ stop() {
2143
+ stopped = true;
2144
+ },
2235
2145
  execute: () => {
2236
2146
  return limit(run);
2237
2147
  }
@@ -2259,14 +2169,17 @@ var createAudio = (options) => {
2259
2169
  let bufferSource;
2260
2170
  let arrayBuffer;
2261
2171
  let audioBuffer;
2172
+ let pendingVolume = options.volume || 1;
2173
+ let pendingLoop = options.loop || false;
2262
2174
  const createAudioContext = () => {
2263
2175
  audioContext = new AudioContext();
2264
2176
  };
2177
+ const getGainNode = () => {
2178
+ return gainNode;
2179
+ };
2265
2180
  const createGainNode = () => {
2266
2181
  gainNode = audioContext.createGain();
2267
- gainNode.gain.value = options.volume || 1;
2268
- const extendAudioGraph = options.extendAudioGraph || (() => gainNode);
2269
- const node = extendAudioGraph({
2182
+ const node = (options.extendAudioGraph || getGainNode)({
2270
2183
  context: audioContext,
2271
2184
  node: gainNode
2272
2185
  });
@@ -2274,31 +2187,51 @@ var createAudio = (options) => {
2274
2187
  };
2275
2188
  const createBufferSource = () => {
2276
2189
  bufferSource = audioContext.createBufferSource();
2277
- bufferSource.loop = options.loop || false;
2278
2190
  };
2279
- const fetchArrayBuffer = fetcherMemo(options.src, () => {
2280
- return fetch(options.src).then((res) => res.arrayBuffer());
2191
+ const interruptQueueThenDestroy = (cause) => {
2192
+ queue.stop();
2193
+ instance.destroy();
2194
+ return new Error("", { cause });
2195
+ };
2196
+ const fetchArrayBuffer = fetcherMemo(options.src, async () => {
2197
+ try {
2198
+ return await fetch(options.src).then((response) => response.arrayBuffer());
2199
+ } catch (error) {
2200
+ throw interruptQueueThenDestroy(error);
2201
+ }
2281
2202
  });
2282
2203
  const setArrayBuffer = async () => {
2283
2204
  arrayBuffer = await fetchArrayBuffer();
2284
2205
  };
2285
- const decodeAudioData = decoderMemo(options.src, () => {
2286
- return audioContext.decodeAudioData(arrayBuffer);
2206
+ const decodeAudioData = decoderMemo(options.src, async () => {
2207
+ try {
2208
+ return await audioContext.decodeAudioData(arrayBuffer);
2209
+ } catch (error) {
2210
+ throw interruptQueueThenDestroy(error);
2211
+ }
2287
2212
  });
2288
2213
  const setAudioData = async () => {
2289
2214
  audioBuffer = await decodeAudioData();
2290
2215
  };
2291
2216
  const connectSources = () => {
2292
- if (bufferSource.buffer === null) {
2217
+ if (bufferSource && bufferSource.buffer === null) {
2293
2218
  bufferSource.buffer = audioBuffer;
2294
2219
  bufferSource.connect(gainNode);
2295
2220
  }
2296
2221
  };
2222
+ const setVolume = () => {
2223
+ gainNode.gain.value = pendingVolume;
2224
+ };
2225
+ const setLoop = () => {
2226
+ bufferSource.loop = pendingLoop;
2227
+ };
2297
2228
  const queue = createQueue([
2298
2229
  waitForInteraction,
2299
2230
  createAudioContext,
2300
2231
  createGainNode,
2232
+ setVolume,
2301
2233
  createBufferSource,
2234
+ setLoop,
2302
2235
  fetchArrayBuffer,
2303
2236
  setArrayBuffer,
2304
2237
  decodeAudioData,
@@ -2308,14 +2241,14 @@ var createAudio = (options) => {
2308
2241
  let resume = false;
2309
2242
  const unregister = registerEventListeners({
2310
2243
  focus: () => {
2311
- if (!options.pauseOnBlur || !resume)
2244
+ if (!options.pauseOnBlur || !resume || state.destroyed)
2312
2245
  return;
2313
2246
  resume = false;
2314
2247
  queue.queue.push(playAudio);
2315
2248
  queue.execute();
2316
2249
  },
2317
2250
  blur: () => {
2318
- if (!options.pauseOnBlur || !state.playing)
2251
+ if (!options.pauseOnBlur || !state.playing || state.destroyed)
2319
2252
  return;
2320
2253
  resume = true;
2321
2254
  queue.queue.push(pauseAudio);
@@ -2328,6 +2261,8 @@ var createAudio = (options) => {
2328
2261
  destroyed: false
2329
2262
  };
2330
2263
  const playAudio = async () => {
2264
+ if (state.destroyed)
2265
+ return;
2331
2266
  if (audioContext.state === "suspended") {
2332
2267
  await audioContext.resume();
2333
2268
  if (state.started) {
@@ -2341,6 +2276,8 @@ var createAudio = (options) => {
2341
2276
  }
2342
2277
  };
2343
2278
  const pauseAudio = async () => {
2279
+ if (state.destroyed)
2280
+ return;
2344
2281
  if (audioContext.state === "suspended" && queue.queue.at(-1) === playAudio) {
2345
2282
  queue.queue.pop();
2346
2283
  }
@@ -2350,35 +2287,22 @@ var createAudio = (options) => {
2350
2287
  }
2351
2288
  };
2352
2289
  const disconnectAudio = async () => {
2353
- bufferSource.disconnect();
2290
+ bufferSource && bufferSource.disconnect();
2354
2291
  state.started = false;
2355
2292
  };
2356
- if (options.autoplay) {
2357
- queue.queue.push(playAudio);
2358
- queue.execute();
2359
- }
2360
- return {
2361
- /**
2362
- * Play
2363
- */
2293
+ const instance = {
2364
2294
  async play() {
2365
2295
  if (state.destroyed)
2366
2296
  return;
2367
2297
  queue.queue.push(playAudio);
2368
2298
  return queue.execute();
2369
2299
  },
2370
- /**
2371
- * Pause
2372
- */
2373
2300
  async pause() {
2374
2301
  if (state.destroyed)
2375
2302
  return;
2376
2303
  queue.queue.push(pauseAudio);
2377
2304
  return queue.execute();
2378
2305
  },
2379
- /**
2380
- * Reset
2381
- */
2382
2306
  async reset() {
2383
2307
  if (state.destroyed)
2384
2308
  return;
@@ -2388,6 +2312,7 @@ var createAudio = (options) => {
2388
2312
  queue.queue.push(
2389
2313
  disconnectAudio,
2390
2314
  createBufferSource,
2315
+ setLoop,
2391
2316
  connectSources
2392
2317
  );
2393
2318
  if (state.playing) {
@@ -2395,9 +2320,6 @@ var createAudio = (options) => {
2395
2320
  }
2396
2321
  return queue.execute();
2397
2322
  },
2398
- /**
2399
- * Stop
2400
- */
2401
2323
  async stop() {
2402
2324
  if (state.destroyed)
2403
2325
  return;
@@ -2405,21 +2327,19 @@ var createAudio = (options) => {
2405
2327
  pauseAudio,
2406
2328
  disconnectAudio,
2407
2329
  createBufferSource,
2330
+ setLoop,
2408
2331
  connectSources
2409
2332
  );
2410
2333
  return queue.execute();
2411
2334
  },
2412
- /**
2413
- * Destroy
2414
- */
2415
2335
  async destroy() {
2416
2336
  if (state.destroyed)
2417
2337
  return;
2418
2338
  unregister();
2419
- queue.queue.push(
2339
+ queue.queue = [
2420
2340
  pauseAudio,
2421
2341
  disconnectAudio
2422
- );
2342
+ ];
2423
2343
  await queue.execute();
2424
2344
  state.destroyed = true;
2425
2345
  audioContext = null;
@@ -2433,25 +2353,38 @@ var createAudio = (options) => {
2433
2353
  return;
2434
2354
  await fetchArrayBuffer();
2435
2355
  },
2436
- /**
2437
- * Is currently playing
2438
- */
2439
2356
  get playing() {
2440
2357
  return state.playing;
2441
2358
  },
2359
+ get destroyed() {
2360
+ return state.destroyed;
2361
+ },
2442
2362
  get volume() {
2443
- return gainNode.gain.value;
2363
+ return pendingVolume;
2444
2364
  },
2445
2365
  set volume(value) {
2446
- gainNode.gain.value = value;
2366
+ if (state.destroyed)
2367
+ return;
2368
+ pendingVolume = value;
2369
+ queue.queue.push(setVolume);
2370
+ queue.execute();
2447
2371
  },
2448
2372
  get loop() {
2449
- return bufferSource.loop;
2373
+ return pendingLoop;
2450
2374
  },
2451
2375
  set loop(value) {
2452
- bufferSource.loop = value;
2376
+ if (state.destroyed)
2377
+ return;
2378
+ pendingLoop = value;
2379
+ queue.queue.push(setLoop);
2380
+ queue.execute();
2453
2381
  }
2454
2382
  };
2383
+ if (options.autoplay) {
2384
+ queue.queue.push(playAudio);
2385
+ queue.execute();
2386
+ }
2387
+ return instance;
2455
2388
  };
2456
2389
  var prefetchAudio = (src) => {
2457
2390
  const fetcher = fetcherMemo(src, () => fetch(src).then((res) => res.arrayBuffer()));
@@ -3647,7 +3580,7 @@ var Modal = (props) => {
3647
3580
  });
3648
3581
  };
3649
3582
 
3650
- // ../../node_modules/.pnpm/@solid-primitives+transition-group@1.0.5_solid-js@1.8.18/node_modules/@solid-primitives/transition-group/dist/index.js
3583
+ // ../../node_modules/.pnpm/@solid-primitives+transition-group@1.0.5_solid-js@1.8.19/node_modules/@solid-primitives/transition-group/dist/index.js
3651
3584
  var noop2 = () => {
3652
3585
  };
3653
3586
  var noopTransition = (el, done) => done();
@@ -3715,10 +3648,10 @@ function createSwitchTransition(source, options) {
3715
3648
  return returned;
3716
3649
  }
3717
3650
 
3718
- // ../../node_modules/.pnpm/@solid-primitives+utils@6.2.3_solid-js@1.8.18/node_modules/@solid-primitives/utils/dist/chunk/R5675YMU.js
3651
+ // ../../node_modules/.pnpm/@solid-primitives+utils@6.2.3_solid-js@1.8.19/node_modules/@solid-primitives/utils/dist/chunk/R5675YMU.js
3719
3652
  var access = (v) => typeof v === "function" && !v.length ? v() : v;
3720
3653
 
3721
- // ../../node_modules/.pnpm/@solid-primitives+refs@1.0.8_solid-js@1.8.18/node_modules/@solid-primitives/refs/dist/index.js
3654
+ // ../../node_modules/.pnpm/@solid-primitives+refs@1.0.8_solid-js@1.8.19/node_modules/@solid-primitives/refs/dist/index.js
3722
3655
  var defaultElementPredicate = isServer ? (item) => item != null && typeof item === "object" && "t" in item : (item) => item instanceof Element;
3723
3656
  function getFirstChild(value, predicate) {
3724
3657
  if (predicate(value))
@@ -3739,7 +3672,7 @@ function resolveFirst(fn, predicate = defaultElementPredicate, serverPredicate =
3739
3672
  return createMemo(() => getFirstChild(children2(), isServer ? serverPredicate : predicate));
3740
3673
  }
3741
3674
 
3742
- // ../../node_modules/.pnpm/solid-transition-group@0.2.3_solid-js@1.8.18/node_modules/solid-transition-group/dist/index.js
3675
+ // ../../node_modules/.pnpm/solid-transition-group@0.2.3_solid-js@1.8.19/node_modules/solid-transition-group/dist/index.js
3743
3676
  function createClassnames(props) {
3744
3677
  return createMemo(() => {
3745
3678
  const name = props.name || "s";
@@ -4342,7 +4275,7 @@ var Range = (props) => {
4342
4275
  })();
4343
4276
  };
4344
4277
 
4345
- // ../../node_modules/.pnpm/@solid-primitives+destructure@0.1.17_solid-js@1.8.18/node_modules/@solid-primitives/destructure/dist/index.js
4278
+ // ../../node_modules/.pnpm/@solid-primitives+destructure@0.1.17_solid-js@1.8.19/node_modules/@solid-primitives/destructure/dist/index.js
4346
4279
  var isReactiveObject = (value) => typeof value === "object" && value !== null;
4347
4280
  function createProxyCache(obj, get) {
4348
4281
  return new Proxy(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.36.0-experemental",
3
+ "version": "0.36.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,10 +17,10 @@
17
17
  "dependencies": {
18
18
  "@solid-primitives/destructure": "^0.1.17",
19
19
  "retrieved": "^0.1.0",
20
- "solid-js": "1.8.18",
20
+ "solid-js": "1.8.19",
21
21
  "solid-transition-group": "^0.2.3",
22
22
  "@novely/core": "0.38.2",
23
- "@novely/renderer-toolkit": "0.8.0-experemental",
23
+ "@novely/renderer-toolkit": "0.8.0",
24
24
  "@novely/typewriter": "0.5.1"
25
25
  },
26
26
  "peerDependencies": {