@almadar/std 1.0.0 → 1.0.1

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 (40) hide show
  1. package/dist/behaviors/async.d.ts +8 -8
  2. package/dist/behaviors/async.js +548 -500
  3. package/dist/behaviors/async.js.map +1 -1
  4. package/dist/behaviors/data-management.d.ts +11 -19
  5. package/dist/behaviors/data-management.js +468 -449
  6. package/dist/behaviors/data-management.js.map +1 -1
  7. package/dist/behaviors/feedback.d.ts +6 -6
  8. package/dist/behaviors/feedback.js +312 -278
  9. package/dist/behaviors/feedback.js.map +1 -1
  10. package/dist/behaviors/game-core.d.ts +11 -12
  11. package/dist/behaviors/game-core.js +357 -406
  12. package/dist/behaviors/game-core.js.map +1 -1
  13. package/dist/behaviors/game-entity.d.ts +13 -14
  14. package/dist/behaviors/game-entity.js +622 -592
  15. package/dist/behaviors/game-entity.js.map +1 -1
  16. package/dist/behaviors/game-ui.d.ts +9 -10
  17. package/dist/behaviors/game-ui.js +522 -459
  18. package/dist/behaviors/game-ui.js.map +1 -1
  19. package/dist/behaviors/index.d.ts +3 -3
  20. package/dist/behaviors/index.js +3876 -3843
  21. package/dist/behaviors/index.js.map +1 -1
  22. package/dist/behaviors/registry.d.ts +14 -24
  23. package/dist/behaviors/registry.js +3868 -3803
  24. package/dist/behaviors/registry.js.map +1 -1
  25. package/dist/behaviors/types.d.ts +14 -138
  26. package/dist/behaviors/types.js +10 -47
  27. package/dist/behaviors/types.js.map +1 -1
  28. package/dist/behaviors/ui-interaction.d.ts +13 -20
  29. package/dist/behaviors/ui-interaction.js +961 -1043
  30. package/dist/behaviors/ui-interaction.js.map +1 -1
  31. package/dist/index.d.ts +44 -11
  32. package/dist/index.js +3913 -3870
  33. package/dist/index.js.map +1 -1
  34. package/dist/modules/index.js +11 -0
  35. package/dist/modules/index.js.map +1 -1
  36. package/dist/modules/str.js +11 -0
  37. package/dist/modules/str.js.map +1 -1
  38. package/dist/registry.js +11 -0
  39. package/dist/registry.js.map +1 -1
  40. package/package.json +3 -2
@@ -1,300 +1,334 @@
1
1
  // behaviors/feedback.ts
2
2
  var NOTIFICATION_BEHAVIOR = {
3
- name: "std/Notification",
4
- category: "feedback",
3
+ name: "std-notification",
4
+ version: "1.0.0",
5
5
  description: "Toast notification with auto-dismiss",
6
- suggestedFor: [
7
- "Success messages",
8
- "Error alerts",
9
- "Status updates",
10
- "User feedback"
11
- ],
12
- dataEntities: [
6
+ orbitals: [
13
7
  {
14
- name: "NotificationState",
15
- runtime: true,
16
- singleton: true,
17
- fields: [
18
- { name: "notifications", type: "array", default: [] },
19
- { name: "currentId", type: "number", default: 0 }
20
- ]
21
- }
22
- ],
23
- stateMachine: {
24
- initial: "Hidden",
25
- states: [
26
- { name: "Hidden", isInitial: true },
27
- { name: "Visible" },
28
- { name: "Dismissing" }
29
- ],
30
- events: [
31
- { key: "SHOW" },
32
- { key: "HIDE" },
33
- { key: "DISMISS" },
34
- { key: "AUTO_DISMISS" }
35
- ],
36
- transitions: [
37
- {
38
- from: "*",
39
- event: "SHOW",
40
- effects: [
41
- [
42
- "let",
43
- [["id", ["+", "@entity.currentId", 1]]],
44
- [
45
- "do",
46
- ["set", "@entity.currentId", "@id"],
47
- [
48
- "set",
49
- "@entity.notifications",
50
- ["array/append", "@entity.notifications", {
51
- id: "@id",
52
- type: "@payload.type",
53
- message: "@payload.message",
54
- title: "@payload.title"
55
- }]
56
- ],
57
- [
58
- "when",
59
- [">", "@config.autoDismissMs", 0],
60
- ["async/delay", "@config.autoDismissMs", ["emit", "AUTO_DISMISS", { id: "@id" }]]
61
- ]
62
- ]
63
- ]
64
- ]
65
- },
66
- {
67
- event: "DISMISS",
68
- effects: [
69
- [
70
- "set",
71
- "@entity.notifications",
72
- ["array/filter", "@entity.notifications", ["fn", "n", ["!=", "@n.id", "@payload.id"]]]
73
- ]
74
- ]
75
- },
76
- {
77
- event: "AUTO_DISMISS",
78
- effects: [
79
- [
80
- "set",
81
- "@entity.notifications",
82
- ["array/filter", "@entity.notifications", ["fn", "n", ["!=", "@n.id", "@payload.id"]]]
83
- ]
8
+ name: "NotificationOrbital",
9
+ entity: {
10
+ name: "NotificationState",
11
+ persistence: "runtime",
12
+ fields: [
13
+ { name: "id", type: "string", required: true },
14
+ { name: "notifications", type: "array", default: [] },
15
+ { name: "currentId", type: "number", default: 0 },
16
+ { name: "autoDismissMs", type: "number", default: 5e3 }
84
17
  ]
85
18
  },
86
- {
87
- event: "HIDE",
88
- effects: [
89
- ["set", "@entity.notifications", []]
90
- ]
91
- }
92
- ]
93
- },
94
- configSchema: {
95
- required: [],
96
- optional: [
97
- { name: "autoDismissMs", type: "number", description: "Auto dismiss delay (0 = no auto)", default: 5e3 },
98
- { name: "position", type: "string", description: "Toast position", default: "top-right", enum: ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"] },
99
- { name: "maxVisible", type: "number", description: "Maximum visible notifications", default: 5 }
100
- ]
101
- }
19
+ traits: [
20
+ {
21
+ name: "Notification",
22
+ linkedEntity: "NotificationState",
23
+ category: "interaction",
24
+ stateMachine: {
25
+ states: [
26
+ { name: "Hidden", isInitial: true },
27
+ { name: "Visible" },
28
+ { name: "Dismissing" }
29
+ ],
30
+ events: [
31
+ { key: "SHOW", name: "Show" },
32
+ { key: "HIDE", name: "Hide" },
33
+ { key: "DISMISS", name: "Dismiss" },
34
+ { key: "AUTO_DISMISS", name: "Auto Dismiss" }
35
+ ],
36
+ transitions: [
37
+ {
38
+ from: "Hidden",
39
+ to: "Visible",
40
+ event: "SHOW",
41
+ effects: [
42
+ [
43
+ "let",
44
+ [["id", ["+", "@entity.currentId", 1]]],
45
+ [
46
+ "do",
47
+ ["set", "@entity.currentId", "@id"],
48
+ [
49
+ "set",
50
+ "@entity.notifications",
51
+ ["array/append", "@entity.notifications", {
52
+ id: "@id",
53
+ type: "@payload.type",
54
+ message: "@payload.message",
55
+ title: "@payload.title"
56
+ }]
57
+ ],
58
+ [
59
+ "when",
60
+ [">", "@entity.autoDismissMs", 0],
61
+ ["async/delay", "@entity.autoDismissMs", ["emit", "AUTO_DISMISS", { id: "@id" }]]
62
+ ]
63
+ ]
64
+ ]
65
+ ]
66
+ },
67
+ {
68
+ from: "Visible",
69
+ to: "Visible",
70
+ event: "SHOW",
71
+ effects: [
72
+ [
73
+ "let",
74
+ [["id", ["+", "@entity.currentId", 1]]],
75
+ [
76
+ "do",
77
+ ["set", "@entity.currentId", "@id"],
78
+ [
79
+ "set",
80
+ "@entity.notifications",
81
+ ["array/append", "@entity.notifications", {
82
+ id: "@id",
83
+ type: "@payload.type",
84
+ message: "@payload.message",
85
+ title: "@payload.title"
86
+ }]
87
+ ],
88
+ [
89
+ "when",
90
+ [">", "@entity.autoDismissMs", 0],
91
+ ["async/delay", "@entity.autoDismissMs", ["emit", "AUTO_DISMISS", { id: "@id" }]]
92
+ ]
93
+ ]
94
+ ]
95
+ ]
96
+ },
97
+ {
98
+ from: "Visible",
99
+ to: "Visible",
100
+ event: "DISMISS",
101
+ effects: [
102
+ [
103
+ "set",
104
+ "@entity.notifications",
105
+ ["array/filter", "@entity.notifications", ["fn", "n", ["!=", "@n.id", "@payload.id"]]]
106
+ ]
107
+ ]
108
+ },
109
+ {
110
+ from: "Visible",
111
+ to: "Visible",
112
+ event: "AUTO_DISMISS",
113
+ effects: [
114
+ [
115
+ "set",
116
+ "@entity.notifications",
117
+ ["array/filter", "@entity.notifications", ["fn", "n", ["!=", "@n.id", "@payload.id"]]]
118
+ ]
119
+ ]
120
+ },
121
+ {
122
+ from: "Visible",
123
+ to: "Hidden",
124
+ event: "HIDE",
125
+ effects: [["set", "@entity.notifications", []]]
126
+ }
127
+ ]
128
+ }
129
+ }
130
+ ],
131
+ pages: []
132
+ }
133
+ ]
102
134
  };
103
135
  var CONFIRMATION_BEHAVIOR = {
104
- name: "std/Confirmation",
105
- category: "feedback",
136
+ name: "std-confirmation",
137
+ version: "1.0.0",
106
138
  description: "Confirmation dialog with confirm/cancel actions",
107
- suggestedFor: [
108
- "Delete confirmation",
109
- "Destructive actions",
110
- "Important decisions",
111
- "Exit warnings"
112
- ],
113
- dataEntities: [
139
+ orbitals: [
114
140
  {
115
- name: "ConfirmationState",
116
- runtime: true,
117
- singleton: true,
118
- fields: [
119
- { name: "title", type: "string", default: "" },
120
- { name: "message", type: "string", default: "" },
121
- { name: "pendingAction", type: "object", default: null }
122
- ]
123
- }
124
- ],
125
- stateMachine: {
126
- initial: "Closed",
127
- states: [
128
- { name: "Closed", isInitial: true },
129
- { name: "Open" }
130
- ],
131
- events: [
132
- { key: "REQUEST" },
133
- { key: "CONFIRM" },
134
- { key: "CANCEL" }
135
- ],
136
- transitions: [
137
- {
138
- from: "Closed",
139
- to: "Open",
140
- event: "REQUEST",
141
- effects: [
142
- ["set", "@entity.title", "@payload.title"],
143
- ["set", "@entity.message", "@payload.message"],
144
- ["set", "@entity.pendingAction", "@payload.onConfirm"],
145
- ["render-ui", "modal", {
146
- type: "confirmation",
147
- title: "@entity.title",
148
- message: "@entity.message",
149
- confirmLabel: "@config.confirmLabel",
150
- cancelLabel: "@config.cancelLabel",
151
- confirmVariant: "@config.confirmVariant"
152
- }]
153
- ]
154
- },
155
- {
156
- from: "Open",
157
- to: "Closed",
158
- event: "CONFIRM",
159
- effects: [
160
- ["render-ui", "modal", null],
161
- ["when", "@entity.pendingAction", ["emit", "@entity.pendingAction.event", "@entity.pendingAction.payload"]],
162
- ["set", "@entity.pendingAction", null]
141
+ name: "ConfirmationOrbital",
142
+ entity: {
143
+ name: "ConfirmationState",
144
+ persistence: "runtime",
145
+ fields: [
146
+ { name: "id", type: "string", required: true },
147
+ { name: "title", type: "string", default: "" },
148
+ { name: "message", type: "string", default: "" },
149
+ { name: "pendingAction", type: "object", default: null },
150
+ { name: "confirmLabel", type: "string", default: "Confirm" },
151
+ { name: "cancelLabel", type: "string", default: "Cancel" },
152
+ { name: "confirmVariant", type: "string", default: "danger" }
163
153
  ]
164
154
  },
165
- {
166
- from: "Open",
167
- to: "Closed",
168
- event: "CANCEL",
169
- effects: [
170
- ["render-ui", "modal", null],
171
- ["set", "@entity.pendingAction", null]
172
- ]
173
- }
174
- ]
175
- },
176
- configSchema: {
177
- required: [],
178
- optional: [
179
- { name: "confirmLabel", type: "string", description: "Confirm button label", default: "Confirm" },
180
- { name: "cancelLabel", type: "string", description: "Cancel button label", default: "Cancel" },
181
- { name: "confirmVariant", type: "string", description: "Confirm button variant", default: "primary", enum: ["primary", "danger", "warning"] }
182
- ]
183
- }
155
+ traits: [
156
+ {
157
+ name: "Confirmation",
158
+ linkedEntity: "ConfirmationState",
159
+ category: "interaction",
160
+ stateMachine: {
161
+ states: [
162
+ { name: "Closed", isInitial: true },
163
+ { name: "Open" }
164
+ ],
165
+ events: [
166
+ { key: "REQUEST", name: "Request" },
167
+ { key: "CONFIRM", name: "Confirm" },
168
+ { key: "CANCEL", name: "Cancel" }
169
+ ],
170
+ transitions: [
171
+ {
172
+ from: "Closed",
173
+ to: "Open",
174
+ event: "REQUEST",
175
+ effects: [
176
+ ["set", "@entity.title", "@payload.title"],
177
+ ["set", "@entity.message", "@payload.message"],
178
+ ["set", "@entity.pendingAction", "@payload.onConfirm"],
179
+ ["render-ui", "modal", {
180
+ type: "confirm-dialog",
181
+ isOpen: true,
182
+ onClose: "CANCEL",
183
+ onConfirm: "CONFIRM",
184
+ title: "@entity.title",
185
+ message: "@entity.message",
186
+ confirmText: "@entity.confirmLabel",
187
+ cancelText: "@entity.cancelLabel",
188
+ variant: "@entity.confirmVariant"
189
+ }]
190
+ ]
191
+ },
192
+ {
193
+ from: "Open",
194
+ to: "Closed",
195
+ event: "CONFIRM",
196
+ effects: [
197
+ ["when", "@entity.pendingAction", ["emit", "@entity.pendingAction.event", "@entity.pendingAction.payload"]],
198
+ ["set", "@entity.pendingAction", null]
199
+ ]
200
+ },
201
+ {
202
+ from: "Open",
203
+ to: "Closed",
204
+ event: "CANCEL",
205
+ effects: [["set", "@entity.pendingAction", null]]
206
+ }
207
+ ]
208
+ }
209
+ }
210
+ ],
211
+ pages: []
212
+ }
213
+ ]
184
214
  };
185
215
  var UNDO_BEHAVIOR = {
186
- name: "std/Undo",
187
- category: "feedback",
216
+ name: "std-undo",
217
+ version: "1.0.0",
188
218
  description: "Undo/redo stack for reversible actions",
189
- suggestedFor: [
190
- "Document editing",
191
- "Form changes",
192
- "Canvas operations",
193
- "Reversible actions"
194
- ],
195
- dataEntities: [
219
+ orbitals: [
196
220
  {
197
- name: "UndoState",
198
- runtime: true,
199
- singleton: true,
200
- fields: [
201
- { name: "undoStack", type: "array", default: [] },
202
- { name: "redoStack", type: "array", default: [] }
203
- ]
204
- }
205
- ],
206
- stateMachine: {
207
- initial: "Ready",
208
- states: [
209
- { name: "Ready", isInitial: true }
210
- ],
211
- events: [
212
- { key: "PUSH" },
213
- { key: "UNDO" },
214
- { key: "REDO" },
215
- { key: "CLEAR" }
216
- ],
217
- transitions: [
218
- {
219
- event: "PUSH",
220
- effects: [
221
- [
222
- "set",
223
- "@entity.undoStack",
224
- [
225
- "array/slice",
226
- ["array/prepend", "@entity.undoStack", {
227
- action: "@payload.action",
228
- data: "@payload.data",
229
- reverseAction: "@payload.reverseAction",
230
- reverseData: "@payload.reverseData",
231
- description: "@payload.description"
232
- }],
233
- 0,
234
- "@config.maxHistory"
235
- ]
236
- ],
237
- ["set", "@entity.redoStack", []],
238
- [
239
- "when",
240
- "@config.showToast",
241
- ["emit", "NOTIFY", {
242
- type: "info",
243
- message: ["str/concat", "@payload.description", " - Click to undo"],
244
- action: { label: "Undo", event: "UNDO" }
245
- }]
246
- ]
247
- ]
248
- },
249
- {
250
- event: "UNDO",
251
- guard: [">", ["array/len", "@entity.undoStack"], 0],
252
- effects: [
253
- [
254
- "let",
255
- [["action", ["array/first", "@entity.undoStack"]]],
256
- [
257
- "do",
258
- ["set", "@entity.undoStack", ["array/slice", "@entity.undoStack", 1]],
259
- ["set", "@entity.redoStack", ["array/prepend", "@entity.redoStack", "@action"]],
260
- ["emit", "@action.reverseAction", "@action.reverseData"]
261
- ]
262
- ]
221
+ name: "UndoOrbital",
222
+ entity: {
223
+ name: "UndoState",
224
+ persistence: "runtime",
225
+ fields: [
226
+ { name: "id", type: "string", required: true },
227
+ { name: "undoStack", type: "array", default: [] },
228
+ { name: "redoStack", type: "array", default: [] },
229
+ { name: "maxHistory", type: "number", default: 50 },
230
+ { name: "showToast", type: "boolean", default: true }
263
231
  ]
264
232
  },
265
- {
266
- event: "REDO",
267
- guard: [">", ["array/len", "@entity.redoStack"], 0],
268
- effects: [
269
- [
270
- "let",
271
- [["action", ["array/first", "@entity.redoStack"]]],
272
- [
273
- "do",
274
- ["set", "@entity.redoStack", ["array/slice", "@entity.redoStack", 1]],
275
- ["set", "@entity.undoStack", ["array/prepend", "@entity.undoStack", "@action"]],
276
- ["emit", "@action.action", "@action.data"]
233
+ traits: [
234
+ {
235
+ name: "Undo",
236
+ linkedEntity: "UndoState",
237
+ category: "interaction",
238
+ stateMachine: {
239
+ states: [{ name: "Ready", isInitial: true }],
240
+ events: [
241
+ { key: "PUSH", name: "Push" },
242
+ { key: "UNDO", name: "Undo" },
243
+ { key: "REDO", name: "Redo" },
244
+ { key: "CLEAR", name: "Clear" }
245
+ ],
246
+ transitions: [
247
+ {
248
+ from: "Ready",
249
+ to: "Ready",
250
+ event: "PUSH",
251
+ effects: [
252
+ [
253
+ "set",
254
+ "@entity.undoStack",
255
+ [
256
+ "array/slice",
257
+ ["array/prepend", "@entity.undoStack", {
258
+ action: "@payload.action",
259
+ data: "@payload.data",
260
+ reverseAction: "@payload.reverseAction",
261
+ reverseData: "@payload.reverseData",
262
+ description: "@payload.description"
263
+ }],
264
+ 0,
265
+ "@entity.maxHistory"
266
+ ]
267
+ ],
268
+ ["set", "@entity.redoStack", []],
269
+ [
270
+ "when",
271
+ "@entity.showToast",
272
+ ["emit", "NOTIFY", {
273
+ type: "info",
274
+ message: ["str/concat", "@payload.description", " - Click to undo"],
275
+ action: { label: "Undo", event: "UNDO" }
276
+ }]
277
+ ]
278
+ ]
279
+ },
280
+ {
281
+ from: "Ready",
282
+ to: "Ready",
283
+ event: "UNDO",
284
+ guard: [">", ["array/len", "@entity.undoStack"], 0],
285
+ effects: [
286
+ [
287
+ "let",
288
+ [["action", ["array/first", "@entity.undoStack"]]],
289
+ [
290
+ "do",
291
+ ["set", "@entity.undoStack", ["array/slice", "@entity.undoStack", 1]],
292
+ ["set", "@entity.redoStack", ["array/prepend", "@entity.redoStack", "@action"]],
293
+ ["emit", "@action.reverseAction", "@action.reverseData"]
294
+ ]
295
+ ]
296
+ ]
297
+ },
298
+ {
299
+ from: "Ready",
300
+ to: "Ready",
301
+ event: "REDO",
302
+ guard: [">", ["array/len", "@entity.redoStack"], 0],
303
+ effects: [
304
+ [
305
+ "let",
306
+ [["action", ["array/first", "@entity.redoStack"]]],
307
+ [
308
+ "do",
309
+ ["set", "@entity.redoStack", ["array/slice", "@entity.redoStack", 1]],
310
+ ["set", "@entity.undoStack", ["array/prepend", "@entity.undoStack", "@action"]],
311
+ ["emit", "@action.action", "@action.data"]
312
+ ]
313
+ ]
314
+ ]
315
+ },
316
+ {
317
+ from: "Ready",
318
+ to: "Ready",
319
+ event: "CLEAR",
320
+ effects: [
321
+ ["set", "@entity.undoStack", []],
322
+ ["set", "@entity.redoStack", []]
323
+ ]
324
+ }
277
325
  ]
278
- ]
279
- ]
280
- },
281
- {
282
- event: "CLEAR",
283
- effects: [
284
- ["set", "@entity.undoStack", []],
285
- ["set", "@entity.redoStack", []]
286
- ]
287
- }
288
- ]
289
- },
290
- configSchema: {
291
- required: [],
292
- optional: [
293
- { name: "maxHistory", type: "number", description: "Maximum undo history", default: 50 },
294
- { name: "showToast", type: "boolean", description: "Show undo toast", default: true },
295
- { name: "toastDurationMs", type: "number", description: "Toast display duration", default: 5e3 }
296
- ]
297
- }
326
+ }
327
+ }
328
+ ],
329
+ pages: []
330
+ }
331
+ ]
298
332
  };
299
333
  var FEEDBACK_BEHAVIORS = [
300
334
  NOTIFICATION_BEHAVIOR,