aboutsummaryrefslogtreecommitdiffstats
path: root/vanilla/node_modules/vite/bin
diff options
context:
space:
mode:
Diffstat (limited to 'vanilla/node_modules/vite/bin')
-rw-r--r--vanilla/node_modules/vite/bin/openChrome.js68
-rwxr-xr-xvanilla/node_modules/vite/bin/vite.js79
2 files changed, 147 insertions, 0 deletions
diff --git a/vanilla/node_modules/vite/bin/openChrome.js b/vanilla/node_modules/vite/bin/openChrome.js
new file mode 100644
index 0000000..5a4aa95
--- /dev/null
+++ b/vanilla/node_modules/vite/bin/openChrome.js
@@ -0,0 +1,68 @@
+/*
+Copyright (c) 2015-present, Facebook, Inc.
+
+This source code is licensed under the MIT license found in the
+LICENSE file at
+https://github.com/facebook/create-react-app/blob/main/LICENSE
+*/
+
+/* global Application */
+
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+function run(argv) {
+ const urlToOpen = argv[0]
+ // Allow requested program to be optional, default to Google Chrome
+ const programName = argv[1] ?? 'Google Chrome'
+
+ const app = Application(programName)
+
+ if (app.windows.length === 0) {
+ app.Window().make()
+ }
+
+ // 1: Looking for tab running debugger then,
+ // Reload debugging tab if found, then return
+ const found = lookupTabWithUrl(urlToOpen, app)
+ if (found) {
+ found.targetWindow.activeTabIndex = found.targetTabIndex
+ found.targetTab.reload()
+ found.targetWindow.index = 1
+ app.activate()
+ return
+ }
+
+ // 2: Looking for Empty tab
+ // In case debugging tab was not found
+ // We try to find an empty tab instead
+ const emptyTabFound = lookupTabWithUrl('chrome://newtab/', app)
+ if (emptyTabFound) {
+ emptyTabFound.targetWindow.activeTabIndex = emptyTabFound.targetTabIndex
+ emptyTabFound.targetTab.url = urlToOpen
+ app.activate()
+ return
+ }
+
+ // 3: Create new tab
+ // both debugging and empty tab were not found make a new tab with url
+ const firstWindow = app.windows[0]
+ firstWindow.tabs.push(app.Tab({ url: urlToOpen }))
+ app.activate()
+}
+
+/**
+ * Lookup tab with given url
+ */
+function lookupTabWithUrl(lookupUrl, app) {
+ const windows = app.windows()
+ for (const window of windows) {
+ for (const [tabIndex, tab] of window.tabs().entries()) {
+ if (tab.url().includes(lookupUrl)) {
+ return {
+ targetTab: tab,
+ targetTabIndex: tabIndex + 1,
+ targetWindow: window,
+ }
+ }
+ }
+ }
+}
diff --git a/vanilla/node_modules/vite/bin/vite.js b/vanilla/node_modules/vite/bin/vite.js
new file mode 100755
index 0000000..79c49ab
--- /dev/null
+++ b/vanilla/node_modules/vite/bin/vite.js
@@ -0,0 +1,79 @@
+#!/usr/bin/env node
+import { performance } from 'node:perf_hooks'
+import module from 'node:module'
+
+if (!import.meta.url.includes('node_modules')) {
+ if (!process.env.DEBUG_DISABLE_SOURCE_MAP) {
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins -- only used in dev
+ process.setSourceMapsEnabled(true)
+ }
+
+ process.on('unhandledRejection', (err) => {
+ throw new Error('UNHANDLED PROMISE REJECTION', { cause: err })
+ })
+}
+
+global.__vite_start_time = performance.now()
+
+// check debug mode first before requiring the CLI.
+const debugIndex = process.argv.findIndex((arg) => /^(?:-d|--debug)$/.test(arg))
+const filterIndex = process.argv.findIndex((arg) =>
+ /^(?:-f|--filter)$/.test(arg),
+)
+const profileIndex = process.argv.indexOf('--profile')
+
+if (debugIndex > 0) {
+ let value = process.argv[debugIndex + 1]
+ if (!value || value[0] === '-') {
+ value = 'vite:*'
+ } else {
+ // support debugging multiple flags with comma-separated list
+ value = value
+ .split(',')
+ .map((v) => `vite:${v}`)
+ .join(',')
+ }
+ process.env.DEBUG = `${
+ process.env.DEBUG ? process.env.DEBUG + ',' : ''
+ }${value}`
+
+ if (filterIndex > 0) {
+ const filter = process.argv[filterIndex + 1]
+ if (filter && filter[0] !== '-') {
+ process.env.VITE_DEBUG_FILTER = filter
+ }
+ }
+}
+
+function start() {
+ try {
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins -- it is supported in Node 22.8.0+ and only called if it exists
+ module.enableCompileCache?.()
+ // flush the cache after 10s because the cache is not flushed until process end
+ // for dev server, the cache is never flushed unless manually flushed because the process.exit is called
+ // also flushing the cache in SIGINT handler seems to cause the process to hang
+ setTimeout(() => {
+ try {
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins -- it is supported in Node 22.12.0+ and only called if it exists
+ module.flushCompileCache?.()
+ } catch {}
+ }, 10 * 1000).unref()
+ } catch {}
+ return import('../dist/node/cli.js')
+}
+
+if (profileIndex > 0) {
+ process.argv.splice(profileIndex, 1)
+ const next = process.argv[profileIndex]
+ if (next && next[0] !== '-') {
+ process.argv.splice(profileIndex, 1)
+ }
+ const inspector = await import('node:inspector').then((r) => r.default)
+ const session = (global.__vite_profile_session = new inspector.Session())
+ session.connect()
+ session.post('Profiler.enable', () => {
+ session.post('Profiler.start', start)
+ })
+} else {
+ start()
+}