@sanity/cli-build 6.4.1 → 6.4.3
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/actions/build/getEntryModule.js +10 -4
- package/dist/actions/build/getEntryModule.js.map +1 -1
- package/dist/actions/build/renderDocumentWorker/components/GlobalErrorHandler.js +3 -1
- package/dist/actions/build/renderDocumentWorker/components/GlobalErrorHandler.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { RESOURCE_BINDINGS_ENTRY_IMPORT } from '@sanity/workbench-cli/build';
|
|
2
|
+
// The user module (`sanity.config.*`, or the app's `App`) is the first import
|
|
3
|
+
// after resource bindings. ESM evaluates static imports in source order, and
|
|
4
|
+
// `react-dom` reads `__REACT_DEVTOOLS_GLOBAL_HOOK__` once at module init, so a
|
|
5
|
+
// side-effect import at the top of the user module (for example
|
|
6
|
+
// `react-devtools-cdt-mcp/register`) only runs before react-dom if the user
|
|
7
|
+
// module is requested before `sanity` / `react-dom/client`.
|
|
2
8
|
const entryModule = `
|
|
3
9
|
// This file is auto-generated on 'sanity dev'
|
|
4
10
|
// Modifications to this file is automatically discarded
|
|
5
|
-
%RESOURCE_BINDINGS_IMPORT%import
|
|
6
|
-
import
|
|
11
|
+
%RESOURCE_BINDINGS_IMPORT%import studioConfig from %STUDIO_CONFIG_LOCATION%
|
|
12
|
+
import {renderStudio} from "sanity"
|
|
7
13
|
|
|
8
14
|
renderStudio(
|
|
9
15
|
document.getElementById("sanity"),
|
|
@@ -27,9 +33,9 @@ renderStudio(
|
|
|
27
33
|
const appEntryModule = `
|
|
28
34
|
// This file is auto-generated on 'sanity dev'
|
|
29
35
|
// Modifications to this file is automatically discarded
|
|
30
|
-
%RESOURCE_BINDINGS_IMPORT%import
|
|
36
|
+
%RESOURCE_BINDINGS_IMPORT%import App from %ENTRY%
|
|
37
|
+
import {createRoot} from 'react-dom/client'
|
|
31
38
|
import {createElement} from 'react'
|
|
32
|
-
import App from %ENTRY%
|
|
33
39
|
|
|
34
40
|
const root = createRoot(document.getElementById('root'))
|
|
35
41
|
const element = createElement(App)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/getEntryModule.ts"],"sourcesContent":["import {RESOURCE_BINDINGS_ENTRY_IMPORT} from '@sanity/workbench-cli/build'\n\nconst entryModule = `\n// This file is auto-generated on 'sanity dev'\n// Modifications to this file is automatically discarded\n%RESOURCE_BINDINGS_IMPORT%import {renderStudio} from \"sanity\"\
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/getEntryModule.ts"],"sourcesContent":["import {RESOURCE_BINDINGS_ENTRY_IMPORT} from '@sanity/workbench-cli/build'\n\n// The user module (`sanity.config.*`, or the app's `App`) is the first import\n// after resource bindings. ESM evaluates static imports in source order, and\n// `react-dom` reads `__REACT_DEVTOOLS_GLOBAL_HOOK__` once at module init, so a\n// side-effect import at the top of the user module (for example\n// `react-devtools-cdt-mcp/register`) only runs before react-dom if the user\n// module is requested before `sanity` / `react-dom/client`.\nconst entryModule = `\n// This file is auto-generated on 'sanity dev'\n// Modifications to this file is automatically discarded\n%RESOURCE_BINDINGS_IMPORT%import studioConfig from %STUDIO_CONFIG_LOCATION%\nimport {renderStudio} from \"sanity\"\n\nrenderStudio(\n document.getElementById(\"sanity\"),\n studioConfig,\n {reactStrictMode: %STUDIO_REACT_STRICT_MODE%, basePath: %STUDIO_BASE_PATH%}\n)\n`\n\nconst noConfigEntryModule = `\n// This file is auto-generated on 'sanity dev'\n// Modifications to this file is automatically discarded\n%RESOURCE_BINDINGS_IMPORT%import {renderStudio} from \"sanity\"\n\nconst studioConfig = {missingConfigFile: true}\n\nrenderStudio(\n document.getElementById(\"sanity\"),\n studioConfig,\n {reactStrictMode: %STUDIO_REACT_STRICT_MODE%, basePath: %STUDIO_BASE_PATH%}\n)\n`\n\nconst appEntryModule = `\n// This file is auto-generated on 'sanity dev'\n// Modifications to this file is automatically discarded\n%RESOURCE_BINDINGS_IMPORT%import App from %ENTRY%\nimport {createRoot} from 'react-dom/client'\nimport {createElement} from 'react'\n\nconst root = createRoot(document.getElementById('root'))\nconst element = createElement(App)\nroot.render(element)\n`\n\n// A branded app with no \\`entry\\` (sanity-io/workbench spec 002-workbench-extension-api, US5) has no navigable app view, so there's no\n// \\`App\\` to import or render standalone — it contributes panels/services to the\n// workbench instead. The page stays valid (no broken import) for the dev server.\nconst noAppViewEntryModule = `\n// This file is auto-generated on 'sanity dev'\n// Modifications to this file is automatically discarded\n%RESOURCE_BINDINGS_IMPORT%const root = document.getElementById('root')\nif (root) {\n root.textContent = 'This application has no app view.'\n}\n`\n\nexport function getEntryModule(options: {\n basePath?: string\n entry?: string\n isApp?: boolean\n isBlueprints?: boolean\n reactStrictMode: boolean | undefined\n relativeConfigLocation: string | null\n}): string {\n const {basePath, entry, isApp, isBlueprints, reactStrictMode, relativeConfigLocation} = options\n\n // Under Blueprints the entry statically imports the resource-bindings module\n // first (writeSanityRuntime emits it); otherwise the placeholder resolves to\n // nothing so the import — and the module — are absent.\n const withBindings = (module: string): string =>\n module.replace(\n /%RESOURCE_BINDINGS_IMPORT%/,\n isBlueprints ? `${RESOURCE_BINDINGS_ENTRY_IMPORT}\\n` : '',\n )\n\n if (isApp) {\n return withBindings(\n entry ? appEntryModule.replace(/%ENTRY%/, JSON.stringify(entry)) : noAppViewEntryModule,\n )\n }\n\n const sourceModule = relativeConfigLocation ? entryModule : noConfigEntryModule\n\n return withBindings(\n sourceModule\n .replace(\n /%STUDIO_REACT_STRICT_MODE%/,\n reactStrictMode === undefined ? 'undefined' : JSON.stringify(reactStrictMode),\n )\n .replace(/%STUDIO_CONFIG_LOCATION%/, JSON.stringify(relativeConfigLocation))\n .replace(/%STUDIO_BASE_PATH%/, JSON.stringify(basePath || '/')),\n )\n}\n"],"names":["RESOURCE_BINDINGS_ENTRY_IMPORT","entryModule","noConfigEntryModule","appEntryModule","noAppViewEntryModule","getEntryModule","options","basePath","entry","isApp","isBlueprints","reactStrictMode","relativeConfigLocation","withBindings","module","replace","JSON","stringify","sourceModule","undefined"],"mappings":"AAAA,SAAQA,8BAA8B,QAAO,8BAA6B;AAE1E,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,gEAAgE;AAChE,4EAA4E;AAC5E,4DAA4D;AAC5D,MAAMC,cAAc,CAAC;;;;;;;;;;;AAWrB,CAAC;AAED,MAAMC,sBAAsB,CAAC;;;;;;;;;;;;AAY7B,CAAC;AAED,MAAMC,iBAAiB,CAAC;;;;;;;;;;AAUxB,CAAC;AAED,uIAAuI;AACvI,iFAAiF;AACjF,iFAAiF;AACjF,MAAMC,uBAAuB,CAAC;;;;;;;AAO9B,CAAC;AAED,OAAO,SAASC,eAAeC,OAO9B;IACC,MAAM,EAACC,QAAQ,EAAEC,KAAK,EAAEC,KAAK,EAAEC,YAAY,EAAEC,eAAe,EAAEC,sBAAsB,EAAC,GAAGN;IAExF,6EAA6E;IAC7E,6EAA6E;IAC7E,uDAAuD;IACvD,MAAMO,eAAe,CAACC,SACpBA,OAAOC,OAAO,CACZ,8BACAL,eAAe,GAAGV,+BAA+B,EAAE,CAAC,GAAG;IAG3D,IAAIS,OAAO;QACT,OAAOI,aACLL,QAAQL,eAAeY,OAAO,CAAC,WAAWC,KAAKC,SAAS,CAACT,UAAUJ;IAEvE;IAEA,MAAMc,eAAeN,yBAAyBX,cAAcC;IAE5D,OAAOW,aACLK,aACGH,OAAO,CACN,8BACAJ,oBAAoBQ,YAAY,cAAcH,KAAKC,SAAS,CAACN,kBAE9DI,OAAO,CAAC,4BAA4BC,KAAKC,SAAS,CAACL,yBACnDG,OAAO,CAAC,sBAAsBC,KAAKC,SAAS,CAACV,YAAY;AAEhE"}
|
|
@@ -43,7 +43,9 @@ const errorHandlerScript = `
|
|
|
43
43
|
// - If there are no subscribers, then we log the error to the console and render the error overlay.
|
|
44
44
|
if (errorChannel.subscribers.length) {
|
|
45
45
|
errorChannel.publish({error, params})
|
|
46
|
-
} else {
|
|
46
|
+
} else if (error) {
|
|
47
|
+
// Browsers fire some error events without an error object (a ResizeObserver loop,
|
|
48
|
+
// a cross-origin "Script error."), and there is nothing useful to show for them.
|
|
47
49
|
console.error(error)
|
|
48
50
|
|
|
49
51
|
_renderErrorOverlay(error, params)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/actions/build/renderDocumentWorker/components/GlobalErrorHandler.tsx"],"sourcesContent":["import {type JSX} from 'react'\n\nconst errorHandlerScript = `\n;(function () {\n var _caughtErrors = []\n\n var errorChannel = (function () {\n var subscribers = []\n\n function publish(msg) {\n for (var i = 0; i < subscribers.length; i += 1) {\n subscribers[i](msg)\n }\n }\n\n function subscribe(subscriber) {\n subscribers.push(subscriber)\n\n return function () {\n var idx = subscribers.indexOf(subscriber)\n\n if (idx > -1) {\n subscribers.splice(idx, 1)\n }\n }\n }\n\n return {publish, subscribe, subscribers}\n })()\n\n // NOTE: Store the error channel instance in the global scope so that the application can\n // access it and subscribe to errors.\n window.__sanityErrorChannel = {\n subscribe: errorChannel.subscribe,\n }\n\n function _nextTick(callback) {\n setTimeout(callback, 0)\n }\n\n function _handleError(error, params) {\n _nextTick(function () {\n // - If there are error channel subscribers, then we notify them (no console error).\n // - If there are no subscribers, then we log the error to the console and render the error overlay.\n if (errorChannel.subscribers.length) {\n errorChannel.publish({error, params})\n } else {\n console.error(error)\n\n _renderErrorOverlay(error, params)\n }\n })\n }\n\n var ERROR_BOX_STYLE = [\n 'background: #fff',\n 'border-radius: 6px',\n 'box-sizing: border-box',\n 'color: #121923',\n 'flex: 1',\n \"font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue','Liberation Sans',Helvetica,Arial,system-ui,sans-serif\",\n 'font-size: 16px',\n 'line-height: 21px',\n 'margin: 0 auto',\n 'max-width: 960px',\n 'max-height: 90dvh',\n 'overflow: auto',\n 'padding: 20px',\n 'width: 100%',\n ].join(';')\n\n var ERROR_CODE_STYLE = [\n 'color: #972E2A',\n \"font-family: -apple-system-ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace\",\n 'font-size: 13px',\n 'line-height: 17px',\n 'margin: 0',\n ].join(';')\n\n function _renderErrorOverlay(error, params) {\n var errorElement = document.querySelector('#__sanityError') || document.createElement('div')\n var colno = params.event.colno\n var lineno = params.event.lineno\n var filename = params.event.filename\n\n errorElement.id = '__sanityError'\n errorElement.innerHTML = [\n '<div style=\"' + ERROR_BOX_STYLE + '\">',\n '<div style=\"font-weight: 700;\">Uncaught error: ' + error.message + '</div>',\n '<div style=\"color: #515E72; font-size: 13px; line-height: 17px; margin: 10px 0;\">' +\n filename +\n ':' +\n lineno +\n ':' +\n colno +\n '</div>',\n '<pre style=\"' + ERROR_CODE_STYLE + '\">' + error.stack + '</pre>',\n '</div>',\n ].join('')\n\n errorElement.style.position = 'fixed'\n errorElement.style.zIndex = 1000000\n errorElement.style.top = 0\n errorElement.style.left = 0\n errorElement.style.right = 0\n errorElement.style.bottom = 0\n errorElement.style.padding = '20px'\n errorElement.style.background = 'rgba(16,17,18,0.66)'\n errorElement.style.display = 'flex'\n errorElement.style.alignItems = 'center'\n errorElement.style.justifyContent = 'center'\n\n document.body.appendChild(errorElement)\n }\n\n // NOTE:\n // Yes – we're attaching 2 error listeners below 👀\n // This is because React makes the same error throw twice (in development mode).\n // See: https://github.com/facebook/react/issues/10384\n\n // Error listener #1\n window.onerror = function (event, source, lineno, colno, error) {\n _nextTick(function () {\n if (_caughtErrors.indexOf(error) !== -1) return\n\n _caughtErrors.push(error)\n\n _handleError(error, {\n event,\n lineno,\n colno,\n source,\n })\n\n _nextTick(function () {\n var idx = _caughtErrors.indexOf(error)\n\n if (idx > -1) _caughtErrors.splice(idx, 1)\n })\n })\n\n // IMPORTANT: this callback must return \\`true\\` to prevent the error from being rendered in\n // the browser’s console.\n return true\n }\n\n // Error listener #2\n window.addEventListener('error', function (event) {\n if (_caughtErrors.indexOf(event.error) !== -1) return true\n\n _caughtErrors.push(event.error)\n\n _handleError(event.error, {\n event,\n lineno: event.lineno,\n colno: event.colno,\n })\n\n _nextTick(function () {\n _nextTick(function () {\n var idx = _caughtErrors.indexOf(event.error)\n\n if (idx > -1) _caughtErrors.splice(idx, 1)\n })\n })\n\n return true\n })\n})()\n`\n\n/** @internal */\nexport function GlobalErrorHandler(): JSX.Element {\n return <script dangerouslySetInnerHTML={{__html: errorHandlerScript}} />\n}\n"],"names":["errorHandlerScript","GlobalErrorHandler","script","dangerouslySetInnerHTML","__html"],"mappings":";AAEA,MAAMA,qBAAqB,CAAC
|
|
1
|
+
{"version":3,"sources":["../../../../../src/actions/build/renderDocumentWorker/components/GlobalErrorHandler.tsx"],"sourcesContent":["import {type JSX} from 'react'\n\nconst errorHandlerScript = `\n;(function () {\n var _caughtErrors = []\n\n var errorChannel = (function () {\n var subscribers = []\n\n function publish(msg) {\n for (var i = 0; i < subscribers.length; i += 1) {\n subscribers[i](msg)\n }\n }\n\n function subscribe(subscriber) {\n subscribers.push(subscriber)\n\n return function () {\n var idx = subscribers.indexOf(subscriber)\n\n if (idx > -1) {\n subscribers.splice(idx, 1)\n }\n }\n }\n\n return {publish, subscribe, subscribers}\n })()\n\n // NOTE: Store the error channel instance in the global scope so that the application can\n // access it and subscribe to errors.\n window.__sanityErrorChannel = {\n subscribe: errorChannel.subscribe,\n }\n\n function _nextTick(callback) {\n setTimeout(callback, 0)\n }\n\n function _handleError(error, params) {\n _nextTick(function () {\n // - If there are error channel subscribers, then we notify them (no console error).\n // - If there are no subscribers, then we log the error to the console and render the error overlay.\n if (errorChannel.subscribers.length) {\n errorChannel.publish({error, params})\n } else if (error) {\n // Browsers fire some error events without an error object (a ResizeObserver loop,\n // a cross-origin \"Script error.\"), and there is nothing useful to show for them.\n console.error(error)\n\n _renderErrorOverlay(error, params)\n }\n })\n }\n\n var ERROR_BOX_STYLE = [\n 'background: #fff',\n 'border-radius: 6px',\n 'box-sizing: border-box',\n 'color: #121923',\n 'flex: 1',\n \"font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue','Liberation Sans',Helvetica,Arial,system-ui,sans-serif\",\n 'font-size: 16px',\n 'line-height: 21px',\n 'margin: 0 auto',\n 'max-width: 960px',\n 'max-height: 90dvh',\n 'overflow: auto',\n 'padding: 20px',\n 'width: 100%',\n ].join(';')\n\n var ERROR_CODE_STYLE = [\n 'color: #972E2A',\n \"font-family: -apple-system-ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace\",\n 'font-size: 13px',\n 'line-height: 17px',\n 'margin: 0',\n ].join(';')\n\n function _renderErrorOverlay(error, params) {\n var errorElement = document.querySelector('#__sanityError') || document.createElement('div')\n var colno = params.event.colno\n var lineno = params.event.lineno\n var filename = params.event.filename\n\n errorElement.id = '__sanityError'\n errorElement.innerHTML = [\n '<div style=\"' + ERROR_BOX_STYLE + '\">',\n '<div style=\"font-weight: 700;\">Uncaught error: ' + error.message + '</div>',\n '<div style=\"color: #515E72; font-size: 13px; line-height: 17px; margin: 10px 0;\">' +\n filename +\n ':' +\n lineno +\n ':' +\n colno +\n '</div>',\n '<pre style=\"' + ERROR_CODE_STYLE + '\">' + error.stack + '</pre>',\n '</div>',\n ].join('')\n\n errorElement.style.position = 'fixed'\n errorElement.style.zIndex = 1000000\n errorElement.style.top = 0\n errorElement.style.left = 0\n errorElement.style.right = 0\n errorElement.style.bottom = 0\n errorElement.style.padding = '20px'\n errorElement.style.background = 'rgba(16,17,18,0.66)'\n errorElement.style.display = 'flex'\n errorElement.style.alignItems = 'center'\n errorElement.style.justifyContent = 'center'\n\n document.body.appendChild(errorElement)\n }\n\n // NOTE:\n // Yes – we're attaching 2 error listeners below 👀\n // This is because React makes the same error throw twice (in development mode).\n // See: https://github.com/facebook/react/issues/10384\n\n // Error listener #1\n window.onerror = function (event, source, lineno, colno, error) {\n _nextTick(function () {\n if (_caughtErrors.indexOf(error) !== -1) return\n\n _caughtErrors.push(error)\n\n _handleError(error, {\n event,\n lineno,\n colno,\n source,\n })\n\n _nextTick(function () {\n var idx = _caughtErrors.indexOf(error)\n\n if (idx > -1) _caughtErrors.splice(idx, 1)\n })\n })\n\n // IMPORTANT: this callback must return \\`true\\` to prevent the error from being rendered in\n // the browser’s console.\n return true\n }\n\n // Error listener #2\n window.addEventListener('error', function (event) {\n if (_caughtErrors.indexOf(event.error) !== -1) return true\n\n _caughtErrors.push(event.error)\n\n _handleError(event.error, {\n event,\n lineno: event.lineno,\n colno: event.colno,\n })\n\n _nextTick(function () {\n _nextTick(function () {\n var idx = _caughtErrors.indexOf(event.error)\n\n if (idx > -1) _caughtErrors.splice(idx, 1)\n })\n })\n\n return true\n })\n})()\n`\n\n/** @internal */\nexport function GlobalErrorHandler(): JSX.Element {\n return <script dangerouslySetInnerHTML={{__html: errorHandlerScript}} />\n}\n"],"names":["errorHandlerScript","GlobalErrorHandler","script","dangerouslySetInnerHTML","__html"],"mappings":";AAEA,MAAMA,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyK5B,CAAC;AAED,cAAc,GACd,OAAO,SAASC;IACd,qBAAO,KAACC;QAAOC,yBAAyB;YAACC,QAAQJ;QAAkB;;AACrE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli-build",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.3",
|
|
4
4
|
"description": "Internal Sanity package for building studios and apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@oclif/core": "^4.11.14",
|
|
54
54
|
"@rolldown/plugin-babel": "^0.2.3",
|
|
55
|
-
"@sanity/cli-core": "^3.8.
|
|
55
|
+
"@sanity/cli-core": "^3.8.2",
|
|
56
56
|
"@sanity/generate-help-url": "^4.0.0",
|
|
57
57
|
"@sanity/schema": "^6.15.0",
|
|
58
58
|
"@sanity/telemetry": "^1.1.0",
|
|
59
59
|
"@sanity/types": "^6.15.0",
|
|
60
|
-
"@sanity/workbench-cli": "^2.
|
|
60
|
+
"@sanity/workbench-cli": "^2.8.2",
|
|
61
61
|
"@vitejs/plugin-react": "^6.1.1",
|
|
62
62
|
"chokidar": "^5.0.0",
|
|
63
63
|
"cjs-module-lexer": "^2.2.1",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@eslint/compat": "^2.1.0",
|
|
80
80
|
"@repo/package.config": "0.0.1",
|
|
81
81
|
"@repo/tsconfig": "3.70.0",
|
|
82
|
-
"@sanity/cli-test": "18.0.
|
|
82
|
+
"@sanity/cli-test": "18.0.2",
|
|
83
83
|
"@sanity/eslint-config-cli": "^1.1.3",
|
|
84
84
|
"@sanity/pkg-utils": "^12.3.4",
|
|
85
85
|
"@sanity/ui": "^4.2.1",
|