@operato/scene-storage 10.0.0-beta.33 → 10.0.0-beta.34

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 (89) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/crane-3d.d.ts +14 -0
  3. package/dist/crane-3d.js +238 -0
  4. package/dist/crane-3d.js.map +1 -0
  5. package/dist/crane.d.ts +157 -0
  6. package/dist/crane.js +440 -0
  7. package/dist/crane.js.map +1 -0
  8. package/dist/index.d.ts +13 -6
  9. package/dist/index.js +9 -4
  10. package/dist/index.js.map +1 -1
  11. package/dist/mobile-storage-rack.d.ts +17 -0
  12. package/dist/mobile-storage-rack.js +55 -0
  13. package/dist/mobile-storage-rack.js.map +1 -0
  14. package/dist/rack-column.d.ts +35 -0
  15. package/dist/rack-column.js +258 -0
  16. package/dist/rack-column.js.map +1 -0
  17. package/dist/rack-grid-3d.d.ts +13 -0
  18. package/dist/rack-grid-3d.js +94 -0
  19. package/dist/rack-grid-3d.js.map +1 -0
  20. package/dist/rack-grid-cell.d.ts +341 -0
  21. package/dist/rack-grid-cell.js +321 -0
  22. package/dist/rack-grid-cell.js.map +1 -0
  23. package/dist/rack-grid-helpers.d.ts +28 -0
  24. package/dist/rack-grid-helpers.js +71 -0
  25. package/dist/rack-grid-helpers.js.map +1 -0
  26. package/dist/rack-grid-location.d.ts +37 -0
  27. package/dist/rack-grid-location.js +227 -0
  28. package/dist/rack-grid-location.js.map +1 -0
  29. package/dist/rack-grid.d.ts +80 -0
  30. package/dist/rack-grid.js +829 -0
  31. package/dist/rack-grid.js.map +1 -0
  32. package/dist/stock.d.ts +78 -0
  33. package/dist/stock.js +333 -0
  34. package/dist/stock.js.map +1 -0
  35. package/dist/{rack-cell-3d.d.ts → storage-cell-3d.d.ts} +1 -1
  36. package/dist/{rack-cell-3d.js → storage-cell-3d.js} +3 -3
  37. package/dist/storage-cell-3d.js.map +1 -0
  38. package/dist/{rack-cell.d.ts → storage-cell.d.ts} +12 -6
  39. package/dist/{rack-cell.js → storage-cell.js} +9 -9
  40. package/dist/storage-cell.js.map +1 -0
  41. package/dist/{asrs-rack-3d.d.ts → storage-rack-3d.d.ts} +1 -1
  42. package/dist/{asrs-rack-3d.js → storage-rack-3d.js} +4 -4
  43. package/dist/storage-rack-3d.js.map +1 -0
  44. package/dist/{asrs-rack.d.ts → storage-rack.d.ts} +22 -16
  45. package/dist/{asrs-rack.js → storage-rack.js} +32 -26
  46. package/dist/storage-rack.js.map +1 -0
  47. package/dist/templates/index.d.ts +60 -0
  48. package/dist/templates/index.js +59 -17
  49. package/dist/templates/index.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/crane-3d.ts +273 -0
  52. package/src/crane.ts +538 -0
  53. package/src/index.ts +13 -6
  54. package/src/mobile-storage-rack.ts +56 -0
  55. package/src/rack-column.ts +340 -0
  56. package/src/rack-grid-3d.ts +128 -0
  57. package/src/rack-grid-cell.ts +404 -0
  58. package/src/rack-grid-helpers.ts +77 -0
  59. package/src/rack-grid-location.ts +286 -0
  60. package/src/rack-grid.ts +994 -0
  61. package/src/stock.ts +426 -0
  62. package/src/{rack-cell-3d.ts → storage-cell-3d.ts} +2 -2
  63. package/src/{rack-cell.ts → storage-cell.ts} +19 -13
  64. package/src/{asrs-rack-3d.ts → storage-rack-3d.ts} +3 -3
  65. package/src/{asrs-rack.ts → storage-rack.ts} +31 -25
  66. package/src/templates/index.ts +59 -17
  67. package/test/test-rack-grid-crane.ts +212 -0
  68. package/test/test-rack-grid.ts +77 -0
  69. package/test/{test-asrs-crane.ts → test-storage-rack-crane.ts} +8 -8
  70. package/translations/en.json +55 -7
  71. package/translations/ja.json +52 -4
  72. package/translations/ko.json +52 -4
  73. package/translations/ms.json +55 -7
  74. package/translations/zh.json +52 -4
  75. package/tsconfig.tsbuildinfo +1 -1
  76. package/dist/asrs-crane-3d.d.ts +0 -17
  77. package/dist/asrs-crane-3d.js +0 -181
  78. package/dist/asrs-crane-3d.js.map +0 -1
  79. package/dist/asrs-crane.d.ts +0 -98
  80. package/dist/asrs-crane.js +0 -216
  81. package/dist/asrs-crane.js.map +0 -1
  82. package/dist/asrs-rack-3d.js.map +0 -1
  83. package/dist/asrs-rack.js.map +0 -1
  84. package/dist/rack-cell-3d.js.map +0 -1
  85. package/dist/rack-cell.js.map +0 -1
  86. package/src/asrs-crane-3d.ts +0 -211
  87. package/src/asrs-crane.ts +0 -275
  88. /package/icons/{asrs-crane.png → crane.png} +0 -0
  89. /package/icons/{asrs-rack.png → storage-rack.png} +0 -0
@@ -0,0 +1,286 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ *
4
+ * RackGrid location management utilities.
5
+ * Extracted from rack-table.ts for separation of concerns.
6
+ */
7
+
8
+ import type { RackGridCell } from './rack-grid-cell.js'
9
+
10
+ /**
11
+ * Classify cells by their row index.
12
+ */
13
+ export function classifyByRow(cells: RackGridCell[]): RackGridCell[][] {
14
+ const classified: RackGridCell[][] = []
15
+
16
+ cells.forEach(c => {
17
+ const { row, column } = c.index
18
+
19
+ if (!classified[row]) {
20
+ classified[row] = []
21
+ }
22
+
23
+ classified[row][column] = c
24
+ })
25
+
26
+ return classified
27
+ }
28
+
29
+ /**
30
+ * Find aisle rows (rows where all cells are empty).
31
+ */
32
+ export function findAisle(rows?: RackGridCell[][]): RackGridCell[][] {
33
+ if (!rows) {
34
+ return []
35
+ }
36
+
37
+ return rows.filter(r => {
38
+ return r[0] && r[0].isAisle
39
+ })
40
+ }
41
+
42
+ /**
43
+ * Get indices of aisle rows.
44
+ */
45
+ export function getAisleRowIndices(rows: RackGridCell[][]): number[] {
46
+ const aisles = findAisle(rows)
47
+ const aisleRowIndices: number[] = []
48
+
49
+ aisles.forEach(aisle => {
50
+ aisleRowIndices.push(rows.indexOf(aisle))
51
+ })
52
+
53
+ return aisleRowIndices
54
+ }
55
+
56
+ /**
57
+ * Classify rows into sections separated by aisle rows.
58
+ */
59
+ export function classifyCellsBySection(
60
+ rows: RackGridCell[][],
61
+ aisleRowIndices: number[]
62
+ ): RackGridCell[][][] {
63
+ const sections: RackGridCell[][][] = []
64
+ let wasAisle = false
65
+ let section!: RackGridCell[][]
66
+
67
+ rows.forEach((row, i) => {
68
+ const isAisle = aisleRowIndices.indexOf(i) > -1
69
+
70
+ if (!(wasAisle || isAisle)) {
71
+ section = []
72
+ sections.push(section)
73
+ }
74
+
75
+ wasAisle = isAisle
76
+
77
+ section.push(row)
78
+ })
79
+
80
+ return sections
81
+ }
82
+
83
+ /**
84
+ * Rearrange cells by aisle direction pattern.
85
+ */
86
+ export function rearrangeByAisle(type: string, sections: RackGridCell[][][]): RackGridCell[][][] {
87
+ const rearranged: RackGridCell[][][] = []
88
+
89
+ switch (type.toLowerCase()) {
90
+ case 'cw': {
91
+ let reverse = false
92
+ sections.forEach(rows => {
93
+ const section: RackGridCell[][] = []
94
+ rearranged.push(section)
95
+ rows.forEach((r, i) => {
96
+ if (reverse) r.reverse()
97
+
98
+ if (i % 2 === 0) {
99
+ section.push(r)
100
+ reverse = !reverse
101
+ }
102
+ })
103
+ })
104
+ break
105
+ }
106
+ case 'ccw': {
107
+ let reverse = true
108
+ sections.forEach(rows => {
109
+ const section: RackGridCell[][] = []
110
+ rearranged.push(section)
111
+ rows.forEach((r, i) => {
112
+ if (reverse) r.reverse()
113
+
114
+ if (i % 2 === 0) {
115
+ section.push(r)
116
+ reverse = !reverse
117
+ }
118
+ })
119
+ })
120
+ break
121
+ }
122
+ case 'zigzag':
123
+ sections.forEach(rows => {
124
+ const section: RackGridCell[][] = []
125
+
126
+ rows.forEach((r, i) => {
127
+ if (i % 2 === 0) {
128
+ section.push(r)
129
+ }
130
+ })
131
+
132
+ const sectionLength = section.length
133
+ const tempRow: RackGridCell[] = []
134
+ const tempSection: RackGridCell[][] = []
135
+
136
+ section.forEach((row, rowIdx) => {
137
+ row.forEach((cell, idx) => {
138
+ tempRow[rowIdx + idx * section.length] = cell
139
+ })
140
+ })
141
+
142
+ const chunkSize = tempRow.length / sectionLength
143
+ for (let idx = 0; idx < sectionLength; idx++) {
144
+ tempSection.push(tempRow.slice(idx * chunkSize, (idx + 1) * chunkSize))
145
+ }
146
+
147
+ rearranged.push(tempSection)
148
+ })
149
+ break
150
+ case 'zigzag-reverse':
151
+ sections.forEach(rows => {
152
+ const section: RackGridCell[][] = []
153
+
154
+ rows.forEach((r, i) => {
155
+ if (i % 2 === 0) {
156
+ r.reverse()
157
+ section.push(r)
158
+ }
159
+ })
160
+
161
+ const sectionLength = section.length
162
+ const tempRow: RackGridCell[] = []
163
+ const tempSection: RackGridCell[][] = []
164
+
165
+ section.forEach((row, rowIdx) => {
166
+ row.forEach((cell, idx) => {
167
+ tempRow[rowIdx + idx * section.length] = cell
168
+ })
169
+ })
170
+
171
+ const chunkSize = tempRow.length / sectionLength
172
+ for (let idx = 0; idx < sectionLength; idx++) {
173
+ tempSection.push(tempRow.slice(idx * chunkSize, (idx + 1) * chunkSize))
174
+ }
175
+
176
+ rearranged.push(tempSection)
177
+ })
178
+ break
179
+ }
180
+
181
+ return rearranged
182
+ }
183
+
184
+ /**
185
+ * Remove empty cells from sections.
186
+ */
187
+ export function removeEmptyCells(sections: RackGridCell[][][]): RackGridCell[][][] {
188
+ const newSections: RackGridCell[][][] = []
189
+ sections.forEach(rows => {
190
+ const newRows: RackGridCell[][] = []
191
+ newSections.push(newRows)
192
+ rows.forEach(row => {
193
+ const newRow: RackGridCell[] = []
194
+ newRows.push(newRow)
195
+ row.forEach(c => {
196
+ if (!c.isEmpty) newRow.push(c)
197
+ })
198
+ })
199
+ })
200
+
201
+ return newSections
202
+ }
203
+
204
+ /**
205
+ * Merge section rows into flat arrays.
206
+ */
207
+ export function mergeRows(sections: RackGridCell[][][]): RackGridCell[][] {
208
+ const merged: RackGridCell[][] = []
209
+
210
+ sections.forEach(section => {
211
+ let newSection: RackGridCell[] = []
212
+
213
+ section.forEach(rows => {
214
+ let mergedRow: RackGridCell[] = []
215
+ rows.forEach(row => {
216
+ mergedRow = mergedRow.concat(row)
217
+ })
218
+ newSection = newSection.concat(mergedRow)
219
+ })
220
+ merged.push(newSection)
221
+ })
222
+
223
+ return merged
224
+ }
225
+
226
+ /**
227
+ * Set section/unit location on cells.
228
+ */
229
+ export function setLocations(
230
+ sections: RackGridCell[][],
231
+ startSection: number,
232
+ startUnit: number,
233
+ sectionDigits: number,
234
+ unitDigits: number
235
+ ) {
236
+ let sectionNumber = Number(startSection) || 1
237
+
238
+ sections.forEach(section => {
239
+ let unitNumber = Number(startUnit) || 1
240
+ section.forEach(c => {
241
+ if (!c.isEmpty) {
242
+ c.set('section', String(sectionNumber).padStart(sectionDigits, '0'))
243
+ c.set('unit', String(unitNumber).padStart(unitDigits, '0'))
244
+ } else {
245
+ c.set('section', null)
246
+ c.set('unit', null)
247
+ }
248
+ unitNumber++
249
+ })
250
+ sectionNumber++
251
+ })
252
+ }
253
+
254
+ /**
255
+ * Run the full location increase flow.
256
+ */
257
+ export function increaseLocation(
258
+ selectedCells: RackGridCell[],
259
+ type: string,
260
+ skipNumbering: boolean,
261
+ startSection: number,
262
+ startUnit: number,
263
+ sectionDigits: number,
264
+ unitDigits: number
265
+ ) {
266
+ // step 1: classify cells by row
267
+ const classified = classifyByRow(selectedCells)
268
+
269
+ // step 2: find aisle row indices
270
+ const aisleRowIndices = getAisleRowIndices(classified)
271
+
272
+ // step 3: classify cells by section
273
+ const sections = classifyCellsBySection(classified, aisleRowIndices)
274
+
275
+ // step 4: rearrange by aisle
276
+ let rearranged = rearrangeByAisle(type, sections)
277
+
278
+ // step 5: if skip numbering, remove empty cells
279
+ if (skipNumbering) rearranged = removeEmptyCells(rearranged)
280
+
281
+ // step 6: merge rows
282
+ const merged = mergeRows(rearranged)
283
+
284
+ // step 7: set location
285
+ setLocations(merged, startSection, startUnit, sectionDigits, unitDigits)
286
+ }