@novely/core 0.30.3 → 0.31.1

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/dist/index.js CHANGED
@@ -298,7 +298,9 @@ var createQueueProcessor = (queue, options) => {
298
298
  const next = (i) => queue.slice(i + 1);
299
299
  for (const [i, item] of queue.entries()) {
300
300
  const [action, ...params] = item;
301
- keep.add(action);
301
+ if (isUserRequiredAction(item) && !queue.slice(0, i + 1).some((action2) => isUserRequiredAction(action2))) {
302
+ keep.add(action);
303
+ }
302
304
  if (options.skip.has(item) && item !== options.skipPreserve) {
303
305
  continue;
304
306
  }
@@ -506,7 +508,7 @@ var store = (current, subscribers = /* @__PURE__ */ new Set()) => {
506
508
  return { subscribe, update, set, get };
507
509
  };
508
510
 
509
- // ../../node_modules/.pnpm/@novely+deepmerge@0.0.0/node_modules/@novely/deepmerge/dist/index.js
511
+ // ../deepmerge/dist/index.js
510
512
  var { isArray } = Array;
511
513
  var { hasOwnProperty, propertyIsEnumerable, getOwnPropertySymbols } = Object;
512
514
  var propertyIsOnObject = (object, property) => {
@@ -517,7 +519,9 @@ var propertyIsOnObject = (object, property) => {
517
519
  }
518
520
  };
519
521
  var propertyIsUnsafe = (target, key) => {
520
- return propertyIsOnObject(target, key) && !(hasOwnProperty.call(target, key) && propertyIsEnumerable.call(target, key));
522
+ return propertyIsOnObject(target, key) && // Properties are safe to merge if they don't exist in the target yet,
523
+ !(hasOwnProperty.call(target, key) && // unsafe if they exist up the prototype chain,
524
+ propertyIsEnumerable.call(target, key));
521
525
  };
522
526
  var getEnumerableOwnPropertySymbols = (target) => {
523
527
  if (!getOwnPropertySymbols)
@@ -770,6 +774,9 @@ var novely = ({
770
774
  };
771
775
  const action = new Proxy({}, {
772
776
  get(_, action2) {
777
+ if (action2 in renderer.actions) {
778
+ return renderer.actions[action2];
779
+ }
773
780
  return (...props) => {
774
781
  if (preloadAssets === "blocking") {
775
782
  if (action2 === "showBackground") {
@@ -952,11 +959,10 @@ var novely = ({
952
959
  const [path] = stack.value = latest;
953
960
  renderer.ui.showScreen("game");
954
961
  const { queue, skip, skipPreserve } = getActionsFromPath(story, path, false);
955
- const processor = createQueueProcessor(queue, {
962
+ const { run, keep: { keep, characters: characters2, audio } } = createQueueProcessor(queue, {
956
963
  skip,
957
964
  skipPreserve
958
965
  });
959
- const { keep, characters: characters2, audio } = processor.keep;
960
966
  if (previous) {
961
967
  const { queue: prevQueue } = getActionsFromPath(story, previous[0], false);
962
968
  for (let i = prevQueue.length - 1; i > queue.length - 1; i--) {
@@ -976,7 +982,7 @@ var novely = ({
976
982
  });
977
983
  const lastQueueItem = queue.at(-1) || [];
978
984
  const lastQueueItemRequiresUserAction = isSkippedDuringRestore(lastQueueItem[0]) || isUserRequiredAction(lastQueueItem);
979
- await processor.run((item) => {
985
+ await run((item) => {
980
986
  if (!latest)
981
987
  return;
982
988
  if (lastQueueItem === item && lastQueueItemRequiresUserAction) {
@@ -1519,6 +1525,12 @@ var novely = ({
1519
1525
  });
1520
1526
  return void 0;
1521
1527
  };
1528
+ const typeEssentials = {
1529
+ l: null,
1530
+ s: null,
1531
+ d: null,
1532
+ c: null
1533
+ };
1522
1534
  return {
1523
1535
  /**
1524
1536
  * Function to set game script
@@ -1568,11 +1580,18 @@ var novely = ({
1568
1580
  */
1569
1581
  data,
1570
1582
  /**
1571
- * @deprecated Renamed into `templateReplace`
1583
+ * Used in combination with type utilities
1584
+ *
1585
+ * @example
1586
+ * ```ts
1587
+ * import type { ConditionParams, StateFunction } from '@novely/core';
1588
+ *
1589
+ * const conditionCheck = (state: StateFunction<ConditionParams<typeof engine.typeEssintials>>) => {
1590
+ * return state.age >= 18;
1591
+ * }
1592
+ * ```
1572
1593
  */
1573
- unwrap(content) {
1574
- return templateReplace(content);
1575
- },
1594
+ typeEssentials,
1576
1595
  /**
1577
1596
  * Replaces content inside {{braces}} with using global data
1578
1597
  * @example