@player-ui/make-flow 0.10.5-next.0 → 0.10.5-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.legacy-esm.js +0 -123
- package/package.json +2 -2
package/dist/index.legacy-esm.js
CHANGED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/make-flow/src/identify.ts
|
|
2
|
-
var ObjType = /* @__PURE__ */ ((ObjType2) => {
|
|
3
|
-
ObjType2[ObjType2["FLOW"] = 0] = "FLOW";
|
|
4
|
-
ObjType2[ObjType2["ASSET"] = 1] = "ASSET";
|
|
5
|
-
ObjType2[ObjType2["ASSET_WRAPPER"] = 2] = "ASSET_WRAPPER";
|
|
6
|
-
ObjType2[ObjType2["UNKNOWN"] = 3] = "UNKNOWN";
|
|
7
|
-
return ObjType2;
|
|
8
|
-
})(ObjType || {});
|
|
9
|
-
function identify(obj) {
|
|
10
|
-
if ("id" in obj && "type" in obj) {
|
|
11
|
-
return 1 /* ASSET */;
|
|
12
|
-
}
|
|
13
|
-
if ("asset" in obj && identify(obj.asset) === 1 /* ASSET */) {
|
|
14
|
-
return 2 /* ASSET_WRAPPER */;
|
|
15
|
-
}
|
|
16
|
-
if ("navigation" in obj || "schema" in obj || "views" in obj) {
|
|
17
|
-
return 0 /* FLOW */;
|
|
18
|
-
}
|
|
19
|
-
return 3 /* UNKNOWN */;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/make-flow/src/index.ts
|
|
23
|
-
function unwrapJSend(obj) {
|
|
24
|
-
const isJSend = "status" in obj && "data" in obj;
|
|
25
|
-
if (isJSend) {
|
|
26
|
-
return obj.data;
|
|
27
|
-
}
|
|
28
|
-
return obj;
|
|
29
|
-
}
|
|
30
|
-
var createDefaultNav = (flow, options) => {
|
|
31
|
-
if ((flow.navigation === void 0 || flow.navigation === null) && Array.isArray(flow.views) && flow.views.length === 1) {
|
|
32
|
-
const navFlow = {
|
|
33
|
-
startState: "VIEW_0",
|
|
34
|
-
VIEW_0: {
|
|
35
|
-
state_type: "VIEW",
|
|
36
|
-
ref: flow.views[0].id ?? `${flow.id}-views-0`,
|
|
37
|
-
transitions: {
|
|
38
|
-
"*": "END_done",
|
|
39
|
-
Prev: "END_back"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
END_done: {
|
|
43
|
-
state_type: "END",
|
|
44
|
-
outcome: options?.outcome ?? "doneWithFlow"
|
|
45
|
-
},
|
|
46
|
-
END_back: {
|
|
47
|
-
state_type: "END",
|
|
48
|
-
outcome: "BACK"
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
if (options?.onStart !== void 0) {
|
|
52
|
-
navFlow.onStart = options.onStart;
|
|
53
|
-
}
|
|
54
|
-
if (options?.onEnd !== void 0) {
|
|
55
|
-
navFlow.onEnd = options.onEnd;
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
...flow,
|
|
59
|
-
navigation: {
|
|
60
|
-
BEGIN: "Flow",
|
|
61
|
-
Flow: navFlow
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return flow;
|
|
66
|
-
};
|
|
67
|
-
function makeFlow(obj, args) {
|
|
68
|
-
const objified = unwrapJSend(typeof obj === "string" ? JSON.parse(obj) : obj);
|
|
69
|
-
if (Array.isArray(objified)) {
|
|
70
|
-
const collection = {
|
|
71
|
-
id: "collection",
|
|
72
|
-
type: "collection",
|
|
73
|
-
values: objified.map((v) => {
|
|
74
|
-
const type2 = identify(v);
|
|
75
|
-
if (type2 === 1 /* ASSET */) {
|
|
76
|
-
return { asset: v };
|
|
77
|
-
}
|
|
78
|
-
return v;
|
|
79
|
-
})
|
|
80
|
-
};
|
|
81
|
-
return makeFlow(collection);
|
|
82
|
-
}
|
|
83
|
-
const type = identify(obj);
|
|
84
|
-
if (type === 3 /* UNKNOWN */) {
|
|
85
|
-
throw new Error(
|
|
86
|
-
"No clue how to convert this into a flow. Just do it yourself"
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
if (type === 0 /* FLOW */) {
|
|
90
|
-
return createDefaultNav(obj, args);
|
|
91
|
-
}
|
|
92
|
-
if (type === 2 /* ASSET_WRAPPER */) {
|
|
93
|
-
return makeFlow(obj.asset);
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
id: "generated-flow",
|
|
97
|
-
views: [obj],
|
|
98
|
-
data: {},
|
|
99
|
-
navigation: {
|
|
100
|
-
BEGIN: "FLOW_1",
|
|
101
|
-
FLOW_1: {
|
|
102
|
-
startState: "VIEW_1",
|
|
103
|
-
VIEW_1: {
|
|
104
|
-
state_type: "VIEW",
|
|
105
|
-
ref: obj.id,
|
|
106
|
-
transitions: {
|
|
107
|
-
"*": "END_Done"
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
END_Done: {
|
|
111
|
-
state_type: "END",
|
|
112
|
-
outcome: "done"
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
export {
|
|
119
|
-
ObjType,
|
|
120
|
-
identify,
|
|
121
|
-
makeFlow
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
"types"
|
|
7
7
|
],
|
|
8
8
|
"name": "@player-ui/make-flow",
|
|
9
|
-
"version": "0.10.5-next.
|
|
9
|
+
"version": "0.10.5-next.1",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@player-ui/types": "0.10.5-next.
|
|
12
|
+
"@player-ui/types": "0.10.5-next.1",
|
|
13
13
|
"tslib": "^2.6.2"
|
|
14
14
|
},
|
|
15
15
|
"module": "dist/index.legacy-esm.js",
|