@plurid/plurid-engine 0.0.0-2 → 0.0.0-20
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.
- package/distribution/index.d.mts +734 -0
- package/distribution/index.d.ts +734 -3
- package/distribution/index.js +3317 -2495
- package/distribution/index.js.map +1 -1
- package/distribution/index.mjs +3426 -0
- package/distribution/index.mjs.map +1 -0
- package/package.json +71 -79
- package/distribution/data/constants/index.d.ts +0 -1
- package/distribution/data/interfaces/index.d.ts +0 -4
- package/distribution/functions/index.d.ts +0 -2
- package/distribution/functions/navigate/index.d.ts +0 -1
- package/distribution/functions/template/index.d.ts +0 -1
- package/distribution/index.es.js +0 -2590
- package/distribution/index.es.js.map +0 -1
- package/distribution/modules/general/configuration/index.d.ts +0 -2
- package/distribution/modules/general/index.d.ts +0 -3
- package/distribution/modules/general/tree/index.d.ts +0 -6
- package/distribution/modules/index.d.ts +0 -9
- package/distribution/modules/interaction/direction/index.d.ts +0 -2
- package/distribution/modules/interaction/index.d.ts +0 -5
- package/distribution/modules/interaction/mathematics/matrix/index.d.ts +0 -31
- package/distribution/modules/interaction/mathematics/quaternion/index.d.ts +0 -79
- package/distribution/modules/interaction/mathematics/transform/index.d.ts +0 -69
- package/distribution/modules/internationalization/index.d.ts +0 -3
- package/distribution/modules/planes/index.d.ts +0 -2
- package/distribution/modules/planes/logic/index.d.ts +0 -6
- package/distribution/modules/planes/registrar/index.d.ts +0 -3
- package/distribution/modules/planes/registrar/object.d.ts +0 -14
- package/distribution/modules/planes/registrar/utilities.d.ts +0 -6
- package/distribution/modules/routing/IsoMatcher/index.d.ts +0 -44
- package/distribution/modules/routing/IsoMatcher/interfaces.d.ts +0 -57
- package/distribution/modules/routing/Parser/index.d.ts +0 -21
- package/distribution/modules/routing/Parser/interfaces.d.ts +0 -31
- package/distribution/modules/routing/Parser/logic.d.ts +0 -68
- package/distribution/modules/routing/index.d.ts +0 -7
- package/distribution/modules/routing/logic/general/index.d.ts +0 -6
- package/distribution/modules/routing/logic/index.d.ts +0 -3
- package/distribution/modules/routing/logic/utilities/index.d.ts +0 -29
- package/distribution/modules/routing/logic/validity/index.d.ts +0 -3
- package/distribution/modules/space/index.d.ts +0 -6
- package/distribution/modules/space/layout/column.d.ts +0 -3
- package/distribution/modules/space/layout/faceToFace.d.ts +0 -3
- package/distribution/modules/space/layout/index.d.ts +0 -6
- package/distribution/modules/space/layout/row.d.ts +0 -3
- package/distribution/modules/space/layout/sheaves.d.ts +0 -3
- package/distribution/modules/space/layout/zigZag.d.ts +0 -3
- package/distribution/modules/space/location/index.d.ts +0 -2
- package/distribution/modules/space/location/logic.d.ts +0 -22
- package/distribution/modules/space/tree/index.d.ts +0 -3
- package/distribution/modules/space/tree/logic.d.ts +0 -32
- package/distribution/modules/space/tree/object.d.ts +0 -13
- package/distribution/modules/space/utilities/index.d.ts +0 -16
- package/distribution/modules/space/view/index.d.ts +0 -2
- package/distribution/modules/space/view/logic.d.ts +0 -13
- package/distribution/modules/state/compute/index.d.ts +0 -3
- package/distribution/modules/state/compute/space/index.d.ts +0 -3
- package/distribution/modules/state/compute/themes/index.d.ts +0 -3
- package/distribution/modules/state/index.d.ts +0 -3
- package/distribution/modules/state/local/index.d.ts +0 -3
- package/distribution/modules/utilities/index.d.ts +0 -1
|
@@ -0,0 +1,3426 @@
|
|
|
1
|
+
import { defaultConfiguration, internationalization, protocols, HTTPS_PROTOCOL, HTTP_PROTOCOL, compareTypes, ROOTS_GAP, LAYOUT_TYPES, PLANE_DEFAULT_ANGLE, PLURID_ROUTER_LOCATION_CHANGED } from '@plurid/plurid-data';
|
|
2
|
+
import { mathematics, objects, uuid } from '@plurid/plurid-functions';
|
|
3
|
+
import themes, { THEME_NAMES } from '@plurid/plurid-themes';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// source/modules/general/index.ts
|
|
12
|
+
var general_exports = {};
|
|
13
|
+
__export(general_exports, {
|
|
14
|
+
configuration: () => configuration_exports,
|
|
15
|
+
tree: () => tree_exports
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// source/modules/general/configuration/index.ts
|
|
19
|
+
var configuration_exports = {};
|
|
20
|
+
__export(configuration_exports, {
|
|
21
|
+
definePluridConfiguration: () => definePluridConfiguration,
|
|
22
|
+
merge: () => merge
|
|
23
|
+
});
|
|
24
|
+
var resolveTheme = (theme, type) => {
|
|
25
|
+
if (!theme) {
|
|
26
|
+
return "plurid";
|
|
27
|
+
}
|
|
28
|
+
if (typeof theme === "string") {
|
|
29
|
+
return theme;
|
|
30
|
+
}
|
|
31
|
+
if (typeof theme !== "object") {
|
|
32
|
+
return "plurid";
|
|
33
|
+
}
|
|
34
|
+
const {
|
|
35
|
+
general,
|
|
36
|
+
interaction
|
|
37
|
+
} = theme;
|
|
38
|
+
if (type === "general" && general) {
|
|
39
|
+
return general;
|
|
40
|
+
}
|
|
41
|
+
if (type === "interaction" && interaction) {
|
|
42
|
+
return interaction;
|
|
43
|
+
}
|
|
44
|
+
return "plurid";
|
|
45
|
+
};
|
|
46
|
+
var merge = (configuration, target) => {
|
|
47
|
+
const targetConfiguration = {
|
|
48
|
+
...objects.clone(defaultConfiguration),
|
|
49
|
+
...objects.clone(target || {})
|
|
50
|
+
};
|
|
51
|
+
if (!configuration) {
|
|
52
|
+
return targetConfiguration;
|
|
53
|
+
}
|
|
54
|
+
const mergedConfiguration = objects.merge(
|
|
55
|
+
targetConfiguration,
|
|
56
|
+
configuration,
|
|
57
|
+
{
|
|
58
|
+
"global.theme": () => {
|
|
59
|
+
return {
|
|
60
|
+
general: resolveTheme(configuration.global?.theme, "general"),
|
|
61
|
+
interaction: resolveTheme(configuration.global?.theme, "interaction")
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
return mergedConfiguration;
|
|
67
|
+
};
|
|
68
|
+
var definePluridConfiguration = (flat = {}) => {
|
|
69
|
+
const partial = {};
|
|
70
|
+
const global = {};
|
|
71
|
+
if (flat.theme !== void 0) {
|
|
72
|
+
global.theme = flat.theme;
|
|
73
|
+
}
|
|
74
|
+
if (flat.micro !== void 0) {
|
|
75
|
+
global.micro = flat.micro;
|
|
76
|
+
}
|
|
77
|
+
if (flat.transparentUI !== void 0) {
|
|
78
|
+
global.transparentUI = flat.transparentUI;
|
|
79
|
+
}
|
|
80
|
+
if (flat.language !== void 0) {
|
|
81
|
+
global.language = flat.language;
|
|
82
|
+
}
|
|
83
|
+
if (Object.keys(global).length > 0) {
|
|
84
|
+
partial.global = global;
|
|
85
|
+
}
|
|
86
|
+
const space = {};
|
|
87
|
+
if (flat.layout !== void 0) {
|
|
88
|
+
space.layout = flat.layout;
|
|
89
|
+
}
|
|
90
|
+
if (flat.spaceDimensions !== void 0) {
|
|
91
|
+
space.dimensions = flat.spaceDimensions;
|
|
92
|
+
}
|
|
93
|
+
if (flat.perspective !== void 0) {
|
|
94
|
+
space.perspective = flat.perspective;
|
|
95
|
+
}
|
|
96
|
+
if (flat.center !== void 0) {
|
|
97
|
+
space.center = flat.center;
|
|
98
|
+
}
|
|
99
|
+
if (flat.firstPerson !== void 0) {
|
|
100
|
+
space.firstPerson = flat.firstPerson;
|
|
101
|
+
}
|
|
102
|
+
if (flat.collaboration !== void 0) {
|
|
103
|
+
space.collaboration = flat.collaboration;
|
|
104
|
+
}
|
|
105
|
+
if (flat.undo !== void 0) {
|
|
106
|
+
space.undo = flat.undo;
|
|
107
|
+
}
|
|
108
|
+
if (flat.viewpointURLWrite !== void 0) {
|
|
109
|
+
space.viewpointURLWrite = flat.viewpointURLWrite;
|
|
110
|
+
}
|
|
111
|
+
if (flat.viewpointURLRestore !== void 0) {
|
|
112
|
+
space.viewpointURLRestore = flat.viewpointURLRestore;
|
|
113
|
+
}
|
|
114
|
+
if (flat.viewpointURLParam !== void 0) {
|
|
115
|
+
space.viewpointURLParam = flat.viewpointURLParam;
|
|
116
|
+
}
|
|
117
|
+
if (flat.viewpointURLDebounce !== void 0) {
|
|
118
|
+
space.viewpointURLDebounce = flat.viewpointURLDebounce;
|
|
119
|
+
}
|
|
120
|
+
if (flat.timings !== void 0) {
|
|
121
|
+
space.timings = flat.timings;
|
|
122
|
+
}
|
|
123
|
+
if (flat.gestures !== void 0) {
|
|
124
|
+
space.gestures = flat.gestures;
|
|
125
|
+
}
|
|
126
|
+
if (flat.shortcuts !== void 0) {
|
|
127
|
+
space.shortcuts = flat.shortcuts;
|
|
128
|
+
}
|
|
129
|
+
if (flat.transformLocks !== void 0) {
|
|
130
|
+
space.transformLocks = flat.transformLocks;
|
|
131
|
+
}
|
|
132
|
+
if (flat.opaque !== void 0) {
|
|
133
|
+
space.opaque = flat.opaque;
|
|
134
|
+
}
|
|
135
|
+
if (flat.camera !== void 0) {
|
|
136
|
+
space.camera = flat.camera;
|
|
137
|
+
}
|
|
138
|
+
if (flat.transformOrigin !== void 0) {
|
|
139
|
+
space.transformOrigin = flat.transformOrigin;
|
|
140
|
+
}
|
|
141
|
+
if (flat.transformMode !== void 0) {
|
|
142
|
+
space.transformMode = flat.transformMode;
|
|
143
|
+
}
|
|
144
|
+
if (flat.transformMultimode !== void 0) {
|
|
145
|
+
space.transformMultimode = flat.transformMultimode;
|
|
146
|
+
}
|
|
147
|
+
if (flat.transformTouch !== void 0) {
|
|
148
|
+
space.transformTouch = flat.transformTouch;
|
|
149
|
+
}
|
|
150
|
+
if (flat.cullingDistance !== void 0) {
|
|
151
|
+
space.cullingDistance = flat.cullingDistance;
|
|
152
|
+
}
|
|
153
|
+
if (flat.fadeInTime !== void 0) {
|
|
154
|
+
space.fadeInTime = flat.fadeInTime;
|
|
155
|
+
}
|
|
156
|
+
if (flat.bridgeLength !== void 0 || flat.bridgePlaneAngle !== void 0) {
|
|
157
|
+
space.bridge = {};
|
|
158
|
+
if (flat.bridgeLength !== void 0) {
|
|
159
|
+
space.bridge.length = flat.bridgeLength;
|
|
160
|
+
}
|
|
161
|
+
if (flat.bridgePlaneAngle !== void 0) {
|
|
162
|
+
space.bridge.planeAngle = flat.bridgePlaneAngle;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (Object.keys(space).length > 0) {
|
|
166
|
+
partial.space = space;
|
|
167
|
+
}
|
|
168
|
+
const elements = {};
|
|
169
|
+
const plane = {};
|
|
170
|
+
if (flat.planeWidth !== void 0) {
|
|
171
|
+
plane.width = flat.planeWidth;
|
|
172
|
+
}
|
|
173
|
+
if (flat.planeOpacity !== void 0) {
|
|
174
|
+
plane.opacity = flat.planeOpacity;
|
|
175
|
+
}
|
|
176
|
+
if (flat.planeControls !== void 0) {
|
|
177
|
+
plane.controls = { show: flat.planeControls };
|
|
178
|
+
}
|
|
179
|
+
if (Object.keys(plane).length > 0) {
|
|
180
|
+
elements.plane = plane;
|
|
181
|
+
}
|
|
182
|
+
if (flat.toolbar !== void 0) {
|
|
183
|
+
elements.toolbar = { show: flat.toolbar };
|
|
184
|
+
}
|
|
185
|
+
if (flat.viewcube !== void 0) {
|
|
186
|
+
elements.viewcube = { show: flat.viewcube };
|
|
187
|
+
}
|
|
188
|
+
if (flat.minimap !== void 0) {
|
|
189
|
+
elements.minimap = { show: flat.minimap };
|
|
190
|
+
}
|
|
191
|
+
if (Object.keys(elements).length > 0) {
|
|
192
|
+
partial.elements = elements;
|
|
193
|
+
}
|
|
194
|
+
const resolved = flat.extend ? objects.merge(partial, flat.extend) : partial;
|
|
195
|
+
return merge(resolved);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// source/modules/general/tree/index.ts
|
|
199
|
+
var tree_exports = {};
|
|
200
|
+
__export(tree_exports, {
|
|
201
|
+
updateTreeByPlaneIDWithLinkCoordinates: () => updateTreeByPlaneIDWithLinkCoordinates,
|
|
202
|
+
updateTreePlane: () => updateTreePlane
|
|
203
|
+
});
|
|
204
|
+
var updateTreePlane = (tree, page) => {
|
|
205
|
+
const updatedTree = tree.map((treePlane) => {
|
|
206
|
+
if (treePlane.planeID === page.planeID) {
|
|
207
|
+
return {
|
|
208
|
+
...page
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
if (treePlane.children) {
|
|
212
|
+
return {
|
|
213
|
+
...treePlane,
|
|
214
|
+
children: updateTreePlane(treePlane.children, page)
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return treePlane;
|
|
218
|
+
});
|
|
219
|
+
return updatedTree;
|
|
220
|
+
};
|
|
221
|
+
var updateTreeByPlaneIDWithLinkCoordinates = (tree, planeID, linkCoordinates) => {
|
|
222
|
+
let changed = false;
|
|
223
|
+
const updatedTree = tree.map((treePlane) => {
|
|
224
|
+
if (treePlane.planeID === planeID) {
|
|
225
|
+
changed = true;
|
|
226
|
+
return {
|
|
227
|
+
...treePlane,
|
|
228
|
+
linkCoordinates
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
if (treePlane.children) {
|
|
232
|
+
const updatedChildren = updateTreeByPlaneIDWithLinkCoordinates(
|
|
233
|
+
treePlane.children,
|
|
234
|
+
planeID,
|
|
235
|
+
linkCoordinates
|
|
236
|
+
);
|
|
237
|
+
if (updatedChildren !== treePlane.children) {
|
|
238
|
+
changed = true;
|
|
239
|
+
return {
|
|
240
|
+
...treePlane,
|
|
241
|
+
children: updatedChildren
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return treePlane;
|
|
246
|
+
});
|
|
247
|
+
return changed ? updatedTree : tree;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// source/modules/interaction/index.ts
|
|
251
|
+
var interaction_exports = {};
|
|
252
|
+
__export(interaction_exports, {
|
|
253
|
+
direction: () => direction_exports,
|
|
254
|
+
matrix: () => matrix_exports,
|
|
255
|
+
quaternion: () => quaternion_exports,
|
|
256
|
+
transform: () => transform_exports
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// source/modules/interaction/direction/index.ts
|
|
260
|
+
var direction_exports = {};
|
|
261
|
+
__export(direction_exports, {
|
|
262
|
+
getWheelDirection: () => getWheelDirection
|
|
263
|
+
});
|
|
264
|
+
var getWheelDirection = (deltas, ABSTHRESHOLD = 10, THRESHOLD = 0) => {
|
|
265
|
+
let direction = "left";
|
|
266
|
+
const wheelDeltaX = deltas.deltaX;
|
|
267
|
+
const wheelDeltaY = deltas.deltaY;
|
|
268
|
+
const absWheelDeltaX = Math.abs(wheelDeltaX);
|
|
269
|
+
const absWheelDeltaY = Math.abs(wheelDeltaY);
|
|
270
|
+
if (wheelDeltaX > THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
|
|
271
|
+
direction = "left";
|
|
272
|
+
}
|
|
273
|
+
if (wheelDeltaX < THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
|
|
274
|
+
direction = "right";
|
|
275
|
+
}
|
|
276
|
+
if (wheelDeltaY > THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
|
|
277
|
+
direction = "up";
|
|
278
|
+
}
|
|
279
|
+
if (wheelDeltaY < THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
|
|
280
|
+
direction = "down";
|
|
281
|
+
}
|
|
282
|
+
return direction;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// source/modules/interaction/mathematics/matrix/index.ts
|
|
286
|
+
var matrix_exports = {};
|
|
287
|
+
__export(matrix_exports, {
|
|
288
|
+
matrixArrayToCSSMatrix: () => matrixArrayToCSSMatrix,
|
|
289
|
+
multiplyArrayOfMatrices: () => multiplyArrayOfMatrices,
|
|
290
|
+
multiplyMatrices: () => multiplyMatrices,
|
|
291
|
+
rotateMatrix: () => rotateMatrix,
|
|
292
|
+
scaleMatrix: () => scaleMatrix,
|
|
293
|
+
translateMatrix: () => translateMatrix
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// source/modules/interaction/mathematics/quaternion/index.ts
|
|
297
|
+
var quaternion_exports = {};
|
|
298
|
+
__export(quaternion_exports, {
|
|
299
|
+
computeQuaternionFromEulers: () => computeQuaternionFromEulers,
|
|
300
|
+
conjugateQuaternion: () => conjugateQuaternion,
|
|
301
|
+
degToRad: () => degToRad,
|
|
302
|
+
inverseQuaternion: () => inverseQuaternion,
|
|
303
|
+
makeQuaternion: () => makeQuaternion,
|
|
304
|
+
makeRotationMatrixFromQuaternion: () => makeRotationMatrixFromQuaternion,
|
|
305
|
+
quaternionFromAxisAngle: () => quaternionFromAxisAngle,
|
|
306
|
+
quaternionMultiply: () => quaternionMultiply,
|
|
307
|
+
radToDeg: () => radToDeg,
|
|
308
|
+
rotatePointViaQuaternion: () => rotatePointViaQuaternion,
|
|
309
|
+
zeroQuaternion: () => zeroQuaternion
|
|
310
|
+
});
|
|
311
|
+
var degToRad = (deg) => {
|
|
312
|
+
return deg * 0.01745329252;
|
|
313
|
+
};
|
|
314
|
+
var radToDeg = (rad) => {
|
|
315
|
+
return rad * 57.2957795131;
|
|
316
|
+
};
|
|
317
|
+
var makeQuaternion = (x, y, z, w) => {
|
|
318
|
+
return {
|
|
319
|
+
x,
|
|
320
|
+
y,
|
|
321
|
+
z,
|
|
322
|
+
w
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
var zeroQuaternion = () => {
|
|
326
|
+
return makeQuaternion(0, 0, 0, 0);
|
|
327
|
+
};
|
|
328
|
+
function inverseQuaternion(quaternion) {
|
|
329
|
+
return makeQuaternion(
|
|
330
|
+
quaternion.x,
|
|
331
|
+
quaternion.y,
|
|
332
|
+
quaternion.z,
|
|
333
|
+
-quaternion.w
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
function conjugateQuaternion(quaternion) {
|
|
337
|
+
return makeQuaternion(
|
|
338
|
+
-quaternion.x,
|
|
339
|
+
-quaternion.y,
|
|
340
|
+
-quaternion.z,
|
|
341
|
+
quaternion.w
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
function computeQuaternionFromEulers(alpha, beta, gamma, radians = true) {
|
|
345
|
+
const x = radians ? beta : degToRad(beta);
|
|
346
|
+
const y = radians ? gamma : degToRad(gamma);
|
|
347
|
+
const z = radians ? alpha : degToRad(alpha);
|
|
348
|
+
const cX = Math.cos(x / 2);
|
|
349
|
+
const cY = Math.cos(y / 2);
|
|
350
|
+
const cZ = Math.cos(z / 2);
|
|
351
|
+
const sX = Math.sin(x / 2);
|
|
352
|
+
const sY = Math.sin(y / 2);
|
|
353
|
+
const sZ = Math.sin(z / 2);
|
|
354
|
+
const xQ = sX * cY * cZ - cX * sY * sZ;
|
|
355
|
+
const yQ = cX * sY * cZ + sX * cY * sZ;
|
|
356
|
+
const zQ = cX * cY * sZ + sX * sY * cZ;
|
|
357
|
+
const wQ = cX * cY * cZ - sX * sY * sZ;
|
|
358
|
+
return makeQuaternion(xQ, yQ, zQ, wQ);
|
|
359
|
+
}
|
|
360
|
+
function quaternionFromAxisAngle(x, y, z, angle) {
|
|
361
|
+
const q = zeroQuaternion();
|
|
362
|
+
const halfAngle = angle / 2;
|
|
363
|
+
const sine = Math.sin(halfAngle);
|
|
364
|
+
q.x = x * sine;
|
|
365
|
+
q.y = y * sine;
|
|
366
|
+
q.z = z * sine;
|
|
367
|
+
q.w = Math.cos(halfAngle);
|
|
368
|
+
return q;
|
|
369
|
+
}
|
|
370
|
+
function quaternionMultiply(quaternionArray) {
|
|
371
|
+
const firstQuaternion = quaternionArray[0];
|
|
372
|
+
const valueQuaternion = {
|
|
373
|
+
...firstQuaternion
|
|
374
|
+
};
|
|
375
|
+
for (let i = 1; i < quaternionArray.length; i++) {
|
|
376
|
+
const nextQuaternion = quaternionArray[i];
|
|
377
|
+
const w = valueQuaternion.w * nextQuaternion.w - valueQuaternion.x * nextQuaternion.x - valueQuaternion.y * nextQuaternion.y - valueQuaternion.z * nextQuaternion.z;
|
|
378
|
+
const x = valueQuaternion.x * nextQuaternion.w + valueQuaternion.w * nextQuaternion.x + valueQuaternion.y * nextQuaternion.z - valueQuaternion.z * nextQuaternion.y;
|
|
379
|
+
const y = valueQuaternion.y * nextQuaternion.w + valueQuaternion.w * nextQuaternion.y + valueQuaternion.z * nextQuaternion.x - valueQuaternion.x * nextQuaternion.z;
|
|
380
|
+
const z = valueQuaternion.z * nextQuaternion.w + valueQuaternion.w * nextQuaternion.z + valueQuaternion.x * nextQuaternion.y - valueQuaternion.y * nextQuaternion.x;
|
|
381
|
+
valueQuaternion.x = x;
|
|
382
|
+
valueQuaternion.y = y;
|
|
383
|
+
valueQuaternion.z = z;
|
|
384
|
+
valueQuaternion.w = w;
|
|
385
|
+
}
|
|
386
|
+
return valueQuaternion;
|
|
387
|
+
}
|
|
388
|
+
function rotatePointViaQuaternion(pointRotate, quaternion) {
|
|
389
|
+
const temporaryQuaternion = {
|
|
390
|
+
x: pointRotate[0],
|
|
391
|
+
y: pointRotate[1],
|
|
392
|
+
z: pointRotate[2],
|
|
393
|
+
w: 0
|
|
394
|
+
};
|
|
395
|
+
const rotatedPointQuaternion = quaternionMultiply([
|
|
396
|
+
quaternion,
|
|
397
|
+
temporaryQuaternion,
|
|
398
|
+
conjugateQuaternion(quaternion)
|
|
399
|
+
]);
|
|
400
|
+
return rotatedPointQuaternion;
|
|
401
|
+
}
|
|
402
|
+
function makeRotationMatrixFromQuaternion(quaternion) {
|
|
403
|
+
const num = quaternion.x * 2;
|
|
404
|
+
const num2 = quaternion.y * 2;
|
|
405
|
+
const num3 = quaternion.z * 2;
|
|
406
|
+
const num4 = quaternion.x * num;
|
|
407
|
+
const num5 = quaternion.y * num2;
|
|
408
|
+
const num6 = quaternion.z * num3;
|
|
409
|
+
const num7 = quaternion.x * num2;
|
|
410
|
+
const num8 = quaternion.x * num3;
|
|
411
|
+
const num9 = quaternion.y * num3;
|
|
412
|
+
const num10 = quaternion.w * num;
|
|
413
|
+
const num11 = quaternion.w * num2;
|
|
414
|
+
const num12 = quaternion.w * num3;
|
|
415
|
+
return [
|
|
416
|
+
1 - (num5 + num6),
|
|
417
|
+
num7 - num12,
|
|
418
|
+
num8 + num11,
|
|
419
|
+
0,
|
|
420
|
+
num7 + num12,
|
|
421
|
+
1 - (num4 + num6),
|
|
422
|
+
num9 - num10,
|
|
423
|
+
0,
|
|
424
|
+
num8 - num11,
|
|
425
|
+
num9 + num10,
|
|
426
|
+
1 - (num4 + num5),
|
|
427
|
+
0,
|
|
428
|
+
0,
|
|
429
|
+
0,
|
|
430
|
+
0,
|
|
431
|
+
1
|
|
432
|
+
];
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// source/modules/interaction/mathematics/matrix/index.ts
|
|
436
|
+
function rotateMatrix(xAngle, yAngle, zAngle = 0) {
|
|
437
|
+
const xQuaternion = computeQuaternionFromEulers(0, xAngle, 0);
|
|
438
|
+
const yQuaternion = computeQuaternionFromEulers(0, 0, yAngle);
|
|
439
|
+
const zQuaternion = computeQuaternionFromEulers(zAngle, 0, 0);
|
|
440
|
+
const quartenionMultiplication = quaternionMultiply([
|
|
441
|
+
yQuaternion,
|
|
442
|
+
xQuaternion,
|
|
443
|
+
zQuaternion
|
|
444
|
+
]);
|
|
445
|
+
const rotationMatrix = makeRotationMatrixFromQuaternion(
|
|
446
|
+
quartenionMultiplication
|
|
447
|
+
);
|
|
448
|
+
return rotationMatrix;
|
|
449
|
+
}
|
|
450
|
+
function translateMatrix(x, y, z) {
|
|
451
|
+
return [
|
|
452
|
+
1,
|
|
453
|
+
0,
|
|
454
|
+
0,
|
|
455
|
+
0,
|
|
456
|
+
0,
|
|
457
|
+
1,
|
|
458
|
+
0,
|
|
459
|
+
0,
|
|
460
|
+
0,
|
|
461
|
+
0,
|
|
462
|
+
1,
|
|
463
|
+
0,
|
|
464
|
+
x,
|
|
465
|
+
y,
|
|
466
|
+
z,
|
|
467
|
+
1
|
|
468
|
+
];
|
|
469
|
+
}
|
|
470
|
+
function scaleMatrix(s) {
|
|
471
|
+
return [
|
|
472
|
+
s,
|
|
473
|
+
0,
|
|
474
|
+
0,
|
|
475
|
+
0,
|
|
476
|
+
0,
|
|
477
|
+
s,
|
|
478
|
+
0,
|
|
479
|
+
0,
|
|
480
|
+
0,
|
|
481
|
+
0,
|
|
482
|
+
s,
|
|
483
|
+
0,
|
|
484
|
+
0,
|
|
485
|
+
0,
|
|
486
|
+
0,
|
|
487
|
+
1
|
|
488
|
+
];
|
|
489
|
+
}
|
|
490
|
+
function multiplyMatrices(matrixA, matrixB) {
|
|
491
|
+
const result = [];
|
|
492
|
+
const a00 = matrixA[0];
|
|
493
|
+
const a01 = matrixA[1];
|
|
494
|
+
const a02 = matrixA[2];
|
|
495
|
+
const a03 = matrixA[3];
|
|
496
|
+
const a10 = matrixA[4];
|
|
497
|
+
const a11 = matrixA[5];
|
|
498
|
+
const a12 = matrixA[6];
|
|
499
|
+
const a13 = matrixA[7];
|
|
500
|
+
const a20 = matrixA[8];
|
|
501
|
+
const a21 = matrixA[9];
|
|
502
|
+
const a22 = matrixA[10];
|
|
503
|
+
const a23 = matrixA[11];
|
|
504
|
+
const a30 = matrixA[12];
|
|
505
|
+
const a31 = matrixA[13];
|
|
506
|
+
const a32 = matrixA[14];
|
|
507
|
+
const a33 = matrixA[15];
|
|
508
|
+
let b0 = matrixB[0];
|
|
509
|
+
let b1 = matrixB[1];
|
|
510
|
+
let b2 = matrixB[2];
|
|
511
|
+
let b3 = matrixB[3];
|
|
512
|
+
result[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
513
|
+
result[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
514
|
+
result[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
515
|
+
result[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
516
|
+
b0 = matrixB[4];
|
|
517
|
+
b1 = matrixB[5];
|
|
518
|
+
b2 = matrixB[6];
|
|
519
|
+
b3 = matrixB[7];
|
|
520
|
+
result[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
521
|
+
result[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
522
|
+
result[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
523
|
+
result[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
524
|
+
b0 = matrixB[8];
|
|
525
|
+
b1 = matrixB[9];
|
|
526
|
+
b2 = matrixB[10];
|
|
527
|
+
b3 = matrixB[11];
|
|
528
|
+
result[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
529
|
+
result[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
530
|
+
result[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
531
|
+
result[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
532
|
+
b0 = matrixB[12];
|
|
533
|
+
b1 = matrixB[13];
|
|
534
|
+
b2 = matrixB[14];
|
|
535
|
+
b3 = matrixB[15];
|
|
536
|
+
result[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
537
|
+
result[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
538
|
+
result[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
539
|
+
result[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
540
|
+
return result;
|
|
541
|
+
}
|
|
542
|
+
function multiplyArrayOfMatrices(matrices) {
|
|
543
|
+
let inputMatrix = matrices[0];
|
|
544
|
+
for (let i = 1; i < matrices.length; i++) {
|
|
545
|
+
inputMatrix = multiplyMatrices(inputMatrix, matrices[i]);
|
|
546
|
+
}
|
|
547
|
+
return inputMatrix;
|
|
548
|
+
}
|
|
549
|
+
function matrixArrayToCSSMatrix(array) {
|
|
550
|
+
return "matrix3d(" + array.join(",") + ")";
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// source/modules/interaction/mathematics/transform/index.ts
|
|
554
|
+
var transform_exports = {};
|
|
555
|
+
__export(transform_exports, {
|
|
556
|
+
general: () => general_exports2,
|
|
557
|
+
matrix3d: () => matrix3d_exports
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
// source/modules/interaction/mathematics/transform/general/index.ts
|
|
561
|
+
var general_exports2 = {};
|
|
562
|
+
__export(general_exports2, {
|
|
563
|
+
arrayToMatrix: () => arrayToMatrix,
|
|
564
|
+
getInitialMatrix: () => getInitialMatrix,
|
|
565
|
+
identityMatrix: () => identityMatrix,
|
|
566
|
+
inverseMatrix: () => inverseMatrix,
|
|
567
|
+
matrix3DToMatrix: () => matrix3DToMatrix,
|
|
568
|
+
matrixToArray: () => matrixToArray,
|
|
569
|
+
matrixToCSSMatrix: () => matrixToCSSMatrix,
|
|
570
|
+
multiplyMatrices: () => multiplyMatrices2,
|
|
571
|
+
multiplyMatricesArray: () => multiplyMatricesArray,
|
|
572
|
+
rotateXMatrix: () => rotateXMatrix,
|
|
573
|
+
rotateYMatrix: () => rotateYMatrix,
|
|
574
|
+
rotateZMatrix: () => rotateZMatrix,
|
|
575
|
+
rotationMatrixFromQuaternion: () => rotationMatrixFromQuaternion,
|
|
576
|
+
scaleMatrix: () => scaleMatrix2,
|
|
577
|
+
translateMatrix: () => translateMatrix2
|
|
578
|
+
});
|
|
579
|
+
var getInitialMatrix = () => {
|
|
580
|
+
const matrix = [
|
|
581
|
+
[1, 0, 0, 0],
|
|
582
|
+
[0, 1, 0, 0],
|
|
583
|
+
[0, 0, 1, 0],
|
|
584
|
+
[0, 0, 0, 1]
|
|
585
|
+
];
|
|
586
|
+
return matrix;
|
|
587
|
+
};
|
|
588
|
+
var multiplyMatrices2 = (m1, m2) => {
|
|
589
|
+
const result = [];
|
|
590
|
+
for (let i = 0; i < m1.length; i++) {
|
|
591
|
+
result[i] = [];
|
|
592
|
+
for (let j = 0; j < m2[0].length; j++) {
|
|
593
|
+
let sum = 0;
|
|
594
|
+
for (let k = 0; k < m1[0].length; k++) {
|
|
595
|
+
sum += m1[i][k] * m2[k][j];
|
|
596
|
+
}
|
|
597
|
+
result[i][j] = sum;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return result;
|
|
601
|
+
};
|
|
602
|
+
var multiplyMatricesArray = (matrices) => {
|
|
603
|
+
if (matrices.length < 2) {
|
|
604
|
+
throw new Error("invalid number of matrices");
|
|
605
|
+
}
|
|
606
|
+
const first = matrices[0];
|
|
607
|
+
let result = first;
|
|
608
|
+
for (const [index, matrix] of matrices.entries()) {
|
|
609
|
+
if (index === 0) {
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
result = multiplyMatrices2(
|
|
613
|
+
result,
|
|
614
|
+
matrix
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
return result;
|
|
618
|
+
};
|
|
619
|
+
var arrayToMatrix = (array) => {
|
|
620
|
+
const matrix = [];
|
|
621
|
+
for (let i = 0; i < array.length; i += 4) {
|
|
622
|
+
const row = [];
|
|
623
|
+
row.push(array[i]);
|
|
624
|
+
row.push(array[i + 1]);
|
|
625
|
+
row.push(array[i + 2]);
|
|
626
|
+
row.push(array[i + 3]);
|
|
627
|
+
matrix.push(row);
|
|
628
|
+
}
|
|
629
|
+
return matrix;
|
|
630
|
+
};
|
|
631
|
+
var matrixToArray = (matrix) => {
|
|
632
|
+
return matrix.flat();
|
|
633
|
+
};
|
|
634
|
+
var matrix3DToMatrix = (value) => {
|
|
635
|
+
const values = value.replace("matrix3d(", "").replace(")", "").split(",").map((val) => parseFloat(val));
|
|
636
|
+
return arrayToMatrix(values);
|
|
637
|
+
};
|
|
638
|
+
var rotateXMatrix = (angle) => {
|
|
639
|
+
const x = Math.cos(angle);
|
|
640
|
+
const y = -1 * Math.sin(angle);
|
|
641
|
+
const z = Math.sin(angle);
|
|
642
|
+
const m = [
|
|
643
|
+
[1, 0, 0, 0],
|
|
644
|
+
[0, x, y, 0],
|
|
645
|
+
[0, z, x, 0],
|
|
646
|
+
[0, 0, 0, 1]
|
|
647
|
+
];
|
|
648
|
+
return m;
|
|
649
|
+
};
|
|
650
|
+
var rotateYMatrix = (angle) => {
|
|
651
|
+
const x = Math.cos(angle);
|
|
652
|
+
const y = -1 * Math.sin(angle);
|
|
653
|
+
const z = Math.sin(angle);
|
|
654
|
+
const m = [
|
|
655
|
+
[x, 0, z, 0],
|
|
656
|
+
[0, 1, 0, 0],
|
|
657
|
+
[y, 0, x, 0],
|
|
658
|
+
[0, 0, 0, 1]
|
|
659
|
+
];
|
|
660
|
+
return m;
|
|
661
|
+
};
|
|
662
|
+
var rotateZMatrix = (angle) => {
|
|
663
|
+
const x = Math.cos(angle);
|
|
664
|
+
const y = -1 * Math.sin(angle);
|
|
665
|
+
const z = Math.sin(angle);
|
|
666
|
+
const m = [
|
|
667
|
+
[x, y, 0, 0],
|
|
668
|
+
[z, x, 0, 0],
|
|
669
|
+
[0, 0, 1, 0],
|
|
670
|
+
[0, 0, 0, 1]
|
|
671
|
+
];
|
|
672
|
+
return m;
|
|
673
|
+
};
|
|
674
|
+
var translateMatrix2 = (x = 0, y = 0, z = 0) => {
|
|
675
|
+
const m = [
|
|
676
|
+
[1, 0, 0, 0],
|
|
677
|
+
[0, 1, 0, 0],
|
|
678
|
+
[0, 0, 1, 0],
|
|
679
|
+
[x, y, z, 1]
|
|
680
|
+
];
|
|
681
|
+
return m;
|
|
682
|
+
};
|
|
683
|
+
var scaleMatrix2 = (s) => {
|
|
684
|
+
return [
|
|
685
|
+
[s, 0, 0, 0],
|
|
686
|
+
[0, s, 0, 0],
|
|
687
|
+
[0, 0, s, 0],
|
|
688
|
+
[0, 0, 0, 1]
|
|
689
|
+
];
|
|
690
|
+
};
|
|
691
|
+
function rotationMatrixFromQuaternion(quaternion) {
|
|
692
|
+
const num = quaternion.x * 2;
|
|
693
|
+
const num2 = quaternion.y * 2;
|
|
694
|
+
const num3 = quaternion.z * 2;
|
|
695
|
+
const num4 = quaternion.x * num;
|
|
696
|
+
const num5 = quaternion.y * num2;
|
|
697
|
+
const num6 = quaternion.z * num3;
|
|
698
|
+
const num7 = quaternion.x * num2;
|
|
699
|
+
const num8 = quaternion.x * num3;
|
|
700
|
+
const num9 = quaternion.y * num3;
|
|
701
|
+
const num10 = quaternion.w * num;
|
|
702
|
+
const num11 = quaternion.w * num2;
|
|
703
|
+
const num12 = quaternion.w * num3;
|
|
704
|
+
return [
|
|
705
|
+
[1 - (num5 + num6), num7 - num12, num8 + num11, 0],
|
|
706
|
+
[num7 + num12, 1 - (num4 + num6), num9 - num10, 0],
|
|
707
|
+
[num8 - num11, num9 + num10, 1 - (num4 + num5), 0],
|
|
708
|
+
[0, 0, 0, 1]
|
|
709
|
+
];
|
|
710
|
+
}
|
|
711
|
+
var matrixToCSSMatrix = (matrix) => {
|
|
712
|
+
const value = matrix.flat().join(",");
|
|
713
|
+
return `matrix3d(${value})`;
|
|
714
|
+
};
|
|
715
|
+
var identityMatrix = () => {
|
|
716
|
+
const matrix = [
|
|
717
|
+
[1, 0, 0, 0],
|
|
718
|
+
[0, 1, 0, 0],
|
|
719
|
+
[0, 0, 1, 0],
|
|
720
|
+
[0, 0, 0, 1]
|
|
721
|
+
];
|
|
722
|
+
return matrix;
|
|
723
|
+
};
|
|
724
|
+
var inverseMatrix = (matrix) => {
|
|
725
|
+
const cols = 4;
|
|
726
|
+
const rows = 4;
|
|
727
|
+
const A = matrix.map((row) => [...row]);
|
|
728
|
+
const B = identityMatrix();
|
|
729
|
+
let r;
|
|
730
|
+
let s;
|
|
731
|
+
let f;
|
|
732
|
+
let temp;
|
|
733
|
+
for (let c = 0; c < cols; c++) {
|
|
734
|
+
let ABig = Math.abs(A[c][c]);
|
|
735
|
+
let rBig = c;
|
|
736
|
+
r = c + 1;
|
|
737
|
+
while (r < rows) {
|
|
738
|
+
if (Math.abs(A[r][c]) > ABig) {
|
|
739
|
+
ABig = Math.abs(A[r][c]);
|
|
740
|
+
rBig = r;
|
|
741
|
+
}
|
|
742
|
+
r++;
|
|
743
|
+
}
|
|
744
|
+
if (ABig === 0) {
|
|
745
|
+
throw Error("Cannot calculate inverse, determinant is zero");
|
|
746
|
+
}
|
|
747
|
+
r = rBig;
|
|
748
|
+
if (r !== c) {
|
|
749
|
+
temp = A[c];
|
|
750
|
+
A[c] = A[r];
|
|
751
|
+
A[r] = temp;
|
|
752
|
+
temp = B[c];
|
|
753
|
+
B[c] = B[r];
|
|
754
|
+
B[r] = temp;
|
|
755
|
+
}
|
|
756
|
+
const Ac = A[c];
|
|
757
|
+
const Bc = B[c];
|
|
758
|
+
for (r = 0; r < rows; r++) {
|
|
759
|
+
const Ar = A[r];
|
|
760
|
+
const Br = B[r];
|
|
761
|
+
if (r !== c) {
|
|
762
|
+
if (Ar[c] !== 0) {
|
|
763
|
+
f = -Ar[c] / Ac[c];
|
|
764
|
+
for (s = c; s < cols; s++) {
|
|
765
|
+
Ar[s] = Ar[s] + f * Ac[s];
|
|
766
|
+
}
|
|
767
|
+
for (s = 0; s < cols; s++) {
|
|
768
|
+
Br[s] = Br[s] + f * Bc[s];
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
} else {
|
|
772
|
+
f = Ac[c];
|
|
773
|
+
for (s = c; s < cols; s++) {
|
|
774
|
+
Ar[s] = Ar[s] / f;
|
|
775
|
+
}
|
|
776
|
+
for (s = 0; s < cols; s++) {
|
|
777
|
+
Br[s] = Br[s] / f;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return B;
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
// source/modules/interaction/mathematics/transform/matrix3d/index.ts
|
|
786
|
+
var matrix3d_exports = {};
|
|
787
|
+
__export(matrix3d_exports, {
|
|
788
|
+
getMatrixValues: () => getMatrixValues,
|
|
789
|
+
getRotationMatrix: () => getRotationMatrix,
|
|
790
|
+
getScalationValue: () => getScalationValue,
|
|
791
|
+
getTransformRotate: () => getTransformRotate,
|
|
792
|
+
getTransformScale: () => getTransformScale,
|
|
793
|
+
getTransformTranslate: () => getTransformTranslate,
|
|
794
|
+
getTranslationMatrix: () => getTranslationMatrix
|
|
795
|
+
});
|
|
796
|
+
function getMatrixValues(matrix3d) {
|
|
797
|
+
const matrixValues = matrix3d.split("(")[1].split(")")[0].split(",");
|
|
798
|
+
const matrixValuesInt = [];
|
|
799
|
+
for (let i = 0; i < matrixValues.length; i++) {
|
|
800
|
+
matrixValuesInt[i] = parseFloat(matrixValues[i]);
|
|
801
|
+
}
|
|
802
|
+
return matrixValuesInt;
|
|
803
|
+
}
|
|
804
|
+
function getRotationMatrix(matrix3d) {
|
|
805
|
+
const valuesMatrix = getMatrixValues(matrix3d);
|
|
806
|
+
const scale = getScalationValue(matrix3d);
|
|
807
|
+
if (valuesMatrix.length === 16) {
|
|
808
|
+
for (let i = 0; i < 11; i++) {
|
|
809
|
+
valuesMatrix[i] /= scale;
|
|
810
|
+
}
|
|
811
|
+
} else if (valuesMatrix.length === 6) {
|
|
812
|
+
for (let i = 0; i < 4; i++) {
|
|
813
|
+
valuesMatrix[i] /= scale;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
const rotationMatrix = valuesMatrix;
|
|
817
|
+
return rotationMatrix;
|
|
818
|
+
}
|
|
819
|
+
function getTranslationMatrix(matrix3d) {
|
|
820
|
+
const valuesMatrix = getMatrixValues(matrix3d);
|
|
821
|
+
let translationMatrix;
|
|
822
|
+
if (valuesMatrix.length === 16) {
|
|
823
|
+
translationMatrix = getMatrixValues(matrix3d).slice(12, 15);
|
|
824
|
+
} else if (valuesMatrix.length === 6) {
|
|
825
|
+
translationMatrix = getMatrixValues(matrix3d).slice(4);
|
|
826
|
+
}
|
|
827
|
+
return translationMatrix;
|
|
828
|
+
}
|
|
829
|
+
function getScalationValue(matrix3d) {
|
|
830
|
+
const valuesMatrix = getMatrixValues(matrix3d);
|
|
831
|
+
let temp = 0;
|
|
832
|
+
let scale;
|
|
833
|
+
if (valuesMatrix.length === 16) {
|
|
834
|
+
const scaleMatrix3 = getMatrixValues(matrix3d).slice(0, 4);
|
|
835
|
+
scale = 0;
|
|
836
|
+
for (const el of scaleMatrix3) {
|
|
837
|
+
scale += parseFloat(el) * parseFloat(el);
|
|
838
|
+
}
|
|
839
|
+
scale = parseFloat(Math.sqrt(scale).toPrecision(4));
|
|
840
|
+
} else if (valuesMatrix.length === 6) {
|
|
841
|
+
temp = valuesMatrix[0] * valuesMatrix[0] + valuesMatrix[1] * valuesMatrix[1];
|
|
842
|
+
scale = parseFloat(Math.sqrt(temp).toPrecision(4));
|
|
843
|
+
}
|
|
844
|
+
return scale;
|
|
845
|
+
}
|
|
846
|
+
function getTransformRotate(matrix3d) {
|
|
847
|
+
const pi = Math.PI;
|
|
848
|
+
const values = getRotationMatrix(matrix3d);
|
|
849
|
+
let rotateX = 0;
|
|
850
|
+
let rotateY = 0;
|
|
851
|
+
if (values.length === 6) {
|
|
852
|
+
const cosa = values[0];
|
|
853
|
+
const sina = values[1];
|
|
854
|
+
if (cosa === 1 && sina === 0) {
|
|
855
|
+
rotateX = Math.asin(sina);
|
|
856
|
+
rotateY = Math.acos(cosa);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
if (values.length === 16) {
|
|
860
|
+
const cosaX1 = values[5];
|
|
861
|
+
const sinaX3 = values[9];
|
|
862
|
+
if (sinaX3 <= 0) {
|
|
863
|
+
rotateX = Math.acos(cosaX1);
|
|
864
|
+
}
|
|
865
|
+
if (sinaX3 > 0) {
|
|
866
|
+
rotateX = 2 * pi - Math.acos(cosaX1);
|
|
867
|
+
}
|
|
868
|
+
const cosaY1 = values[0];
|
|
869
|
+
const sinaY2 = values[2];
|
|
870
|
+
if (sinaY2 <= 0) {
|
|
871
|
+
rotateY = Math.acos(cosaY1);
|
|
872
|
+
}
|
|
873
|
+
if (sinaY2 > 0) {
|
|
874
|
+
rotateY = 2 * pi - Math.acos(cosaY1);
|
|
875
|
+
}
|
|
876
|
+
rotateX = Math.atan2(values[9], values[5]);
|
|
877
|
+
rotateY = Math.atan2(values[2], values[0]);
|
|
878
|
+
}
|
|
879
|
+
return {
|
|
880
|
+
rotateX,
|
|
881
|
+
rotateY,
|
|
882
|
+
rotateZ: 0
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
function getTransformTranslate(matrix3d) {
|
|
886
|
+
const values = getTranslationMatrix(matrix3d);
|
|
887
|
+
const translateX = values[0];
|
|
888
|
+
const translateY = values[1];
|
|
889
|
+
const translateZ = values[2];
|
|
890
|
+
return {
|
|
891
|
+
translateX,
|
|
892
|
+
translateY,
|
|
893
|
+
translateZ
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
function getTransformScale(matrix3d) {
|
|
897
|
+
const scale = getScalationValue(matrix3d);
|
|
898
|
+
return {
|
|
899
|
+
scale
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
var internatiolate = (lamguage, field) => {
|
|
903
|
+
return internationalization[lamguage]?.[field] ?? internationalization.english?.[field] ?? field;
|
|
904
|
+
};
|
|
905
|
+
var internationalization_default = internatiolate;
|
|
906
|
+
|
|
907
|
+
// source/modules/planes/index.ts
|
|
908
|
+
var planes_exports = {};
|
|
909
|
+
__export(planes_exports, {
|
|
910
|
+
Registrar: () => object_default,
|
|
911
|
+
getPlanesRegistrar: () => getPlanesRegistrar,
|
|
912
|
+
getPluridPlaneIDByData: () => getPluridPlaneIDByData,
|
|
913
|
+
getRegisteredPlane: () => getRegisteredPlane,
|
|
914
|
+
getRegisteredPlanes: () => getRegisteredPlanes,
|
|
915
|
+
registerPlanes: () => registerPlanes,
|
|
916
|
+
resolvePluridPlaneData: () => resolvePluridPlaneData,
|
|
917
|
+
resolvePluridRoutePlaneData: () => resolvePluridRoutePlaneData
|
|
918
|
+
});
|
|
919
|
+
|
|
920
|
+
// source/modules/planes/logic/index.ts
|
|
921
|
+
var resolvePluridPlaneData = (plane) => {
|
|
922
|
+
if (Array.isArray(plane)) {
|
|
923
|
+
const [
|
|
924
|
+
route,
|
|
925
|
+
component,
|
|
926
|
+
options
|
|
927
|
+
] = plane;
|
|
928
|
+
return {
|
|
929
|
+
route,
|
|
930
|
+
component,
|
|
931
|
+
...options
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
return plane;
|
|
935
|
+
};
|
|
936
|
+
var resolvePluridRoutePlaneData = (plane) => {
|
|
937
|
+
if (Array.isArray(plane)) {
|
|
938
|
+
const [
|
|
939
|
+
value,
|
|
940
|
+
component,
|
|
941
|
+
options
|
|
942
|
+
] = plane;
|
|
943
|
+
return {
|
|
944
|
+
value,
|
|
945
|
+
component,
|
|
946
|
+
...options
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
return plane;
|
|
950
|
+
};
|
|
951
|
+
var getPluridPlaneIDByData = (element) => {
|
|
952
|
+
if (!element) {
|
|
953
|
+
return "";
|
|
954
|
+
}
|
|
955
|
+
const parent = element.parentElement;
|
|
956
|
+
if (parent && parent.dataset.pluridPlane) {
|
|
957
|
+
return parent.dataset.pluridPlane;
|
|
958
|
+
}
|
|
959
|
+
return getPluridPlaneIDByData(parent);
|
|
960
|
+
};
|
|
961
|
+
|
|
962
|
+
// source/modules/routing/index.ts
|
|
963
|
+
var routing_exports = {};
|
|
964
|
+
__export(routing_exports, {
|
|
965
|
+
IsoMatcher: () => IsoMatcher_default,
|
|
966
|
+
RouteParser: () => Parser,
|
|
967
|
+
checkParameterLength: () => checkParameterLength,
|
|
968
|
+
checkPlaneAddressType: () => checkPlaneAddressType,
|
|
969
|
+
checkValidPath: () => checkValidPath,
|
|
970
|
+
cleanPathValue: () => cleanPathValue,
|
|
971
|
+
cleanupPath: () => cleanupPath,
|
|
972
|
+
computePlaneAddress: () => computePlaneAddress,
|
|
973
|
+
extractQuery: () => extractQuery,
|
|
974
|
+
isAbsolutePlane: () => isAbsolutePlane,
|
|
975
|
+
pluridLinkPathDivider: () => pluridLinkPathDivider,
|
|
976
|
+
removeTrailingSlash: () => removeTrailingSlash,
|
|
977
|
+
resolveRoute: () => resolveRoute,
|
|
978
|
+
stringInsertInitial: () => stringInsertInitial,
|
|
979
|
+
stringRemoveTrailing: () => stringRemoveTrailing
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
// source/modules/routing/Parser/logic.ts
|
|
983
|
+
var extractPathname = (location2) => {
|
|
984
|
+
const queryIndex = location2.indexOf("?");
|
|
985
|
+
const noQueryPath = queryIndex === -1 ? location2 : location2.substring(0, queryIndex);
|
|
986
|
+
const fragmentIndex = noQueryPath.indexOf("#:~:");
|
|
987
|
+
const noFragmentPath = fragmentIndex === -1 ? noQueryPath : noQueryPath.substring(0, fragmentIndex);
|
|
988
|
+
return noFragmentPath;
|
|
989
|
+
};
|
|
990
|
+
var extractParametersAndMatch = (location2, route) => {
|
|
991
|
+
const routeElements = splitPath(route);
|
|
992
|
+
const parameters = [];
|
|
993
|
+
routeElements.forEach((routeElement) => {
|
|
994
|
+
if (routeElement[0] === ":") {
|
|
995
|
+
parameters.push(routeElement);
|
|
996
|
+
} else {
|
|
997
|
+
parameters.push("");
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
const {
|
|
1001
|
+
locationElements,
|
|
1002
|
+
comparingPath
|
|
1003
|
+
} = computeComparingPath(location2, parameters);
|
|
1004
|
+
if (comparingPath !== route) {
|
|
1005
|
+
return {
|
|
1006
|
+
match: false,
|
|
1007
|
+
parameters: {},
|
|
1008
|
+
elements: locationElements
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
const parametersValues = extractParametersValues(
|
|
1012
|
+
parameters,
|
|
1013
|
+
locationElements
|
|
1014
|
+
);
|
|
1015
|
+
return {
|
|
1016
|
+
match: true,
|
|
1017
|
+
parameters: parametersValues,
|
|
1018
|
+
elements: locationElements
|
|
1019
|
+
};
|
|
1020
|
+
};
|
|
1021
|
+
var extractParametersValues = (parameters, pathElements) => {
|
|
1022
|
+
const parametersValues = {};
|
|
1023
|
+
parameters.forEach(
|
|
1024
|
+
(parameter, index) => {
|
|
1025
|
+
if (parameter) {
|
|
1026
|
+
const parameterKey = parameter.slice(1);
|
|
1027
|
+
parametersValues[parameterKey] = pathElements[index];
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
);
|
|
1031
|
+
return parametersValues;
|
|
1032
|
+
};
|
|
1033
|
+
var computeComparingPath = (path, parameters) => {
|
|
1034
|
+
const pathname = extractPathname(path);
|
|
1035
|
+
const locationElements = splitPath(pathname);
|
|
1036
|
+
const comparingPathElements = [...locationElements];
|
|
1037
|
+
for (const index of locationElements.keys()) {
|
|
1038
|
+
if (parameters[index]) {
|
|
1039
|
+
comparingPathElements[index] = parameters[index];
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
const comparingPath = comparingPathElements.join("/");
|
|
1043
|
+
return {
|
|
1044
|
+
locationElements,
|
|
1045
|
+
comparingPath
|
|
1046
|
+
};
|
|
1047
|
+
};
|
|
1048
|
+
var splitPath = (path) => {
|
|
1049
|
+
return path.split("/").filter((i) => i !== "");
|
|
1050
|
+
};
|
|
1051
|
+
var extractQuery = (path) => {
|
|
1052
|
+
const fragmentIndex = path.indexOf("#:~:");
|
|
1053
|
+
const noFragmentPath = fragmentIndex === -1 ? path : path.substring(0, fragmentIndex);
|
|
1054
|
+
const querySplit = noFragmentPath.split("?");
|
|
1055
|
+
if (querySplit.length === 2) {
|
|
1056
|
+
const queryValues = {};
|
|
1057
|
+
const query = querySplit[1];
|
|
1058
|
+
const params = new URLSearchParams(query);
|
|
1059
|
+
for (const [id, value] of params) {
|
|
1060
|
+
queryValues[id] = value;
|
|
1061
|
+
}
|
|
1062
|
+
return queryValues;
|
|
1063
|
+
} else {
|
|
1064
|
+
return {};
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
var extractFragments = (location2) => {
|
|
1068
|
+
if (!location2) {
|
|
1069
|
+
return {
|
|
1070
|
+
texts: [],
|
|
1071
|
+
elements: []
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
const split = location2.split("#:~:");
|
|
1075
|
+
const fragmentsValues = split[1];
|
|
1076
|
+
if (!fragmentsValues) {
|
|
1077
|
+
return {
|
|
1078
|
+
texts: [],
|
|
1079
|
+
elements: []
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
const fragmentItems = fragmentsValues.split("&");
|
|
1083
|
+
const textFragments = [];
|
|
1084
|
+
const elementFragments = [];
|
|
1085
|
+
for (const item of fragmentItems) {
|
|
1086
|
+
const parsedFragment = parseFragment(item);
|
|
1087
|
+
if (parsedFragment) {
|
|
1088
|
+
switch (parsedFragment.type) {
|
|
1089
|
+
case "text":
|
|
1090
|
+
textFragments.push(parsedFragment);
|
|
1091
|
+
break;
|
|
1092
|
+
case "element":
|
|
1093
|
+
elementFragments.push(parsedFragment);
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
return {
|
|
1099
|
+
texts: textFragments,
|
|
1100
|
+
elements: elementFragments
|
|
1101
|
+
};
|
|
1102
|
+
};
|
|
1103
|
+
var parseFragment = (fragment) => {
|
|
1104
|
+
const fragmentData = fragment.split("=");
|
|
1105
|
+
const fragmentType = fragmentData[0];
|
|
1106
|
+
const fragmentValues = fragmentData[1];
|
|
1107
|
+
switch (fragmentType.toLowerCase()) {
|
|
1108
|
+
case "text": {
|
|
1109
|
+
const textValues = fragmentValues.split(",");
|
|
1110
|
+
const textStart = textValues[0];
|
|
1111
|
+
const textEnd = textValues[1];
|
|
1112
|
+
const textOccurence = extractOccurence(textValues[2]);
|
|
1113
|
+
if (!textStart) {
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
return {
|
|
1117
|
+
type: "text",
|
|
1118
|
+
start: textStart,
|
|
1119
|
+
end: textEnd || "",
|
|
1120
|
+
occurence: textOccurence
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
case "element": {
|
|
1124
|
+
const elementValues = fragmentValues.split(",");
|
|
1125
|
+
const elementID = elementValues[0];
|
|
1126
|
+
const elementOccurence = extractOccurence(elementValues[1]);
|
|
1127
|
+
if (!elementID) {
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
return {
|
|
1131
|
+
type: "element",
|
|
1132
|
+
id: elementID,
|
|
1133
|
+
occurence: elementOccurence
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return void 0;
|
|
1138
|
+
};
|
|
1139
|
+
var extractOccurence = (occurence) => {
|
|
1140
|
+
if (!occurence) {
|
|
1141
|
+
return 0;
|
|
1142
|
+
}
|
|
1143
|
+
const occurenceMatch = occurence.match(/\[(\d*)\]/);
|
|
1144
|
+
const occurenceValue = occurenceMatch ? parseInt(occurenceMatch[1]) : 0;
|
|
1145
|
+
return occurenceValue;
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
// source/modules/routing/logic/general/index.ts
|
|
1149
|
+
var stringInsertInitial = (value, insert) => {
|
|
1150
|
+
if (!value.startsWith(insert)) {
|
|
1151
|
+
value = insert + value;
|
|
1152
|
+
}
|
|
1153
|
+
return value;
|
|
1154
|
+
};
|
|
1155
|
+
var stringRemoveTrailing = (value, trail) => {
|
|
1156
|
+
if (value.endsWith(trail)) {
|
|
1157
|
+
value = value.slice(0, value.length - trail.length);
|
|
1158
|
+
}
|
|
1159
|
+
return value;
|
|
1160
|
+
};
|
|
1161
|
+
var PATH_SEPARATOR = "/";
|
|
1162
|
+
var cleanupPath = (value) => {
|
|
1163
|
+
value = stringInsertInitial(value, PATH_SEPARATOR);
|
|
1164
|
+
value = stringRemoveTrailing(value, PATH_SEPARATOR);
|
|
1165
|
+
return value;
|
|
1166
|
+
};
|
|
1167
|
+
var computePlaneAddress = (plane, route, origin = "origin") => {
|
|
1168
|
+
if (origin === "origin" && typeof location !== "undefined" && location.host) {
|
|
1169
|
+
origin = location.host;
|
|
1170
|
+
}
|
|
1171
|
+
const cleanPlane = extractPathname(plane);
|
|
1172
|
+
const planeAddressType = checkPlaneAddressType(cleanPlane);
|
|
1173
|
+
switch (planeAddressType) {
|
|
1174
|
+
case "http":
|
|
1175
|
+
case "https":
|
|
1176
|
+
case "pttp":
|
|
1177
|
+
return cleanPlane;
|
|
1178
|
+
}
|
|
1179
|
+
origin = stringRemoveTrailing(origin, "/");
|
|
1180
|
+
const absolutePlane = isAbsolutePlane(plane);
|
|
1181
|
+
const path = route && route !== "/" ? absolutePlane ? cleanupPath(cleanPlane) : cleanupPath(route) + cleanupPath(cleanPlane) : cleanupPath(cleanPlane);
|
|
1182
|
+
const planeAddress = protocols.plurid + origin + path;
|
|
1183
|
+
return planeAddress;
|
|
1184
|
+
};
|
|
1185
|
+
var isAbsolutePlane = (value) => {
|
|
1186
|
+
return value[0] === "/";
|
|
1187
|
+
};
|
|
1188
|
+
var checkPlaneAddressType = (value) => {
|
|
1189
|
+
value = value.toLowerCase().trim();
|
|
1190
|
+
if (value.startsWith(protocols.plurid)) {
|
|
1191
|
+
return "pttp";
|
|
1192
|
+
}
|
|
1193
|
+
if (value.startsWith(protocols.https)) {
|
|
1194
|
+
return HTTPS_PROTOCOL;
|
|
1195
|
+
}
|
|
1196
|
+
if (value.startsWith(protocols.http)) {
|
|
1197
|
+
return HTTP_PROTOCOL;
|
|
1198
|
+
}
|
|
1199
|
+
return "relative";
|
|
1200
|
+
};
|
|
1201
|
+
var removeTrailingSlash = (value) => {
|
|
1202
|
+
if (value.endsWith("/") && value.length > 1) {
|
|
1203
|
+
return value.slice(0, value.length - 1);
|
|
1204
|
+
}
|
|
1205
|
+
return value;
|
|
1206
|
+
};
|
|
1207
|
+
var cleanPathValue = (value) => {
|
|
1208
|
+
const queryStart = value.indexOf("?");
|
|
1209
|
+
if (queryStart < 0) {
|
|
1210
|
+
return removeTrailingSlash(
|
|
1211
|
+
value
|
|
1212
|
+
);
|
|
1213
|
+
}
|
|
1214
|
+
return removeTrailingSlash(
|
|
1215
|
+
value.substring(0, queryStart)
|
|
1216
|
+
);
|
|
1217
|
+
};
|
|
1218
|
+
var checkParameterLength = (parameter, length, compareType) => {
|
|
1219
|
+
const parameterLength = parameter.length;
|
|
1220
|
+
switch (compareType) {
|
|
1221
|
+
case compareTypes.equal:
|
|
1222
|
+
return parameterLength === length;
|
|
1223
|
+
case compareTypes.equalLessThan:
|
|
1224
|
+
return parameterLength <= length;
|
|
1225
|
+
case compareTypes.lessThan:
|
|
1226
|
+
return parameterLength < length;
|
|
1227
|
+
case compareTypes.equalGreaterThan:
|
|
1228
|
+
return parameterLength >= length;
|
|
1229
|
+
case compareTypes.greaterThan:
|
|
1230
|
+
return parameterLength > length;
|
|
1231
|
+
default:
|
|
1232
|
+
return parameterLength <= length;
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
var checkValidPath = (validationParameters, parameters) => {
|
|
1236
|
+
if (validationParameters) {
|
|
1237
|
+
for (const [parameterKey, parameterData] of Object.entries(validationParameters)) {
|
|
1238
|
+
const {
|
|
1239
|
+
length,
|
|
1240
|
+
lengthType,
|
|
1241
|
+
startsWith,
|
|
1242
|
+
endsWith,
|
|
1243
|
+
includes
|
|
1244
|
+
} = parameterData;
|
|
1245
|
+
const paramaterValue = parameters[parameterKey];
|
|
1246
|
+
if (!paramaterValue) {
|
|
1247
|
+
return false;
|
|
1248
|
+
}
|
|
1249
|
+
if (startsWith && !paramaterValue.startsWith(startsWith)) {
|
|
1250
|
+
return false;
|
|
1251
|
+
}
|
|
1252
|
+
if (endsWith && !paramaterValue.endsWith(endsWith)) {
|
|
1253
|
+
return false;
|
|
1254
|
+
}
|
|
1255
|
+
if (includes && !includes.includes(paramaterValue)) {
|
|
1256
|
+
return false;
|
|
1257
|
+
}
|
|
1258
|
+
if (length) {
|
|
1259
|
+
const validLength = checkParameterLength(
|
|
1260
|
+
paramaterValue,
|
|
1261
|
+
length,
|
|
1262
|
+
lengthType
|
|
1263
|
+
);
|
|
1264
|
+
if (!validLength) {
|
|
1265
|
+
return false;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
return true;
|
|
1271
|
+
};
|
|
1272
|
+
|
|
1273
|
+
// source/modules/utilities/index.ts
|
|
1274
|
+
var utilities_exports = {};
|
|
1275
|
+
__export(utilities_exports, {
|
|
1276
|
+
cleanPathElement: () => cleanPathElement
|
|
1277
|
+
});
|
|
1278
|
+
var cleanPathElement = (path) => {
|
|
1279
|
+
if (path[0] === "/") {
|
|
1280
|
+
return path.slice(1);
|
|
1281
|
+
}
|
|
1282
|
+
return path;
|
|
1283
|
+
};
|
|
1284
|
+
|
|
1285
|
+
// source/modules/routing/logic/utilities/index.ts
|
|
1286
|
+
var pluridLinkPathDivider = (route) => {
|
|
1287
|
+
const windowProtocol = typeof window === "undefined" ? "http" : window.location.protocol.replace(":", "");
|
|
1288
|
+
const windowHost = typeof window === "undefined" ? "localhost:63000" : window.location.host;
|
|
1289
|
+
const split = route.split("://").filter((value) => value !== "").map((value) => cleanPathElement(value));
|
|
1290
|
+
let protocol = windowProtocol;
|
|
1291
|
+
const host = {
|
|
1292
|
+
value: windowHost,
|
|
1293
|
+
controlled: false
|
|
1294
|
+
};
|
|
1295
|
+
const path = {
|
|
1296
|
+
value: "",
|
|
1297
|
+
parameters: {},
|
|
1298
|
+
query: {}
|
|
1299
|
+
};
|
|
1300
|
+
const space = {
|
|
1301
|
+
value: "",
|
|
1302
|
+
parameters: {},
|
|
1303
|
+
query: {}
|
|
1304
|
+
};
|
|
1305
|
+
const universe = {
|
|
1306
|
+
value: "",
|
|
1307
|
+
parameters: {},
|
|
1308
|
+
query: {}
|
|
1309
|
+
};
|
|
1310
|
+
const cluster = {
|
|
1311
|
+
value: "",
|
|
1312
|
+
parameters: {},
|
|
1313
|
+
query: {}
|
|
1314
|
+
};
|
|
1315
|
+
const plane = {
|
|
1316
|
+
value: "",
|
|
1317
|
+
parameters: {},
|
|
1318
|
+
query: {},
|
|
1319
|
+
fragments: {
|
|
1320
|
+
texts: [],
|
|
1321
|
+
elements: []
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
const valid = false;
|
|
1325
|
+
if (split.length === 0 || split.length > 7) {
|
|
1326
|
+
const url2 = {
|
|
1327
|
+
protocol: {
|
|
1328
|
+
value: protocol,
|
|
1329
|
+
secure: true
|
|
1330
|
+
},
|
|
1331
|
+
host,
|
|
1332
|
+
path,
|
|
1333
|
+
space,
|
|
1334
|
+
universe,
|
|
1335
|
+
cluster,
|
|
1336
|
+
plane,
|
|
1337
|
+
valid
|
|
1338
|
+
};
|
|
1339
|
+
return url2;
|
|
1340
|
+
}
|
|
1341
|
+
if (route.startsWith("/://")) {
|
|
1342
|
+
const routeSplit = split.slice(1);
|
|
1343
|
+
switch (routeSplit.length) {
|
|
1344
|
+
case 1:
|
|
1345
|
+
path.value = routeSplit[0];
|
|
1346
|
+
break;
|
|
1347
|
+
case 5:
|
|
1348
|
+
path.value = routeSplit[0];
|
|
1349
|
+
space.value = routeSplit[1];
|
|
1350
|
+
universe.value = routeSplit[2];
|
|
1351
|
+
cluster.value = routeSplit[3];
|
|
1352
|
+
plane.value = routeSplit[4];
|
|
1353
|
+
break;
|
|
1354
|
+
}
|
|
1355
|
+
const url2 = {
|
|
1356
|
+
protocol: {
|
|
1357
|
+
value: protocol,
|
|
1358
|
+
secure: true
|
|
1359
|
+
},
|
|
1360
|
+
host,
|
|
1361
|
+
path,
|
|
1362
|
+
space,
|
|
1363
|
+
universe,
|
|
1364
|
+
cluster,
|
|
1365
|
+
plane,
|
|
1366
|
+
valid: true
|
|
1367
|
+
};
|
|
1368
|
+
return url2;
|
|
1369
|
+
}
|
|
1370
|
+
if (split[0] !== "http" && split[0] !== "https" && split[0] !== "chrome-extension") {
|
|
1371
|
+
switch (split.length) {
|
|
1372
|
+
case 1:
|
|
1373
|
+
plane.value = split[0];
|
|
1374
|
+
break;
|
|
1375
|
+
case 2:
|
|
1376
|
+
cluster.value = split[0];
|
|
1377
|
+
plane.value = split[1];
|
|
1378
|
+
break;
|
|
1379
|
+
case 3:
|
|
1380
|
+
universe.value = split[0];
|
|
1381
|
+
cluster.value = split[1];
|
|
1382
|
+
plane.value = split[2];
|
|
1383
|
+
break;
|
|
1384
|
+
case 4:
|
|
1385
|
+
space.value = split[0];
|
|
1386
|
+
universe.value = split[1];
|
|
1387
|
+
cluster.value = split[2];
|
|
1388
|
+
plane.value = split[3];
|
|
1389
|
+
break;
|
|
1390
|
+
case 5:
|
|
1391
|
+
path.value = split[0];
|
|
1392
|
+
space.value = split[1];
|
|
1393
|
+
universe.value = split[2];
|
|
1394
|
+
cluster.value = split[3];
|
|
1395
|
+
plane.value = split[4];
|
|
1396
|
+
break;
|
|
1397
|
+
case 6:
|
|
1398
|
+
host.value = split[0];
|
|
1399
|
+
path.value = split[1];
|
|
1400
|
+
space.value = split[2];
|
|
1401
|
+
universe.value = split[3];
|
|
1402
|
+
cluster.value = split[4];
|
|
1403
|
+
plane.value = split[5];
|
|
1404
|
+
break;
|
|
1405
|
+
default:
|
|
1406
|
+
const url2 = {
|
|
1407
|
+
protocol: {
|
|
1408
|
+
value: protocol,
|
|
1409
|
+
secure: true
|
|
1410
|
+
},
|
|
1411
|
+
host,
|
|
1412
|
+
path,
|
|
1413
|
+
space,
|
|
1414
|
+
universe,
|
|
1415
|
+
cluster,
|
|
1416
|
+
plane,
|
|
1417
|
+
valid
|
|
1418
|
+
};
|
|
1419
|
+
return url2;
|
|
1420
|
+
}
|
|
1421
|
+
} else {
|
|
1422
|
+
switch (split.length) {
|
|
1423
|
+
case 3:
|
|
1424
|
+
protocol = split[0];
|
|
1425
|
+
host.value = split[1];
|
|
1426
|
+
path.value = split[2];
|
|
1427
|
+
break;
|
|
1428
|
+
case 7:
|
|
1429
|
+
protocol = split[0];
|
|
1430
|
+
host.value = split[1];
|
|
1431
|
+
path.value = split[2];
|
|
1432
|
+
space.value = split[3];
|
|
1433
|
+
universe.value = split[4];
|
|
1434
|
+
cluster.value = split[5];
|
|
1435
|
+
plane.value = split[6];
|
|
1436
|
+
break;
|
|
1437
|
+
default:
|
|
1438
|
+
const url2 = {
|
|
1439
|
+
protocol: {
|
|
1440
|
+
value: protocol,
|
|
1441
|
+
secure: true
|
|
1442
|
+
},
|
|
1443
|
+
host,
|
|
1444
|
+
path,
|
|
1445
|
+
space,
|
|
1446
|
+
universe,
|
|
1447
|
+
cluster,
|
|
1448
|
+
plane,
|
|
1449
|
+
valid
|
|
1450
|
+
};
|
|
1451
|
+
return url2;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
const url = {
|
|
1455
|
+
protocol: {
|
|
1456
|
+
value: protocol,
|
|
1457
|
+
secure: true
|
|
1458
|
+
},
|
|
1459
|
+
host,
|
|
1460
|
+
path,
|
|
1461
|
+
space,
|
|
1462
|
+
universe,
|
|
1463
|
+
cluster,
|
|
1464
|
+
plane,
|
|
1465
|
+
valid: true
|
|
1466
|
+
};
|
|
1467
|
+
return url;
|
|
1468
|
+
};
|
|
1469
|
+
var resolveRoute = (route, protocol, host) => {
|
|
1470
|
+
const windowProtocol = typeof window === "undefined" ? protocol || "http" : window.location.protocol.replace(":", "");
|
|
1471
|
+
const windowHost = typeof window === "undefined" ? host || "localhost:63000" : window.location.host;
|
|
1472
|
+
const divisions = pluridLinkPathDivider(route);
|
|
1473
|
+
const defaultPathname = typeof window !== "undefined" ? window.location.pathname === "/" ? "p" : window.location.pathname.slice(1) : divisions.path.value ? divisions.path.value : "p";
|
|
1474
|
+
const protocolDivision = divisions.protocol.value || windowProtocol;
|
|
1475
|
+
const hostDivision = divisions.host.value ? divisions.host : {
|
|
1476
|
+
value: windowHost,
|
|
1477
|
+
controlled: true
|
|
1478
|
+
};
|
|
1479
|
+
const path = divisions.path.value ? divisions.path : {
|
|
1480
|
+
value: defaultPathname,
|
|
1481
|
+
parameters: {},
|
|
1482
|
+
query: {}
|
|
1483
|
+
};
|
|
1484
|
+
const space = divisions.space.value ? divisions.space : {
|
|
1485
|
+
value: "s",
|
|
1486
|
+
parameters: {},
|
|
1487
|
+
query: {}
|
|
1488
|
+
};
|
|
1489
|
+
const universe = divisions.universe.value ? divisions.universe : {
|
|
1490
|
+
value: "u",
|
|
1491
|
+
parameters: {},
|
|
1492
|
+
query: {}
|
|
1493
|
+
};
|
|
1494
|
+
const cluster = divisions.cluster.value ? divisions.cluster : {
|
|
1495
|
+
value: "c",
|
|
1496
|
+
parameters: {},
|
|
1497
|
+
query: {}
|
|
1498
|
+
};
|
|
1499
|
+
const plane = divisions.plane;
|
|
1500
|
+
const separator = "://";
|
|
1501
|
+
if (!plane.value && route !== "/") {
|
|
1502
|
+
const resolvers2 = [
|
|
1503
|
+
protocolDivision,
|
|
1504
|
+
hostDivision.value,
|
|
1505
|
+
path.value
|
|
1506
|
+
];
|
|
1507
|
+
const absoluteRoute2 = resolvers2.join(separator);
|
|
1508
|
+
return {
|
|
1509
|
+
protocol: protocolDivision,
|
|
1510
|
+
host: hostDivision,
|
|
1511
|
+
path,
|
|
1512
|
+
space,
|
|
1513
|
+
universe,
|
|
1514
|
+
cluster,
|
|
1515
|
+
plane,
|
|
1516
|
+
route: absoluteRoute2
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
[
|
|
1520
|
+
protocolDivision,
|
|
1521
|
+
hostDivision.value,
|
|
1522
|
+
path.value,
|
|
1523
|
+
space.value,
|
|
1524
|
+
universe.value,
|
|
1525
|
+
cluster.value,
|
|
1526
|
+
cleanPathElement(plane.value)
|
|
1527
|
+
];
|
|
1528
|
+
return {
|
|
1529
|
+
protocol: "",
|
|
1530
|
+
host: "",
|
|
1531
|
+
path,
|
|
1532
|
+
space: "",
|
|
1533
|
+
universe: "",
|
|
1534
|
+
cluster: "",
|
|
1535
|
+
plane: "",
|
|
1536
|
+
route
|
|
1537
|
+
};
|
|
1538
|
+
};
|
|
1539
|
+
|
|
1540
|
+
// source/modules/routing/IsoMatcher/index.ts
|
|
1541
|
+
var IsoMatcher = class {
|
|
1542
|
+
origin;
|
|
1543
|
+
routesIndex = /* @__PURE__ */ new Map();
|
|
1544
|
+
planesIndex = /* @__PURE__ */ new Map();
|
|
1545
|
+
routesKeys = [];
|
|
1546
|
+
planesKeys = [];
|
|
1547
|
+
constructor(data, origin = "origin") {
|
|
1548
|
+
if (origin === "origin" && typeof location !== "undefined" && location.host) {
|
|
1549
|
+
this.origin = location.host;
|
|
1550
|
+
} else {
|
|
1551
|
+
this.origin = origin;
|
|
1552
|
+
}
|
|
1553
|
+
this.updateIndexes(
|
|
1554
|
+
data.routes || [],
|
|
1555
|
+
data.routePlanes || [],
|
|
1556
|
+
data.planes || []
|
|
1557
|
+
);
|
|
1558
|
+
}
|
|
1559
|
+
match(path, context = "plane") {
|
|
1560
|
+
switch (context) {
|
|
1561
|
+
case "plane":
|
|
1562
|
+
return this.matchPlane(path);
|
|
1563
|
+
case "route":
|
|
1564
|
+
return this.matchRoute(path);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Dynammically update the planes and routes indexes.
|
|
1569
|
+
*
|
|
1570
|
+
* @param data
|
|
1571
|
+
*/
|
|
1572
|
+
index(data) {
|
|
1573
|
+
this.updateIndexes(
|
|
1574
|
+
data.routes || [],
|
|
1575
|
+
data.routePlanes || [],
|
|
1576
|
+
data.planes || []
|
|
1577
|
+
);
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Clear all data.
|
|
1581
|
+
*
|
|
1582
|
+
*/
|
|
1583
|
+
clear() {
|
|
1584
|
+
this.routesIndex = /* @__PURE__ */ new Map();
|
|
1585
|
+
this.planesIndex = /* @__PURE__ */ new Map();
|
|
1586
|
+
this.routesKeys = [];
|
|
1587
|
+
this.planesKeys = [];
|
|
1588
|
+
}
|
|
1589
|
+
getPlanesIndex() {
|
|
1590
|
+
return this.planesIndex;
|
|
1591
|
+
}
|
|
1592
|
+
/**
|
|
1593
|
+
* Creates a common data structure able to match and route accordingly.
|
|
1594
|
+
*
|
|
1595
|
+
*/
|
|
1596
|
+
updateIndexes(routes, routePlanes, planes) {
|
|
1597
|
+
this.indexPlanes(
|
|
1598
|
+
planes,
|
|
1599
|
+
"Plane"
|
|
1600
|
+
);
|
|
1601
|
+
this.indexPlanes(
|
|
1602
|
+
routePlanes,
|
|
1603
|
+
"RoutePlane"
|
|
1604
|
+
);
|
|
1605
|
+
for (const route of routes) {
|
|
1606
|
+
if (route.planes) {
|
|
1607
|
+
this.indexPlanes(
|
|
1608
|
+
route.planes,
|
|
1609
|
+
"RoutePlane",
|
|
1610
|
+
route.value
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
this.routesIndex.set(
|
|
1614
|
+
route.value,
|
|
1615
|
+
{
|
|
1616
|
+
data: {
|
|
1617
|
+
...route
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
);
|
|
1621
|
+
}
|
|
1622
|
+
this.routesKeys = Array.from(this.routesIndex.keys());
|
|
1623
|
+
this.planesKeys = Array.from(this.planesIndex.keys());
|
|
1624
|
+
}
|
|
1625
|
+
indexPlanes(planes, kind, parent) {
|
|
1626
|
+
for (const plane of planes) {
|
|
1627
|
+
const planeData = kind === "Plane" ? resolvePluridPlaneData(plane) : resolvePluridRoutePlaneData(plane);
|
|
1628
|
+
const address = computePlaneAddress(
|
|
1629
|
+
kind === "Plane" ? planeData.route : planeData.value,
|
|
1630
|
+
parent,
|
|
1631
|
+
this.origin
|
|
1632
|
+
);
|
|
1633
|
+
const indexedPlane = {
|
|
1634
|
+
kind,
|
|
1635
|
+
data: {
|
|
1636
|
+
...planeData
|
|
1637
|
+
}
|
|
1638
|
+
};
|
|
1639
|
+
if (parent) {
|
|
1640
|
+
indexedPlane["parent"] = parent;
|
|
1641
|
+
}
|
|
1642
|
+
this.planesIndex.set(
|
|
1643
|
+
address,
|
|
1644
|
+
indexedPlane
|
|
1645
|
+
);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
matchPlane(value) {
|
|
1649
|
+
const planeAddress = computePlaneAddress(
|
|
1650
|
+
value,
|
|
1651
|
+
void 0,
|
|
1652
|
+
this.origin
|
|
1653
|
+
);
|
|
1654
|
+
const plane = this.planesIndex.get(planeAddress);
|
|
1655
|
+
if (plane) {
|
|
1656
|
+
const query = extractQuery(
|
|
1657
|
+
value
|
|
1658
|
+
);
|
|
1659
|
+
const fragments = extractFragments(
|
|
1660
|
+
value
|
|
1661
|
+
);
|
|
1662
|
+
const match = {
|
|
1663
|
+
value: planeAddress,
|
|
1664
|
+
fragments,
|
|
1665
|
+
query,
|
|
1666
|
+
parameters: {}
|
|
1667
|
+
};
|
|
1668
|
+
if (plane.kind === "Plane") {
|
|
1669
|
+
const {
|
|
1670
|
+
kind,
|
|
1671
|
+
data,
|
|
1672
|
+
parent
|
|
1673
|
+
} = plane;
|
|
1674
|
+
const result = {
|
|
1675
|
+
kind,
|
|
1676
|
+
data,
|
|
1677
|
+
parent,
|
|
1678
|
+
match
|
|
1679
|
+
};
|
|
1680
|
+
return result;
|
|
1681
|
+
}
|
|
1682
|
+
if (plane.kind === "RoutePlane") {
|
|
1683
|
+
const {
|
|
1684
|
+
kind,
|
|
1685
|
+
data,
|
|
1686
|
+
parent
|
|
1687
|
+
} = plane;
|
|
1688
|
+
const result = {
|
|
1689
|
+
kind,
|
|
1690
|
+
data,
|
|
1691
|
+
parent,
|
|
1692
|
+
match
|
|
1693
|
+
};
|
|
1694
|
+
return result;
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
for (const planePath of this.planesKeys) {
|
|
1698
|
+
const normalizedPlanePath = planePath.replace(protocols.plurid, "");
|
|
1699
|
+
const normalizedPlaneAddress = planeAddress.replace(protocols.plurid, "");
|
|
1700
|
+
const planePathSplit = normalizedPlanePath.split("/");
|
|
1701
|
+
const planeAddressSplit = normalizedPlaneAddress.split("/");
|
|
1702
|
+
if (planePathSplit[0] !== planeAddressSplit[0]) {
|
|
1703
|
+
continue;
|
|
1704
|
+
}
|
|
1705
|
+
if (planePathSplit.length !== planeAddressSplit.length) {
|
|
1706
|
+
continue;
|
|
1707
|
+
}
|
|
1708
|
+
const parametersAndMatch = extractParametersAndMatch(
|
|
1709
|
+
normalizedPlaneAddress,
|
|
1710
|
+
normalizedPlanePath
|
|
1711
|
+
);
|
|
1712
|
+
if (parametersAndMatch.match) {
|
|
1713
|
+
const plane2 = this.planesIndex.get(planePath);
|
|
1714
|
+
if (!plane2) {
|
|
1715
|
+
continue;
|
|
1716
|
+
}
|
|
1717
|
+
const {
|
|
1718
|
+
parameters
|
|
1719
|
+
} = parametersAndMatch;
|
|
1720
|
+
const validPath = checkValidPath(
|
|
1721
|
+
plane2.data.parameters,
|
|
1722
|
+
parameters
|
|
1723
|
+
);
|
|
1724
|
+
if (!validPath) {
|
|
1725
|
+
continue;
|
|
1726
|
+
}
|
|
1727
|
+
const query = extractQuery(
|
|
1728
|
+
value
|
|
1729
|
+
);
|
|
1730
|
+
const fragments = extractFragments(
|
|
1731
|
+
value
|
|
1732
|
+
);
|
|
1733
|
+
const match = {
|
|
1734
|
+
value: planeAddress,
|
|
1735
|
+
fragments,
|
|
1736
|
+
query,
|
|
1737
|
+
parameters
|
|
1738
|
+
};
|
|
1739
|
+
if (plane2.kind === "Plane") {
|
|
1740
|
+
const {
|
|
1741
|
+
kind,
|
|
1742
|
+
data,
|
|
1743
|
+
parent
|
|
1744
|
+
} = plane2;
|
|
1745
|
+
const result = {
|
|
1746
|
+
kind,
|
|
1747
|
+
data,
|
|
1748
|
+
parent,
|
|
1749
|
+
match
|
|
1750
|
+
};
|
|
1751
|
+
return result;
|
|
1752
|
+
}
|
|
1753
|
+
if (plane2.kind === "RoutePlane") {
|
|
1754
|
+
const {
|
|
1755
|
+
kind,
|
|
1756
|
+
data,
|
|
1757
|
+
parent
|
|
1758
|
+
} = plane2;
|
|
1759
|
+
const result = {
|
|
1760
|
+
kind,
|
|
1761
|
+
data,
|
|
1762
|
+
parent,
|
|
1763
|
+
match
|
|
1764
|
+
};
|
|
1765
|
+
return result;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
matchRoute(value) {
|
|
1772
|
+
const routeValue = cleanPathValue(value);
|
|
1773
|
+
const route = this.routesIndex.get(routeValue);
|
|
1774
|
+
if (route) {
|
|
1775
|
+
const query = extractQuery(
|
|
1776
|
+
value
|
|
1777
|
+
);
|
|
1778
|
+
const result = {
|
|
1779
|
+
kind: "Route",
|
|
1780
|
+
data: route.data,
|
|
1781
|
+
match: {
|
|
1782
|
+
// value: extractPathname(value),
|
|
1783
|
+
value: routeValue,
|
|
1784
|
+
query,
|
|
1785
|
+
parameters: {}
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1788
|
+
return result;
|
|
1789
|
+
}
|
|
1790
|
+
for (const routePath of this.routesKeys) {
|
|
1791
|
+
const routeSplit = routePath.split("/");
|
|
1792
|
+
const valueSplit = routeValue.split("/");
|
|
1793
|
+
if (routeSplit.length !== valueSplit.length) {
|
|
1794
|
+
continue;
|
|
1795
|
+
}
|
|
1796
|
+
const parametersAndMatch = extractParametersAndMatch(
|
|
1797
|
+
routeValue.slice(1),
|
|
1798
|
+
routePath.slice(1)
|
|
1799
|
+
);
|
|
1800
|
+
if (parametersAndMatch.match) {
|
|
1801
|
+
const route2 = this.routesIndex.get(routePath);
|
|
1802
|
+
if (!route2) {
|
|
1803
|
+
continue;
|
|
1804
|
+
}
|
|
1805
|
+
const {
|
|
1806
|
+
parameters
|
|
1807
|
+
} = parametersAndMatch;
|
|
1808
|
+
const validPath = checkValidPath(
|
|
1809
|
+
route2.data.parameters,
|
|
1810
|
+
parameters
|
|
1811
|
+
);
|
|
1812
|
+
if (!validPath) {
|
|
1813
|
+
continue;
|
|
1814
|
+
}
|
|
1815
|
+
const query = extractQuery(
|
|
1816
|
+
value
|
|
1817
|
+
);
|
|
1818
|
+
const match = {
|
|
1819
|
+
// value: extractPathname(value),
|
|
1820
|
+
value: routeValue,
|
|
1821
|
+
query,
|
|
1822
|
+
parameters
|
|
1823
|
+
};
|
|
1824
|
+
if (route2) {
|
|
1825
|
+
const result = {
|
|
1826
|
+
kind: "Route",
|
|
1827
|
+
data: route2.data,
|
|
1828
|
+
match
|
|
1829
|
+
};
|
|
1830
|
+
return result;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
const routePlane = this.matchPlane(routeValue);
|
|
1835
|
+
if (routePlane) {
|
|
1836
|
+
const result = {
|
|
1837
|
+
kind: "RoutePlane",
|
|
1838
|
+
data: routePlane.data,
|
|
1839
|
+
// HACK
|
|
1840
|
+
match: {
|
|
1841
|
+
// value: extractPathname(value),
|
|
1842
|
+
value: routeValue,
|
|
1843
|
+
query: routePlane.match.query,
|
|
1844
|
+
parameters: routePlane.match.parameters
|
|
1845
|
+
}
|
|
1846
|
+
};
|
|
1847
|
+
return result;
|
|
1848
|
+
}
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1851
|
+
};
|
|
1852
|
+
var IsoMatcher_default = IsoMatcher;
|
|
1853
|
+
|
|
1854
|
+
// source/modules/routing/Parser/index.ts
|
|
1855
|
+
var Parser = class {
|
|
1856
|
+
/** properties */
|
|
1857
|
+
location;
|
|
1858
|
+
path;
|
|
1859
|
+
options;
|
|
1860
|
+
/** constructor */
|
|
1861
|
+
constructor(location2, path, options) {
|
|
1862
|
+
this.location = location2;
|
|
1863
|
+
this.path = path;
|
|
1864
|
+
this.options = this.handleOptions(options);
|
|
1865
|
+
}
|
|
1866
|
+
/** private */
|
|
1867
|
+
handleOptions(options) {
|
|
1868
|
+
const parserOptions = {
|
|
1869
|
+
fragment: options?.fragment || true
|
|
1870
|
+
};
|
|
1871
|
+
return parserOptions;
|
|
1872
|
+
}
|
|
1873
|
+
extractPathname() {
|
|
1874
|
+
const pathname = extractPathname(
|
|
1875
|
+
this.location
|
|
1876
|
+
);
|
|
1877
|
+
return pathname;
|
|
1878
|
+
}
|
|
1879
|
+
extractParametersAndMatch() {
|
|
1880
|
+
const parametersAndMatch = extractParametersAndMatch(
|
|
1881
|
+
this.location,
|
|
1882
|
+
this.path.value
|
|
1883
|
+
);
|
|
1884
|
+
return parametersAndMatch;
|
|
1885
|
+
}
|
|
1886
|
+
extractQuery() {
|
|
1887
|
+
const query = extractQuery(
|
|
1888
|
+
this.location
|
|
1889
|
+
);
|
|
1890
|
+
return query;
|
|
1891
|
+
}
|
|
1892
|
+
extractFragments() {
|
|
1893
|
+
const fragments = this.options.fragment ? extractFragments(this.location) : extractFragments();
|
|
1894
|
+
return fragments;
|
|
1895
|
+
}
|
|
1896
|
+
/** public */
|
|
1897
|
+
/**
|
|
1898
|
+
* Extract pathname, parameters, query, and fragment, if available.
|
|
1899
|
+
*/
|
|
1900
|
+
extract() {
|
|
1901
|
+
const pathname = this.extractPathname();
|
|
1902
|
+
const {
|
|
1903
|
+
match,
|
|
1904
|
+
parameters,
|
|
1905
|
+
elements
|
|
1906
|
+
} = this.extractParametersAndMatch();
|
|
1907
|
+
const query = this.extractQuery();
|
|
1908
|
+
const queryData = Object.entries(query).map(([key, value]) => {
|
|
1909
|
+
return key + "=" + value;
|
|
1910
|
+
}).join("&");
|
|
1911
|
+
const queryString = queryData ? "?" + queryData : "";
|
|
1912
|
+
const fragments = this.extractFragments();
|
|
1913
|
+
const parserResponse = {
|
|
1914
|
+
path: this.path,
|
|
1915
|
+
pathname,
|
|
1916
|
+
elements,
|
|
1917
|
+
match,
|
|
1918
|
+
parameters,
|
|
1919
|
+
query,
|
|
1920
|
+
fragments,
|
|
1921
|
+
route: pathname + queryString
|
|
1922
|
+
};
|
|
1923
|
+
return parserResponse;
|
|
1924
|
+
}
|
|
1925
|
+
};
|
|
1926
|
+
|
|
1927
|
+
// source/modules/planes/registrar/object.ts
|
|
1928
|
+
var PluridPlanesRegistrar = class {
|
|
1929
|
+
isoMatcher;
|
|
1930
|
+
constructor(planes, origin = "origin") {
|
|
1931
|
+
this.isoMatcher = new IsoMatcher_default(
|
|
1932
|
+
{
|
|
1933
|
+
planes
|
|
1934
|
+
},
|
|
1935
|
+
origin
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1938
|
+
register(planes) {
|
|
1939
|
+
this.isoMatcher.index({
|
|
1940
|
+
planes
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1943
|
+
identify() {
|
|
1944
|
+
const planes = this.isoMatcher.getPlanesIndex();
|
|
1945
|
+
return [...planes.keys()];
|
|
1946
|
+
}
|
|
1947
|
+
get(route) {
|
|
1948
|
+
const match = this.isoMatcher.match(route);
|
|
1949
|
+
if (match) {
|
|
1950
|
+
const absoluteRoute = match.kind === "Plane" ? match.data.route : match.data.value;
|
|
1951
|
+
const registeredPlane = {
|
|
1952
|
+
route: {
|
|
1953
|
+
absolute: absoluteRoute,
|
|
1954
|
+
fragments: match.match.fragments,
|
|
1955
|
+
parameters: match.match.parameters,
|
|
1956
|
+
query: match.match.query
|
|
1957
|
+
},
|
|
1958
|
+
component: match.data.component
|
|
1959
|
+
};
|
|
1960
|
+
return registeredPlane;
|
|
1961
|
+
}
|
|
1962
|
+
return;
|
|
1963
|
+
}
|
|
1964
|
+
getAll() {
|
|
1965
|
+
const planes = this.isoMatcher.getPlanesIndex();
|
|
1966
|
+
const all = /* @__PURE__ */ new Map();
|
|
1967
|
+
for (const [path, plane] of planes) {
|
|
1968
|
+
const absoluteRoute = plane.kind === "Plane" ? plane.data.route : plane.data.value;
|
|
1969
|
+
const registeredPlane = {
|
|
1970
|
+
route: {
|
|
1971
|
+
absolute: absoluteRoute,
|
|
1972
|
+
fragments: {
|
|
1973
|
+
elements: [],
|
|
1974
|
+
texts: []
|
|
1975
|
+
},
|
|
1976
|
+
parameters: {},
|
|
1977
|
+
query: {}
|
|
1978
|
+
},
|
|
1979
|
+
component: plane.data.component
|
|
1980
|
+
};
|
|
1981
|
+
all.set(
|
|
1982
|
+
path,
|
|
1983
|
+
registeredPlane
|
|
1984
|
+
);
|
|
1985
|
+
}
|
|
1986
|
+
return all;
|
|
1987
|
+
}
|
|
1988
|
+
};
|
|
1989
|
+
var object_default = PluridPlanesRegistrar;
|
|
1990
|
+
|
|
1991
|
+
// source/modules/planes/registrar/utilities.ts
|
|
1992
|
+
var registerPlanes = (planes, planesRegistrar, origin = "origin") => {
|
|
1993
|
+
if (!planes) {
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
if (planesRegistrar) {
|
|
1997
|
+
planesRegistrar.register(planes);
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
if (typeof window === "undefined") {
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
2003
|
+
if (typeof window.__pluridPlanesRegistrar__ === "undefined") {
|
|
2004
|
+
const pluridPlanesRegistrar = new object_default([], origin);
|
|
2005
|
+
window.__pluridPlanesRegistrar__ = pluridPlanesRegistrar;
|
|
2006
|
+
window.__pluridPlanesRegistrar__.register(planes);
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
window.__pluridPlanesRegistrar__.register(planes);
|
|
2010
|
+
return;
|
|
2011
|
+
};
|
|
2012
|
+
var getPlanesRegistrar = (planesRegistrar) => {
|
|
2013
|
+
if (planesRegistrar) {
|
|
2014
|
+
return planesRegistrar;
|
|
2015
|
+
}
|
|
2016
|
+
if (typeof window !== "undefined") {
|
|
2017
|
+
if (window.__pluridPlanesRegistrar__ !== void 0) {
|
|
2018
|
+
return window.__pluridPlanesRegistrar__;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
return;
|
|
2022
|
+
};
|
|
2023
|
+
var getRegisteredPlanes = (planesRegistrar) => {
|
|
2024
|
+
if (planesRegistrar) {
|
|
2025
|
+
return planesRegistrar.getAll();
|
|
2026
|
+
}
|
|
2027
|
+
if (typeof window !== "undefined") {
|
|
2028
|
+
if (window.__pluridPlanesRegistrar__ !== void 0) {
|
|
2029
|
+
return window.__pluridPlanesRegistrar__.getAll();
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
return /* @__PURE__ */ new Map();
|
|
2033
|
+
};
|
|
2034
|
+
var getRegisteredPlane = (route, planesRegistrar) => {
|
|
2035
|
+
if (planesRegistrar) {
|
|
2036
|
+
return planesRegistrar.get(route);
|
|
2037
|
+
}
|
|
2038
|
+
if (typeof window !== "undefined") {
|
|
2039
|
+
if (window.__pluridPlanesRegistrar__ !== void 0) {
|
|
2040
|
+
return window.__pluridPlanesRegistrar__.get(route);
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
return;
|
|
2044
|
+
};
|
|
2045
|
+
|
|
2046
|
+
// source/modules/space/index.ts
|
|
2047
|
+
var space_exports = {};
|
|
2048
|
+
__export(space_exports, {
|
|
2049
|
+
layout: () => layout_exports,
|
|
2050
|
+
location: () => location_exports,
|
|
2051
|
+
tree: () => tree_exports2,
|
|
2052
|
+
utilities: () => utilities_exports2,
|
|
2053
|
+
view: () => view_exports
|
|
2054
|
+
});
|
|
2055
|
+
|
|
2056
|
+
// source/modules/space/layout/index.ts
|
|
2057
|
+
var layout_exports = {};
|
|
2058
|
+
__export(layout_exports, {
|
|
2059
|
+
computeColumnLayout: () => column_default,
|
|
2060
|
+
computeFaceToFaceLayout: () => faceToFace_default,
|
|
2061
|
+
computeRowLayout: () => row_default,
|
|
2062
|
+
computeSheavesLayout: () => sheaves_default,
|
|
2063
|
+
computeZigZagLayout: () => zigZag_default
|
|
2064
|
+
});
|
|
2065
|
+
|
|
2066
|
+
// source/modules/space/location/index.ts
|
|
2067
|
+
var location_exports = {};
|
|
2068
|
+
__export(location_exports, {
|
|
2069
|
+
computePath: () => computePath,
|
|
2070
|
+
computePluridPlaneLocation: () => computePluridPlaneLocation,
|
|
2071
|
+
recomputeChildrenLocation: () => recomputeChildrenLocation
|
|
2072
|
+
});
|
|
2073
|
+
|
|
2074
|
+
// source/modules/space/utilities/index.ts
|
|
2075
|
+
var utilities_exports2 = {};
|
|
2076
|
+
__export(utilities_exports2, {
|
|
2077
|
+
computeSpaceSize: () => computeSpaceSize,
|
|
2078
|
+
findPage: () => findPage,
|
|
2079
|
+
getTreePlaneByPlaneID: () => getTreePlaneByPlaneID,
|
|
2080
|
+
splitIntoGroups: () => splitIntoGroups
|
|
2081
|
+
});
|
|
2082
|
+
var computeSpaceSize = (tree) => {
|
|
2083
|
+
let width = 0;
|
|
2084
|
+
let height = 0;
|
|
2085
|
+
let depth = 0;
|
|
2086
|
+
const topCorner = {
|
|
2087
|
+
x: 0,
|
|
2088
|
+
y: 0,
|
|
2089
|
+
z: 0
|
|
2090
|
+
};
|
|
2091
|
+
tree.map((treePage) => {
|
|
2092
|
+
const spaceWidth = treePage.location.translateX + treePage.width;
|
|
2093
|
+
if (spaceWidth > width) {
|
|
2094
|
+
width = spaceWidth;
|
|
2095
|
+
}
|
|
2096
|
+
const spaceHeight = treePage.location.translateY + treePage.height;
|
|
2097
|
+
if (spaceHeight > height) {
|
|
2098
|
+
height = spaceHeight;
|
|
2099
|
+
}
|
|
2100
|
+
const spaceDepth = treePage.location.translateZ;
|
|
2101
|
+
if (spaceDepth > depth) {
|
|
2102
|
+
depth = spaceDepth;
|
|
2103
|
+
}
|
|
2104
|
+
});
|
|
2105
|
+
return {
|
|
2106
|
+
width,
|
|
2107
|
+
height,
|
|
2108
|
+
depth,
|
|
2109
|
+
topCorner
|
|
2110
|
+
};
|
|
2111
|
+
};
|
|
2112
|
+
var findPage = (view, pages) => {
|
|
2113
|
+
for (const page of pages) {
|
|
2114
|
+
if (page.route === view) {
|
|
2115
|
+
return page;
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
return;
|
|
2119
|
+
};
|
|
2120
|
+
var splitIntoGroups = (data, length) => {
|
|
2121
|
+
const initialArray = [...data];
|
|
2122
|
+
const groups = [];
|
|
2123
|
+
while (initialArray.length) {
|
|
2124
|
+
const group = initialArray.splice(0, length);
|
|
2125
|
+
groups.push(group);
|
|
2126
|
+
}
|
|
2127
|
+
return groups;
|
|
2128
|
+
};
|
|
2129
|
+
var getTreePlaneByPlaneID = (tree, planeID) => {
|
|
2130
|
+
let _page = null;
|
|
2131
|
+
for (const page of tree) {
|
|
2132
|
+
if (page.planeID === planeID) {
|
|
2133
|
+
_page = page;
|
|
2134
|
+
}
|
|
2135
|
+
if (page.children && !_page) {
|
|
2136
|
+
_page = getTreePlaneByPlaneID(page.children, planeID);
|
|
2137
|
+
}
|
|
2138
|
+
if (_page) {
|
|
2139
|
+
break;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
return _page;
|
|
2143
|
+
};
|
|
2144
|
+
|
|
2145
|
+
// source/modules/space/location/logic.ts
|
|
2146
|
+
var toRadians = mathematics.geometry.toRadians;
|
|
2147
|
+
var computePath = (tree, planeID) => {
|
|
2148
|
+
const path = [];
|
|
2149
|
+
const page = getTreePlaneByPlaneID(tree, planeID);
|
|
2150
|
+
if (page) {
|
|
2151
|
+
path.push({ ...page });
|
|
2152
|
+
let parentID = page.parentPlaneID;
|
|
2153
|
+
if (!parentID) {
|
|
2154
|
+
return path;
|
|
2155
|
+
}
|
|
2156
|
+
while (parentID) {
|
|
2157
|
+
const parentPage = getTreePlaneByPlaneID(tree, parentID);
|
|
2158
|
+
if (parentPage) {
|
|
2159
|
+
const page2 = { ...parentPage };
|
|
2160
|
+
page2.children = [];
|
|
2161
|
+
path.push(page2);
|
|
2162
|
+
parentID = parentPage.parentPlaneID;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
return path.reverse();
|
|
2167
|
+
};
|
|
2168
|
+
var computePluridPlaneLocation = (linkCoordinates, treePageParent, bridgeLength = 100, linkPlaneAngle = 90) => {
|
|
2169
|
+
const parentAngleRadians = toRadians(treePageParent.location.rotateY);
|
|
2170
|
+
const linkPoint = {
|
|
2171
|
+
x: treePageParent.location.translateX + linkCoordinates.x * Math.cos(parentAngleRadians),
|
|
2172
|
+
z: treePageParent.location.translateZ - linkCoordinates.x * Math.sin(parentAngleRadians)
|
|
2173
|
+
};
|
|
2174
|
+
const linkAngleRadians = toRadians(linkPlaneAngle + treePageParent.location.rotateY);
|
|
2175
|
+
const x = linkPoint.x + bridgeLength * Math.cos(linkAngleRadians);
|
|
2176
|
+
const z = linkPoint.z - bridgeLength * Math.sin(linkAngleRadians);
|
|
2177
|
+
const y = treePageParent.location.translateY + linkCoordinates.y;
|
|
2178
|
+
const locationCoordinates = {
|
|
2179
|
+
x,
|
|
2180
|
+
y,
|
|
2181
|
+
z
|
|
2182
|
+
};
|
|
2183
|
+
return locationCoordinates;
|
|
2184
|
+
};
|
|
2185
|
+
var recomputeChildrenLocation = (page) => {
|
|
2186
|
+
if (!page.children) {
|
|
2187
|
+
return [];
|
|
2188
|
+
}
|
|
2189
|
+
const updatedChildren = [];
|
|
2190
|
+
for (const child of page.children) {
|
|
2191
|
+
if (child.linkCoordinates) {
|
|
2192
|
+
const location2 = computePluridPlaneLocation(
|
|
2193
|
+
child.linkCoordinates,
|
|
2194
|
+
page,
|
|
2195
|
+
child.bridgeLength,
|
|
2196
|
+
child.planeAngle
|
|
2197
|
+
);
|
|
2198
|
+
const updatedChild = {
|
|
2199
|
+
...child,
|
|
2200
|
+
location: {
|
|
2201
|
+
...child.location,
|
|
2202
|
+
translateX: location2.x,
|
|
2203
|
+
translateY: location2.y,
|
|
2204
|
+
translateZ: location2.z
|
|
2205
|
+
}
|
|
2206
|
+
};
|
|
2207
|
+
const children = updatedChild.children ? recomputeChildrenLocation(updatedChild) : [];
|
|
2208
|
+
const updatedChildWithChildren = {
|
|
2209
|
+
...updatedChild,
|
|
2210
|
+
children
|
|
2211
|
+
};
|
|
2212
|
+
updatedChildren.push(updatedChildWithChildren);
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
return updatedChildren;
|
|
2216
|
+
};
|
|
2217
|
+
|
|
2218
|
+
// source/modules/space/layout/column.ts
|
|
2219
|
+
var computeColumnLayout = (roots, columns = 1, columnLength, gap = ROOTS_GAP, configuration = defaultConfiguration) => {
|
|
2220
|
+
const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
|
|
2221
|
+
const windowInnerHeight = typeof window === "undefined" ? 840 : window.innerHeight;
|
|
2222
|
+
const tree = [];
|
|
2223
|
+
const configurationWidth = configuration.elements.plane.width;
|
|
2224
|
+
const width = mathematics.numbers.checkIntegerNonUnit(configurationWidth) ? configurationWidth : configurationWidth * windowInnerWidth;
|
|
2225
|
+
const height = windowInnerHeight;
|
|
2226
|
+
const gapValue = mathematics.numbers.checkIntegerNonUnit(gap) ? gap : gap * width;
|
|
2227
|
+
const safeColumns = columns > 0 ? columns : 1;
|
|
2228
|
+
const length = columnLength && columnLength > 0 ? columnLength : Math.ceil(roots.length / safeColumns);
|
|
2229
|
+
for (const [index, root] of roots.entries()) {
|
|
2230
|
+
const rowIndex = index % length;
|
|
2231
|
+
const columnIndex = Math.floor(index / length);
|
|
2232
|
+
const translateX = columnIndex * (width + gapValue);
|
|
2233
|
+
const translateY = rowIndex * (height + gapValue);
|
|
2234
|
+
const treePage = {
|
|
2235
|
+
...root,
|
|
2236
|
+
location: {
|
|
2237
|
+
translateX,
|
|
2238
|
+
translateY,
|
|
2239
|
+
translateZ: 0,
|
|
2240
|
+
rotateX: 0,
|
|
2241
|
+
rotateY: 0
|
|
2242
|
+
}
|
|
2243
|
+
};
|
|
2244
|
+
const children = recomputeChildrenLocation(treePage);
|
|
2245
|
+
const treePageWithChildren = {
|
|
2246
|
+
...treePage,
|
|
2247
|
+
children
|
|
2248
|
+
};
|
|
2249
|
+
tree.push(treePageWithChildren);
|
|
2250
|
+
}
|
|
2251
|
+
return tree;
|
|
2252
|
+
};
|
|
2253
|
+
var column_default = computeColumnLayout;
|
|
2254
|
+
var computeRowLayout = (roots, rows = 1, rowLength, gap = ROOTS_GAP, configuration = defaultConfiguration) => {
|
|
2255
|
+
const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
|
|
2256
|
+
const windowInnerHeight = typeof window === "undefined" ? 840 : window.innerHeight;
|
|
2257
|
+
const tree = [];
|
|
2258
|
+
const configurationWidth = configuration.elements.plane.width;
|
|
2259
|
+
const width = mathematics.numbers.checkIntegerNonUnit(configurationWidth) ? configurationWidth : configurationWidth * windowInnerWidth;
|
|
2260
|
+
const height = windowInnerHeight;
|
|
2261
|
+
const gapValue = mathematics.numbers.checkIntegerNonUnit(gap) ? gap : gap * width;
|
|
2262
|
+
const safeRows = rows > 0 ? rows : 1;
|
|
2263
|
+
const length = rowLength && rowLength > 0 ? rowLength : Math.ceil(roots.length / safeRows);
|
|
2264
|
+
for (const [index, root] of roots.entries()) {
|
|
2265
|
+
const rowIndex = Math.floor(index / length);
|
|
2266
|
+
const columnIndex = index % length;
|
|
2267
|
+
const translateX = columnIndex * (width + gapValue);
|
|
2268
|
+
const translateY = rowIndex * (height + gapValue);
|
|
2269
|
+
const treePage = {
|
|
2270
|
+
...root,
|
|
2271
|
+
location: {
|
|
2272
|
+
translateX,
|
|
2273
|
+
translateY,
|
|
2274
|
+
translateZ: 0,
|
|
2275
|
+
rotateX: 0,
|
|
2276
|
+
rotateY: 0
|
|
2277
|
+
}
|
|
2278
|
+
};
|
|
2279
|
+
const children = recomputeChildrenLocation(treePage);
|
|
2280
|
+
const treePageWithChildren = {
|
|
2281
|
+
...treePage,
|
|
2282
|
+
children
|
|
2283
|
+
};
|
|
2284
|
+
tree.push(treePageWithChildren);
|
|
2285
|
+
}
|
|
2286
|
+
return tree;
|
|
2287
|
+
};
|
|
2288
|
+
var row_default = computeRowLayout;
|
|
2289
|
+
var toRadians2 = mathematics.geometry.toRadians;
|
|
2290
|
+
var computeFaceToFaceTranslateZ = (width, angle, first) => {
|
|
2291
|
+
if (first) {
|
|
2292
|
+
return width * Math.sin(toRadians2(angle));
|
|
2293
|
+
}
|
|
2294
|
+
return 0;
|
|
2295
|
+
};
|
|
2296
|
+
var computeFaceToFaceTranslateX = (width, angle, gap, first, index) => {
|
|
2297
|
+
const firstTranslateX = width * Math.cos(toRadians2(angle));
|
|
2298
|
+
if (first) {
|
|
2299
|
+
return firstTranslateX;
|
|
2300
|
+
}
|
|
2301
|
+
const value = width * (index - 1) + 2 * firstTranslateX + gap * index;
|
|
2302
|
+
return value;
|
|
2303
|
+
};
|
|
2304
|
+
var computeFaceToFaceRotateY = (angle, first, last) => {
|
|
2305
|
+
const rotateY = first ? angle : last ? -angle : 0;
|
|
2306
|
+
return rotateY;
|
|
2307
|
+
};
|
|
2308
|
+
var computeFaceToFaceLayout = (roots, angle = 45, gap = 0, middle = 0, configuration = defaultConfiguration) => {
|
|
2309
|
+
const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
|
|
2310
|
+
const windowInnerHeight = typeof window === "undefined" ? 840 : window.innerHeight;
|
|
2311
|
+
const tree = [];
|
|
2312
|
+
const width = mathematics.numbers.checkIntegerNonUnit(configuration.elements.plane.width) ? configuration.elements.plane.width : configuration.elements.plane.width * windowInnerWidth;
|
|
2313
|
+
const height = windowInnerHeight;
|
|
2314
|
+
const planeAngle = 90 - angle / 2;
|
|
2315
|
+
const columns = 2 + middle;
|
|
2316
|
+
const rows = splitIntoGroups(roots, columns);
|
|
2317
|
+
const gapValue = mathematics.numbers.checkIntegerNonUnit(gap) ? gap : gap * width;
|
|
2318
|
+
for (const [rowIndex, row] of rows.entries()) {
|
|
2319
|
+
const translateY = rowIndex * (height + gapValue);
|
|
2320
|
+
for (const [index, page] of row.entries()) {
|
|
2321
|
+
const first = index === 0;
|
|
2322
|
+
const last = index === row.length - 1;
|
|
2323
|
+
const translateZ = computeFaceToFaceTranslateZ(
|
|
2324
|
+
width,
|
|
2325
|
+
planeAngle,
|
|
2326
|
+
first
|
|
2327
|
+
);
|
|
2328
|
+
const translateX = computeFaceToFaceTranslateX(
|
|
2329
|
+
width,
|
|
2330
|
+
planeAngle,
|
|
2331
|
+
gapValue,
|
|
2332
|
+
first,
|
|
2333
|
+
index
|
|
2334
|
+
);
|
|
2335
|
+
const rotateY = computeFaceToFaceRotateY(
|
|
2336
|
+
planeAngle,
|
|
2337
|
+
first,
|
|
2338
|
+
last
|
|
2339
|
+
);
|
|
2340
|
+
const treePage = {
|
|
2341
|
+
...page,
|
|
2342
|
+
location: {
|
|
2343
|
+
translateX,
|
|
2344
|
+
translateY,
|
|
2345
|
+
translateZ,
|
|
2346
|
+
rotateX: 0,
|
|
2347
|
+
rotateY
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
const children = recomputeChildrenLocation(treePage);
|
|
2351
|
+
const treePageWithChildren = {
|
|
2352
|
+
...treePage,
|
|
2353
|
+
children
|
|
2354
|
+
};
|
|
2355
|
+
tree.push(treePageWithChildren);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
return tree;
|
|
2359
|
+
};
|
|
2360
|
+
var faceToFace_default = computeFaceToFaceLayout;
|
|
2361
|
+
var computeSheavesLayout = (roots, depth = 0.3, offsetX = 0, offsetY = 0, configuration = defaultConfiguration) => {
|
|
2362
|
+
const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
|
|
2363
|
+
const tree = [];
|
|
2364
|
+
const width = mathematics.numbers.checkIntegerNonUnit(configuration.elements.plane.width) ? configuration.elements.plane.width : configuration.elements.plane.width * windowInnerWidth;
|
|
2365
|
+
const depthStep = mathematics.numbers.checkIntegerNonUnit(depth) ? depth : depth * width;
|
|
2366
|
+
for (const [index, page] of roots.entries()) {
|
|
2367
|
+
const translateX = index * offsetX;
|
|
2368
|
+
const translateY = index * offsetY;
|
|
2369
|
+
const translateZ = -index * depthStep;
|
|
2370
|
+
const treePage = {
|
|
2371
|
+
...page,
|
|
2372
|
+
location: {
|
|
2373
|
+
translateX,
|
|
2374
|
+
translateY,
|
|
2375
|
+
translateZ,
|
|
2376
|
+
rotateX: 0,
|
|
2377
|
+
rotateY: 0
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
const children = recomputeChildrenLocation(treePage);
|
|
2381
|
+
const treePageWithChildren = {
|
|
2382
|
+
...treePage,
|
|
2383
|
+
children
|
|
2384
|
+
};
|
|
2385
|
+
tree.push(treePageWithChildren);
|
|
2386
|
+
}
|
|
2387
|
+
return tree;
|
|
2388
|
+
};
|
|
2389
|
+
var sheaves_default = computeSheavesLayout;
|
|
2390
|
+
var computeZigZagLayout = (pages, angle = 45, configuration = defaultConfiguration) => {
|
|
2391
|
+
const tree = [];
|
|
2392
|
+
const singleColumnedRoots = column_default(pages, 1);
|
|
2393
|
+
for (const [index, page] of singleColumnedRoots.entries()) {
|
|
2394
|
+
const value = index % 2 === 0 ? 1 : -1;
|
|
2395
|
+
page.location.rotateY = value * angle;
|
|
2396
|
+
const children = recomputeChildrenLocation(page);
|
|
2397
|
+
const treePageWithChildren = {
|
|
2398
|
+
...page,
|
|
2399
|
+
children
|
|
2400
|
+
};
|
|
2401
|
+
tree.push(
|
|
2402
|
+
{ ...treePageWithChildren }
|
|
2403
|
+
);
|
|
2404
|
+
}
|
|
2405
|
+
return tree;
|
|
2406
|
+
};
|
|
2407
|
+
var zigZag_default = computeZigZagLayout;
|
|
2408
|
+
|
|
2409
|
+
// source/modules/space/tree/index.ts
|
|
2410
|
+
var tree_exports2 = {};
|
|
2411
|
+
__export(tree_exports2, {
|
|
2412
|
+
Tree: () => Tree,
|
|
2413
|
+
logic: () => logic_exports
|
|
2414
|
+
});
|
|
2415
|
+
|
|
2416
|
+
// source/modules/space/tree/logic.ts
|
|
2417
|
+
var logic_exports = {};
|
|
2418
|
+
__export(logic_exports, {
|
|
2419
|
+
computeSpaceTree: () => computeSpaceTree,
|
|
2420
|
+
getTreePlaneByID: () => getTreePlaneByID,
|
|
2421
|
+
reconcileTree: () => reconcileTree,
|
|
2422
|
+
removePlaneFromTree: () => removePlaneFromTree,
|
|
2423
|
+
removeRootFromTree: () => removeRootFromTree,
|
|
2424
|
+
resolveViewItem: () => resolveViewItem,
|
|
2425
|
+
toggleAllChildren: () => toggleAllChildren,
|
|
2426
|
+
toggleChildren: () => toggleChildren,
|
|
2427
|
+
togglePlaneFromTree: () => togglePlaneFromTree,
|
|
2428
|
+
updatePlaneLocation: () => updatePlaneLocation,
|
|
2429
|
+
updateTreePlane: () => updateTreePlane2,
|
|
2430
|
+
updateTreeWithNewPage: () => updateTreeWithNewPage,
|
|
2431
|
+
updateTreeWithNewPlane: () => updateTreeWithNewPlane
|
|
2432
|
+
});
|
|
2433
|
+
var resolveViewItem = (planes, view, configuration, origin = "origin", getCount) => {
|
|
2434
|
+
const {
|
|
2435
|
+
protocol,
|
|
2436
|
+
host
|
|
2437
|
+
} = configuration.network;
|
|
2438
|
+
const viewData = typeof view === "string" ? view : view.plane;
|
|
2439
|
+
const viewAddress = computePlaneAddress(
|
|
2440
|
+
viewData,
|
|
2441
|
+
void 0,
|
|
2442
|
+
origin
|
|
2443
|
+
);
|
|
2444
|
+
const iPlanes = planes.values();
|
|
2445
|
+
const pluridPlanes = [];
|
|
2446
|
+
for (const iPlane of iPlanes) {
|
|
2447
|
+
const plane = {
|
|
2448
|
+
route: iPlane.route.absolute,
|
|
2449
|
+
component: iPlane.component
|
|
2450
|
+
};
|
|
2451
|
+
pluridPlanes.push(plane);
|
|
2452
|
+
}
|
|
2453
|
+
const isoMatcher = new IsoMatcher_default(
|
|
2454
|
+
{
|
|
2455
|
+
planes: pluridPlanes
|
|
2456
|
+
},
|
|
2457
|
+
origin
|
|
2458
|
+
);
|
|
2459
|
+
const match = isoMatcher.match(viewData);
|
|
2460
|
+
if (match) {
|
|
2461
|
+
const route = match.match.value;
|
|
2462
|
+
const count = getCount ? getCount() : uuid.generate();
|
|
2463
|
+
const planeID = route + "@" + count;
|
|
2464
|
+
const treePlane = {
|
|
2465
|
+
sourceID: route,
|
|
2466
|
+
planeID,
|
|
2467
|
+
// route: resolvedView.route,
|
|
2468
|
+
route: viewAddress,
|
|
2469
|
+
routeDivisions: {
|
|
2470
|
+
protocol: {
|
|
2471
|
+
value: "",
|
|
2472
|
+
secure: false
|
|
2473
|
+
},
|
|
2474
|
+
host: {
|
|
2475
|
+
value: host,
|
|
2476
|
+
controlled: true
|
|
2477
|
+
},
|
|
2478
|
+
path: {
|
|
2479
|
+
parameters: {},
|
|
2480
|
+
query: {},
|
|
2481
|
+
value: ""
|
|
2482
|
+
},
|
|
2483
|
+
space: {
|
|
2484
|
+
parameters: {},
|
|
2485
|
+
query: {},
|
|
2486
|
+
value: ""
|
|
2487
|
+
},
|
|
2488
|
+
universe: {
|
|
2489
|
+
parameters: {},
|
|
2490
|
+
query: {},
|
|
2491
|
+
value: ""
|
|
2492
|
+
},
|
|
2493
|
+
cluster: {
|
|
2494
|
+
parameters: {},
|
|
2495
|
+
query: {},
|
|
2496
|
+
value: ""
|
|
2497
|
+
},
|
|
2498
|
+
plane: {
|
|
2499
|
+
parameters: {},
|
|
2500
|
+
fragments: {
|
|
2501
|
+
elements: [],
|
|
2502
|
+
texts: []
|
|
2503
|
+
},
|
|
2504
|
+
query: {},
|
|
2505
|
+
value: ""
|
|
2506
|
+
},
|
|
2507
|
+
valid: true
|
|
2508
|
+
},
|
|
2509
|
+
height: 0,
|
|
2510
|
+
width: 0,
|
|
2511
|
+
location: {
|
|
2512
|
+
translateX: 0,
|
|
2513
|
+
translateY: 0,
|
|
2514
|
+
translateZ: 0,
|
|
2515
|
+
rotateX: 0,
|
|
2516
|
+
rotateY: 0
|
|
2517
|
+
},
|
|
2518
|
+
show: true
|
|
2519
|
+
};
|
|
2520
|
+
return treePlane;
|
|
2521
|
+
}
|
|
2522
|
+
return;
|
|
2523
|
+
};
|
|
2524
|
+
var computeSpaceTree = (planes, view, configuration, layout, origin = "origin", getCount) => {
|
|
2525
|
+
const treePlanes = [];
|
|
2526
|
+
for (const viewItem of view) {
|
|
2527
|
+
const treePlane = resolveViewItem(
|
|
2528
|
+
planes,
|
|
2529
|
+
viewItem,
|
|
2530
|
+
configuration,
|
|
2531
|
+
origin,
|
|
2532
|
+
getCount
|
|
2533
|
+
);
|
|
2534
|
+
if (treePlane) {
|
|
2535
|
+
treePlanes.push(treePlane);
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
if (!layout) {
|
|
2539
|
+
const layoutlessTreePlanes = treePlanes.map((plane) => {
|
|
2540
|
+
return {
|
|
2541
|
+
...plane,
|
|
2542
|
+
location: {
|
|
2543
|
+
rotateX: 0,
|
|
2544
|
+
rotateY: 0,
|
|
2545
|
+
translateX: 0,
|
|
2546
|
+
translateY: 0,
|
|
2547
|
+
translateZ: 0
|
|
2548
|
+
}
|
|
2549
|
+
};
|
|
2550
|
+
});
|
|
2551
|
+
return layoutlessTreePlanes;
|
|
2552
|
+
}
|
|
2553
|
+
switch (configuration.space.layout.type) {
|
|
2554
|
+
case LAYOUT_TYPES.COLUMNS: {
|
|
2555
|
+
const {
|
|
2556
|
+
columns,
|
|
2557
|
+
columnLength,
|
|
2558
|
+
gap
|
|
2559
|
+
} = configuration.space.layout;
|
|
2560
|
+
const columnLayoutTree = column_default(
|
|
2561
|
+
treePlanes,
|
|
2562
|
+
columns,
|
|
2563
|
+
columnLength,
|
|
2564
|
+
gap,
|
|
2565
|
+
configuration
|
|
2566
|
+
);
|
|
2567
|
+
return columnLayoutTree;
|
|
2568
|
+
}
|
|
2569
|
+
case LAYOUT_TYPES.ROWS: {
|
|
2570
|
+
const {
|
|
2571
|
+
rows,
|
|
2572
|
+
rowLength,
|
|
2573
|
+
gap
|
|
2574
|
+
} = configuration.space.layout;
|
|
2575
|
+
const rowLayoutTree = row_default(
|
|
2576
|
+
treePlanes,
|
|
2577
|
+
rows,
|
|
2578
|
+
rowLength,
|
|
2579
|
+
gap,
|
|
2580
|
+
configuration
|
|
2581
|
+
);
|
|
2582
|
+
return rowLayoutTree;
|
|
2583
|
+
}
|
|
2584
|
+
case LAYOUT_TYPES.ZIG_ZAG: {
|
|
2585
|
+
const {
|
|
2586
|
+
angle
|
|
2587
|
+
} = configuration.space.layout;
|
|
2588
|
+
const zigzagLayoutTree = zigZag_default(
|
|
2589
|
+
treePlanes,
|
|
2590
|
+
angle,
|
|
2591
|
+
configuration
|
|
2592
|
+
);
|
|
2593
|
+
return zigzagLayoutTree;
|
|
2594
|
+
}
|
|
2595
|
+
case LAYOUT_TYPES.FACE_TO_FACE: {
|
|
2596
|
+
const {
|
|
2597
|
+
angle,
|
|
2598
|
+
gap,
|
|
2599
|
+
middle
|
|
2600
|
+
} = configuration.space.layout;
|
|
2601
|
+
const faceToFaceLayoutTree = faceToFace_default(
|
|
2602
|
+
treePlanes,
|
|
2603
|
+
angle,
|
|
2604
|
+
gap,
|
|
2605
|
+
middle,
|
|
2606
|
+
configuration
|
|
2607
|
+
);
|
|
2608
|
+
return faceToFaceLayoutTree;
|
|
2609
|
+
}
|
|
2610
|
+
case LAYOUT_TYPES.SHEAVES: {
|
|
2611
|
+
const {
|
|
2612
|
+
depth,
|
|
2613
|
+
offsetX,
|
|
2614
|
+
offsetY
|
|
2615
|
+
} = configuration.space.layout;
|
|
2616
|
+
const sheavesLayoutTree = sheaves_default(
|
|
2617
|
+
treePlanes,
|
|
2618
|
+
depth,
|
|
2619
|
+
offsetX,
|
|
2620
|
+
offsetY,
|
|
2621
|
+
configuration
|
|
2622
|
+
);
|
|
2623
|
+
return sheavesLayoutTree;
|
|
2624
|
+
}
|
|
2625
|
+
case LAYOUT_TYPES.META: {
|
|
2626
|
+
return [];
|
|
2627
|
+
}
|
|
2628
|
+
default:
|
|
2629
|
+
return [];
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
2632
|
+
var updateTreePlane2 = (tree, updatedPlane) => {
|
|
2633
|
+
let changed = false;
|
|
2634
|
+
const mapped = tree.map((treePlane) => {
|
|
2635
|
+
if (treePlane.planeID === updatedPlane.planeID) {
|
|
2636
|
+
changed = true;
|
|
2637
|
+
return updatedPlane;
|
|
2638
|
+
}
|
|
2639
|
+
if (treePlane.children) {
|
|
2640
|
+
const newChildren = updateTreePlane2(
|
|
2641
|
+
treePlane.children,
|
|
2642
|
+
updatedPlane
|
|
2643
|
+
);
|
|
2644
|
+
if (newChildren !== treePlane.children) {
|
|
2645
|
+
changed = true;
|
|
2646
|
+
return {
|
|
2647
|
+
...treePlane,
|
|
2648
|
+
children: newChildren
|
|
2649
|
+
};
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
return treePlane;
|
|
2653
|
+
});
|
|
2654
|
+
return changed ? mapped : tree;
|
|
2655
|
+
};
|
|
2656
|
+
var updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree, planesRegistry, configuration, hostname = "origin") => {
|
|
2657
|
+
const parentPlane = getTreePlaneByPlaneID(tree, parentPlaneID);
|
|
2658
|
+
if (!parentPlane) {
|
|
2659
|
+
return {
|
|
2660
|
+
pluridPlaneID: "",
|
|
2661
|
+
updatedTree: tree
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
const location2 = computePluridPlaneLocation(
|
|
2665
|
+
linkCoordinates,
|
|
2666
|
+
parentPlane,
|
|
2667
|
+
// Couple the parent→child GAP to the same configured length the bridge renders at,
|
|
2668
|
+
// otherwise the bridge visual (width) overshoots/undershoots the actual gap.
|
|
2669
|
+
configuration.space.bridge?.length ?? 100
|
|
2670
|
+
);
|
|
2671
|
+
const treePlane = resolveViewItem(
|
|
2672
|
+
planesRegistry,
|
|
2673
|
+
planeRoute,
|
|
2674
|
+
configuration,
|
|
2675
|
+
hostname
|
|
2676
|
+
);
|
|
2677
|
+
if (!treePlane) {
|
|
2678
|
+
return {
|
|
2679
|
+
pluridPlaneID: "",
|
|
2680
|
+
updatedTree: tree
|
|
2681
|
+
};
|
|
2682
|
+
}
|
|
2683
|
+
const updatedTreePlane = {
|
|
2684
|
+
...treePlane,
|
|
2685
|
+
parentPlaneID,
|
|
2686
|
+
location: {
|
|
2687
|
+
translateX: location2.x,
|
|
2688
|
+
translateY: location2.y,
|
|
2689
|
+
translateZ: location2.z,
|
|
2690
|
+
rotateX: 0,
|
|
2691
|
+
rotateY: parentPlane.location.rotateY + PLANE_DEFAULT_ANGLE
|
|
2692
|
+
},
|
|
2693
|
+
// Configurable bridge geometry (defaults preserve the original 100 / 90).
|
|
2694
|
+
bridgeLength: configuration.space.bridge?.length ?? 100,
|
|
2695
|
+
planeAngle: configuration.space.bridge?.planeAngle ?? 90,
|
|
2696
|
+
linkCoordinates
|
|
2697
|
+
};
|
|
2698
|
+
const updatedParentPlane = {
|
|
2699
|
+
...parentPlane,
|
|
2700
|
+
children: parentPlane.children ? [...parentPlane.children, updatedTreePlane] : [updatedTreePlane]
|
|
2701
|
+
};
|
|
2702
|
+
const updatedTree = updateTreePlane2(tree, updatedParentPlane);
|
|
2703
|
+
return {
|
|
2704
|
+
pluridPlaneID: updatedTreePlane.planeID,
|
|
2705
|
+
updatedTree,
|
|
2706
|
+
updatedTreePlane
|
|
2707
|
+
};
|
|
2708
|
+
};
|
|
2709
|
+
var updatePlaneLocation = (tree, parentPlaneID, planeID, linkCoordinates) => {
|
|
2710
|
+
const parentPlane = getTreePlaneByPlaneID(tree, parentPlaneID);
|
|
2711
|
+
const plane = getTreePlaneByPlaneID(tree, planeID);
|
|
2712
|
+
if (!parentPlane || !plane) {
|
|
2713
|
+
return tree;
|
|
2714
|
+
}
|
|
2715
|
+
const location2 = computePluridPlaneLocation(
|
|
2716
|
+
linkCoordinates,
|
|
2717
|
+
parentPlane,
|
|
2718
|
+
// Use the plane's STORED bridge geometry (set at spawn from config), otherwise this
|
|
2719
|
+
// recompute resets the gap to the default 100 and the bridge visual overshoots.
|
|
2720
|
+
plane.bridgeLength,
|
|
2721
|
+
plane.planeAngle
|
|
2722
|
+
);
|
|
2723
|
+
const updatedPlane = {
|
|
2724
|
+
...plane,
|
|
2725
|
+
location: {
|
|
2726
|
+
translateX: location2.x,
|
|
2727
|
+
translateY: location2.y,
|
|
2728
|
+
translateZ: location2.z,
|
|
2729
|
+
rotateX: 0,
|
|
2730
|
+
rotateY: parentPlane.location.rotateY + PLANE_DEFAULT_ANGLE
|
|
2731
|
+
}
|
|
2732
|
+
};
|
|
2733
|
+
const updatedTree = updateTreePlane2(
|
|
2734
|
+
tree,
|
|
2735
|
+
updatedPlane
|
|
2736
|
+
);
|
|
2737
|
+
return updatedTree;
|
|
2738
|
+
};
|
|
2739
|
+
var updateTreeWithNewPage = (tree, treePageParentPlaneID, pagePath, pageID, linkCoordinates, parameters) => {
|
|
2740
|
+
const treePageParent = getTreePlaneByPlaneID(tree, treePageParentPlaneID);
|
|
2741
|
+
if (treePageParent) {
|
|
2742
|
+
const location2 = computePluridPlaneLocation(
|
|
2743
|
+
linkCoordinates,
|
|
2744
|
+
treePageParent
|
|
2745
|
+
);
|
|
2746
|
+
const planeID = uuid.generate();
|
|
2747
|
+
const newTreePlane = {
|
|
2748
|
+
sourceID: pageID,
|
|
2749
|
+
route: pagePath,
|
|
2750
|
+
routeDivisions: {
|
|
2751
|
+
protocol: {
|
|
2752
|
+
value: "",
|
|
2753
|
+
secure: false
|
|
2754
|
+
},
|
|
2755
|
+
host: {
|
|
2756
|
+
value: "",
|
|
2757
|
+
controlled: false
|
|
2758
|
+
},
|
|
2759
|
+
path: {
|
|
2760
|
+
value: "",
|
|
2761
|
+
parameters: {},
|
|
2762
|
+
query: {}
|
|
2763
|
+
},
|
|
2764
|
+
space: {
|
|
2765
|
+
value: "",
|
|
2766
|
+
parameters: {},
|
|
2767
|
+
query: {}
|
|
2768
|
+
},
|
|
2769
|
+
universe: {
|
|
2770
|
+
value: "",
|
|
2771
|
+
parameters: {},
|
|
2772
|
+
query: {}
|
|
2773
|
+
},
|
|
2774
|
+
cluster: {
|
|
2775
|
+
value: "",
|
|
2776
|
+
parameters: {},
|
|
2777
|
+
query: {}
|
|
2778
|
+
},
|
|
2779
|
+
plane: {
|
|
2780
|
+
value: "",
|
|
2781
|
+
parameters: {},
|
|
2782
|
+
query: {},
|
|
2783
|
+
fragments: {
|
|
2784
|
+
texts: [],
|
|
2785
|
+
elements: []
|
|
2786
|
+
}
|
|
2787
|
+
},
|
|
2788
|
+
valid: false
|
|
2789
|
+
},
|
|
2790
|
+
// parameters: extractedParameters,
|
|
2791
|
+
// parameters: {},
|
|
2792
|
+
planeID,
|
|
2793
|
+
width: 0,
|
|
2794
|
+
height: 0,
|
|
2795
|
+
parentPlaneID: treePageParentPlaneID,
|
|
2796
|
+
location: {
|
|
2797
|
+
translateX: location2.x,
|
|
2798
|
+
translateY: location2.y,
|
|
2799
|
+
translateZ: location2.z,
|
|
2800
|
+
rotateX: 0,
|
|
2801
|
+
rotateY: treePageParent.location.rotateY + PLANE_DEFAULT_ANGLE
|
|
2802
|
+
},
|
|
2803
|
+
show: true,
|
|
2804
|
+
bridgeLength: 100,
|
|
2805
|
+
planeAngle: 90,
|
|
2806
|
+
linkCoordinates
|
|
2807
|
+
};
|
|
2808
|
+
const updatedTreePlaneParent = {
|
|
2809
|
+
...treePageParent,
|
|
2810
|
+
children: treePageParent.children ? [...treePageParent.children, newTreePlane] : [newTreePlane]
|
|
2811
|
+
};
|
|
2812
|
+
const updatedTree = updateTreePlane2(tree, updatedTreePlaneParent);
|
|
2813
|
+
return {
|
|
2814
|
+
pluridPlaneID: planeID,
|
|
2815
|
+
updatedTree
|
|
2816
|
+
};
|
|
2817
|
+
}
|
|
2818
|
+
return {
|
|
2819
|
+
pluridPlaneID: "",
|
|
2820
|
+
updatedTree: tree
|
|
2821
|
+
};
|
|
2822
|
+
};
|
|
2823
|
+
var toggleChildren = (children) => {
|
|
2824
|
+
const updatedChildren = children.map((child) => {
|
|
2825
|
+
if (child.children) {
|
|
2826
|
+
const updatedChild2 = {
|
|
2827
|
+
...child,
|
|
2828
|
+
show: !child.show,
|
|
2829
|
+
children: toggleChildren(child.children)
|
|
2830
|
+
};
|
|
2831
|
+
return updatedChild2;
|
|
2832
|
+
}
|
|
2833
|
+
const updatedChild = {
|
|
2834
|
+
...child,
|
|
2835
|
+
show: !child.show
|
|
2836
|
+
};
|
|
2837
|
+
return updatedChild;
|
|
2838
|
+
});
|
|
2839
|
+
return updatedChildren;
|
|
2840
|
+
};
|
|
2841
|
+
var toggleAllChildren = (tree, show) => {
|
|
2842
|
+
return tree.map((plane) => ({
|
|
2843
|
+
...plane,
|
|
2844
|
+
show,
|
|
2845
|
+
children: plane.children ? toggleAllChildren(plane.children, show) : plane.children
|
|
2846
|
+
}));
|
|
2847
|
+
};
|
|
2848
|
+
var togglePlaneFromTree = (tree, pluridPlaneID, forceShow) => {
|
|
2849
|
+
const updatedTree = [];
|
|
2850
|
+
let updatedPlane;
|
|
2851
|
+
for (const plane of tree) {
|
|
2852
|
+
if (plane.planeID === pluridPlaneID) {
|
|
2853
|
+
const show = forceShow ?? !plane.show;
|
|
2854
|
+
const treeUpdatedPlane = {
|
|
2855
|
+
...plane,
|
|
2856
|
+
show
|
|
2857
|
+
};
|
|
2858
|
+
if (treeUpdatedPlane.children) {
|
|
2859
|
+
const children = toggleAllChildren(
|
|
2860
|
+
treeUpdatedPlane.children,
|
|
2861
|
+
show
|
|
2862
|
+
);
|
|
2863
|
+
treeUpdatedPlane.children = children;
|
|
2864
|
+
}
|
|
2865
|
+
updatedTree.push(treeUpdatedPlane);
|
|
2866
|
+
updatedPlane = {
|
|
2867
|
+
...treeUpdatedPlane
|
|
2868
|
+
};
|
|
2869
|
+
continue;
|
|
2870
|
+
}
|
|
2871
|
+
if (plane.children) {
|
|
2872
|
+
const {
|
|
2873
|
+
updatedTree: childrenUpdatedTree,
|
|
2874
|
+
updatedPlane: childrenUpdatedPlane
|
|
2875
|
+
} = togglePlaneFromTree(
|
|
2876
|
+
plane.children,
|
|
2877
|
+
pluridPlaneID,
|
|
2878
|
+
forceShow
|
|
2879
|
+
);
|
|
2880
|
+
updatedTree.push({
|
|
2881
|
+
...plane,
|
|
2882
|
+
children: [...childrenUpdatedTree]
|
|
2883
|
+
});
|
|
2884
|
+
if (childrenUpdatedPlane) {
|
|
2885
|
+
updatedPlane = {
|
|
2886
|
+
...childrenUpdatedPlane
|
|
2887
|
+
};
|
|
2888
|
+
}
|
|
2889
|
+
continue;
|
|
2890
|
+
}
|
|
2891
|
+
updatedTree.push(plane);
|
|
2892
|
+
}
|
|
2893
|
+
return {
|
|
2894
|
+
updatedTree,
|
|
2895
|
+
updatedPlane
|
|
2896
|
+
};
|
|
2897
|
+
};
|
|
2898
|
+
var getTreePlaneByID = (stateTree, id) => {
|
|
2899
|
+
if (!id) {
|
|
2900
|
+
return;
|
|
2901
|
+
}
|
|
2902
|
+
for (const plane of stateTree) {
|
|
2903
|
+
if (plane.planeID === id) {
|
|
2904
|
+
return plane;
|
|
2905
|
+
}
|
|
2906
|
+
if (plane.children) {
|
|
2907
|
+
const found = getTreePlaneByID(
|
|
2908
|
+
plane.children,
|
|
2909
|
+
id
|
|
2910
|
+
);
|
|
2911
|
+
if (found) {
|
|
2912
|
+
return found;
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
return;
|
|
2917
|
+
};
|
|
2918
|
+
var removeRootFromTree = (tree, pluridPlaneID) => {
|
|
2919
|
+
const updatedTree = tree.filter((plane) => plane.planeID !== pluridPlaneID);
|
|
2920
|
+
return {
|
|
2921
|
+
updatedTree
|
|
2922
|
+
};
|
|
2923
|
+
};
|
|
2924
|
+
var removePlaneFromTree = (tree, pluridPlaneID) => {
|
|
2925
|
+
let changed = false;
|
|
2926
|
+
const updatedTree = [];
|
|
2927
|
+
for (const plane of tree) {
|
|
2928
|
+
if (plane.planeID === pluridPlaneID) {
|
|
2929
|
+
changed = true;
|
|
2930
|
+
continue;
|
|
2931
|
+
}
|
|
2932
|
+
if (plane.children) {
|
|
2933
|
+
const children = removePlaneFromTree(
|
|
2934
|
+
plane.children,
|
|
2935
|
+
pluridPlaneID
|
|
2936
|
+
);
|
|
2937
|
+
if (children !== plane.children) {
|
|
2938
|
+
changed = true;
|
|
2939
|
+
updatedTree.push({ ...plane, children });
|
|
2940
|
+
continue;
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
updatedTree.push(plane);
|
|
2944
|
+
}
|
|
2945
|
+
return changed ? updatedTree : tree;
|
|
2946
|
+
};
|
|
2947
|
+
var carriedDimension = (next, previous) => !next && previous ? previous : next;
|
|
2948
|
+
var sameLocation = (a, b) => a.translateX === b.translateX && a.translateY === b.translateY && a.translateZ === b.translateZ && a.rotateX === b.rotateX && a.rotateY === b.rotateY;
|
|
2949
|
+
var sameNodeOwnFieldsExceptLocation = (a, b) => a.sourceID === b.sourceID && a.planeID === b.planeID && a.parentPlaneID === b.parentPlaneID && a.route === b.route && a.show === b.show && a.bridgeLength === b.bridgeLength && a.planeAngle === b.planeAngle;
|
|
2950
|
+
var sameNodeOwnFields = (a, b) => sameNodeOwnFieldsExceptLocation(a, b) && sameLocation(a.location, b.location);
|
|
2951
|
+
function reconcileNodeList(previous, next) {
|
|
2952
|
+
if (!previous || previous.length === 0) {
|
|
2953
|
+
return next;
|
|
2954
|
+
}
|
|
2955
|
+
const previousByID = /* @__PURE__ */ new Map();
|
|
2956
|
+
for (const node of previous) {
|
|
2957
|
+
if (node.planeID) {
|
|
2958
|
+
previousByID.set(node.planeID, node);
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
let everyReused = previous.length === next.length;
|
|
2962
|
+
const reconciled = next.map((nextNode, index) => {
|
|
2963
|
+
const previousNode = nextNode.planeID && previousByID.get(nextNode.planeID) || previous[index];
|
|
2964
|
+
const result = reconcileNode(previousNode, nextNode);
|
|
2965
|
+
if (result !== previous[index]) {
|
|
2966
|
+
everyReused = false;
|
|
2967
|
+
}
|
|
2968
|
+
return result;
|
|
2969
|
+
});
|
|
2970
|
+
return everyReused ? previous : reconciled;
|
|
2971
|
+
}
|
|
2972
|
+
function reconcileNode(previous, next) {
|
|
2973
|
+
if (!previous || previous === next) {
|
|
2974
|
+
return next;
|
|
2975
|
+
}
|
|
2976
|
+
let children = next.children;
|
|
2977
|
+
if (next.children && next.children.length > 0) {
|
|
2978
|
+
children = reconcileNodeList(previous.children, next.children);
|
|
2979
|
+
} else if ((!next.children || next.children.length === 0) && previous.children && previous.children.length === 0) {
|
|
2980
|
+
children = previous.children;
|
|
2981
|
+
}
|
|
2982
|
+
const width = carriedDimension(next.width, previous.width);
|
|
2983
|
+
const height = carriedDimension(next.height, previous.height);
|
|
2984
|
+
const pinned = previous.manuallyPositioned === true;
|
|
2985
|
+
const location2 = pinned ? previous.location : next.location;
|
|
2986
|
+
const manuallyPositioned = pinned ? true : next.manuallyPositioned;
|
|
2987
|
+
const ownUnchanged = pinned ? sameNodeOwnFieldsExceptLocation(previous, next) : sameNodeOwnFields(previous, next);
|
|
2988
|
+
const unchanged = ownUnchanged && children === previous.children && width === previous.width && height === previous.height && manuallyPositioned === previous.manuallyPositioned;
|
|
2989
|
+
if (unchanged) {
|
|
2990
|
+
return previous;
|
|
2991
|
+
}
|
|
2992
|
+
if (children !== next.children || width !== next.width || height !== next.height || location2 !== next.location || manuallyPositioned !== next.manuallyPositioned) {
|
|
2993
|
+
return {
|
|
2994
|
+
...next,
|
|
2995
|
+
width,
|
|
2996
|
+
height,
|
|
2997
|
+
children,
|
|
2998
|
+
location: location2,
|
|
2999
|
+
manuallyPositioned
|
|
3000
|
+
};
|
|
3001
|
+
}
|
|
3002
|
+
return next;
|
|
3003
|
+
}
|
|
3004
|
+
var reconcileTree = (previousTree, nextTree) => {
|
|
3005
|
+
if (!previousTree || previousTree === nextTree) {
|
|
3006
|
+
return nextTree;
|
|
3007
|
+
}
|
|
3008
|
+
return reconcileNodeList(previousTree, nextTree);
|
|
3009
|
+
};
|
|
3010
|
+
|
|
3011
|
+
// source/modules/space/tree/object.ts
|
|
3012
|
+
var Tree = class {
|
|
3013
|
+
data;
|
|
3014
|
+
origin;
|
|
3015
|
+
count = 0;
|
|
3016
|
+
constructor(data, origin = "origin") {
|
|
3017
|
+
this.data = data;
|
|
3018
|
+
this.origin = origin;
|
|
3019
|
+
}
|
|
3020
|
+
compute() {
|
|
3021
|
+
const {
|
|
3022
|
+
planes,
|
|
3023
|
+
view,
|
|
3024
|
+
configuration,
|
|
3025
|
+
layout
|
|
3026
|
+
} = this.data;
|
|
3027
|
+
return computeSpaceTree(
|
|
3028
|
+
planes,
|
|
3029
|
+
view,
|
|
3030
|
+
configuration,
|
|
3031
|
+
layout,
|
|
3032
|
+
this.origin,
|
|
3033
|
+
this.getCount.bind(this)
|
|
3034
|
+
);
|
|
3035
|
+
}
|
|
3036
|
+
getCount() {
|
|
3037
|
+
return this.count++;
|
|
3038
|
+
}
|
|
3039
|
+
};
|
|
3040
|
+
|
|
3041
|
+
// source/modules/space/view/index.ts
|
|
3042
|
+
var view_exports = {};
|
|
3043
|
+
__export(view_exports, {
|
|
3044
|
+
checkPageInView: () => checkPageInView,
|
|
3045
|
+
computeCulledView: () => computeCulledView,
|
|
3046
|
+
computeViewTree: () => computeViewTree
|
|
3047
|
+
});
|
|
3048
|
+
|
|
3049
|
+
// source/modules/space/view/logic.ts
|
|
3050
|
+
var computeViewTree = (pages, view) => {
|
|
3051
|
+
const viewTree = [];
|
|
3052
|
+
for (const pageView of view) {
|
|
3053
|
+
const page = pages.find((p) => p.route === pageView);
|
|
3054
|
+
if (page) {
|
|
3055
|
+
viewTree.push(page);
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
return viewTree;
|
|
3059
|
+
};
|
|
3060
|
+
var computeCulledView = (pages, view, location2, radius = 8e3) => {
|
|
3061
|
+
const culledView = [];
|
|
3062
|
+
for (const viewPage of view) {
|
|
3063
|
+
const path = typeof viewPage === "string" ? viewPage : viewPage.plane;
|
|
3064
|
+
const page = findPage(
|
|
3065
|
+
path,
|
|
3066
|
+
pages
|
|
3067
|
+
);
|
|
3068
|
+
if (!page) {
|
|
3069
|
+
return;
|
|
3070
|
+
}
|
|
3071
|
+
const pageInView = checkPageInView(
|
|
3072
|
+
page,
|
|
3073
|
+
location2,
|
|
3074
|
+
radius
|
|
3075
|
+
);
|
|
3076
|
+
if (pageInView) {
|
|
3077
|
+
culledView.push(
|
|
3078
|
+
page.route
|
|
3079
|
+
);
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
return culledView;
|
|
3083
|
+
};
|
|
3084
|
+
var checkPageInView = (page, location2, radius) => {
|
|
3085
|
+
const radiusLeft = location2.translationX < 0 ? Math.abs(location2.translationX) - radius : -1 * location2.translationX - radius;
|
|
3086
|
+
const radiusRight = location2.translationX < 0 ? Math.abs(location2.translationX) + radius : -1 * location2.translationX + radius;
|
|
3087
|
+
const locationX = page.location.translateX;
|
|
3088
|
+
const radiusTop = location2.translationY < 0 ? Math.abs(location2.translationY) - radius : -1 * location2.translationY - radius;
|
|
3089
|
+
const radiusBottom = location2.translationY < 0 ? Math.abs(location2.translationY) + radius : -1 * location2.translationY + radius;
|
|
3090
|
+
const locationY = page.location.translateY;
|
|
3091
|
+
const inViewOnX = radiusLeft <= locationX && locationX <= radiusRight;
|
|
3092
|
+
const inViewOnY = radiusTop <= locationY && locationY <= radiusBottom;
|
|
3093
|
+
if (inViewOnX && inViewOnY) {
|
|
3094
|
+
return true;
|
|
3095
|
+
}
|
|
3096
|
+
return false;
|
|
3097
|
+
};
|
|
3098
|
+
|
|
3099
|
+
// source/modules/state/index.ts
|
|
3100
|
+
var state_exports = {};
|
|
3101
|
+
__export(state_exports, {
|
|
3102
|
+
compute: () => compute_default,
|
|
3103
|
+
local: () => local_exports
|
|
3104
|
+
});
|
|
3105
|
+
|
|
3106
|
+
// source/modules/state/compute/space/index.ts
|
|
3107
|
+
var resolveSpace = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState, hostname = "origin") => {
|
|
3108
|
+
const registeredPlanes = getRegisteredPlanes(planesRegistrar);
|
|
3109
|
+
const spaceTree = new tree_exports2.Tree(
|
|
3110
|
+
{
|
|
3111
|
+
planes: registeredPlanes,
|
|
3112
|
+
configuration,
|
|
3113
|
+
view
|
|
3114
|
+
},
|
|
3115
|
+
hostname
|
|
3116
|
+
);
|
|
3117
|
+
const computedTree = spaceTree.compute();
|
|
3118
|
+
const stateSpace = {
|
|
3119
|
+
loading: true,
|
|
3120
|
+
resolvedLayout: false,
|
|
3121
|
+
animatedTransform: false,
|
|
3122
|
+
transformTime: 450,
|
|
3123
|
+
scale: 1,
|
|
3124
|
+
rotationX: 0,
|
|
3125
|
+
rotationY: 0,
|
|
3126
|
+
translationX: 0,
|
|
3127
|
+
translationY: 0,
|
|
3128
|
+
translationZ: 0,
|
|
3129
|
+
transform: "matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)",
|
|
3130
|
+
activeUniverseID: "",
|
|
3131
|
+
camera: {
|
|
3132
|
+
x: 0,
|
|
3133
|
+
y: 0,
|
|
3134
|
+
z: 0
|
|
3135
|
+
},
|
|
3136
|
+
viewSize: {
|
|
3137
|
+
width: 771,
|
|
3138
|
+
height: 764
|
|
3139
|
+
},
|
|
3140
|
+
spaceSize: {
|
|
3141
|
+
width: 771,
|
|
3142
|
+
height: 764,
|
|
3143
|
+
depth: 0,
|
|
3144
|
+
topCorner: {
|
|
3145
|
+
x: 0,
|
|
3146
|
+
y: 0,
|
|
3147
|
+
z: 0
|
|
3148
|
+
}
|
|
3149
|
+
},
|
|
3150
|
+
culledView: [],
|
|
3151
|
+
activePlaneID: "",
|
|
3152
|
+
isolatePlane: "",
|
|
3153
|
+
lastClosedPlane: "",
|
|
3154
|
+
selectedPlaneIDs: [],
|
|
3155
|
+
draggingSelection: false,
|
|
3156
|
+
tree: computedTree,
|
|
3157
|
+
links: [],
|
|
3158
|
+
...precomputedState?.space,
|
|
3159
|
+
...contextState?.space,
|
|
3160
|
+
...localState?.space,
|
|
3161
|
+
...currentState?.space,
|
|
3162
|
+
view
|
|
3163
|
+
};
|
|
3164
|
+
if (currentState) {
|
|
3165
|
+
stateSpace.translationX = currentState.space.translationX;
|
|
3166
|
+
stateSpace.translationY = currentState.space.translationY;
|
|
3167
|
+
stateSpace.translationZ = currentState.space.translationZ;
|
|
3168
|
+
stateSpace.rotationX = currentState.space.rotationX;
|
|
3169
|
+
stateSpace.rotationY = currentState.space.rotationY;
|
|
3170
|
+
stateSpace.scale = currentState.space.scale;
|
|
3171
|
+
}
|
|
3172
|
+
if (localState && !currentState) {
|
|
3173
|
+
stateSpace.translationX = localState.space.translationX;
|
|
3174
|
+
stateSpace.translationY = localState.space.translationY;
|
|
3175
|
+
stateSpace.translationZ = localState.space.translationZ;
|
|
3176
|
+
stateSpace.rotationX = localState.space.rotationX;
|
|
3177
|
+
stateSpace.rotationY = localState.space.rotationY;
|
|
3178
|
+
stateSpace.scale = localState.space.scale;
|
|
3179
|
+
}
|
|
3180
|
+
return stateSpace;
|
|
3181
|
+
};
|
|
3182
|
+
var resolveThemes = (configuration, precomputedState) => {
|
|
3183
|
+
let generalTheme;
|
|
3184
|
+
let interactionTheme;
|
|
3185
|
+
if (typeof configuration.global.theme === "object") {
|
|
3186
|
+
const {
|
|
3187
|
+
general,
|
|
3188
|
+
interaction
|
|
3189
|
+
} = configuration.global.theme;
|
|
3190
|
+
if (typeof general === "string") {
|
|
3191
|
+
if (Object.keys(THEME_NAMES).includes(general)) {
|
|
3192
|
+
generalTheme = themes[general];
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
if (typeof interaction === "string") {
|
|
3196
|
+
if (Object.keys(THEME_NAMES).includes(interaction)) {
|
|
3197
|
+
interactionTheme = themes[interaction];
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
} else {
|
|
3201
|
+
if (Object.keys(THEME_NAMES).includes(configuration.global.theme)) {
|
|
3202
|
+
generalTheme = themes[configuration.global.theme];
|
|
3203
|
+
interactionTheme = themes[configuration.global.theme];
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
const stateThemes = {
|
|
3207
|
+
general: generalTheme || themes.plurid,
|
|
3208
|
+
interaction: interactionTheme || themes.plurid,
|
|
3209
|
+
...precomputedState?.themes
|
|
3210
|
+
};
|
|
3211
|
+
return stateThemes;
|
|
3212
|
+
};
|
|
3213
|
+
|
|
3214
|
+
// source/modules/state/compute/index.ts
|
|
3215
|
+
var compute = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState, hostname = "origin") => {
|
|
3216
|
+
let stateConfiguration = configuration_exports.merge(configuration);
|
|
3217
|
+
const configurations = [
|
|
3218
|
+
precomputedState?.configuration,
|
|
3219
|
+
contextState?.configuration,
|
|
3220
|
+
localState?.configuration,
|
|
3221
|
+
currentState?.configuration
|
|
3222
|
+
];
|
|
3223
|
+
for (const layer of configurations) {
|
|
3224
|
+
if (layer) {
|
|
3225
|
+
stateConfiguration = configuration_exports.merge(layer, stateConfiguration);
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
const stateSpace = resolveSpace(
|
|
3229
|
+
view,
|
|
3230
|
+
stateConfiguration,
|
|
3231
|
+
planesRegistrar,
|
|
3232
|
+
currentState,
|
|
3233
|
+
localState,
|
|
3234
|
+
precomputedState,
|
|
3235
|
+
contextState,
|
|
3236
|
+
hostname
|
|
3237
|
+
);
|
|
3238
|
+
const stateThemes = resolveThemes(
|
|
3239
|
+
stateConfiguration,
|
|
3240
|
+
precomputedState
|
|
3241
|
+
);
|
|
3242
|
+
const state = {
|
|
3243
|
+
configuration: {
|
|
3244
|
+
...stateConfiguration
|
|
3245
|
+
},
|
|
3246
|
+
shortcuts: {
|
|
3247
|
+
global: true,
|
|
3248
|
+
...precomputedState?.shortcuts
|
|
3249
|
+
},
|
|
3250
|
+
space: {
|
|
3251
|
+
...stateSpace
|
|
3252
|
+
},
|
|
3253
|
+
themes: {
|
|
3254
|
+
...stateThemes
|
|
3255
|
+
},
|
|
3256
|
+
ui: {
|
|
3257
|
+
toolbarScrollPosition: 0,
|
|
3258
|
+
...precomputedState?.ui,
|
|
3259
|
+
...contextState?.ui
|
|
3260
|
+
}
|
|
3261
|
+
};
|
|
3262
|
+
return state;
|
|
3263
|
+
};
|
|
3264
|
+
var compute_default = compute;
|
|
3265
|
+
|
|
3266
|
+
// source/modules/state/local/index.ts
|
|
3267
|
+
var local_exports = {};
|
|
3268
|
+
__export(local_exports, {
|
|
3269
|
+
load: () => load,
|
|
3270
|
+
loadContent: () => loadContent,
|
|
3271
|
+
save: () => save,
|
|
3272
|
+
saveContent: () => saveContent,
|
|
3273
|
+
serialize: () => serialize
|
|
3274
|
+
});
|
|
3275
|
+
var PERSISTED_STATE_VERSION = 2;
|
|
3276
|
+
var STORAGE_PREFIX = "pluridState-";
|
|
3277
|
+
var serializeFailureWarned = false;
|
|
3278
|
+
var PERSISTED_SPACE_FIELDS = [
|
|
3279
|
+
"rotationX",
|
|
3280
|
+
"rotationY",
|
|
3281
|
+
"scale",
|
|
3282
|
+
"translationX",
|
|
3283
|
+
"translationY",
|
|
3284
|
+
"translationZ",
|
|
3285
|
+
"transform",
|
|
3286
|
+
"camera",
|
|
3287
|
+
"activePlaneID",
|
|
3288
|
+
"isolatePlane",
|
|
3289
|
+
"lastClosedPlane",
|
|
3290
|
+
"tree",
|
|
3291
|
+
"links"
|
|
3292
|
+
];
|
|
3293
|
+
var storageKey = (id) => STORAGE_PREFIX + (id || "default");
|
|
3294
|
+
var localStorageAdapter = () => {
|
|
3295
|
+
if (typeof localStorage === "undefined") {
|
|
3296
|
+
return void 0;
|
|
3297
|
+
}
|
|
3298
|
+
return {
|
|
3299
|
+
getItem: (key) => localStorage.getItem(key),
|
|
3300
|
+
setItem: (key, value) => {
|
|
3301
|
+
localStorage.setItem(key, value);
|
|
3302
|
+
},
|
|
3303
|
+
removeItem: (key) => {
|
|
3304
|
+
localStorage.removeItem(key);
|
|
3305
|
+
}
|
|
3306
|
+
};
|
|
3307
|
+
};
|
|
3308
|
+
var resolveAdapter = (adapter) => adapter || localStorageAdapter();
|
|
3309
|
+
var serialize = (state) => {
|
|
3310
|
+
const space = {};
|
|
3311
|
+
for (const field of PERSISTED_SPACE_FIELDS) {
|
|
3312
|
+
const value = state.space[field];
|
|
3313
|
+
if (value !== void 0) {
|
|
3314
|
+
space[field] = value;
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
const snapshot = {
|
|
3318
|
+
version: PERSISTED_STATE_VERSION,
|
|
3319
|
+
space
|
|
3320
|
+
};
|
|
3321
|
+
return JSON.stringify(snapshot);
|
|
3322
|
+
};
|
|
3323
|
+
var save = (id, state, adapter) => {
|
|
3324
|
+
const store = resolveAdapter(adapter);
|
|
3325
|
+
if (!state || !store) {
|
|
3326
|
+
return;
|
|
3327
|
+
}
|
|
3328
|
+
let serialized;
|
|
3329
|
+
try {
|
|
3330
|
+
serialized = serialize(state);
|
|
3331
|
+
} catch (error) {
|
|
3332
|
+
if (!serializeFailureWarned && typeof console !== "undefined") {
|
|
3333
|
+
serializeFailureWarned = true;
|
|
3334
|
+
console.warn(
|
|
3335
|
+
"[plurid] state persistence skipped \u2014 could not serialize the space snapshot. A non-serializable value (cycle, DOM node, or function) is in the persisted fields. Persistence is disabled until it is removed.",
|
|
3336
|
+
error
|
|
3337
|
+
);
|
|
3338
|
+
}
|
|
3339
|
+
return;
|
|
3340
|
+
}
|
|
3341
|
+
try {
|
|
3342
|
+
store.setItem(
|
|
3343
|
+
storageKey(id),
|
|
3344
|
+
serialized
|
|
3345
|
+
);
|
|
3346
|
+
} catch (_error) {
|
|
3347
|
+
}
|
|
3348
|
+
};
|
|
3349
|
+
var load = (id, useLocalStorage, adapter) => {
|
|
3350
|
+
if (!useLocalStorage) {
|
|
3351
|
+
return;
|
|
3352
|
+
}
|
|
3353
|
+
const store = resolveAdapter(adapter);
|
|
3354
|
+
if (!store) {
|
|
3355
|
+
return;
|
|
3356
|
+
}
|
|
3357
|
+
try {
|
|
3358
|
+
const stateData = store.getItem(storageKey(id));
|
|
3359
|
+
if (!stateData) {
|
|
3360
|
+
return;
|
|
3361
|
+
}
|
|
3362
|
+
const snapshot = JSON.parse(stateData);
|
|
3363
|
+
if (!snapshot || snapshot.version !== PERSISTED_STATE_VERSION) {
|
|
3364
|
+
return;
|
|
3365
|
+
}
|
|
3366
|
+
if (!snapshot.space) {
|
|
3367
|
+
return;
|
|
3368
|
+
}
|
|
3369
|
+
return { space: snapshot.space };
|
|
3370
|
+
} catch (_error) {
|
|
3371
|
+
return;
|
|
3372
|
+
}
|
|
3373
|
+
};
|
|
3374
|
+
var CONTENT_PREFIX = "pluridContent-";
|
|
3375
|
+
var contentKey = (id) => CONTENT_PREFIX + (id || "default");
|
|
3376
|
+
var saveContent = (id, content, adapter) => {
|
|
3377
|
+
const store = resolveAdapter(adapter);
|
|
3378
|
+
if (content === void 0 || !store) {
|
|
3379
|
+
return;
|
|
3380
|
+
}
|
|
3381
|
+
try {
|
|
3382
|
+
store.setItem(
|
|
3383
|
+
contentKey(id),
|
|
3384
|
+
JSON.stringify(content)
|
|
3385
|
+
);
|
|
3386
|
+
} catch (_error) {
|
|
3387
|
+
}
|
|
3388
|
+
};
|
|
3389
|
+
var loadContent = (id, adapter) => {
|
|
3390
|
+
const store = resolveAdapter(adapter);
|
|
3391
|
+
if (!store) {
|
|
3392
|
+
return void 0;
|
|
3393
|
+
}
|
|
3394
|
+
try {
|
|
3395
|
+
const raw = store.getItem(contentKey(id));
|
|
3396
|
+
if (!raw) {
|
|
3397
|
+
return void 0;
|
|
3398
|
+
}
|
|
3399
|
+
return JSON.parse(raw);
|
|
3400
|
+
} catch (_error) {
|
|
3401
|
+
return void 0;
|
|
3402
|
+
}
|
|
3403
|
+
};
|
|
3404
|
+
|
|
3405
|
+
// source/functions/template/index.ts
|
|
3406
|
+
var cleanTemplate = (template) => {
|
|
3407
|
+
return template.replace(/(?:\r\n|\r|\n)/g, " ").replace(/ +/g, " ").trim();
|
|
3408
|
+
};
|
|
3409
|
+
var pluridRouterNavigate = (path) => {
|
|
3410
|
+
if (typeof CustomEvent === "undefined" || typeof window === "undefined") {
|
|
3411
|
+
return;
|
|
3412
|
+
}
|
|
3413
|
+
const event = new CustomEvent(
|
|
3414
|
+
PLURID_ROUTER_LOCATION_CHANGED,
|
|
3415
|
+
{
|
|
3416
|
+
detail: {
|
|
3417
|
+
path
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
);
|
|
3421
|
+
window.dispatchEvent(event);
|
|
3422
|
+
};
|
|
3423
|
+
|
|
3424
|
+
export { IsoMatcher_default as IsoMatcher, Parser as RouteParser, cleanTemplate, definePluridConfiguration, general_exports as general, interaction_exports as interaction, internationalization_default as internatiolate, planes_exports as planes, pluridRouterNavigate, routing_exports as routing, space_exports as space, state_exports as state, utilities_exports as utilities };
|
|
3425
|
+
//# sourceMappingURL=index.mjs.map
|
|
3426
|
+
//# sourceMappingURL=index.mjs.map
|