1681-engine 0.5.9 → 0.5.10

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 (140) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +3 -0
  3. package/dist/1681-engine.js +501 -438
  4. package/dist/ambient/life/Birds.js +73 -0
  5. package/dist/ambient/life/Butterflies.js +43 -0
  6. package/dist/ambient/life/ChimneySmoke.js +50 -0
  7. package/dist/ambient/life/Drift.js +75 -0
  8. package/dist/ambient/life/Fireflies.js +52 -0
  9. package/dist/ambient/life/lifeMotion.js +49 -0
  10. package/dist/assets/AssetLoader.js +115 -70
  11. package/dist/assets/Prepainter.js +61 -0
  12. package/dist/assets/workerPainter.js +39 -0
  13. package/dist/cjs/electron/electronLike.d.ts +55 -0
  14. package/dist/cjs/electron/electronLike.js +7 -0
  15. package/dist/cjs/electron/index.d.ts +14 -0
  16. package/dist/cjs/electron/index.js +20 -0
  17. package/dist/cjs/electron/lockdown.d.ts +33 -0
  18. package/dist/cjs/electron/lockdown.js +69 -0
  19. package/dist/cjs/electron/lockdownRules.d.ts +28 -0
  20. package/dist/cjs/electron/lockdownRules.js +61 -0
  21. package/dist/cjs/electron/sessionStore.d.ts +40 -0
  22. package/dist/cjs/electron/sessionStore.js +77 -0
  23. package/dist/cjs/electron/shellId.d.ts +22 -0
  24. package/dist/cjs/electron/shellId.js +31 -0
  25. package/dist/cjs/electron/webFiles.d.ts +13 -0
  26. package/dist/cjs/electron/webFiles.js +52 -0
  27. package/dist/cjs/electron/webPatcher.d.ts +80 -0
  28. package/dist/cjs/electron/webPatcher.js +216 -0
  29. package/dist/cjs/electron/webPointers.d.ts +19 -0
  30. package/dist/cjs/electron/webPointers.js +35 -0
  31. package/dist/cjs/package.json +1 -0
  32. package/dist/cjs/updates/index.d.ts +8 -0
  33. package/dist/cjs/updates/index.js +21 -0
  34. package/dist/cjs/updates/manifest.d.ts +73 -0
  35. package/dist/cjs/updates/manifest.js +67 -0
  36. package/dist/cjs/updates/pickUpdate.d.ts +42 -0
  37. package/dist/cjs/updates/pickUpdate.js +52 -0
  38. package/dist/cjs/updates/webPlan.d.ts +20 -0
  39. package/dist/cjs/updates/webPlan.js +34 -0
  40. package/dist/electron/lockdown.js +31 -0
  41. package/dist/electron/lockdownRules.js +42 -0
  42. package/dist/electron/sessionStore.js +48 -0
  43. package/dist/electron/shellId.js +18 -0
  44. package/dist/electron/webFiles.js +36 -0
  45. package/dist/electron/webPatcher.js +147 -0
  46. package/dist/electron/webPointers.js +25 -0
  47. package/dist/electron.js +19 -0
  48. package/dist/input/haptics.js +50 -0
  49. package/dist/net/ApiClient.js +96 -0
  50. package/dist/pixel/lifeArt.js +83 -0
  51. package/dist/pixel.js +63 -58
  52. package/dist/react/ConfirmButton.js +24 -0
  53. package/dist/react/baseCss.js +1 -0
  54. package/dist/react/labels.js +7 -6
  55. package/dist/react/useJsonSelector.js +13 -0
  56. package/dist/react.js +73 -68
  57. package/dist/tilemap/TilemapView.js +57 -32
  58. package/dist/tilemap/autotile.js +103 -0
  59. package/dist/tilemap/collision.js +29 -18
  60. package/dist/tilemap/ldtk.js +21 -0
  61. package/dist/tilemap/ldtkParse.js +191 -0
  62. package/dist/types/ambient/life/Birds.d.ts +50 -0
  63. package/dist/types/ambient/life/Birds.d.ts.map +1 -0
  64. package/dist/types/ambient/life/Butterflies.d.ts +32 -0
  65. package/dist/types/ambient/life/Butterflies.d.ts.map +1 -0
  66. package/dist/types/ambient/life/ChimneySmoke.d.ts +37 -0
  67. package/dist/types/ambient/life/ChimneySmoke.d.ts.map +1 -0
  68. package/dist/types/ambient/life/Drift.d.ts +58 -0
  69. package/dist/types/ambient/life/Drift.d.ts.map +1 -0
  70. package/dist/types/ambient/life/Fireflies.d.ts +43 -0
  71. package/dist/types/ambient/life/Fireflies.d.ts.map +1 -0
  72. package/dist/types/ambient/life/lifeMotion.d.ts +63 -0
  73. package/dist/types/ambient/life/lifeMotion.d.ts.map +1 -0
  74. package/dist/types/assets/AssetLoader.d.ts +20 -0
  75. package/dist/types/assets/AssetLoader.d.ts.map +1 -1
  76. package/dist/types/assets/Prepainter.d.ts +64 -0
  77. package/dist/types/assets/Prepainter.d.ts.map +1 -0
  78. package/dist/types/assets/workerPainter.d.ts +21 -0
  79. package/dist/types/assets/workerPainter.d.ts.map +1 -0
  80. package/dist/types/electron/electronLike.d.ts +56 -0
  81. package/dist/types/electron/electronLike.d.ts.map +1 -0
  82. package/dist/types/electron/index.d.ts +15 -0
  83. package/dist/types/electron/index.d.ts.map +1 -0
  84. package/dist/types/electron/lockdown.d.ts +34 -0
  85. package/dist/types/electron/lockdown.d.ts.map +1 -0
  86. package/dist/types/electron/lockdownRules.d.ts +29 -0
  87. package/dist/types/electron/lockdownRules.d.ts.map +1 -0
  88. package/dist/types/electron/sessionStore.d.ts +41 -0
  89. package/dist/types/electron/sessionStore.d.ts.map +1 -0
  90. package/dist/types/electron/shellId.d.ts +23 -0
  91. package/dist/types/electron/shellId.d.ts.map +1 -0
  92. package/dist/types/electron/webFiles.d.ts +14 -0
  93. package/dist/types/electron/webFiles.d.ts.map +1 -0
  94. package/dist/types/electron/webPatcher.d.ts +81 -0
  95. package/dist/types/electron/webPatcher.d.ts.map +1 -0
  96. package/dist/types/electron/webPointers.d.ts +20 -0
  97. package/dist/types/electron/webPointers.d.ts.map +1 -0
  98. package/dist/types/index.d.ts +15 -2
  99. package/dist/types/index.d.ts.map +1 -1
  100. package/dist/types/input/haptics.d.ts +42 -0
  101. package/dist/types/input/haptics.d.ts.map +1 -0
  102. package/dist/types/net/ApiClient.d.ts +74 -0
  103. package/dist/types/net/ApiClient.d.ts.map +1 -0
  104. package/dist/types/pixel/index.d.ts +1 -0
  105. package/dist/types/pixel/index.d.ts.map +1 -1
  106. package/dist/types/pixel/lifeArt.d.ts +63 -0
  107. package/dist/types/pixel/lifeArt.d.ts.map +1 -0
  108. package/dist/types/react/ConfirmButton.d.ts +26 -0
  109. package/dist/types/react/ConfirmButton.d.ts.map +1 -0
  110. package/dist/types/react/baseCss.d.ts +1 -1
  111. package/dist/types/react/baseCss.d.ts.map +1 -1
  112. package/dist/types/react/index.d.ts +2 -0
  113. package/dist/types/react/index.d.ts.map +1 -1
  114. package/dist/types/react/labels.d.ts +2 -0
  115. package/dist/types/react/labels.d.ts.map +1 -1
  116. package/dist/types/react/useJsonSelector.d.ts +13 -0
  117. package/dist/types/react/useJsonSelector.d.ts.map +1 -0
  118. package/dist/types/tilemap/TilemapView.d.ts +17 -0
  119. package/dist/types/tilemap/TilemapView.d.ts.map +1 -1
  120. package/dist/types/tilemap/autotile.d.ts +95 -0
  121. package/dist/types/tilemap/autotile.d.ts.map +1 -0
  122. package/dist/types/tilemap/collision.d.ts +8 -0
  123. package/dist/types/tilemap/collision.d.ts.map +1 -1
  124. package/dist/types/tilemap/ldtk.d.ts +97 -0
  125. package/dist/types/tilemap/ldtk.d.ts.map +1 -0
  126. package/dist/types/tilemap/ldtkParse.d.ts +26 -0
  127. package/dist/types/tilemap/ldtkParse.d.ts.map +1 -0
  128. package/dist/types/updates/index.d.ts +9 -0
  129. package/dist/types/updates/index.d.ts.map +1 -0
  130. package/dist/types/updates/manifest.d.ts +74 -0
  131. package/dist/types/updates/manifest.d.ts.map +1 -0
  132. package/dist/types/updates/pickUpdate.d.ts +43 -0
  133. package/dist/types/updates/pickUpdate.d.ts.map +1 -0
  134. package/dist/types/updates/webPlan.d.ts +21 -0
  135. package/dist/types/updates/webPlan.d.ts.map +1 -0
  136. package/dist/updates/manifest.js +35 -0
  137. package/dist/updates/pickUpdate.js +27 -0
  138. package/dist/updates/webPlan.js +14 -0
  139. package/dist/updates.js +15 -0
  140. package/package.json +31 -3
package/dist/pixel.js CHANGED
@@ -1,96 +1,101 @@
1
1
  import { PixelLayer as i, addPixelLayer as a } from "./pixel/PixelLayer.js";
2
- import { CLEAR as s, PixelGrid as x, PixelWindow as m, channels as l, hash2 as f, hex as h, makeSheet as n, mix as P, mulberry32 as d, rgba as R, shade as g, toCss as A, upscale as L, valueNoise as u, withAlpha as E } from "./pixel/pixel.js";
3
- import { P as T } from "./pixel/palette.js";
4
- import { art as M, groundShadow as O, litOutline as _, shadeBox as v } from "./pixel/propKit.js";
5
- import { MATERIALS as k, RAMP_FACTOR_SET as w, hueShade as y, outlineOf as C, ramp as W, rampTones as H, registerMaterial as N } from "./pixel/ramp.js";
6
- import { selectiveOutline as D } from "./pixel/selout.js";
2
+ import { CLEAR as x, PixelGrid as s, PixelWindow as m, channels as l, hash2 as f, hex as h, makeSheet as n, mix as P, mulberry32 as R, rgba as L, shade as d, toCss as A, upscale as g, valueNoise as E, withAlpha as S } from "./pixel/pixel.js";
3
+ import { P as M } from "./pixel/palette.js";
4
+ import { art as T, groundShadow as _, litOutline as c, shadeBox as v } from "./pixel/propKit.js";
5
+ import { MATERIALS as C, RAMP_FACTOR_SET as F, hueShade as k, outlineOf as w, ramp as y, rampTones as W, registerMaterial as H } from "./pixel/ramp.js";
6
+ import { selectiveOutline as b } from "./pixel/selout.js";
7
7
  import { chevronPixels as G, discRuns as V, ellipsePixels as q, ringPixels as B } from "./pixel/aimPixels.js";
8
- import { PixelMarks as j } from "./pixel/PixelMarks.js";
8
+ import { PixelMarks as X } from "./pixel/PixelMarks.js";
9
9
  import * as e from "./pixel/pixelPaint.js";
10
10
  import * as r from "./pixel/pixelTone.js";
11
- import { registerHandRamps as J } from "./pixel/pixelTone.js";
12
- import { paintLayer as Q } from "./pixel/paintLayer.js";
11
+ import { registerHandRamps as z } from "./pixel/pixelTone.js";
12
+ import { paintLayer as K } from "./pixel/paintLayer.js";
13
13
  import { Evaporation as Y } from "./pixel/Evaporation.js";
14
14
  import { NO_PIXELS as $, PackedPixels as ee, spritePixels as re } from "./pixel/spritePixels.js";
15
15
  import { CARRIED_LIGHT as oe, Darkness as ie, LAMP_DIM as ae, WARM_LIGHT as pe } from "./pixel/Darkness.js";
16
- import { carriedLight as xe, clearLights as me, flashLight as le, liveLights as fe } from "./pixel/lights.js";
16
+ import { carriedLight as se, clearLights as me, flashLight as le, liveLights as fe } from "./pixel/lights.js";
17
17
  import { NightShade as ne } from "./pixel/NightShade.js";
18
- import { WEATHER_COLORS as de, mistPixels as Re, paintWeatherArt as ge } from "./pixel/weatherArt.js";
19
- import { buildRig as Le, complement as ue, gustAt as Ee, swayOffset as Se, tileHash as Te, trunkPivot as ce } from "./pixel/swayRig.js";
20
- import { SwayProp as Oe, opaqueRowWidths as _e } from "./pixel/SwayProp.js";
21
- import { heartbeat as Ie, vignetteMask as ke } from "./pixel/vignetteMask.js";
22
- import { DitherVignette as ye, ditherVignette as Ce } from "./pixel/DitherVignette.js";
23
- import { FRAME_CORNERS as He, FRAME_TWINS as Ne, frameSvg as be, nineSlice as De } from "./pixel/nineSlice.js";
18
+ import { LIFE_COLORS as Re, PUFF_FRAMES as Le, paintLifeArt as de, puffPixels as Ae } from "./pixel/lifeArt.js";
19
+ import { WEATHER_COLORS as Ee, mistPixels as Se, paintWeatherArt as ue } from "./pixel/weatherArt.js";
20
+ import { buildRig as Oe, complement as Te, gustAt as _e, swayOffset as ce, tileHash as ve, trunkPivot as Ie } from "./pixel/swayRig.js";
21
+ import { SwayProp as Fe, opaqueRowWidths as ke } from "./pixel/SwayProp.js";
22
+ import { heartbeat as ye, vignetteMask as We } from "./pixel/vignetteMask.js";
23
+ import { DitherVignette as Ne, ditherVignette as be } from "./pixel/DitherVignette.js";
24
+ import { FRAME_CORNERS as Ge, FRAME_TWINS as Ve, frameSvg as qe, nineSlice as Be } from "./pixel/nineSlice.js";
24
25
  export {
25
26
  oe as CARRIED_LIGHT,
26
- s as CLEAR,
27
+ x as CLEAR,
27
28
  ie as Darkness,
28
- ye as DitherVignette,
29
+ Ne as DitherVignette,
29
30
  Y as Evaporation,
30
- He as FRAME_CORNERS,
31
- Ne as FRAME_TWINS,
31
+ Ge as FRAME_CORNERS,
32
+ Ve as FRAME_TWINS,
32
33
  ae as LAMP_DIM,
33
- k as MATERIALS,
34
+ Re as LIFE_COLORS,
35
+ C as MATERIALS,
34
36
  $ as NO_PIXELS,
35
37
  ne as NightShade,
36
- T as PALETTE,
38
+ M as PALETTE,
39
+ Le as PUFF_FRAMES,
37
40
  ee as PackedPixels,
38
- x as PixelGrid,
41
+ s as PixelGrid,
39
42
  i as PixelLayer,
40
- j as PixelMarks,
43
+ X as PixelMarks,
41
44
  m as PixelWindow,
42
- w as RAMP_FACTOR_SET,
43
- Oe as SwayProp,
45
+ F as RAMP_FACTOR_SET,
46
+ Fe as SwayProp,
44
47
  pe as WARM_LIGHT,
45
- de as WEATHER_COLORS,
48
+ Ee as WEATHER_COLORS,
46
49
  a as addPixelLayer,
47
- M as art,
48
- Le as buildRig,
49
- xe as carriedLight,
50
+ T as art,
51
+ Oe as buildRig,
52
+ se as carriedLight,
50
53
  l as channels,
51
54
  G as chevronPixels,
52
55
  me as clearLights,
53
- ue as complement,
56
+ Te as complement,
54
57
  V as discRuns,
55
- Ce as ditherVignette,
58
+ be as ditherVignette,
56
59
  q as ellipsePixels,
57
60
  le as flashLight,
58
- be as frameSvg,
59
- O as groundShadow,
60
- Ee as gustAt,
61
+ qe as frameSvg,
62
+ _ as groundShadow,
63
+ _e as gustAt,
61
64
  f as hash2,
62
- Ie as heartbeat,
65
+ ye as heartbeat,
63
66
  h as hex,
64
- y as hueShade,
65
- _ as litOutline,
67
+ k as hueShade,
68
+ c as litOutline,
66
69
  fe as liveLights,
67
70
  n as makeSheet,
68
- Re as mistPixels,
71
+ Se as mistPixels,
69
72
  P as mix,
70
- d as mulberry32,
71
- De as nineSlice,
72
- _e as opaqueRowWidths,
73
- C as outlineOf,
74
- Q as paintLayer,
75
- ge as paintWeatherArt,
73
+ R as mulberry32,
74
+ Be as nineSlice,
75
+ ke as opaqueRowWidths,
76
+ w as outlineOf,
77
+ K as paintLayer,
78
+ de as paintLifeArt,
79
+ ue as paintWeatherArt,
76
80
  e as pixelPaint,
77
81
  r as pixelTone,
78
- W as ramp,
79
- H as rampTones,
80
- J as registerHandRamps,
81
- N as registerMaterial,
82
- R as rgba,
82
+ Ae as puffPixels,
83
+ y as ramp,
84
+ W as rampTones,
85
+ z as registerHandRamps,
86
+ H as registerMaterial,
87
+ L as rgba,
83
88
  B as ringPixels,
84
- D as selectiveOutline,
85
- g as shade,
89
+ b as selectiveOutline,
90
+ d as shade,
86
91
  v as shadeBox,
87
92
  re as spritePixels,
88
- Se as swayOffset,
89
- Te as tileHash,
93
+ ce as swayOffset,
94
+ ve as tileHash,
90
95
  A as toCss,
91
- ce as trunkPivot,
92
- L as upscale,
93
- u as valueNoise,
94
- ke as vignetteMask,
95
- E as withAlpha
96
+ Ie as trunkPivot,
97
+ g as upscale,
98
+ E as valueNoise,
99
+ We as vignetteMask,
100
+ S as withAlpha
96
101
  };
@@ -0,0 +1,24 @@
1
+ import { jsx as g } from "react/jsx-runtime";
2
+ import { useState as A } from "react";
3
+ import { useCx as C, useUi as L } from "./UiProvider.js";
4
+ import { DEFAULT_LABELS as h } from "./labels.js";
5
+ function U({ armKey: n = "armed", armed: s, setArmed: t, onConfirm: c, label: e, armedLabel: l, title: u, className: m = "small", disabled: a }) {
6
+ const f = C(), p = L(), [b, d] = A(null), r = t !== void 0, x = r ? s ?? null : b, i = r ? t : d, o = x === n;
7
+ return /* @__PURE__ */ g(
8
+ "button",
9
+ {
10
+ type: "button",
11
+ className: f("e1681-button", m, o ? "e1681-armed primary" : "ghost"),
12
+ disabled: a,
13
+ onClick: () => {
14
+ if (!o) return i(n);
15
+ c(), i(null);
16
+ },
17
+ title: u,
18
+ children: o ? l ?? p.labels.confirmAgain ?? h.confirmAgain : e
19
+ }
20
+ );
21
+ }
22
+ export {
23
+ U as ConfirmButton
24
+ };
@@ -86,6 +86,7 @@ const o = `
86
86
  .e1681-button { padding: 2px 10px; cursor: pointer; min-height: 28px; }
87
87
  .e1681-button.small { padding: 0 6px; min-height: 22px; }
88
88
  .e1681-button.ghost { background-color: transparent; }
89
+ .e1681-button.e1681-armed { color: var(--e1681-accent); }
89
90
  .e1681-button:hover:not(:disabled) { color: var(--e1681-accent); }
90
91
  /* pressed: the same face a pixel lower, never a transform */
91
92
  .e1681-button:active:not(:disabled) { padding-top: 3px; padding-bottom: 1px; }
@@ -1,4 +1,4 @@
1
- const n = {
1
+ const c = {
2
2
  close: "Close {0}",
3
3
  closeHint: "Close (Esc)",
4
4
  backToList: "‹ List",
@@ -6,12 +6,13 @@ const n = {
6
6
  cancel: "Cancel",
7
7
  ok: "OK",
8
8
  quantity: "Quantity",
9
- choose: "Choose"
9
+ choose: "Choose",
10
+ confirmAgain: "Sure?"
10
11
  };
11
- function l(e, ...t) {
12
- return e.replace(/\{(\d+)\}/g, (o, c) => t[Number(c)] ?? o);
12
+ function i(e, ...n) {
13
+ return e.replace(/\{(\d+)\}/g, (o, t) => n[Number(t)] ?? o);
13
14
  }
14
15
  export {
15
- n as DEFAULT_LABELS,
16
- l as fillLabel
16
+ c as DEFAULT_LABELS,
17
+ i as fillLabel
17
18
  };
@@ -0,0 +1,13 @@
1
+ import { useMemo as n } from "react";
2
+ import { useStore as s } from "./useStore.js";
3
+ function u(o, r) {
4
+ const e = o((t) => JSON.stringify(r(t)) ?? "null");
5
+ return n(() => JSON.parse(e), [e]);
6
+ }
7
+ function m(o, r) {
8
+ return u((e) => s(o, e), r);
9
+ }
10
+ export {
11
+ u as useJsonSelector,
12
+ m as useStoreJson
13
+ };
package/dist/react.js CHANGED
@@ -1,77 +1,82 @@
1
1
  import { UiProvider as r, defaultUiSettings as t, useCx as i, useUi as p } from "./react/UiProvider.js";
2
- import { classJoiner as l } from "./react/classNames.js";
3
- import { DEFAULT_LABELS as m, fillLabel as a } from "./react/labels.js";
4
- import { baseCss as c, injectBaseCss as n } from "./react/baseCss.js";
2
+ import { classJoiner as f } from "./react/classNames.js";
3
+ import { DEFAULT_LABELS as l, fillLabel as x } from "./react/labels.js";
4
+ import { baseCss as n, injectBaseCss as c } from "./react/baseCss.js";
5
5
  import { useStore as C } from "./react/useStore.js";
6
- import { useViewport as u } from "./react/useViewport.js";
7
- import { SCROLL_CLASS as d, useFitToViewport as L } from "./react/useFitToViewport.js";
8
- import { useFillSheet as P } from "./react/useFillSheet.js";
9
- import { SPLIT_STACK_BELOW as w, cursorTip as k, listPlacement as F, pixelFit as A, sheetScaleStyle as E, splitModeFor as U, windowStyle as _ } from "./react/placement.js";
10
- import { Panel as B } from "./react/Panel.js";
11
- import { TabStrip as G } from "./react/TabStrip.js";
12
- import { SplitPane as V } from "./react/SplitPane.js";
13
- import { pickedEntry as K, usePicked as M } from "./react/usePicked.js";
14
- import { Select as j, stepOption as v } from "./react/Select.js";
15
- import { Tooltip as R } from "./react/Tooltip.js";
16
- import { TitleTips as q } from "./react/TitleTips.js";
17
- import { Modal as H } from "./react/Modal.js";
18
- import { ConfirmDialog as X } from "./react/ConfirmDialog.js";
19
- import { answerConfirm as Z, askConfirm as $, askQuantity as ee, cancelConfirm as oe, confirmStore as re, parseQuantity as te } from "./react/confirmStore.js";
20
- import { ChoiceDialog as pe } from "./react/ChoiceDialog.js";
21
- import { answerChoice as le, askChoice as se, cancelChoice as me, choiceStore as ae, firstChoice as xe } from "./react/choiceStore.js";
22
- import { Slider as ne, sliderKeyValue as Se } from "./react/Slider.js";
23
- import { PixelImage as he } from "./react/PixelImage.js";
24
- import { Glyph as ye, glyphPath as de, hasGlyph as Le, registerGlyph as Te } from "./react/Glyph.js";
6
+ import { useJsonSelector as h, useStoreJson as y } from "./react/useJsonSelector.js";
7
+ import { useViewport as L } from "./react/useViewport.js";
8
+ import { SCROLL_CLASS as P, useFitToViewport as g } from "./react/useFitToViewport.js";
9
+ import { useFillSheet as k } from "./react/useFillSheet.js";
10
+ import { SPLIT_STACK_BELOW as A, cursorTip as B, listPlacement as E, pixelFit as U, sheetScaleStyle as _, splitModeFor as b, windowStyle as D } from "./react/placement.js";
11
+ import { Panel as J } from "./react/Panel.js";
12
+ import { TabStrip as V } from "./react/TabStrip.js";
13
+ import { SplitPane as K } from "./react/SplitPane.js";
14
+ import { pickedEntry as Q, usePicked as j } from "./react/usePicked.js";
15
+ import { Select as R, stepOption as W } from "./react/Select.js";
16
+ import { Tooltip as z } from "./react/Tooltip.js";
17
+ import { TitleTips as N } from "./react/TitleTips.js";
18
+ import { Modal as Y } from "./react/Modal.js";
19
+ import { ConfirmDialog as $ } from "./react/ConfirmDialog.js";
20
+ import { ConfirmButton as oe } from "./react/ConfirmButton.js";
21
+ import { answerConfirm as te, askConfirm as ie, askQuantity as pe, cancelConfirm as se, confirmStore as fe, parseQuantity as me } from "./react/confirmStore.js";
22
+ import { ChoiceDialog as xe } from "./react/ChoiceDialog.js";
23
+ import { answerChoice as ne, askChoice as ce, cancelChoice as Se, choiceStore as Ce, firstChoice as ue } from "./react/choiceStore.js";
24
+ import { Slider as ye, sliderKeyValue as de } from "./react/Slider.js";
25
+ import { PixelImage as Te } from "./react/PixelImage.js";
26
+ import { Glyph as ge, glyphPath as we, hasGlyph as ke, registerGlyph as Fe } from "./react/Glyph.js";
25
27
  export {
26
- pe as ChoiceDialog,
27
- X as ConfirmDialog,
28
- m as DEFAULT_LABELS,
29
- ye as Glyph,
30
- H as Modal,
31
- B as Panel,
32
- he as PixelImage,
33
- d as SCROLL_CLASS,
34
- w as SPLIT_STACK_BELOW,
35
- j as Select,
36
- ne as Slider,
37
- V as SplitPane,
38
- G as TabStrip,
39
- q as TitleTips,
40
- R as Tooltip,
28
+ xe as ChoiceDialog,
29
+ oe as ConfirmButton,
30
+ $ as ConfirmDialog,
31
+ l as DEFAULT_LABELS,
32
+ ge as Glyph,
33
+ Y as Modal,
34
+ J as Panel,
35
+ Te as PixelImage,
36
+ P as SCROLL_CLASS,
37
+ A as SPLIT_STACK_BELOW,
38
+ R as Select,
39
+ ye as Slider,
40
+ K as SplitPane,
41
+ V as TabStrip,
42
+ N as TitleTips,
43
+ z as Tooltip,
41
44
  r as UiProvider,
42
- le as answerChoice,
43
- Z as answerConfirm,
44
- se as askChoice,
45
- $ as askConfirm,
46
- ee as askQuantity,
47
- c as baseCss,
48
- me as cancelChoice,
49
- oe as cancelConfirm,
50
- ae as choiceStore,
51
- l as classJoiner,
52
- re as confirmStore,
53
- k as cursorTip,
45
+ ne as answerChoice,
46
+ te as answerConfirm,
47
+ ce as askChoice,
48
+ ie as askConfirm,
49
+ pe as askQuantity,
50
+ n as baseCss,
51
+ Se as cancelChoice,
52
+ se as cancelConfirm,
53
+ Ce as choiceStore,
54
+ f as classJoiner,
55
+ fe as confirmStore,
56
+ B as cursorTip,
54
57
  t as defaultUiSettings,
55
- a as fillLabel,
56
- xe as firstChoice,
57
- de as glyphPath,
58
- Le as hasGlyph,
59
- n as injectBaseCss,
60
- F as listPlacement,
61
- te as parseQuantity,
62
- K as pickedEntry,
63
- A as pixelFit,
64
- Te as registerGlyph,
65
- E as sheetScaleStyle,
66
- Se as sliderKeyValue,
67
- U as splitModeFor,
68
- v as stepOption,
58
+ x as fillLabel,
59
+ ue as firstChoice,
60
+ we as glyphPath,
61
+ ke as hasGlyph,
62
+ c as injectBaseCss,
63
+ E as listPlacement,
64
+ me as parseQuantity,
65
+ Q as pickedEntry,
66
+ U as pixelFit,
67
+ Fe as registerGlyph,
68
+ _ as sheetScaleStyle,
69
+ de as sliderKeyValue,
70
+ b as splitModeFor,
71
+ W as stepOption,
69
72
  i as useCx,
70
- P as useFillSheet,
71
- L as useFitToViewport,
72
- M as usePicked,
73
+ k as useFillSheet,
74
+ g as useFitToViewport,
75
+ h as useJsonSelector,
76
+ j as usePicked,
73
77
  C as useStore,
78
+ y as useStoreJson,
74
79
  p as useUi,
75
- u as useViewport,
76
- _ as windowStyle
80
+ L as useViewport,
81
+ D as windowStyle
77
82
  };
@@ -1,17 +1,17 @@
1
- import { Container as M, Sprite as P } from "pixi.js";
2
- import { tileAt as F, tileRect as H, FLIP_D as V, FLIP_H as $, FLIP_V as L } from "./tiled.js";
3
- let S = 0;
4
- class T {
1
+ import { Container as C, Sprite as F } from "pixi.js";
2
+ import { tileAt as I, tileRect as T, FLIP_D as P, FLIP_H as H, FLIP_V as S } from "./tiled.js";
3
+ let V = 0;
4
+ class _ {
5
5
  constructor(s, i, e = {}) {
6
6
  this.stage = s, this.map = i;
7
- const p = e.textureFor ?? ((t) => t.name), r = Math.max(1, e.chunkTiles ?? 32), m = e.baseDepth ?? -1e6, w = e.layers ? new Set(e.layers) : null, c = i.layers.filter((t) => t.kind === "tiles" && (w ? w.has(t.name) : t.visible)), f = e.parent ?? s.world;
8
- c.forEach((t, y) => {
9
- const x = typeof t.properties.depth == "number" ? t.properties.depth : m + y, l = new M();
10
- l.zIndex = x, l.alpha = t.opacity, l.position.set(t.offsetX, t.offsetY), this.layers.set(t.name, l), f.addChild(l);
11
- for (let n = 0; n < i.height; n += r)
12
- for (let a = 0; a < i.width; a += r) {
13
- const o = Math.min(r, i.width - a), d = Math.min(r, i.height - n);
14
- this.paintChunk(t, l, a, n, o, d, p);
7
+ const l = this.textureFor = e.textureFor ?? ((t) => t.name), h = this.chunkTiles = Math.max(1, e.chunkTiles ?? 32), o = e.baseDepth ?? -1e6, f = e.layers ? new Set(e.layers) : null, n = i.layers.filter((t) => t.kind === "tiles" && (f ? f.has(t.name) : t.visible)), c = e.parent ?? s.world;
8
+ this.originX = e.x ?? 0, this.originY = e.y ?? 0, n.forEach((t, x) => {
9
+ const w = typeof t.properties.depth == "number" ? t.properties.depth : o + x, r = new C();
10
+ r.zIndex = w, r.sortableChildren = !0, r.alpha = t.opacity, r.position.set(this.originX + t.offsetX, this.originY + t.offsetY), this.layers.set(t.name, r), this.drawn.set(t.name, t), c.addChild(r);
11
+ for (let d = 0; d < i.height; d += h)
12
+ for (let p = 0; p < i.width; p += h) {
13
+ const u = Math.min(h, i.width - p), m = Math.min(h, i.height - d);
14
+ this.paintChunk(t, r, p, d, u, m, l);
15
15
  }
16
16
  });
17
17
  }
@@ -20,13 +20,38 @@ class T {
20
20
  /** One container per drawn tile layer, by name, each at its own depth among the bodies. */
21
21
  layers = /* @__PURE__ */ new Map();
22
22
  chunks = [];
23
- id = S++;
23
+ id = V++;
24
+ chunkTiles;
25
+ textureFor;
26
+ drawn = /* @__PURE__ */ new Map();
27
+ originX;
28
+ originY;
24
29
  /** Shows only the chunks in the camera's view (plus a margin in world px). Call once a frame. */
25
30
  update(s = 32) {
26
31
  const i = this.stage.cameras.main.worldView;
27
32
  for (const e of this.chunks)
28
33
  e.sprite.visible = e.x < i.right + s && e.x + e.w > i.x - s && e.y < i.bottom + s && e.y + e.h > i.y - s;
29
34
  }
35
+ /**
36
+ * Repaints the chunks holding these cells (row-major indices) of a drawn layer, after its `data` changed: a door
37
+ * opening, a wall dug out, a cell autotiled again (`updateAutotile` returns exactly the indices to pass). Costs one
38
+ * chunk's painting per chunk touched, so keep it out of every frame.
39
+ */
40
+ refreshTiles(s, i) {
41
+ const e = this.drawn.get(s), l = this.layers.get(s);
42
+ if (!e || !l) return;
43
+ const { map: h, chunkTiles: o } = this, f = /* @__PURE__ */ new Set();
44
+ for (const n of i)
45
+ n < 0 || n >= h.width * h.height || f.add(`${Math.floor(n % h.width / o) * o},${Math.floor(Math.floor(n / h.width) / o) * o}`);
46
+ for (const n of f) {
47
+ const [c, t] = n.split(",").map(Number), x = `tilemap:${this.id}:${e.name}:${c},${t}`, w = this.chunks.findIndex((r) => r.key === x);
48
+ if (w >= 0) {
49
+ const [r] = this.chunks.splice(w, 1);
50
+ r.sprite.destroy(), this.stage.textures.remove(x);
51
+ }
52
+ this.paintChunk(e, l, c, t, Math.min(o, h.width - c), Math.min(o, h.height - t), this.textureFor);
53
+ }
54
+ }
30
55
  /** World size of the map in px. */
31
56
  get widthPx() {
32
57
  return this.map.width * this.map.tileWidth;
@@ -40,29 +65,29 @@ class T {
40
65
  for (const s of this.layers.values()) s.destroy({ children: !0 });
41
66
  this.layers.clear();
42
67
  }
43
- paintChunk(s, i, e, p, r, m, w) {
44
- const { map: c } = this, f = c.tileWidth, t = c.tileHeight;
45
- let y = !1;
46
- const x = `tilemap:${this.id}:${s.name}:${e},${p}`, n = Math.max(t, ...c.tilesets.map((u) => u.tileHeight)) - t, a = this.stage.textures.createCanvas(x, r * f, m * t + n), o = a.context;
47
- o.imageSmoothingEnabled = !1;
48
- for (let u = 0; u < m; u++)
49
- for (let k = 0; k < r; k++) {
50
- const v = s.data[(p + u) * c.width + (e + k)], g = F(c, v);
51
- if (!g) continue;
52
- const b = this.stage.textures.exists(w(g.tileset)) ? this.stage.textures.get(w(g.tileset)).source.resource : null;
53
- if (!b) continue;
54
- const h = H(g.tileset, g.local), C = k * f, I = n + (u + 1) * t - h.h;
55
- o.save(), o.translate(C + h.w / 2, I + h.h / 2), v & V && o.transform(0, 1, 1, 0, 0, 0), o.scale(v & $ ? -1 : 1, v & L ? -1 : 1), o.drawImage(b, h.x, h.y, h.w, h.h, -h.w / 2, -h.h / 2, h.w, h.h), o.restore(), y = !0;
68
+ paintChunk(s, i, e, l, h, o, f) {
69
+ const { map: n } = this, c = n.tileWidth, t = n.tileHeight;
70
+ let x = !1;
71
+ const w = `tilemap:${this.id}:${s.name}:${e},${l}`, d = Math.max(t, ...n.tilesets.map((g) => g.tileHeight)) - t, p = this.stage.textures.createCanvas(w, h * c, o * t + d), u = p.context;
72
+ u.imageSmoothingEnabled = !1;
73
+ for (let g = 0; g < o; g++)
74
+ for (let y = 0; y < h; y++) {
75
+ const M = s.data[(l + g) * n.width + (e + y)], k = I(n, M);
76
+ if (!k) continue;
77
+ const $ = this.stage.textures.exists(f(k.tileset)) ? this.stage.textures.get(f(k.tileset)).source.resource : null;
78
+ if (!$) continue;
79
+ const a = T(k.tileset, k.local), b = y * c, v = d + (g + 1) * t - a.h;
80
+ u.save(), u.translate(b + a.w / 2, v + a.h / 2), M & P && u.transform(0, 1, 1, 0, 0, 0), u.scale(M & H ? -1 : 1, M & S ? -1 : 1), u.drawImage($, a.x, a.y, a.w, a.h, -a.w / 2, -a.h / 2, a.w, a.h), u.restore(), x = !0;
56
81
  }
57
- if (!y) {
58
- this.stage.textures.remove(x);
82
+ if (!x) {
83
+ this.stage.textures.remove(w);
59
84
  return;
60
85
  }
61
- a.refresh();
62
- const d = new P(a.whole);
63
- d.position.set(e * f, p * t - n), i.addChild(d), this.chunks.push({ sprite: d, x: d.x + s.offsetX, y: d.y + s.offsetY, w: r * f, h: m * t + n, key: x });
86
+ p.refresh();
87
+ const m = new F(p.whole);
88
+ m.position.set(e * c, l * t - d), m.zIndex = l * n.width + e, i.addChild(m), this.chunks.push({ sprite: m, x: m.x + i.x, y: m.y + i.y, w: h * c, h: o * t + d, key: w });
64
89
  }
65
90
  }
66
91
  export {
67
- T as TilemapView
92
+ _ as TilemapView
68
93
  };
@@ -0,0 +1,103 @@
1
+ const G = 1, d = 2, m = 4, A = 8, j = 1, T = 2, U = 4, v = 8, I = 16, F = 32, H = 64, K = 128;
2
+ function f(t) {
3
+ let n = t & 85;
4
+ return t & 2 && t & 1 && t & 4 && (n |= 2), t & 8 && t & 16 && t & 4 && (n |= 8), t & 32 && t & 16 && t & 64 && (n |= 32), t & 128 && t & 1 && t & 64 && (n |= 128), n;
5
+ }
6
+ const S = (() => {
7
+ const t = /* @__PURE__ */ new Set();
8
+ for (let n = 0; n < 256; n++) t.add(f(n));
9
+ return [...t].sort((n, e) => n - e);
10
+ })(), w = new Map(S.map((t, n) => [t, n]));
11
+ function R(t) {
12
+ return w.get(f(t));
13
+ }
14
+ const N = [
15
+ [0, -1, 1],
16
+ [1, -1, 2],
17
+ [1, 0, 4],
18
+ [1, 1, 8],
19
+ [0, 1, 16],
20
+ [-1, 1, 32],
21
+ [-1, 0, 64],
22
+ [-1, -1, 128]
23
+ ];
24
+ function _(t, n, e, o, B) {
25
+ if (e < 0 || o < 0 || e >= t.width || o >= t.height) return (B.edge ?? "same") === "same";
26
+ const c = t.cells[o * t.width + e];
27
+ return B.joins ? B.joins(n, c) : c === n;
28
+ }
29
+ function a(t, n, e, o = {}) {
30
+ const B = t.cells[e * t.width + n];
31
+ return (_(t, B, n, e - 1, o) ? 1 : 0) | (_(t, B, n + 1, e, o) ? 2 : 0) | (_(t, B, n, e + 1, o) ? 4 : 0) | (_(t, B, n - 1, e, o) ? 8 : 0);
32
+ }
33
+ function W(t, n, e, o = {}) {
34
+ const B = t.cells[e * t.width + n];
35
+ let c = 0;
36
+ for (const [l, u, s] of N) _(t, B, n + l, e + u, o) && (c |= s);
37
+ return f(c);
38
+ }
39
+ function b(t, n) {
40
+ let e = Math.imul(t, 668265261) ^ Math.imul(n, 374761393);
41
+ return e ^= e >>> 15, e = Math.imul(e, 739982445), (e ^ e >>> 12) >>> 0;
42
+ }
43
+ const p = { edges: 15, blob: 255 }, h = /* @__PURE__ */ new WeakMap();
44
+ function D(t) {
45
+ let n = h.get(t);
46
+ if (n) return n;
47
+ n = /* @__PURE__ */ new Map();
48
+ for (const e of t.rules) {
49
+ const o = e.connectsTo ? new Set(e.connectsTo) : null, B = { edge: t.edge ?? "same" };
50
+ o && (B.joins = (c, l) => l === c || o.has(l)), n.set(e.terrain, { rule: e, options: B });
51
+ }
52
+ return h.set(t, n), n;
53
+ }
54
+ function E(t, n, e) {
55
+ return t === void 0 || typeof t == "number" ? t : t.length ? t[b(n, e) % t.length] : void 0;
56
+ }
57
+ function r(t, n, e, o) {
58
+ const B = D(n).get(t.cells[o * t.width + e]);
59
+ if (!B) return n.empty ?? 0;
60
+ const c = B.rule.mode ?? "blob", l = c === "blob" ? W(t, e, o, B.options) : a(t, e, o, B.options), { tiles: u } = B.rule;
61
+ return typeof u == "function" ? u(l, e, o) : E(u[l], e, o) ?? B.rule.fallback ?? E(u[p[c]], e, o) ?? n.empty ?? 0;
62
+ }
63
+ function X(t, n, e = new Uint32Array(t.width * t.height)) {
64
+ for (let o = 0; o < t.height; o++) for (let B = 0; B < t.width; B++) e[o * t.width + B] = r(t, n, B, o);
65
+ return e;
66
+ }
67
+ function M(t, n, e, o, B) {
68
+ const c = [];
69
+ for (let l = -1; l <= 1; l++)
70
+ for (let u = -1; u <= 1; u++) {
71
+ const s = o + u, i = B + l;
72
+ if (s < 0 || i < 0 || s >= t.width || i >= t.height) continue;
73
+ const L = i * t.width + s, O = r(t, n, s, i);
74
+ e[L] !== O && (e[L] = O, c.push(L));
75
+ }
76
+ return c;
77
+ }
78
+ function q(t, n, e, o, B, c) {
79
+ return o < 0 || B < 0 || o >= t.width || B >= t.height ? [] : (t.cells[B * t.width + o] = c, M(t, n, e, o, B));
80
+ }
81
+ export {
82
+ S as BLOB47_MASKS,
83
+ U as BLOB_E,
84
+ j as BLOB_N,
85
+ T as BLOB_NE,
86
+ K as BLOB_NW,
87
+ I as BLOB_S,
88
+ v as BLOB_SE,
89
+ F as BLOB_SW,
90
+ H as BLOB_W,
91
+ d as EDGE_E,
92
+ G as EDGE_N,
93
+ m as EDGE_S,
94
+ A as EDGE_W,
95
+ X as autotile,
96
+ r as autotileAt,
97
+ R as blob47Index,
98
+ W as blobMask,
99
+ a as edgeMask,
100
+ q as paintTerrain,
101
+ f as reduceBlobMask,
102
+ M as updateAutotile
103
+ };