@sanity/runtime-cli 16.0.3 → 17.1.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/README.md +27 -22
- package/dist/actions/functions/test.js +1 -1
- package/dist/baseCommands.js +13 -2
- package/dist/commands/blueprints/init.js +5 -2
- package/dist/config.d.ts +1 -0
- package/dist/config.js +7 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/cores/blueprints/init.js +16 -2
- package/dist/cores/functions/test.js +44 -0
- package/dist/server/app.js +31 -3
- package/dist/server/handlers/invoke.d.ts +2 -2
- package/dist/server/handlers/invoke.js +7 -4
- package/dist/server/static/components/console-panel.js +59 -8
- package/dist/server/static/components/rule-panel.js +11 -8
- package/dist/server/static/components/shared-styles.js +24 -21
- package/dist/server/static/index.html +1 -1
- package/dist/server/static/vendor/design-tokens/color.css +48 -48
- package/dist/server/static/vendor/design-tokens/index.css +0 -1
- package/dist/server/static/vendor/vendor.bundle.js +3807 -3259
- package/dist/server/static/web-socket.js +41 -0
- package/dist/utils/functions/child-process-wrapper.js +62 -7
- package/dist/utils/functions/{invoke-local.d.ts → invoke/local.d.ts} +1 -1
- package/dist/utils/functions/invoke/local.js +306 -0
- package/dist/utils/functions/invoke/nested.d.ts +25 -0
- package/dist/utils/functions/invoke/nested.js +41 -0
- package/dist/utils/functions/invoke/prepare.d.ts +20 -0
- package/dist/utils/functions/invoke/prepare.js +90 -0
- package/dist/utils/interactive.d.ts +1 -0
- package/dist/utils/interactive.js +4 -0
- package/dist/utils/isTrueish.d.ts +6 -0
- package/dist/utils/isTrueish.js +9 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.js +1 -0
- package/dist/utils/style-text.js +4 -5
- package/dist/utils/traced-fetch.js +2 -0
- package/dist/utils/types.d.ts +62 -4
- package/oclif.manifest.json +928 -927
- package/package.json +18 -14
- package/dist/server/static/hot-reload.js +0 -16
- package/dist/utils/functions/invoke-local.js +0 -185
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* globals customElements document */
|
|
1
|
+
/* globals customElements document window */
|
|
2
2
|
import {ApiBaseElement} from './api-base.js'
|
|
3
3
|
import {getSharedStyleSheets} from './shared-styles.js'
|
|
4
4
|
|
|
@@ -36,6 +36,16 @@ template.innerHTML = `
|
|
|
36
36
|
`
|
|
37
37
|
|
|
38
38
|
class ConsolePanel extends ApiBaseElement {
|
|
39
|
+
/**
|
|
40
|
+
* Nested context.invoke() output for the current run, kept as a list so the
|
|
41
|
+
* final render can order it by call order. Nested runs finish innermost-first
|
|
42
|
+
* (A → B → C resolves C then B), so each carries an `order` stamped when it was
|
|
43
|
+
* initiated; the final render sorts by it. Buffered separately so it survives
|
|
44
|
+
* the result render, which would otherwise overwrite the console when Preserve
|
|
45
|
+
* Log is off.
|
|
46
|
+
*/
|
|
47
|
+
nestedEntries = []
|
|
48
|
+
|
|
39
49
|
constructor() {
|
|
40
50
|
super()
|
|
41
51
|
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
@@ -45,25 +55,59 @@ class ConsolePanel extends ApiBaseElement {
|
|
|
45
55
|
if (!this.consoleOutput || !result) return
|
|
46
56
|
|
|
47
57
|
const {error, logs} = result
|
|
48
|
-
|
|
58
|
+
// Always show the logs. Then append the error, rather than replacing the logs with it.
|
|
59
|
+
let update = logs ?? ''
|
|
49
60
|
if (error) {
|
|
50
|
-
|
|
51
|
-
update = (
|
|
52
|
-
} else {
|
|
53
|
-
// Display regular logs
|
|
54
|
-
update = logs ?? '' // Handle case where logs might be null/undefined
|
|
61
|
+
const errText = (error.stack || error.message || error.name) ?? 'An error occurred.'
|
|
62
|
+
update = update.trim() ? `${update.trimEnd()}\n${errText}` : errText
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
if (this.api.store.preserveLog) {
|
|
66
|
+
// Nested output was already appended live during the run; keep it in place.
|
|
58
67
|
this.consoleOutput.innerText = this.consoleOutput.innerText + update
|
|
59
68
|
} else {
|
|
60
|
-
|
|
69
|
+
// Re-render so the nested output is shown in call order rather than the
|
|
70
|
+
// completion order it streamed in (and so it survives this overwrite).
|
|
71
|
+
this.consoleOutput.innerText = update + this.renderNestedEntries()
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Join the nested runs in call order (the order they were initiated).
|
|
76
|
+
renderNestedEntries = () =>
|
|
77
|
+
[...this.nestedEntries]
|
|
78
|
+
.sort((a, b) => a.order - b.order)
|
|
79
|
+
.map((e) => e.text)
|
|
80
|
+
.join('')
|
|
81
|
+
|
|
82
|
+
updateNested = (event) => {
|
|
83
|
+
const nestedInvoke = event.detail
|
|
84
|
+
if (!this.consoleOutput || !nestedInvoke) return
|
|
85
|
+
|
|
86
|
+
const {name, order, logs, json, error} = nestedInvoke
|
|
87
|
+
// Always show the logs. Then append the error, rather than replacing the logs with it.
|
|
88
|
+
let body = logs ?? ''
|
|
89
|
+
if (error) {
|
|
90
|
+
const errText = (error.stack || error.message || error.name) ?? 'An error occurred.'
|
|
91
|
+
body = body.trim() ? `${body.trimEnd()}\n${errText}` : errText
|
|
92
|
+
} else if (typeof json !== 'undefined') {
|
|
93
|
+
body += `${body && !body.endsWith('\n') ? '\n' : ''}→ returned ${JSON.stringify(json)}\n`
|
|
61
94
|
}
|
|
95
|
+
|
|
96
|
+
const text = `↳ BEGIN: invoke('${name}')\n${body.trim()}\n↳ END: invoke('${name}')\n`
|
|
97
|
+
this.nestedEntries.push({order, text})
|
|
98
|
+
// Append live for immediate feedback; the final result render reorders.
|
|
99
|
+
this.consoleOutput.innerText = this.consoleOutput.innerText + text
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// A new invocation is starting; drop the previous run's nested output.
|
|
103
|
+
resetNested = ({inprogress}) => {
|
|
104
|
+
if (inprogress) this.nestedEntries = []
|
|
62
105
|
}
|
|
63
106
|
|
|
64
107
|
clear = () => {
|
|
65
108
|
const backUp = this.api.store.preserveLog
|
|
66
109
|
this.api.store.result = {logs: undefined, error: undefined}
|
|
110
|
+
this.nestedEntries = []
|
|
67
111
|
this.consoleOutput.innerText = ''
|
|
68
112
|
this.api.store.preserveLog = backUp
|
|
69
113
|
}
|
|
@@ -75,9 +119,14 @@ class ConsolePanel extends ApiBaseElement {
|
|
|
75
119
|
this.consoleOutput = this.shadowRoot.querySelector('#console-output')
|
|
76
120
|
this.addEventListener('clear-console', this.clear)
|
|
77
121
|
|
|
122
|
+
// Nested context.invoke() runs arrive as a stream of discrete DOM events
|
|
123
|
+
// (not state) so none are dropped when several land in one frame.
|
|
124
|
+
window.addEventListener('nested-invoke', this.updateNested)
|
|
125
|
+
|
|
78
126
|
// Subscribe to changes in the result state to update the console
|
|
79
127
|
if (this.api) {
|
|
80
128
|
this.api.subscribe(this.updateConsole, ['result'])
|
|
129
|
+
this.api.subscribe(this.resetNested, ['inprogress'])
|
|
81
130
|
// Initial update in case result is already populated
|
|
82
131
|
if (this.api.store.result) {
|
|
83
132
|
this.updateConsole({result: this.api.store.result})
|
|
@@ -90,9 +139,11 @@ class ConsolePanel extends ApiBaseElement {
|
|
|
90
139
|
|
|
91
140
|
disconnectedCallback() {
|
|
92
141
|
this.removeEventListener('clear-console', this.clear)
|
|
142
|
+
window.removeEventListener('nested-invoke', this.updateNested)
|
|
93
143
|
// Unsubscribe when the element is removed from the DOM
|
|
94
144
|
if (this.api) {
|
|
95
145
|
this.api.unsubscribe(this.updateConsole)
|
|
146
|
+
this.api.unsubscribe(this.resetNested)
|
|
96
147
|
}
|
|
97
148
|
}
|
|
98
149
|
}
|
|
@@ -43,14 +43,17 @@ class RulePanel extends ApiBaseElement {
|
|
|
43
43
|
break
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
// Guard against the sate not being setup
|
|
47
|
+
if (rule?.state) {
|
|
48
|
+
const transaction = rule.state.update({
|
|
49
|
+
changes: {
|
|
50
|
+
from: 0,
|
|
51
|
+
insert: func.event ? JSON.stringify(func.event, null, 2) : '',
|
|
52
|
+
to: rule.state.doc.length,
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
rule.dispatch(transaction)
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
async connectedCallback() {
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
/* globals fetch */
|
|
2
2
|
|
|
3
|
-
let
|
|
3
|
+
let sharedStyleSheetsPromise = null
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
async function loadSharedStyleSheets() {
|
|
6
|
+
// Fetch both stylesheets
|
|
7
|
+
const [mCssResponse, appCssResponse] = await Promise.all([
|
|
8
|
+
fetch('./vendor/m-.css'),
|
|
9
|
+
fetch('./components/app.css'),
|
|
10
|
+
])
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
// Fetch both stylesheets
|
|
12
|
-
const [mCssResponse, appCssResponse] = await Promise.all([
|
|
13
|
-
fetch('./vendor/m-.css'),
|
|
14
|
-
fetch('./components/app.css'),
|
|
15
|
-
])
|
|
12
|
+
const [mCssText, appCssText] = await Promise.all([mCssResponse.text(), appCssResponse.text()])
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
// Create CSSStyleSheet objects
|
|
15
|
+
const mSheet = new CSSStyleSheet()
|
|
16
|
+
const appSheet = new CSSStyleSheet()
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
const mSheet = new CSSStyleSheet()
|
|
21
|
-
const appSheet = new CSSStyleSheet()
|
|
18
|
+
await Promise.all([mSheet.replace(mCssText), appSheet.replace(appCssText)])
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
return [mSheet, appSheet]
|
|
21
|
+
}
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
export function getSharedStyleSheets() {
|
|
24
|
+
if (!sharedStyleSheetsPromise) {
|
|
25
|
+
sharedStyleSheetsPromise = loadSharedStyleSheets().catch((error) => {
|
|
26
|
+
console.error('Failed to load shared stylesheets:', error)
|
|
27
|
+
// Reset so a later caller can retry instead of being stuck with [].
|
|
28
|
+
sharedStyleSheetsPromise = null
|
|
29
|
+
return []
|
|
30
|
+
})
|
|
30
31
|
}
|
|
32
|
+
|
|
33
|
+
return sharedStyleSheetsPromise
|
|
31
34
|
}
|
|
@@ -64,6 +64,6 @@
|
|
|
64
64
|
<script src="./components/clear-button.js" type="module"></script>
|
|
65
65
|
<script src="./components/help-button.js" type="module"></script>
|
|
66
66
|
<script src="./components/fetch-button.js" type="module"></script>
|
|
67
|
-
<script src="./
|
|
67
|
+
<script src="./web-socket.js" type="module"></script>
|
|
68
68
|
</body>
|
|
69
69
|
</html>
|
|
@@ -37,39 +37,39 @@
|
|
|
37
37
|
--gray-800: #252837;
|
|
38
38
|
--gray-900: #1b1d27;
|
|
39
39
|
--gray-950: #13141b;
|
|
40
|
-
--green-100: #
|
|
41
|
-
--green-200: #
|
|
42
|
-
--green-300: #
|
|
43
|
-
--green-400: #
|
|
44
|
-
--green-50: #
|
|
45
|
-
--green-500: #
|
|
40
|
+
--green-100: #c5fce8;
|
|
41
|
+
--green-200: #a9f9dc;
|
|
42
|
+
--green-300: #59f3ba;
|
|
43
|
+
--green-400: #0ff0a1;
|
|
44
|
+
--green-50: #e7fef5;
|
|
45
|
+
--green-500: #04b97a;
|
|
46
46
|
--green-600: #01794f;
|
|
47
47
|
--green-700: #015133;
|
|
48
48
|
--green-800: #023120;
|
|
49
49
|
--green-900: #06231a;
|
|
50
50
|
--green-950: #071715;
|
|
51
|
-
--magenta-100: #
|
|
52
|
-
--magenta-200: #
|
|
53
|
-
--magenta-300: #
|
|
54
|
-
--magenta-400: #
|
|
51
|
+
--magenta-100: #fde8ef;
|
|
52
|
+
--magenta-200: #fcdee9;
|
|
53
|
+
--magenta-300: #f7abc5;
|
|
54
|
+
--magenta-400: #f0709b;
|
|
55
55
|
--magenta-50: #fef6f9;
|
|
56
|
-
--magenta-500: #
|
|
57
|
-
--magenta-600: #
|
|
58
|
-
--magenta-700: #
|
|
59
|
-
--magenta-800: #
|
|
60
|
-
--magenta-900: #
|
|
61
|
-
--magenta-950: #
|
|
62
|
-
--orange-100: #
|
|
63
|
-
--orange-200: #
|
|
64
|
-
--orange-300: #
|
|
65
|
-
--orange-400: #
|
|
56
|
+
--magenta-500: #e72767;
|
|
57
|
+
--magenta-600: #b11651;
|
|
58
|
+
--magenta-700: #7c1342;
|
|
59
|
+
--magenta-800: #4b1130;
|
|
60
|
+
--magenta-900: #341325;
|
|
61
|
+
--magenta-950: #1f0f14;
|
|
62
|
+
--orange-100: #ffeadb;
|
|
63
|
+
--orange-200: #ffddc7;
|
|
64
|
+
--orange-300: #ffb685;
|
|
65
|
+
--orange-400: #ff8e42;
|
|
66
66
|
--orange-50: #fff7f0;
|
|
67
|
-
--orange-500: #
|
|
68
|
-
--orange-600: #
|
|
69
|
-
--orange-700: #
|
|
70
|
-
--orange-800: #
|
|
71
|
-
--orange-900: #
|
|
72
|
-
--orange-950: #
|
|
67
|
+
--orange-500: #fa6400;
|
|
68
|
+
--orange-600: #b14802;
|
|
69
|
+
--orange-700: #7c3404;
|
|
70
|
+
--orange-800: #461e07;
|
|
71
|
+
--orange-900: #32160b;
|
|
72
|
+
--orange-950: #21120d;
|
|
73
73
|
--purple-100: #f1ebff;
|
|
74
74
|
--purple-200: #ece1fe;
|
|
75
75
|
--purple-300: #ccb1fc;
|
|
@@ -81,27 +81,27 @@
|
|
|
81
81
|
--purple-800: #2f1862;
|
|
82
82
|
--purple-900: #23173f;
|
|
83
83
|
--purple-950: #181128;
|
|
84
|
-
--red-100: #
|
|
85
|
-
--red-200: #
|
|
86
|
-
--red-300: #
|
|
87
|
-
--red-400: #
|
|
88
|
-
--red-50: #
|
|
89
|
-
--red-500: #
|
|
90
|
-
--red-600: #
|
|
91
|
-
--red-700: #
|
|
92
|
-
--red-800: #
|
|
93
|
-
--red-900: #
|
|
94
|
-
--red-950: #
|
|
84
|
+
--red-100: #ffe7e5;
|
|
85
|
+
--red-200: #ffdedc;
|
|
86
|
+
--red-300: #fdada5;
|
|
87
|
+
--red-400: #f77769;
|
|
88
|
+
--red-50: #fff6f5;
|
|
89
|
+
--red-500: #ef4434;
|
|
90
|
+
--red-600: #cc2819;
|
|
91
|
+
--red-700: #8b2018;
|
|
92
|
+
--red-800: #4d1714;
|
|
93
|
+
--red-900: #321615;
|
|
94
|
+
--red-950: #1e1011;
|
|
95
95
|
--white: #ffffff;
|
|
96
|
-
--yellow-100: #
|
|
97
|
-
--yellow-200: #
|
|
98
|
-
--yellow-300: #
|
|
99
|
-
--yellow-400: #
|
|
100
|
-
--yellow-50: #
|
|
101
|
-
--yellow-500: #
|
|
102
|
-
--yellow-600: #
|
|
103
|
-
--yellow-700: #
|
|
104
|
-
--yellow-800: #
|
|
105
|
-
--yellow-900: #
|
|
106
|
-
--yellow-950: #
|
|
96
|
+
--yellow-100: #fcf3bb;
|
|
97
|
+
--yellow-200: #f9e994;
|
|
98
|
+
--yellow-300: #f7d455;
|
|
99
|
+
--yellow-400: #f9bc15;
|
|
100
|
+
--yellow-50: #fefae1;
|
|
101
|
+
--yellow-500: #d28a04;
|
|
102
|
+
--yellow-600: #965908;
|
|
103
|
+
--yellow-700: #653a0b;
|
|
104
|
+
--yellow-800: #3b220c;
|
|
105
|
+
--yellow-900: #271a11;
|
|
106
|
+
--yellow-950: #181410;
|
|
107
107
|
}
|