@novely/core 0.25.0 → 0.26.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/dist/index.js CHANGED
@@ -790,7 +790,7 @@ var novely = ({
790
790
  data: klona(defaultData),
791
791
  meta: [getLanguageWithoutParameters(), DEFAULT_TYPEWRITER_SPEED, 1, 1, 1]
792
792
  };
793
- const $ = store(initialData);
793
+ const storageData = store(initialData);
794
794
  const coreData = store({
795
795
  dataLoaded: false
796
796
  });
@@ -812,10 +812,10 @@ var novely = ({
812
812
  const throttledOnStorageDataChange = throttle(onStorageDataChange, throttleTimeout);
813
813
  const throttledEmergencyOnStorageDataChange = throttle(() => {
814
814
  if (saveOnUnload === true || saveOnUnload === "prod" && !DEV2) {
815
- onStorageDataChange($.get());
815
+ onStorageDataChange(storageData.get());
816
816
  }
817
817
  }, 10);
818
- $.subscribe(throttledOnStorageDataChange);
818
+ storageData.subscribe(throttledOnStorageDataChange);
819
819
  const getStoredData = async () => {
820
820
  let stored = await storage.get();
821
821
  for (const migration of migrations) {
@@ -832,7 +832,7 @@ var novely = ({
832
832
  stored.data = defaultData;
833
833
  }
834
834
  dataLoaded.resolve();
835
- $.set(stored);
835
+ storageData.set(stored);
836
836
  };
837
837
  storageDelay.then(getStoredData);
838
838
  const initial = getDefaultSave(klona(defaultState));
@@ -850,7 +850,7 @@ var novely = ({
850
850
  return;
851
851
  const stack = useStack(MAIN_CONTEXT_KEY);
852
852
  const current = klona(stack.value);
853
- $.update((prev) => {
853
+ storageData.update((prev) => {
854
854
  const isLatest = findLastIndex(prev.saves, (value) => times.has(value[2][0])) === prev.saves.length - 1;
855
855
  current[2][0] = intime(Date.now());
856
856
  current[2][1] = type;
@@ -872,7 +872,7 @@ var novely = ({
872
872
  return;
873
873
  const save2 = getDefaultSave(klona(defaultState));
874
874
  if (autosaves) {
875
- $.update((prev) => {
875
+ storageData.update((prev) => {
876
876
  return prev.saves.push(save2), prev;
877
877
  });
878
878
  }
@@ -887,10 +887,10 @@ var novely = ({
887
887
  const restore = async (save2) => {
888
888
  if (!coreData.get().dataLoaded)
889
889
  return;
890
- let latest = save2 || $.get().saves.at(-1);
890
+ let latest = save2 || storageData.get().saves.at(-1);
891
891
  if (!latest) {
892
892
  latest = klona(initial);
893
- $.update((prev) => {
893
+ storageData.update((prev) => {
894
894
  prev.saves.push(latest);
895
895
  return prev;
896
896
  });
@@ -974,7 +974,7 @@ var novely = ({
974
974
  ctx.audio.destroy();
975
975
  const [time, type] = current[2];
976
976
  if (type === "auto" && interacted <= 1 && times.has(time)) {
977
- $.update((prev) => {
977
+ storageData.update((prev) => {
978
978
  prev.saves = prev.saves.filter((save2) => save2 !== current);
979
979
  return prev;
980
980
  });
@@ -1045,8 +1045,8 @@ var novely = ({
1045
1045
  removeContext,
1046
1046
  getStateFunction,
1047
1047
  languages,
1048
- $,
1049
- $$: coreData
1048
+ storageData,
1049
+ coreData
1050
1050
  });
1051
1051
  const useStack = createUseStackFunction(renderer);
1052
1052
  useStack(MAIN_CONTEXT_KEY).push(initial);
@@ -1140,7 +1140,7 @@ var novely = ({
1140
1140
  const name = (() => {
1141
1141
  const c = character;
1142
1142
  const cs = characters;
1143
- const [lang] = $.get().meta;
1143
+ const [lang] = storageData.get().meta;
1144
1144
  if (c && c in cs) {
1145
1145
  const block = cs[c].name;
1146
1146
  if (typeof block === "string") {
@@ -1172,7 +1172,7 @@ var novely = ({
1172
1172
  function({ ctx, push }, [fn]) {
1173
1173
  const { restoring, goingBack, preview: preview2 } = ctx.meta;
1174
1174
  const result = fn({
1175
- lang: $.get().meta[0],
1175
+ lang: storageData.get().meta[0],
1176
1176
  goingBack,
1177
1177
  restoring,
1178
1178
  preview: preview2,
@@ -1191,13 +1191,13 @@ var novely = ({
1191
1191
  }
1192
1192
  const transformedChoices = choices.map(([content, action2, visible]) => {
1193
1193
  const shown = !visible || visible({
1194
- lang: $.get().meta[0],
1194
+ lang: storageData.get().meta[0],
1195
1195
  state: getStateAtCtx(ctx)
1196
1196
  });
1197
1197
  if (DEV2 && action2.length === 0 && !shown) {
1198
1198
  console.warn(`Choice children should not be empty, either add content there or make item not selectable`);
1199
1199
  }
1200
- return [templateReplace(content, data2), action2, shown];
1200
+ return [templateReplace(content, data2), shown];
1201
1201
  });
1202
1202
  if (DEV2 && transformedChoices.length === 0) {
1203
1203
  throw new Error(`Running choice without variants to choose from, look at how to use Choice action properly [https://novely.pages.dev/guide/actions/choice#usage]`);
@@ -1404,7 +1404,7 @@ var novely = ({
1404
1404
  const {
1405
1405
  data: data2,
1406
1406
  meta: [lang]
1407
- } = $.get();
1407
+ } = storageData.get();
1408
1408
  const obj = values || data2;
1409
1409
  const cnt = isFunction(content) ? content(obj) : typeof content === "string" ? content : content[lang];
1410
1410
  const str2 = flattenAllowedContent(
@@ -1422,11 +1422,11 @@ var novely = ({
1422
1422
  );
1423
1423
  };
1424
1424
  const data = (value) => {
1425
- const _data = $.get().data;
1425
+ const _data = storageData.get().data;
1426
1426
  if (!value)
1427
1427
  return _data;
1428
1428
  const val = isFunction(value) ? value(_data) : deepmerge(_data, value);
1429
- $.update((prev) => {
1429
+ storageData.update((prev) => {
1430
1430
  prev.data = val;
1431
1431
  return prev;
1432
1432
  });