@novely/solid-renderer 0.44.0 → 0.44.2

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.
@@ -11,7 +11,6 @@ type ShowImageData = {
11
11
  key: string;
12
12
  image: HTMLImageElement;
13
13
  visible: boolean;
14
- animate: boolean;
15
14
  onIn: () => void;
16
15
  onOut: () => void;
17
16
  };
package/dist/index.jsx CHANGED
@@ -3588,7 +3588,7 @@ var Save = (props) => {
3588
3588
  contentDocument
3589
3589
  } = iframe();
3590
3590
  if (!contentDocument) return;
3591
- contentDocument.head.insertAdjacentHTML("beforeend", `<style>:root { font-size: 30%; background: black; cursor: pointer; } * { pointer-events: none; } *, *::before, *::after { animation-play-state: paused !important; }</style>`);
3591
+ contentDocument.head.insertAdjacentHTML("beforeend", `<style>:root { font-size: 30%; background: black; cursor: pointer; } * { pointer-events: none; } *, *::before, *::after { animation-play-state: paused !important; animation-fill-mode: forwards !important; animation-direction: reverse !important; }</style>`);
3592
3592
  const styleClone = contentDocument.importNode(style2(), true);
3593
3593
  contentDocument.head.appendChild(styleClone);
3594
3594
  context.root = contentDocument.body;
@@ -4612,7 +4612,7 @@ var Game = (props) => {
4612
4612
  done();
4613
4613
  image().onIn();
4614
4614
  };
4615
- if (!image().animate || !classesIn || classesIn.length === 0) {
4615
+ if (!classesIn || classesIn.length === 0) {
4616
4616
  return onCompleted();
4617
4617
  }
4618
4618
  el.classList.add(...classesIn);
@@ -4626,7 +4626,7 @@ var Game = (props) => {
4626
4626
  done();
4627
4627
  image().onOut();
4628
4628
  };
4629
- if (!image().animate || !classesOut || classesOut.length === 0) {
4629
+ if (!classesOut || classesOut.length === 0) {
4630
4630
  return onCompleted();
4631
4631
  }
4632
4632
  el.classList.add(...classesOut);
@@ -5171,11 +5171,6 @@ var showImage = (asset, { classesBase, classesIn, wait } = {}) => {
5171
5171
  const classesInSplitted = classesIn?.split(" ") || [];
5172
5172
  image.classList.add(...classesBaseSplitted);
5173
5173
  image.classList.add("action-image__image");
5174
- if (wait) {
5175
- rendererContext.clearBlockingActions(void 0);
5176
- } else {
5177
- resolve();
5178
- }
5179
5174
  const onIn = () => {
5180
5175
  if (wait) {
5181
5176
  resolve();
@@ -5188,11 +5183,15 @@ var showImage = (asset, { classesBase, classesIn, wait } = {}) => {
5188
5183
  key,
5189
5184
  image,
5190
5185
  visible: false,
5191
- animate: !flags.preview,
5192
5186
  onIn,
5193
5187
  onOut: noop
5194
5188
  });
5195
5189
  setTimeout(() => ctx.mutate((s) => s.images[index].visible, true));
5190
+ if (wait && !flags.preview && !flags.restoring) {
5191
+ rendererContext.clearBlockingActions(void 0);
5192
+ } else {
5193
+ resolve();
5194
+ }
5196
5195
  clear(() => {
5197
5196
  ctx.mutate((s) => s.images[index], {
5198
5197
  classesIn: void 0,
@@ -5200,7 +5199,6 @@ var showImage = (asset, { classesBase, classesIn, wait } = {}) => {
5200
5199
  key,
5201
5200
  image,
5202
5201
  visible: false,
5203
- animate: !flags.preview,
5204
5202
  onIn: noop,
5205
5203
  onOut: noop
5206
5204
  });
@@ -5211,24 +5209,26 @@ var showImage = (asset, { classesBase, classesIn, wait } = {}) => {
5211
5209
  handler.id = SHOW_HIDE_IMAGE;
5212
5210
  handler.key = key;
5213
5211
  handler.assets = [asset];
5214
- handler.callOnlyLatest = true;
5212
+ handler.skipOnRestore = (getNext) => {
5213
+ return getNext().some(
5214
+ (action) => action[0] === "custom" && action[1].id === SHOW_HIDE_IMAGE && action[1].key === key
5215
+ );
5216
+ };
5215
5217
  return ["custom", handler];
5216
5218
  };
5217
5219
  var hideImage = (asset, { classesOut, wait } = {}) => {
5218
5220
  const key = `show-image--${asset.id}`;
5219
- const handler = ({ contextKey, flags, rendererContext }) => {
5220
- const { promise, resolve } = Promise.withResolvers();
5221
+ const handler = ({ contextKey, rendererContext }) => {
5221
5222
  const ctx = useContextState(contextKey);
5222
5223
  const index = getIndex(ctx, key);
5223
- const { image, classesBase } = ctx.get().images[index];
5224
+ const context = ctx.get().images[index];
5225
+ if (!context) {
5226
+ return;
5227
+ }
5228
+ const { promise, resolve } = Promise.withResolvers();
5229
+ const { image, classesBase } = context;
5224
5230
  const classesBaseSplitted = classesBase || [];
5225
5231
  const classesOutSplitted = classesOut?.split(" ") || [];
5226
- if (wait) {
5227
- rendererContext.clearBlockingActions(void 0);
5228
- } else {
5229
- image.classList.remove(...classesBaseSplitted);
5230
- resolve();
5231
- }
5232
5232
  const onOut = () => {
5233
5233
  if (wait) {
5234
5234
  image.classList.remove(...classesBaseSplitted);
@@ -5236,12 +5236,22 @@ var hideImage = (asset, { classesOut, wait } = {}) => {
5236
5236
  }
5237
5237
  };
5238
5238
  ctx.mutate(
5239
- (s) => s.images[index].onOut,
5240
- () => onOut
5239
+ (s) => s.images[index],
5240
+ (prev) => {
5241
+ return {
5242
+ ...prev,
5243
+ onOut,
5244
+ classesOut: classesOutSplitted
5245
+ };
5246
+ }
5241
5247
  );
5242
- ctx.mutate((s) => s.images[index].animate, !flags.preview);
5243
- ctx.mutate((s) => s.images[index].classesOut, classesOutSplitted);
5244
5248
  setTimeout(() => ctx.mutate((s) => s.images[index].visible, false));
5249
+ if (wait) {
5250
+ rendererContext.clearBlockingActions(void 0);
5251
+ } else {
5252
+ image.classList.remove(...classesBaseSplitted);
5253
+ resolve();
5254
+ }
5245
5255
  return promise;
5246
5256
  };
5247
5257
  handler.id = SHOW_HIDE_IMAGE;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.44.0",
3
+ "version": "0.44.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"