@novely/solid-renderer 0.33.0 → 0.34.1-beta.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.
@@ -0,0 +1,8 @@
1
+ import type { JSX, VoidComponent } from 'solid-js';
2
+ type NativeCanvasProps = JSX.CanvasHTMLAttributes<HTMLCanvasElement>;
3
+ type CanvasProps = Omit<NativeCanvasProps, 'ref'> & {
4
+ resize?: boolean;
5
+ render: (canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D) => void;
6
+ };
7
+ declare const Canvas: VoidComponent<CanvasProps>;
8
+ export { Canvas };
@@ -6,3 +6,4 @@ export { Modal } from './Modal';
6
6
  export { Save } from './Save';
7
7
  export { createTypewriter } from './Typewriter';
8
8
  export { createRootComponent } from './Root';
9
+ export { Canvas } from './Canvas';
package/dist/index.jsx CHANGED
@@ -3179,6 +3179,63 @@ function mergeProps(...sources) {
3179
3179
  }
3180
3180
  return target;
3181
3181
  }
3182
+ function splitProps(props, ...keys2) {
3183
+ if ($PROXY in props) {
3184
+ const blocked = new Set(keys2.length > 1 ? keys2.flat() : keys2[0]);
3185
+ const res = keys2.map((k) => {
3186
+ return new Proxy(
3187
+ {
3188
+ get(property) {
3189
+ return k.includes(property) ? props[property] : void 0;
3190
+ },
3191
+ has(property) {
3192
+ return k.includes(property) && property in props;
3193
+ },
3194
+ keys() {
3195
+ return k.filter((property) => property in props);
3196
+ }
3197
+ },
3198
+ propTraps
3199
+ );
3200
+ });
3201
+ res.push(
3202
+ new Proxy(
3203
+ {
3204
+ get(property) {
3205
+ return blocked.has(property) ? void 0 : props[property];
3206
+ },
3207
+ has(property) {
3208
+ return blocked.has(property) ? false : property in props;
3209
+ },
3210
+ keys() {
3211
+ return Object.keys(props).filter((k) => !blocked.has(k));
3212
+ }
3213
+ },
3214
+ propTraps
3215
+ )
3216
+ );
3217
+ return res;
3218
+ }
3219
+ const otherObject = {};
3220
+ const objects = keys2.map(() => ({}));
3221
+ for (const propName of Object.getOwnPropertyNames(props)) {
3222
+ const desc = Object.getOwnPropertyDescriptor(props, propName);
3223
+ const isDefaultDesc = !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
3224
+ let blocked = false;
3225
+ let objectIndex = 0;
3226
+ for (const k of keys2) {
3227
+ if (k.includes(propName)) {
3228
+ blocked = true;
3229
+ isDefaultDesc ? objects[objectIndex][propName] = desc.value : Object.defineProperty(objects[objectIndex], propName, desc);
3230
+ }
3231
+ ++objectIndex;
3232
+ }
3233
+ if (!blocked) {
3234
+ isDefaultDesc ? otherObject[propName] = desc.value : Object.defineProperty(otherObject, propName, desc);
3235
+ }
3236
+ }
3237
+ return [...objects, otherObject];
3238
+ }
3182
3239
  var counter = 0;
3183
3240
  function createUniqueId() {
3184
3241
  const ctx = sharedConfig.context;
@@ -4989,6 +5046,22 @@ var createImage = (src) => {
4989
5046
  });
4990
5047
  return img;
4991
5048
  };
5049
+ var imageLoaded = (image) => {
5050
+ const { promise, resolve } = Promise.withResolvers();
5051
+ if (image.complete && image.naturalHeight !== 0) {
5052
+ return resolve(true);
5053
+ }
5054
+ image.addEventListener("load", () => {
5055
+ resolve(true);
5056
+ });
5057
+ image.addEventListener("abort", () => {
5058
+ resolve(false);
5059
+ });
5060
+ image.addEventListener("error", () => {
5061
+ resolve(false);
5062
+ });
5063
+ return promise;
5064
+ };
4992
5065
  var createCanvas = () => {
4993
5066
  return document.createElement("canvas");
4994
5067
  };
@@ -5650,32 +5723,19 @@ var Save = (props) => {
5650
5723
  context.root = contentDocument.body;
5651
5724
  setIframeLoaded(true);
5652
5725
  };
5653
- createEffect(() => {
5654
- if (props.observed && iframeLoaded() && !previewStarted()) {
5655
- setPreviewStarted(true);
5656
- options.preview(props.save, KEY).then(() => {
5657
- const background = useContextState(KEY).get().background.background;
5658
- if (!background || !isCSSImage(background)) {
5659
- return previewDone();
5660
- }
5661
- if (PRELOADED_IMAGE_MAP.has(background)) {
5662
- return previewDone();
5663
- }
5664
- const backgroundElement = context.root.querySelector("img.background");
5665
- if (!backgroundElement) {
5666
- return previewDone();
5667
- }
5668
- if (backgroundElement.complete && backgroundElement.naturalHeight !== 0) {
5669
- return previewDone();
5670
- }
5671
- const onLoadingStatusChange = () => {
5672
- backgroundElement.removeEventListener("load", onLoadingStatusChange);
5673
- backgroundElement.removeEventListener("error", onLoadingStatusChange);
5674
- previewDone();
5675
- };
5676
- backgroundElement.addEventListener("load", onLoadingStatusChange);
5677
- backgroundElement.addEventListener("error", onLoadingStatusChange);
5678
- });
5726
+ createEffect(async () => {
5727
+ const ready = props.observed && iframeLoaded() && !previewStarted();
5728
+ if (!ready)
5729
+ return;
5730
+ setPreviewStarted(true);
5731
+ setTimeout(() => {
5732
+ previewDone();
5733
+ }, 1e3);
5734
+ try {
5735
+ await options.preview(props.save, KEY);
5736
+ return previewDone();
5737
+ } catch {
5738
+ return previewDone();
5679
5739
  }
5680
5740
  });
5681
5741
  onCleanup(() => {
@@ -5987,6 +6047,53 @@ var createTypewriter = ({
5987
6047
  };
5988
6048
  };
5989
6049
 
6050
+ // src/components/Canvas.tsx
6051
+ var _tmpl$19 = /* @__PURE__ */ template(`<canvas>`);
6052
+ var Canvas = (props) => {
6053
+ const [local, rest] = splitProps(props, ["resize", "render"]);
6054
+ const [canvas, setCanvas] = createSignal();
6055
+ const ctx = createMemo(() => canvas()?.getContext("2d"));
6056
+ createEffect(() => {
6057
+ const canvasElement = canvas();
6058
+ const canvasContext = ctx();
6059
+ if (canvasElement && canvasContext) {
6060
+ try {
6061
+ local.render(canvasElement, canvasContext);
6062
+ } catch {
6063
+ }
6064
+ }
6065
+ });
6066
+ const onResize = () => {
6067
+ if (!local.resize)
6068
+ return;
6069
+ const canvasElement = untrack(canvas);
6070
+ const canvasContext = untrack(ctx);
6071
+ if (canvasElement) {
6072
+ canvasElement.width = window.innerWidth * devicePixelRatio;
6073
+ canvasElement.height = window.innerHeight * devicePixelRatio;
6074
+ if (canvasContext) {
6075
+ untrack(() => {
6076
+ try {
6077
+ local.render(canvasElement, canvasContext);
6078
+ } catch {
6079
+ }
6080
+ });
6081
+ }
6082
+ }
6083
+ };
6084
+ onMount(onResize);
6085
+ addEventListener("resize", onResize);
6086
+ onCleanup(() => {
6087
+ removeEventListener("resize", onResize);
6088
+ });
6089
+ return (() => {
6090
+ const _el$ = _tmpl$19();
6091
+ use(setCanvas, _el$);
6092
+ spread(_el$, rest, false, false);
6093
+ return _el$;
6094
+ })();
6095
+ };
6096
+
5990
6097
  // ../../node_modules/.pnpm/@solid-primitives+destructure@0.1.17_solid-js@1.8.17/node_modules/@solid-primitives/destructure/dist/index.js
5991
6098
  var isReactiveObject = (value) => typeof value === "object" && value !== null;
5992
6099
  function createProxyCache(obj, get) {
@@ -6033,7 +6140,7 @@ function destructure(source, options) {
6033
6140
  }
6034
6141
 
6035
6142
  // src/screens/game.tsx
6036
- var _tmpl$19 = /* @__PURE__ */ template(`<div class="action-dialog-person">`);
6143
+ var _tmpl$20 = /* @__PURE__ */ template(`<div class="action-dialog-person">`);
6037
6144
  var _tmpl$25 = /* @__PURE__ */ template(`<div class="dialog-container"><span class="dialog-fix" aria-hidden="true">&#8203;</span><div class="dialog-panel"><span class="dialog-panel-label">`);
6038
6145
  var _tmpl$34 = /* @__PURE__ */ template(`<div class="dialog-container"><span class="dialog-fix" aria-hidden="true">&#8203;</span><div class="dialog-panel input-dialog-panel"><label for="novely-input" class="input-dialog-label"><span class="input-dialog-label-text"></span></label><span class="input-dialog-label-text input-dialog-label__error" aria-live="polite" aria-atomic="true"></span><button type="submit" class="button dialog-input__button">`);
6039
6146
  var _tmpl$44 = /* @__PURE__ */ template(`<div class="dialog-container"><span class="dialog-fix" aria-hidden="true">&#8203;</span><div class="dialog-backdrop"></div><div class="dialog-panel exit-dialog-panel"><span class="dialog-panel-label"></span><div class="exit-dialog-panel-buttons"><button type="button" class="button"></button><button type="button" class="button">`);
@@ -6042,8 +6149,7 @@ var _tmpl$62 = /* @__PURE__ */ template(`<span class="control-panel-container-fi
6042
6149
  var _tmpl$72 = /* @__PURE__ */ template(`<div class="control-panel-container-backdrop">`);
6043
6150
  var _tmpl$82 = /* @__PURE__ */ template(`<div class="control-panel"><div role="menubar" class="control-panel-container">`);
6044
6151
  var _tmpl$92 = /* @__PURE__ */ template(`<div><div class="characters"></div><div class="action-dialog"><div class="action-dialog-container" role="button" tabindex="0"><div class="action-dialog-content"></div></div></div><div></div><div class="action-text" role="button" tabindex="0">`);
6045
- var _tmpl$102 = /* @__PURE__ */ template(`<div class="background">`);
6046
- var _tmpl$112 = /* @__PURE__ */ template(`<button type="button" class="button">`);
6152
+ var _tmpl$102 = /* @__PURE__ */ template(`<button type="button" class="button">`);
6047
6153
  var Game = (props) => {
6048
6154
  const data = useData();
6049
6155
  const {
@@ -6120,14 +6226,6 @@ var Game = (props) => {
6120
6226
  setControlPanelMenuExpanded(false);
6121
6227
  }
6122
6228
  });
6123
- const bg = () => {
6124
- const bg2 = background().background;
6125
- const isImage = isCSSImage(bg2);
6126
- return {
6127
- "background-image": isImage ? bg2 : void 0,
6128
- "background-color": isImage ? void 0 : bg2
6129
- };
6130
- };
6131
6229
  const charactersCount = createMemo(() => {
6132
6230
  return Object.values(characters()).reduce((acc, c) => {
6133
6231
  if (c && c.visible) {
@@ -6138,33 +6236,28 @@ var Game = (props) => {
6138
6236
  });
6139
6237
  return (() => {
6140
6238
  const _el$ = _tmpl$92(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$6 = _el$4.firstChild, _el$26 = _el$3.nextSibling, _el$27 = _el$26.nextSibling;
6141
- insert(_el$, createComponent(Show, {
6142
- get when() {
6143
- return bg()["background-image"];
6144
- },
6145
- get fallback() {
6146
- return (() => {
6147
- const _el$33 = _tmpl$102();
6148
- createRenderEffect((_$p) => style(_el$33, bg(), _$p));
6149
- return _el$33;
6150
- })();
6151
- },
6152
- keyed: true,
6153
- children: (src) => {
6154
- let img = PRELOADED_IMAGE_MAP.get(src);
6155
- if (img) {
6156
- const image = img.isConnected ? img.cloneNode(true) : img;
6157
- return Object.assign(image, {
6158
- className: "background"
6159
- });
6239
+ insert(_el$, createComponent(Canvas, {
6240
+ "class": "background",
6241
+ resize: false,
6242
+ render: async (canvas, ctx) => {
6243
+ const bg = background().background;
6244
+ const isColor = !isCSSImage(bg);
6245
+ if (isColor) {
6246
+ ctx.fillStyle = bg;
6247
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
6248
+ } else {
6249
+ const img = PRELOADED_IMAGE_MAP.get(bg) || createImage(bg);
6250
+ await imageLoaded(img);
6251
+ if (!PRELOADED_IMAGE_MAP.has(bg)) {
6252
+ PRELOADED_IMAGE_MAP.set(bg, img);
6253
+ }
6254
+ if (bg !== background().background) {
6255
+ return;
6256
+ }
6257
+ canvas.width = img.width;
6258
+ canvas.height = img.height;
6259
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
6160
6260
  }
6161
- img = createImage(src);
6162
- img.addEventListener("load", () => {
6163
- PRELOADED_IMAGE_MAP.set(src, img);
6164
- });
6165
- return Object.assign(img, {
6166
- className: "background"
6167
- });
6168
6261
  }
6169
6262
  }), _el$2);
6170
6263
  setAttribute(_el$2, "data-characters", true);
@@ -6206,7 +6299,7 @@ var Game = (props) => {
6206
6299
  return dialog().miniature.emotion;
6207
6300
  },
6208
6301
  get children() {
6209
- const _el$5 = _tmpl$19();
6302
+ const _el$5 = _tmpl$20();
6210
6303
  insert(_el$5, createComponent(Show, {
6211
6304
  get when() {
6212
6305
  return dialog().miniature.emotion;
@@ -6262,12 +6355,12 @@ var Game = (props) => {
6262
6355
  const disabled = !active;
6263
6356
  const index = i();
6264
6357
  return (() => {
6265
- const _el$34 = _tmpl$112();
6266
- _el$34.$$click = onChoicesButtonClick;
6267
- _el$34.$$clickData = [disabled, index];
6268
- setAttribute(_el$34, "aria-disabled", disabled);
6269
- insert(_el$34, text2);
6270
- return _el$34;
6358
+ const _el$33 = _tmpl$102();
6359
+ _el$33.$$click = onChoicesButtonClick;
6360
+ _el$33.$$clickData = [disabled, index];
6361
+ setAttribute(_el$33, "aria-disabled", disabled);
6362
+ insert(_el$33, text2);
6363
+ return _el$33;
6271
6364
  })();
6272
6365
  }
6273
6366
  }), null);
@@ -6453,18 +6546,18 @@ var Game = (props) => {
6453
6546
  delegateEvents(["click", "keydown"]);
6454
6547
 
6455
6548
  // src/screens/loading.tsx
6456
- var _tmpl$20 = /* @__PURE__ */ template(`<div class="loading"><div class="loading__animation"><div></div><div></div><div></div><div>`);
6549
+ var _tmpl$21 = /* @__PURE__ */ template(`<div class="loading"><div class="loading__animation"><div></div><div></div><div></div><div>`);
6457
6550
  var Loading = (props) => {
6458
6551
  return (() => {
6459
- const _el$ = _tmpl$20();
6552
+ const _el$ = _tmpl$21();
6460
6553
  createRenderEffect(() => _el$.classList.toggle("overlay", !!props.overlay));
6461
6554
  return _el$;
6462
6555
  })();
6463
6556
  };
6464
6557
 
6465
6558
  // src/screens/mainmenu.tsx
6466
- var _tmpl$21 = /* @__PURE__ */ template(`<div class="main-menu"><div class="main-menu__controls"><button type="button" class="button main-menu__button"><span class="main-menu__button__text"></span></button><button type="button" class="button main-menu__button"><span class="main-menu__button__text"></span></button><button type="button" class="button main-menu__button"><span class="main-menu__button__text"></span></button><button type="button" class="button main-menu__button"><span class="main-menu__button__text">`);
6467
- var _tmpl$26 = /* @__PURE__ */ template(`<button>`);
6559
+ var _tmpl$26 = /* @__PURE__ */ template(`<div class="main-menu"><div class="main-menu__controls"><button type="button" class="button main-menu__button"><span class="main-menu__button__text"></span></button><button type="button" class="button main-menu__button"><span class="main-menu__button__text"></span></button><button type="button" class="button main-menu__button"><span class="main-menu__button__text"></span></button><button type="button" class="button main-menu__button"><span class="main-menu__button__text">`);
6560
+ var _tmpl$27 = /* @__PURE__ */ template(`<button>`);
6468
6561
  var MainMenu = () => {
6469
6562
  const {
6470
6563
  t,
@@ -6481,7 +6574,7 @@ var MainMenu = () => {
6481
6574
  $rendererState.mutate((s) => s.screen, screen);
6482
6575
  });
6483
6576
  return (() => {
6484
- const _el$ = _tmpl$21(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild, _el$5 = _el$3.nextSibling, _el$6 = _el$5.firstChild, _el$7 = _el$5.nextSibling, _el$8 = _el$7.firstChild, _el$9 = _el$7.nextSibling, _el$10 = _el$9.firstChild;
6577
+ const _el$ = _tmpl$26(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild, _el$5 = _el$3.nextSibling, _el$6 = _el$5.firstChild, _el$7 = _el$5.nextSibling, _el$8 = _el$7.firstChild, _el$9 = _el$7.nextSibling, _el$10 = _el$9.firstChild;
6485
6578
  _el$3.$$click = () => {
6486
6579
  options.newGame();
6487
6580
  };
@@ -6520,7 +6613,7 @@ var MainMenu = () => {
6520
6613
  return rendererStore().mainmenu;
6521
6614
  },
6522
6615
  children: (item) => (() => {
6523
- const _el$11 = _tmpl$26();
6616
+ const _el$11 = _tmpl$27();
6524
6617
  spread(_el$11, mergeProps(() => item(goto)), false, false);
6525
6618
  return _el$11;
6526
6619
  })()
@@ -6532,8 +6625,8 @@ var MainMenu = () => {
6532
6625
  delegateEvents(["click"]);
6533
6626
 
6534
6627
  // src/screens/saves.tsx
6535
- var _tmpl$27 = /* @__PURE__ */ template(`<ol class="saves__list">`);
6536
- var _tmpl$28 = /* @__PURE__ */ template(`<div class="saves"><div class="saves__controls"><button type="button" class="button saves__button"></button></div><div class="saves__list-container">`);
6628
+ var _tmpl$28 = /* @__PURE__ */ template(`<ol class="saves__list">`);
6629
+ var _tmpl$29 = /* @__PURE__ */ template(`<div class="saves"><div class="saves__controls"><button type="button" class="button saves__button"></button></div><div class="saves__list-container">`);
6537
6630
  var _tmpl$35 = /* @__PURE__ */ template(`<div class="saves__list saves__list--empty">`);
6538
6631
  var Saves = () => {
6539
6632
  const {
@@ -6605,7 +6698,7 @@ var Saves = () => {
6605
6698
  return !targets.every((item) => completed.includes(item));
6606
6699
  };
6607
6700
  return (() => {
6608
- const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$2.nextSibling;
6701
+ const _el$ = _tmpl$29(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$2.nextSibling;
6609
6702
  _el$3.$$click = () => {
6610
6703
  $rendererState.setKey("screen", "mainmenu");
6611
6704
  };
@@ -6622,7 +6715,7 @@ var Saves = () => {
6622
6715
  })();
6623
6716
  },
6624
6717
  get children() {
6625
- const _el$5 = _tmpl$27();
6718
+ const _el$5 = _tmpl$28();
6626
6719
  use(setList, _el$5);
6627
6720
  insert(_el$5, createComponent(For, {
6628
6721
  get each() {
@@ -6653,7 +6746,7 @@ var Saves = () => {
6653
6746
  delegateEvents(["click"]);
6654
6747
 
6655
6748
  // src/screens/settings.tsx
6656
- var _tmpl$29 = /* @__PURE__ */ template(`<div class="root settings"><div class="settings__controls"><button type="button" class="button settings__button"></button><button type="button" class="button settings__button"></button></div><div class="settings__options"><div><div class="select"><label class="select__label"><span class="select__label__icon"></span> </label><select class="select__select"></select></div><div class="select"><label class="select__label"><span class="select__label__icon"></span> </label><select class="select__select"></select></div></div><div><div class="range"><label class="range__label"><span class="range__label__icon"></span> </label><input class="range__range" type="range" min="0" max="1" step="0.01"></div><div class="range"><label class="range__label"><span class="range__label__icon"></span> </label><input class="range__range" type="range" min="0" max="1" step="0.01"></div><div class="range"><label class="range__label"><span class="range__label__icon"></span> </label><input class="range__range" type="range" min="0" max="1" step="0.01">`);
6749
+ var _tmpl$30 = /* @__PURE__ */ template(`<div class="root settings"><div class="settings__controls"><button type="button" class="button settings__button"></button><button type="button" class="button settings__button"></button></div><div class="settings__options"><div><div class="select"><label class="select__label"><span class="select__label__icon"></span> </label><select class="select__select"></select></div><div class="select"><label class="select__label"><span class="select__label__icon"></span> </label><select class="select__select"></select></div></div><div><div class="range"><label class="range__label"><span class="range__label__icon"></span> </label><input class="range__range" type="range" min="0" max="1" step="0.01"></div><div class="range"><label class="range__label"><span class="range__label__icon"></span> </label><input class="range__range" type="range" min="0" max="1" step="0.01"></div><div class="range"><label class="range__label"><span class="range__label__icon"></span> </label><input class="range__range" type="range" min="0" max="1" step="0.01">`);
6657
6750
  var _tmpl$210 = /* @__PURE__ */ template(`<option>`);
6658
6751
  var Settings = (props) => {
6659
6752
  const {
@@ -6705,7 +6798,7 @@ var Settings = (props) => {
6705
6798
  const soundVolumeSelectID = createUniqueId();
6706
6799
  const voiceVolumeSelectID = createUniqueId();
6707
6800
  return (() => {
6708
- const _el$ = _tmpl$29(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$2.nextSibling, _el$6 = _el$5.firstChild, _el$7 = _el$6.firstChild, _el$8 = _el$7.firstChild, _el$9 = _el$8.firstChild, _el$10 = _el$9.nextSibling, _el$11 = _el$8.nextSibling, _el$12 = _el$7.nextSibling, _el$13 = _el$12.firstChild, _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling, _el$16 = _el$13.nextSibling, _el$17 = _el$6.nextSibling, _el$18 = _el$17.firstChild, _el$19 = _el$18.firstChild, _el$20 = _el$19.firstChild, _el$21 = _el$20.nextSibling, _el$22 = _el$19.nextSibling, _el$23 = _el$18.nextSibling, _el$24 = _el$23.firstChild, _el$25 = _el$24.firstChild, _el$26 = _el$25.nextSibling, _el$27 = _el$24.nextSibling, _el$28 = _el$23.nextSibling, _el$29 = _el$28.firstChild, _el$30 = _el$29.firstChild, _el$31 = _el$30.nextSibling, _el$32 = _el$29.nextSibling;
6801
+ const _el$ = _tmpl$30(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$2.nextSibling, _el$6 = _el$5.firstChild, _el$7 = _el$6.firstChild, _el$8 = _el$7.firstChild, _el$9 = _el$8.firstChild, _el$10 = _el$9.nextSibling, _el$11 = _el$8.nextSibling, _el$12 = _el$7.nextSibling, _el$13 = _el$12.firstChild, _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling, _el$16 = _el$13.nextSibling, _el$17 = _el$6.nextSibling, _el$18 = _el$17.firstChild, _el$19 = _el$18.firstChild, _el$20 = _el$19.firstChild, _el$21 = _el$20.nextSibling, _el$22 = _el$19.nextSibling, _el$23 = _el$18.nextSibling, _el$24 = _el$23.firstChild, _el$25 = _el$24.firstChild, _el$26 = _el$25.nextSibling, _el$27 = _el$24.nextSibling, _el$28 = _el$23.nextSibling, _el$29 = _el$28.firstChild, _el$30 = _el$29.firstChild, _el$31 = _el$30.nextSibling, _el$32 = _el$29.nextSibling;
6709
6802
  _el$3.$$click = () => {
6710
6803
  $rendererState.setKey("screen", "mainmenu");
6711
6804
  };
@@ -6785,7 +6878,7 @@ var Settings = (props) => {
6785
6878
  delegateEvents(["click"]);
6786
6879
 
6787
6880
  // src/components/Root.tsx
6788
- var _tmpl$30 = /* @__PURE__ */ template(`<div class="root">`);
6881
+ var _tmpl$31 = /* @__PURE__ */ template(`<div class="root">`);
6789
6882
  var createRootComponent = ({
6790
6883
  $rendererState,
6791
6884
  $contextState,
@@ -6820,7 +6913,7 @@ var createRootComponent = ({
6820
6913
  emitter.emit("screen:change", currentScreen);
6821
6914
  });
6822
6915
  return (() => {
6823
- const _el$ = _tmpl$30();
6916
+ const _el$ = _tmpl$31();
6824
6917
  const _ref$ = setRoot;
6825
6918
  typeof _ref$ === "function" ? use(_ref$, _el$) : setRoot = _el$;
6826
6919
  insert(_el$, createComponent(Provider, {
@@ -6928,7 +7021,7 @@ var createShowArbitraryCharacterAction = (_) => {
6928
7021
  // src/custom-actions/show-hide-image.ts
6929
7022
  var SHOW_IMAGE = Symbol();
6930
7023
  var showImage = (source, params = {}) => {
6931
- const handler = ({ getDomNodes, clear, flags, data }) => {
7024
+ const handler = ({ getDomNodes, clear, flags, data, rendererContext }) => {
6932
7025
  const { promise, resolve } = Promise.withResolvers();
6933
7026
  const { element } = getDomNodes(true);
6934
7027
  {
@@ -6954,6 +7047,7 @@ var showImage = (source, params = {}) => {
6954
7047
  clearAnimation = () => {
6955
7048
  image.classList.remove(...classes);
6956
7049
  if (params.await) {
7050
+ rendererContext.clearBlockingActions(void 0);
6957
7051
  resolve();
6958
7052
  }
6959
7053
  };
@@ -6978,7 +7072,7 @@ var showImage = (source, params = {}) => {
6978
7072
  return ["custom", handler];
6979
7073
  };
6980
7074
  var hideImage = (source, params = {}) => {
6981
- const handler = async ({ data }) => {
7075
+ const handler = async ({ data, rendererContext }) => {
6982
7076
  const { promise, resolve } = Promise.withResolvers();
6983
7077
  const { image, in: inClasses } = data();
6984
7078
  if (!image) {
@@ -6995,6 +7089,7 @@ var hideImage = (source, params = {}) => {
6995
7089
  const onAnimationEnd = () => {
6996
7090
  image.classList.remove(...classes);
6997
7091
  if (params.await) {
7092
+ rendererContext.clearBlockingActions(void 0);
6998
7093
  resolve();
6999
7094
  }
7000
7095
  };
@@ -7017,8 +7112,7 @@ var hideImage = (source, params = {}) => {
7017
7112
  };
7018
7113
 
7019
7114
  // src/renderer.tsx
7020
- var _tmpl$31 = /* @__PURE__ */ template(`<canvas>`);
7021
- var _tmpl$211 = /* @__PURE__ */ template(`<link rel="preload" as="image">`);
7115
+ var _tmpl$36 = /* @__PURE__ */ template(`<canvas>`);
7022
7116
  var {
7023
7117
  preloadAudioBlocking
7024
7118
  } = createAudioMisc();
@@ -7068,7 +7162,7 @@ var createSolidRenderer = ({
7068
7162
  return chars[character];
7069
7163
  }
7070
7164
  const canvas = (() => {
7071
- const _el$ = _tmpl$31();
7165
+ const _el$ = _tmpl$36();
7072
7166
  setAttribute(_el$, "data-character", character);
7073
7167
  return _el$;
7074
7168
  })();
@@ -7250,12 +7344,6 @@ var createSolidRenderer = ({
7250
7344
  },
7251
7345
  preloadImageBlocking: (src) => {
7252
7346
  const img = createImage(src);
7253
- document.head.appendChild((() => {
7254
- const _el$2 = _tmpl$211();
7255
- setAttribute(_el$2, "href", src);
7256
- return _el$2;
7257
- })());
7258
- return Promise.resolve();
7259
7347
  return new Promise((resolve) => {
7260
7348
  const done = () => {
7261
7349
  PRELOADED_IMAGE_MAP.set(src, img);
@@ -715,9 +715,6 @@ input[name=novely-input][type=password] {
715
715
  object-fit: cover;
716
716
  object-position: 50% 50%;
717
717
  z-index: 1;
718
- background-position: center;
719
- background-repeat: no-repeat;
720
- background-size: cover;
721
718
  width: 100vw;
722
719
  height: 100vh;
723
720
  position: fixed;
package/dist/utils.d.ts CHANGED
@@ -6,6 +6,7 @@ declare const findLast: <T>(array: T[], fn: (this: T[], item: T, index: number,
6
6
  declare const capitalize: (str: string) => string;
7
7
  declare const isCSSImage: (str: string) => boolean;
8
8
  declare const createImage: (src: string) => HTMLImageElement;
9
+ declare const imageLoaded: (image: HTMLImageElement) => void | Promise<boolean>;
9
10
  /**
10
11
  * Draws passed `images` array on a `canvas`
11
12
  */
@@ -19,4 +20,4 @@ declare const getDocumentStyles: () => string;
19
20
  * @param fn Function that needed to run no more than one time
20
21
  */
21
22
  declare const once: (fn: () => void) => () => void;
22
- export { isCSSImage, canvasDrawImages, url, createImage, capitalize, onKey, findLast, simple, getDocumentStyles, once };
23
+ export { isCSSImage, canvasDrawImages, url, createImage, capitalize, onKey, findLast, simple, getDocumentStyles, once, imageLoaded };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.33.0",
3
+ "version": "0.34.1-beta.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"