@turnipxenon/pineapple 3.1.0-alpha.5 → 3.1.0-alpha.7

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.
@@ -16,7 +16,7 @@ export declare class DialogManager implements IDialogManager {
16
16
  previousTimestamp: number;
17
17
  isDoneTransition: boolean;
18
18
  currentPortrait: import("svelte/store").Writable<string>;
19
- portraitMap: Map<string, any>;
19
+ portraitMap: Map<string, string>;
20
20
  currentState: DialogState;
21
21
  currentReadableState: import("svelte/store").Writable<DialogState>;
22
22
  hidePercent: import("svelte/motion").Tweened<number>;
@@ -80,3 +80,4 @@ export declare class DialogManager implements IDialogManager {
80
80
  toggleDialogOverlay(): void;
81
81
  parseAndSetDialogTree(dialogYarn: string): Promise<DialogDetail[]>;
82
82
  }
83
+ export declare const dialogManager: DialogManager;
@@ -37,13 +37,14 @@ export class DialogManager {
37
37
  easing: backOut
38
38
  }); // 100 = 100%
39
39
  skipNextActiveTime = 0;
40
- dialogProcessor = new DialogProcessor();
40
+ dialogProcessor;
41
41
  // for queueing actions
42
42
  _setDialogChoiceQueue = [];
43
43
  _setDialogChoiceMutex = false;
44
44
  onSetDialogListeners = [];
45
45
  enableDialogueOverlayCache = false;
46
46
  constructor() {
47
+ this.dialogProcessor = new DialogProcessor(this);
47
48
  enableDialogueOverlay.subscribe((value) => {
48
49
  // todo: investigate why we cant put setDialogDefault inside the then clause
49
50
  // ISSUE #82 https://github.com/TurnipXenon/pineapple/issues/82
@@ -162,7 +163,7 @@ export class DialogManager {
162
163
  // set the portrait
163
164
  let portraitValue = AresHappy;
164
165
  if (this.currentMessageMeta.portraitType) {
165
- portraitValue = this.portraitMap.get(this.currentMessageMeta.portraitType);
166
+ portraitValue = this.portraitMap.get(this.currentMessageMeta.portraitType ?? AresHappy);
166
167
  }
167
168
  if (portraitValue) {
168
169
  this.currentPortrait.update(() => portraitValue);
@@ -212,7 +213,7 @@ export class DialogManager {
212
213
  if (!this.isDoneTransition && this.currentIndex > this.fullCurrentMessage.length) {
213
214
  const elementList = document.getElementsByClassName("dialog-choice");
214
215
  for (const el of elementList) {
215
- el.addEventListener("click", (event) => {
216
+ el.addEventListener("click", () => {
216
217
  // todo: make more robust; for now we're assuming first class is our choice
217
218
  const choice = el.classList[0].split("-")[1];
218
219
  this.setDialogChoice(this.dialogMessageMap.get(choice));
@@ -261,3 +262,4 @@ export class DialogManager {
261
262
  });
262
263
  }
263
264
  }
265
+ export const dialogManager = new DialogManager();
@@ -1,10 +1,12 @@
1
1
  import type { DialogDetail } from "../../types/pineapple_fiber/DialogDetail";
2
- import { LineSelectorNode } from "./behavior_tree/line_core/LineSelectorNode";
2
+ import type { IDialogManager } from "../..";
3
3
  /**
4
4
  * DialogProcessor processes dialogs
5
5
  */
6
6
  export declare class DialogProcessor {
7
- processingTree: LineSelectorNode;
7
+ private readonly dialogManager;
8
+ private processingTree;
9
+ constructor(dialogManager: IDialogManager);
8
10
  /**
9
11
  * process the dialog line by line and return a presentable string
10
12
  * @param dialogDetail
@@ -17,24 +17,29 @@ import { UnvisitCommand } from "./behavior_tree/line_processors/commands/Unvisit
17
17
  * DialogProcessor processes dialogs
18
18
  */
19
19
  export class DialogProcessor {
20
- processingTree = new LineSelectorNode([
21
- /*region comment based formats*/
22
- new IgnoreJumpNode(), // must be prioritized above line comment node
23
- new LineCommentNode(),
24
- /*endregion commend based formats*/
25
- new EndIfNode(),
26
- new ElseIfNode(),
27
- new ElseNode(),
28
- new IfNode(),
29
- new IgnoreGuardNode(),
30
- /*region commands*/
31
- new SetVariableNode(),
32
- new DeclareCommand(),
33
- new JumpCommand(),
34
- new UnvisitCommand(),
35
- /*endregion commands*/
36
- new NormalLineProcessorNode()
37
- ]);
20
+ dialogManager;
21
+ processingTree;
22
+ constructor(dialogManager) {
23
+ this.dialogManager = dialogManager;
24
+ this.processingTree = new LineSelectorNode([
25
+ /*region comment based formats*/
26
+ new IgnoreJumpNode(), // must be prioritized above line comment node
27
+ new LineCommentNode(),
28
+ /*endregion commend based formats*/
29
+ new EndIfNode(),
30
+ new ElseIfNode(),
31
+ new ElseNode(),
32
+ new IfNode(),
33
+ new IgnoreGuardNode(),
34
+ /*region commands*/
35
+ new SetVariableNode(),
36
+ new DeclareCommand(),
37
+ new JumpCommand(this.dialogManager),
38
+ new UnvisitCommand(),
39
+ /*endregion commands*/
40
+ new NormalLineProcessorNode()
41
+ ]);
42
+ }
38
43
  /**
39
44
  * process the dialog line by line and return a presentable string
40
45
  * @param dialogDetail
@@ -7,7 +7,6 @@ import type { OnSetDialogChoiceCallback } from "./DialogManager";
7
7
  export interface IDialogManager {
8
8
  dialogMessageMap: Map<string, DialogDetail>;
9
9
  currentDialogTree: DialogDetail[];
10
- fullCurrentMessage: string;
11
10
  currentMessageMeta: DialogDetail;
12
11
  currentMessage: Writable<string>;
13
12
  currentIndex: number;
@@ -5,7 +5,7 @@ import { SetVariableNode } from "../SetVariableNode";
5
5
  import type { IDialogManager } from "../../../IDialogManager";
6
6
  export declare class JumpCommand implements LineBehaviorNode {
7
7
  setVariableNode: SetVariableNode;
8
- dialogManager: undefined | IDialogManager;
9
- constructor();
8
+ dialogManager: IDialogManager;
9
+ constructor(dialogManager: IDialogManager);
10
10
  process(nodeArgs: LineNodeArguments): LineBehaviorResult;
11
11
  }
@@ -1,16 +1,15 @@
1
1
  import { BehaviorStatus } from "../../core/BehaviorStatus";
2
2
  import { SetVariableNode } from "../SetVariableNode";
3
3
  import { btreeUtils } from "../../core/BTreeUtils";
4
- import { getDialogManager } from "../../../DialogMangerInit";
5
4
  export class JumpCommand {
6
5
  setVariableNode = new SetVariableNode();
7
- dialogManager = undefined;
8
- constructor() {
9
- getDialogManager().then(dm => this.dialogManager = dm);
6
+ dialogManager;
7
+ constructor(dialogManager) {
8
+ this.dialogManager = dialogManager;
10
9
  }
11
10
  process(nodeArgs) {
12
11
  if (this.dialogManager === undefined) {
13
- console.warn('Dialog Manger not yet initialized');
12
+ console.warn("Dialog Manger not yet initialized");
14
13
  return {
15
14
  renderedLine: "",
16
15
  nextState: nodeArgs.initState,
@@ -2,8 +2,7 @@
2
2
  import AresHappy from "../../assets/characters/ares/ares_happy.webp";
3
3
  import { onMount } from "svelte";
4
4
  import { DialogState } from "../../types/pineapple_fiber/DialogState";
5
- import { getDialogManager } from "../dialog_manager/DialogMangerInit";
6
- import type { IDialogManager } from "../dialog_manager/IDialogManager";
5
+ import { dialogManager } from "../dialog_manager/DialogManager";
7
6
  import PinyaCard from "../../ui/elements/PinyaCard/PinyaCard.svelte";
8
7
  import { appState } from "../../ui/templates/index";
9
8
  import CloseIcon from "../../assets/icons/close.svg";
@@ -18,34 +17,31 @@
18
17
 
19
18
  let hidePercent = $state(100);
20
19
  let isHidden = $state(true);
21
- let dialogManager: IDialogManager | undefined = $state(undefined);
22
20
  onMount(() => {
23
- getDialogManager()
24
- .then(dm => {
25
- dialogManager = dm;
26
21
 
27
- dialogManager.currentMessage.subscribe((value) => {
28
- currentMessage = value;
29
- });
22
+ dialogManager.currentMessage.subscribe((value) => {
23
+ currentMessage = value;
24
+ });
30
25
 
31
- dialogManager.currentPortrait.subscribe((value) => {
32
- if (value) {
33
- currentPortrait = value;
34
- }
35
- });
26
+ dialogManager.currentPortrait.subscribe((value) => {
27
+ console.log("sub value", value);
28
+ if (value) {
29
+ currentPortrait = value;
30
+ }
31
+ });
36
32
 
37
- dialogManager.hidePercent.subscribe((value) => {
38
- hidePercent = value * 0.4;
39
- isHidden = false;
40
- });
33
+ dialogManager.hidePercent.subscribe((value) => {
34
+ hidePercent = value * 0.4;
35
+ isHidden = false;
36
+ });
41
37
 
42
- dialogManager.currentReadableState.subscribe((value) => {
43
- isHidden = value === DialogState.Invisible;
44
- });
38
+ dialogManager.currentReadableState.subscribe((value) => {
39
+ isHidden = value === DialogState.Invisible;
40
+ });
45
41
 
46
- dialogManager.update(0);
47
- isMounted = true;
48
- });
42
+ console.log("CAlling update");
43
+ dialogManager.update(0);
44
+ isMounted = true;
49
45
 
50
46
  });
51
47
 
@@ -84,13 +80,13 @@
84
80
  paddingClass=""
85
81
  className="dialog-name"
86
82
  >
87
- <div>
88
- <b class="fake-h1">Turnip</b>
89
- </div>
83
+ <div class="fake-h1">Turnip</div>
90
84
  </PinyaCard>
91
85
  <PinyaCard
92
86
  widthClass="w-full"
93
87
  className="dialog-text"
88
+ colorClass=""
89
+ flexClass=""
94
90
  >
95
91
  <!-- Made for 140 characters, like the original tweets -->
96
92
  {@html currentMessage}
@@ -103,9 +99,8 @@
103
99
  <div class="fab-container" in:slide>
104
100
  <PinyaButton
105
101
  classes="fab"
106
- onclick={()=>{
107
- getDialogManager().then(dm => dm.toggleDialogOverlay());
108
- }}>
102
+ onclick={()=>{dialogManager.toggleDialogOverlay();}}
103
+ >
109
104
  {#if (enableDialogueOverlayValue)}
110
105
  <img class="turnip-icon" src={CloseIcon} alt="interactive floating action button represented as a turnip">
111
106
  {:else }
@@ -121,9 +116,9 @@
121
116
  padding: 1.2lh 2rem 0.5lh;
122
117
  }
123
118
 
124
- :global(.dialog-box *,.dialog-name *) {
125
- font-size: clamp(1em, 5vw, 1.3em);
126
- line-height: 1.5em;
119
+ :global(.dialog-text) {
120
+ font-size: clamp(1em, 3vw, 1.75em);
121
+ line-height: 1.5lh;
127
122
  }
128
123
 
129
124
  .dialog-elements {
@@ -143,16 +138,6 @@
143
138
  transform: translateY(var(--hidePercentHeight));
144
139
  }
145
140
 
146
-
147
- .dialog-padding :global(p) {
148
- font-size: clamp(1em, 5vw, 1.3em) !important;
149
- line-height: 1.5em !important;
150
- }
151
-
152
- .dialog-padding {
153
- padding: clamp(1.5em, 5vw, 1.75em) clamp(0em, 5vw - 0.5em, 2em) 0;
154
- }
155
-
156
141
  :global(.dialog-name) {
157
142
  padding-left: 2rem;
158
143
  padding-right: 2rem;
@@ -194,9 +179,16 @@
194
179
  transform: scaleX(-1);
195
180
  }
196
181
 
182
+ :global(html) {
183
+ --bg-dialog: rgba(255, 247, 225, 0.9);
184
+ }
185
+
186
+ :global(html.dark) {
187
+ --bg-dialog: rgba(76, 71, 59, 0.9);
188
+ }
197
189
 
198
190
  .dialog-box {
199
- background-color: var(--color-surface-500);
191
+ background-color: var(--bg-dialog);
200
192
  position: fixed;
201
193
  bottom: 0;
202
194
  width: var(--dialog-box-width); /*75em + 4em padding*/
@@ -205,12 +197,6 @@
205
197
  border-radius: 1rem;
206
198
  }
207
199
 
208
- .dark .dialog-box {
209
- background-color: rgb(var(--color-surface-900) / 0.95);
210
- --tw-ring-color: rgb(var(--color-text-400));
211
- /*background-color: red;*/
212
- }
213
-
214
200
  :global(.fab) {
215
201
  /*@apply btn preset-filled-tertiary-500;*/
216
202
  background-color: var(--color-tertiary-500);
@@ -224,7 +210,7 @@
224
210
 
225
211
  .fab-container {
226
212
  position: fixed;
227
- bottom: 0;
213
+ bottom: 0;
228
214
  }
229
215
 
230
216
  .fab-container:dir(ltr) {
@@ -20,7 +20,7 @@
20
20
  import Toast from "./toast/Toast.svelte";
21
21
  import DialogOverlay from "../dialog_overlay/DialogOverlay.svelte";
22
22
  import { fade } from "svelte/transition";
23
- import { getDialogManager } from "../dialog_manager/DialogMangerInit";
23
+ import { dialogManager } from "../dialog_manager/DialogManager";
24
24
 
25
25
  interface Props {
26
26
  showDialogByDefault?: boolean;
@@ -77,7 +77,7 @@
77
77
 
78
78
  <!--todo: turn off hidden when it's time-->
79
79
  <button class="fab" onclick={()=>{
80
- getDialogManager().then(dm => dm.toggleDialogOverlay());
80
+ dialogManager.toggleDialogOverlay();
81
81
  }}>
82
82
  {#if (enableDialogueOverlayValue)}
83
83
  <img class="turnip-icon" src={CloseIcon} alt="interactive floating action button represented as a turnip">
package/dist/index.d.ts CHANGED
@@ -11,4 +11,4 @@ export * from "./types/pineapple_fiber/DialogDetail";
11
11
  export * from "./util/util";
12
12
  export * from "./api/index";
13
13
  export type { IDialogManager } from "./components/dialog_manager/IDialogManager";
14
- export { getDialogManager } from "./components/dialog_manager/DialogMangerInit";
14
+ export { dialogManager } from "./components/dialog_manager/DialogManager";
package/dist/index.js CHANGED
@@ -11,4 +11,4 @@ export * from "./types/pineapple_fiber/PortraitType";
11
11
  export * from "./types/pineapple_fiber/DialogDetail";
12
12
  export * from "./util/util";
13
13
  export * from "./api/index";
14
- export { getDialogManager } from "./components/dialog_manager/DialogMangerInit";
14
+ export { dialogManager } from "./components/dialog_manager/DialogManager";
@@ -44,7 +44,7 @@ const pineappleWeaverRun = () => {
44
44
  const template = `// this file was generated by PineappleWeaver.ts
45
45
  // do not edit!
46
46
 
47
- import { type DialogDetail, getDialogManager, PortraitType } from "@turnipxenon/pineapple";
47
+ import { type DialogDetail, dialogManager, PortraitType } from "@turnipxenon/pineapple";
48
48
 
49
49
  class _${fileName}Yarn {
50
50
  dialogList: DialogDetail[] = [
@@ -53,7 +53,7 @@ ${dialogDetailListToString(dialogDetailList)}
53
53
 
54
54
  /* Remember to call DialogManager.subscribeToSetDialogChoice before calling this in Svelte */
55
55
  setDialogTree = () => {
56
- getDialogManager().then((dm) => dm?.setDialogTree(this.dialogList));
56
+ dialogManager.setDialogTree(this.dialogList);
57
57
  };
58
58
  }
59
59
 
@@ -22,13 +22,15 @@ html {
22
22
  height: calc(var(--dialog-box-height) + 4em);
23
23
  }
24
24
 
25
- a.dialog-choice {
25
+ .dialog-box a, .dialog-box b, .dialog-box i {
26
26
  font-size: inherit;
27
+ }
28
+
29
+ a.dialog-choice {
27
30
  cursor: url("$pkg/assets/icons/chat-cursor.svg"), auto;
28
31
  }
29
32
 
30
33
  a.external-link {
31
- font-size: inherit;
32
34
  cursor: url("$pkg/assets/icons/external-link.svg"), auto;
33
35
  }
34
36
 
@@ -250,7 +250,7 @@ blockquote {
250
250
  filter: brightness(140%);
251
251
  }
252
252
 
253
- h1, h2, h3, h4, h5, h6, .fake-h2, .fake-h3, .fake-h4 {
253
+ h1, h2, h3, h4, h5, h6, .fake-h1, .fake-h2, .fake-h3, .fake-h4 {
254
254
  text-align: center;
255
255
  margin-top: 0;
256
256
  font-weight: bolder;
@@ -265,7 +265,7 @@ h1 + p, h2 + p, h3 + p, h4 + p, h5 + p, h6 + p, .fake-h2 + p, .fake-h3 + p, .fak
265
265
  margin-top: 0.5lh;
266
266
  }
267
267
 
268
- h1 {
268
+ h1, .fake-h1 {
269
269
  @apply text-4xl;
270
270
  }
271
271
 
@@ -8,14 +8,15 @@ let {
8
8
  flexClass = "flex flex-col",
9
9
  widthClass = "w-full max-w-md",
10
10
  borderClass = "border-[2px] border-primary-500 dark:border-0",
11
+ colorClass = "bg-surface-200 dark:bg-surface-900",
11
12
  marginClass = "",
12
13
  className,
13
14
  includeDataNoSnippet = false,
14
15
  children
15
16
  }: PinyaCardProps = $props();
16
17
 
17
- let cardClass = $derived(`card bg-surface-200 dark:bg-surface-900 text-start rounded-xl
18
- ${paddingClass} ${flexClass} ${className} ${widthClass} ${borderClass} ${marginClass}`);
18
+ let cardClass = $derived(`card text-start rounded-xl
19
+ ${paddingClass} ${flexClass} ${className} ${widthClass} ${borderClass} ${marginClass} ${colorClass}`);
19
20
  </script>
20
21
 
21
22
  {#if includeDataNoSnippet}
@@ -6,5 +6,6 @@ export interface PinyaCardProps extends WrapperProps {
6
6
  widthClass?: string;
7
7
  borderClass?: string;
8
8
  marginClass?: string;
9
+ colorClass?: string;
9
10
  includeDataNoSnippet?: boolean;
10
11
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turnipxenon/pineapple",
3
3
  "description": "personal package for base styling for other personal projects",
4
- "version": "3.1.0-alpha.5",
4
+ "version": "3.1.0-alpha.7",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && yarn package",
@@ -22,13 +22,15 @@ html {
22
22
  height: calc(var(--dialog-box-height) + 4em);
23
23
  }
24
24
 
25
- a.dialog-choice {
25
+ .dialog-box a, .dialog-box b, .dialog-box i {
26
26
  font-size: inherit;
27
+ }
28
+
29
+ a.dialog-choice {
27
30
  cursor: url("$pkg/assets/icons/chat-cursor.svg"), auto;
28
31
  }
29
32
 
30
33
  a.external-link {
31
- font-size: inherit;
32
34
  cursor: url("$pkg/assets/icons/external-link.svg"), auto;
33
35
  }
34
36
 
@@ -1,2 +0,0 @@
1
- import type { IDialogManager } from "./IDialogManager";
2
- export declare const getDialogManager: () => Promise<IDialogManager>;
@@ -1,21 +0,0 @@
1
- /**
2
- * strictly must be declared last! or you might receive a weird error that looks like:
3
- *
4
- * 2:04:21 AM [vite] Error when evaluating SSR module /src/lib/components/dialog_manager/DialogManagerStore.ts:
5
- * |- TypeError: Cannot read properties of undefined (reading '0')
6
- * at <instance_members_initializer> (/src/lib/components/dialog_manager/DialogManager.ts:38:67)
7
- * at new DialogManager (/src/lib/components/dialog_manager/DialogManager.ts:53:14)
8
- * at eval (/src/lib/components/dialog_manager/DialogManagerStore.ts:15:23)
9
- * at async instantiateModule (file:///C:/Users/Pumpkin/Projects/Web/pineapple/node_modules/vite/dist/node/chunks/dep-934dbc7c.js:54360:9)
10
- *
11
- * what this means is that one member of dialogManager cannot be initialized. in our case, it was the
12
- * defaultDialogMessage not yet being initialized
13
- */
14
- let _dialogManager = undefined;
15
- export const getDialogManager = async () => {
16
- if (_dialogManager === undefined) {
17
- const dm = await import('./DialogManager');
18
- _dialogManager = new dm.DialogManager();
19
- }
20
- return _dialogManager;
21
- };
@@ -1 +0,0 @@
1
- export * from "./DialogMangerInit";
@@ -1 +0,0 @@
1
- export * from "./DialogMangerInit";