@dfosco/storyboard-core 2.1.0 → 2.2.0
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/package.json +1 -1
- package/src/devtools.js +2 -1
- package/src/sceneDebug.js +3 -2
- package/src/viewfinder.js +4 -4
- package/src/viewfinder.test.js +11 -11
package/package.json
CHANGED
package/src/devtools.js
CHANGED
|
@@ -181,7 +181,8 @@ const CHECK_ICON = '<svg viewBox="0 0 16 16"><path d="M13.78 4.22a.75.75 0 0 1 0
|
|
|
181
181
|
const ZAP_ICON = '<svg viewBox="0 0 16 16"><path d="M9.504.43a1.516 1.516 0 0 1 2.437 1.713L10.415 5.5h2.123c1.57 0 2.346 1.909 1.22 3.004l-7.34 7.142a1.249 1.249 0 0 1-.871.354h-.302a1.25 1.25 0 0 1-1.157-1.723L5.633 10.5H3.462c-1.57 0-2.346-1.909-1.22-3.004Z"/></svg>'
|
|
182
182
|
|
|
183
183
|
function getFlowName() {
|
|
184
|
-
|
|
184
|
+
const p = new URLSearchParams(window.location.search)
|
|
185
|
+
return p.get('flow') || p.get('scene') || 'default'
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
/**
|
package/src/sceneDebug.js
CHANGED
|
@@ -56,13 +56,14 @@ let stylesInjected = false
|
|
|
56
56
|
* Mount a flow debug panel into the DOM.
|
|
57
57
|
*
|
|
58
58
|
* @param {HTMLElement} [container=document.body] - Where to mount
|
|
59
|
-
* @param {string} [flowName] - Flow name override (defaults to ?
|
|
59
|
+
* @param {string} [flowName] - Flow name override (defaults to ?flow= param or "default")
|
|
60
60
|
* @returns {HTMLElement} The created debug element
|
|
61
61
|
*/
|
|
62
62
|
export function mountFlowDebug(container, flowName) {
|
|
63
63
|
const target = container || document.body
|
|
64
|
+
const sp = new URLSearchParams(window.location.search)
|
|
64
65
|
const activeFlowName = flowName
|
|
65
|
-
||
|
|
66
|
+
|| sp.get('flow') || sp.get('scene')
|
|
66
67
|
|| 'default'
|
|
67
68
|
|
|
68
69
|
// Inject styles once
|
package/src/viewfinder.js
CHANGED
|
@@ -22,13 +22,13 @@ export function hash(str) {
|
|
|
22
22
|
*
|
|
23
23
|
* @param {string} flowName
|
|
24
24
|
* @param {string[]} knownRoutes - Array of route names (e.g. ["Dashboard", "Repositories"])
|
|
25
|
-
* @returns {string} Full path with ?
|
|
25
|
+
* @returns {string} Full path with ?flow= param
|
|
26
26
|
*/
|
|
27
27
|
export function resolveFlowRoute(flowName, knownRoutes = []) {
|
|
28
28
|
// Case-insensitive match against known routes
|
|
29
29
|
for (const route of knownRoutes) {
|
|
30
30
|
if (route.toLowerCase() === flowName.toLowerCase()) {
|
|
31
|
-
// Flow name matches the route — no ?
|
|
31
|
+
// Flow name matches the route — no ?flow= needed,
|
|
32
32
|
// StoryboardProvider auto-matches by page name
|
|
33
33
|
return `/${route}`
|
|
34
34
|
}
|
|
@@ -40,13 +40,13 @@ export function resolveFlowRoute(flowName, knownRoutes = []) {
|
|
|
40
40
|
const route = data?.route || data?.meta?.route || data?.flowMeta?.route || data?.sceneMeta?.route
|
|
41
41
|
if (route) {
|
|
42
42
|
const normalized = route.startsWith('/') ? route : `/${route}`
|
|
43
|
-
return `${normalized}?
|
|
43
|
+
return `${normalized}?flow=${encodeURIComponent(flowName)}`
|
|
44
44
|
}
|
|
45
45
|
} catch {
|
|
46
46
|
// ignore load errors
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
return `/?
|
|
49
|
+
return `/?flow=${encodeURIComponent(flowName)}`
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/** @deprecated Use resolveFlowRoute() */
|
package/src/viewfinder.test.js
CHANGED
|
@@ -53,31 +53,31 @@ describe('resolveFlowRoute', () => {
|
|
|
53
53
|
})
|
|
54
54
|
|
|
55
55
|
it('uses route key from flow data when no route matches', () => {
|
|
56
|
-
expect(resolveFlowRoute('custom-route', routes)).toBe('/Overview?
|
|
56
|
+
expect(resolveFlowRoute('custom-route', routes)).toBe('/Overview?flow=custom-route')
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
it('handles absolute route key (with leading slash)', () => {
|
|
60
|
-
expect(resolveFlowRoute('absolute-route', routes)).toBe('/Forms?
|
|
60
|
+
expect(resolveFlowRoute('absolute-route', routes)).toBe('/Forms?flow=absolute-route')
|
|
61
61
|
})
|
|
62
62
|
|
|
63
63
|
it('falls back to root when no match and no route key', () => {
|
|
64
|
-
expect(resolveFlowRoute('no-route', routes)).toBe('/?
|
|
64
|
+
expect(resolveFlowRoute('no-route', routes)).toBe('/?flow=no-route')
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
it('falls back to root for default flow', () => {
|
|
68
|
-
expect(resolveFlowRoute('default', routes)).toBe('/?
|
|
68
|
+
expect(resolveFlowRoute('default', routes)).toBe('/?flow=default')
|
|
69
69
|
})
|
|
70
70
|
|
|
71
71
|
it('falls back to root when flow does not exist', () => {
|
|
72
|
-
expect(resolveFlowRoute('nonexistent', routes)).toBe('/?
|
|
72
|
+
expect(resolveFlowRoute('nonexistent', routes)).toBe('/?flow=nonexistent')
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
it('works with empty routes array', () => {
|
|
76
|
-
expect(resolveFlowRoute('Dashboard', [])).toBe('/?
|
|
76
|
+
expect(resolveFlowRoute('Dashboard', [])).toBe('/?flow=Dashboard')
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
it('works with no routes argument', () => {
|
|
80
|
-
expect(resolveFlowRoute('custom-route')).toBe('/Overview?
|
|
80
|
+
expect(resolveFlowRoute('custom-route')).toBe('/Overview?flow=custom-route')
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
it('encodes special characters in flow name', () => {
|
|
@@ -86,15 +86,15 @@ describe('resolveFlowRoute', () => {
|
|
|
86
86
|
objects: {},
|
|
87
87
|
records: {},
|
|
88
88
|
})
|
|
89
|
-
expect(resolveFlowRoute('has spaces', [])).toBe('/?
|
|
89
|
+
expect(resolveFlowRoute('has spaces', [])).toBe('/?flow=has%20spaces')
|
|
90
90
|
})
|
|
91
91
|
|
|
92
92
|
it('uses flowMeta.route when no route matches', () => {
|
|
93
|
-
expect(resolveFlowRoute('meta-route', routes)).toBe('/Repositories?
|
|
93
|
+
expect(resolveFlowRoute('meta-route', routes)).toBe('/Repositories?flow=meta-route')
|
|
94
94
|
})
|
|
95
95
|
|
|
96
96
|
it('uses flowMeta.route with absolute path', () => {
|
|
97
|
-
expect(resolveFlowRoute('meta-both', routes)).toBe('/Overview?
|
|
97
|
+
expect(resolveFlowRoute('meta-both', routes)).toBe('/Overview?flow=meta-both')
|
|
98
98
|
})
|
|
99
99
|
|
|
100
100
|
it('prefers top-level route over flowMeta.route', () => {
|
|
@@ -103,7 +103,7 @@ describe('resolveFlowRoute', () => {
|
|
|
103
103
|
objects: {},
|
|
104
104
|
records: {},
|
|
105
105
|
})
|
|
106
|
-
expect(resolveFlowRoute('conflict', [])).toBe('/Forms?
|
|
106
|
+
expect(resolveFlowRoute('conflict', [])).toBe('/Forms?flow=conflict')
|
|
107
107
|
})
|
|
108
108
|
})
|
|
109
109
|
|