@tinacms/app 0.0.21 → 0.0.23

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.
@@ -0,0 +1,205 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import { DocumentBlueprint } from '../formify/types'
14
+
15
+ type Location = number[] | null
16
+
17
+ export const getBlueprintValues = (
18
+ data: object,
19
+ path: string,
20
+ index: number = 0
21
+ ): string[] | undefined => {
22
+ if (!data) {
23
+ return
24
+ }
25
+ const pathArray = path.split('.')
26
+ const next = pathArray[index]
27
+ if (next === '[]') {
28
+ if (Array.isArray(data)) {
29
+ const values: string[] = []
30
+ data.forEach((item) => {
31
+ const res = getBlueprintValues(item, path, index + 1)
32
+ if (res) {
33
+ res.forEach((item) => {
34
+ values.push(item)
35
+ })
36
+ }
37
+ })
38
+ return values
39
+ }
40
+ } else {
41
+ const value = data[next]
42
+ // Is last item
43
+ if (pathArray.length === index + 1) {
44
+ if (Array.isArray(value)) {
45
+ return value
46
+ } else {
47
+ return [value]
48
+ }
49
+ } else {
50
+ return getBlueprintValues(value, path)
51
+ }
52
+ }
53
+ }
54
+
55
+ export const getAllIn = (
56
+ data: object | object[] | null,
57
+ path: string,
58
+ index: number = 0,
59
+ location: Location = null
60
+ ): { value: { id: string }; location: Location }[] | undefined => {
61
+ if (!data) {
62
+ return
63
+ }
64
+ const pathArray = path.split('.')
65
+ const next = pathArray[index]
66
+ if (next === '[]') {
67
+ if (Array.isArray(data)) {
68
+ const values: { value: { id: string }; location: Location }[] = []
69
+ data.forEach((item, dataIndex) => {
70
+ const res = getAllIn(item, path, index + 1, [
71
+ ...(location || []),
72
+ dataIndex,
73
+ ])
74
+ if (res) {
75
+ res.forEach((item) => {
76
+ values.push(item)
77
+ })
78
+ }
79
+ })
80
+ return values
81
+ }
82
+ } else {
83
+ const value = data[next]
84
+ // Is last item
85
+ if (pathArray.length === index + 1) {
86
+ if (Array.isArray(value)) {
87
+ const v = value.map((item, index) => ({
88
+ value: item,
89
+ location: [...(location || []), index],
90
+ }))
91
+ return v
92
+ } else {
93
+ if (typeof value === 'string') {
94
+ const v = [{ value: { id: value }, location }]
95
+ return v
96
+ } else {
97
+ // FIXME: this should always be `_internalSys.path` but we're not populating the
98
+ // data properly on resolveData yet. But even when we are, will need to keep that out
99
+ // of the user-provided payload (maybe not?)
100
+ const id = value?._internalSys?.path || value?.id
101
+ if (id) {
102
+ const v = [{ value: { id, ...value }, location }]
103
+ return v
104
+ }
105
+ }
106
+ }
107
+ } else {
108
+ const v = getAllIn(value, path, index + 1, location)
109
+ return v
110
+ }
111
+ }
112
+ }
113
+ export const getAllInBlueprint = (
114
+ data: object | object[] | null,
115
+ path: string,
116
+ index: number = 0,
117
+ location: Location = null
118
+ ):
119
+ | { value: { _internalSys: { path: string } }; location: Location }[]
120
+ | undefined => {
121
+ if (!data) {
122
+ return
123
+ }
124
+ const pathArray = path.split('.')
125
+ const next = pathArray[index]
126
+ if (next === '[]') {
127
+ if (Array.isArray(data)) {
128
+ const values: {
129
+ value: { _internalSys: { path: string } }
130
+ location: Location
131
+ }[] = []
132
+ data.forEach((item, dataIndex) => {
133
+ const res = getAllInBlueprint(item, path, index + 1, [
134
+ ...(location || []),
135
+ dataIndex,
136
+ ])
137
+ if (res) {
138
+ res.forEach((item) => {
139
+ values.push(item)
140
+ })
141
+ }
142
+ })
143
+ return values
144
+ }
145
+ } else {
146
+ const value = data[next]
147
+ // Is last item
148
+ if (pathArray.length === index + 1) {
149
+ if (Array.isArray(value)) {
150
+ throw new Error(`Unexpected array value for getAllInBlueprint`)
151
+ } else {
152
+ if (typeof value === 'string') {
153
+ throw new Error(`Unexpected string value for getAllInBlueprint`)
154
+ } else {
155
+ const id = value?._internalSys?.path || value?.id
156
+ if (id) {
157
+ const v = [
158
+ { value: { _internalSys: value._internalSys }, location },
159
+ ]
160
+ return v
161
+ }
162
+ }
163
+ }
164
+ } else {
165
+ const v = getAllInBlueprint(value, path, index + 1, location)
166
+ return v
167
+ }
168
+ }
169
+ }
170
+
171
+ export const getBlueprintFromLocation = (
172
+ location: string,
173
+ blueprints: DocumentBlueprint[]
174
+ ) => {
175
+ const blueprintString = location
176
+ .split('.')
177
+ .map((item) => (isNaN(Number(item)) ? item : '[]'))
178
+ .join('.')
179
+ const blueprint = blueprints.find(({ id }) => id === blueprintString)
180
+ if (!blueprint) {
181
+ throw new Error(`Unable to find blueprint at ${blueprintString}`)
182
+ }
183
+ return blueprint
184
+ }
185
+
186
+ // FIXME: this assumes children are in order (which they
187
+ // are AFAIK but shouldn't be relied on)
188
+ export const getBlueprintChildren = (
189
+ blueprint: DocumentBlueprint,
190
+ blueprints: DocumentBlueprint[]
191
+ ) => {
192
+ const foundChildren: DocumentBlueprint[] = []
193
+ blueprints.forEach((otherBlueprint) => {
194
+ if (foundChildren.find(({ id }) => otherBlueprint.id.startsWith(id))) {
195
+ return
196
+ }
197
+ if (
198
+ otherBlueprint.id.startsWith(blueprint.id) &&
199
+ otherBlueprint.id !== blueprint.id
200
+ ) {
201
+ foundChildren.push(otherBlueprint)
202
+ }
203
+ })
204
+ return foundChildren
205
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+
14
+ import React from 'react'
15
+ import ReactDOM from 'react-dom'
16
+ import App from './App'
17
+ import './index.css'
18
+
19
+ ReactDOM.render(
20
+ <React.StrictMode>
21
+ <App />
22
+ </React.StrictMode>,
23
+ document.getElementById('root')
24
+ )
@@ -0,0 +1,108 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import React from 'react'
14
+ import { useMachine } from '@xstate/react'
15
+ import { queryMachine, initialContext } from './lib/machines/query-machine'
16
+ import { useCMS, defineStaticConfig } from 'tinacms'
17
+
18
+ type Config = Parameters<typeof defineStaticConfig>[0]
19
+
20
+ type PostMessage = {
21
+ type: 'open' | 'close'
22
+ id: string
23
+ data: object
24
+ }
25
+
26
+ export const Preview = (
27
+ props: Config & {
28
+ url: string
29
+ iframeRef: React.MutableRefObject<HTMLIFrameElement>
30
+ }
31
+ ) => {
32
+ const [activeQuery, setActiveQuery] = React.useState<PostMessage | null>(null)
33
+
34
+ React.useEffect(() => {
35
+ if (props.iframeRef.current) {
36
+ window.addEventListener('message', (event: MessageEvent<PostMessage>) => {
37
+ if (event.data.type === 'open') {
38
+ setActiveQuery(event.data)
39
+ }
40
+ })
41
+ }
42
+ }, [props.iframeRef.current])
43
+
44
+ return (
45
+ <div className="tina-tailwind">
46
+ {activeQuery && (
47
+ <QueryMachine
48
+ key={activeQuery.id}
49
+ payload={activeQuery}
50
+ iframeRef={props.iframeRef}
51
+ />
52
+ )}
53
+ <div className="h-full overflow-scroll">
54
+ <div className="">
55
+ <div className="col-span-5 ">
56
+ <div className="h-screen flex flex-col">
57
+ <div className="relative flex-1 bg-gray-300 col-span-2 overflow-scroll flex items-center justify-center">
58
+ <iframe
59
+ ref={props.iframeRef}
60
+ className="h-full w-full bg-white"
61
+ src={props.url}
62
+ />
63
+ </div>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ )
70
+ }
71
+
72
+ const QueryMachine = (props: {
73
+ payload: PostMessage
74
+ iframeRef: React.MutableRefObject<HTMLIFrameElement>
75
+ }) => {
76
+ const cms = useCMS()
77
+
78
+ const machine = React.useMemo(
79
+ () =>
80
+ queryMachine.withContext({
81
+ ...initialContext,
82
+ cms,
83
+ // @ts-ignore FIXME: add formifyCallback args to Config type
84
+ formifyCallback: props.formifyCallback,
85
+ }),
86
+ []
87
+ )
88
+
89
+ const [state, send] = useMachine(machine)
90
+ React.useEffect(() => {
91
+ if (state.matches('pipeline.ready')) {
92
+ cms.events.dispatch({ type: 'forms:register', value: 'complete' })
93
+ } else {
94
+ cms.events.dispatch({ type: 'forms:register', value: 'start' })
95
+ }
96
+ }, [JSON.stringify(state.value)])
97
+
98
+ React.useEffect(() => {
99
+ if (props.iframeRef.current) {
100
+ send({ type: 'IFRAME_MOUNTED', value: props.iframeRef.current })
101
+ if (props.payload.type === 'open') {
102
+ send({ type: 'ADD_QUERY', value: props.payload })
103
+ }
104
+ }
105
+ }, [props.iframeRef.current])
106
+
107
+ return null
108
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+
14
+ /// <reference types="vite/client" />
package/dist/index.js CHANGED
@@ -2,22 +2,8 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
5
  var __getProtoOf = Object.getPrototypeOf;
7
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
7
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
22
8
  var __export = (target, all) => {
23
9
  __markAsModule(target);
@@ -40,10 +26,10 @@ var __toModule = (module2) => {
40
26
  __export(exports, {
41
27
  viteBuild: () => viteBuild
42
28
  });
43
- var import_plugin_react = __toModule(require("@vitejs/plugin-react"));
44
29
  var import_fs_extra = __toModule(require("fs-extra"));
45
- var import_vite = __toModule(require("vite"));
46
30
  var import_path2 = __toModule(require("path"));
31
+ var import_vite = __toModule(require("vite"));
32
+ var import_plugin_react = __toModule(require("@vitejs/plugin-react"));
47
33
 
48
34
  // src/tailwind.ts
49
35
  var import_tailwindcss = __toModule(require("tailwindcss"));
@@ -264,6 +250,12 @@ var viteTina = () => {
264
250
  },
265
251
  maxWidth: {
266
252
  form: "900px"
253
+ },
254
+ screens: {
255
+ xs: "320px",
256
+ sm: "560px",
257
+ md: "720px",
258
+ lg: "1030px"
267
259
  }
268
260
  }
269
261
  },
@@ -290,122 +282,163 @@ var viteTina = () => {
290
282
  };
291
283
  };
292
284
 
285
+ // src/html.ts
286
+ var devHTML = `<!DOCTYPE html>
287
+ <html lang="en">
288
+ <head>
289
+ <meta charset="UTF-8" />
290
+ <link rel="icon" type="image/svg+xml" href="/tina.svg" />
291
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
292
+ <title>TinaCMS</title>
293
+ </head>
294
+
295
+ <!-- if development -->
296
+ <script type="module">
297
+ import RefreshRuntime from 'http://localhost:5173/@react-refresh'
298
+ RefreshRuntime.injectIntoGlobalHook(window)
299
+ window.$RefreshReg$ = () => {}
300
+ window.$RefreshSig$ = () => (type) => type
301
+ window.__vite_plugin_react_preamble_installed__ = true
302
+ <\/script>
303
+ <script type="module" src="http://localhost:5173/@vite/client"><\/script>
304
+ <script
305
+ type="module"
306
+ src="http://localhost:5173/INSERT_OUTPUT_FOLDER_NAME/src/main.tsx"
307
+ ><\/script>
308
+ <body class="tina-tailwind">
309
+ <div id="root"></div>
310
+ </body>
311
+ </html>`;
312
+ var prodHTML = `<!DOCTYPE html>
313
+ <html lang="en">
314
+ <head>
315
+ <meta charset="UTF-8" />
316
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
317
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
318
+ <title>TinaCMS</title>
319
+ </head>
320
+ <body>
321
+ <div id="root"></div>
322
+ <script type="module" src="/src/main.tsx"><\/script>
323
+ </body>
324
+ </html>
325
+ `;
326
+
293
327
  // src/index.ts
294
- var import_esbuild = __toModule(require("esbuild"));
295
328
  var server;
296
329
  var viteBuild = async ({
297
330
  rootPath,
298
331
  outputFolder,
299
332
  publicFolder,
300
- local,
333
+ local: l,
301
334
  apiUrl
302
335
  }) => {
303
- const prebuildPath = import_path2.default.resolve(__dirname, "assets");
304
- const pathToConfig = import_path2.default.join(rootPath, ".tina", "config");
305
- const packageJSONFilePath = import_path2.default.join(rootPath, "package.json");
306
- const outDir = import_path2.default.join(rootPath, publicFolder, outputFolder);
307
- await import_fs_extra.default.emptyDir(outDir);
308
- await import_fs_extra.default.ensureDir(outDir);
309
- await import_fs_extra.default.writeFile(import_path2.default.join(rootPath, publicFolder, outputFolder, ".gitignore"), `index.html
310
- assets/
311
- vite.svg`);
312
- const packageJSON = JSON.parse(import_fs_extra.default.readFileSync(packageJSONFilePath).toString() || "{}");
313
- const define = {};
314
- const deps = (packageJSON == null ? void 0 : packageJSON.dependencies) || [];
315
- const peerDeps = (packageJSON == null ? void 0 : packageJSON.peerDependencies) || [];
316
- const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
317
- const external = Object.keys(__spreadValues(__spreadValues(__spreadValues({}, deps), peerDeps), devDeps));
318
- const out = import_path2.default.join(rootPath, ".tina", "__generated__", "out.jsx");
319
- await (0, import_esbuild.build)({
320
- bundle: true,
321
- platform: "browser",
322
- target: ["es2020"],
323
- entryPoints: [pathToConfig],
324
- format: "esm",
325
- treeShaking: true,
326
- outfile: out,
327
- external: [...external, "./node_modules/*"],
328
- loader: loaders,
329
- define
330
- });
331
- const base = `/${outputFolder}/`;
332
- const MONOREPO_DEV = process.env.MONOREPO_DEV;
333
- const root = MONOREPO_DEV ? import_path2.default.join(__dirname, "../appFiles") : outDir;
336
+ const local = l;
337
+ const localBuild = l;
338
+ const node_env = JSON.stringify(process.env.NODE_ENV);
339
+ const generatedPath = import_path2.default.join(rootPath, ".tina/__generated__");
340
+ const outputPath = import_path2.default.join(rootPath, publicFolder, outputFolder);
341
+ const appCopyPath = import_path2.default.join(__dirname, "..", "appFiles");
342
+ const appRootPath = import_path2.default.join(generatedPath, "app");
343
+ const devHTMLPath = import_path2.default.join(outputPath, "index.html");
344
+ const prodHTMLPath = import_path2.default.join(appRootPath, "index.html");
345
+ const configPath = import_path2.default.join(rootPath, ".tina", "config");
346
+ const configPrebuildPath = import_path2.default.join(generatedPath, "prebuild", "config.js");
347
+ const prebuildConfig = {
348
+ root: import_path2.default.join(generatedPath, "prebuild"),
349
+ esbuild: {
350
+ target: "es2020"
351
+ },
352
+ mode: local ? "development" : "production",
353
+ build: {
354
+ outDir: import_path2.default.join(generatedPath, "prebuild"),
355
+ lib: {
356
+ entry: configPath,
357
+ fileName: () => {
358
+ return "config.js";
359
+ },
360
+ formats: ["es"]
361
+ },
362
+ rollupOptions: {
363
+ external: ["react", "react-dom", "tinacms", "next"]
364
+ }
365
+ },
366
+ logLevel: "silent"
367
+ };
368
+ await (0, import_vite.build)(prebuildConfig);
369
+ const alias = {
370
+ TINA_IMPORT: configPrebuildPath
371
+ };
334
372
  const config = {
335
- root,
336
- base,
373
+ root: appRootPath,
374
+ base: `/${outputFolder}/`,
337
375
  mode: local ? "development" : "production",
338
- plugins: [(0, import_plugin_react.default)(), viteTina()],
376
+ plugins: [(0, import_vite.splitVendorChunkPlugin)(), (0, import_plugin_react.default)(), viteTina()],
339
377
  define: {
340
- "process.env": {},
378
+ "process.env": "new Object()",
341
379
  __API_URL__: `"${apiUrl}"`
342
380
  },
381
+ esbuild: {
382
+ target: "es2020"
383
+ },
343
384
  server: {
344
- strictPort: true,
345
385
  port: 5173,
346
386
  fs: {
347
387
  strict: false
348
388
  }
349
389
  },
350
390
  resolve: {
351
- alias: {
352
- TINA_IMPORT: out
353
- }
391
+ alias,
392
+ dedupe: ["graphql"]
354
393
  },
355
394
  build: {
356
395
  sourcemap: true,
357
- outDir,
396
+ outDir: outputPath,
358
397
  emptyOutDir: false
359
398
  },
360
399
  logLevel: "silent"
361
400
  };
362
- if (local) {
363
- const indexDev = await import_fs_extra.default.readFileSync(import_path2.default.join(__dirname, "index.dev.html")).toString();
364
- if (MONOREPO_DEV) {
365
- console.warn("MONOREPO_DEV mode, vite root is @tinacms/app");
366
- await import_fs_extra.default.outputFileSync(import_path2.default.join(outDir, "index.html"), indexDev.replace(`INSERT_OUTPUT_FOLDER_NAME`, outputFolder).replace("assets/out.es.js", "src/main.tsx"));
367
- } else {
368
- await import_fs_extra.default.outputFileSync(import_path2.default.join(outDir, "index.html"), indexDev.replace(`INSERT_OUTPUT_FOLDER_NAME`, outputFolder));
369
- await import_fs_extra.default.copySync(prebuildPath, import_path2.default.join(outDir, "assets"));
370
- }
401
+ if (true) {
402
+ await import_fs_extra.default.copy(appCopyPath, appRootPath);
403
+ } else {
404
+ await import_fs_extra.default.createSymlink(import_path2.default.join(appCopyPath, "src"), import_path2.default.join(appRootPath, "src"), "dir");
405
+ await import_fs_extra.default.createSymlink(import_path2.default.join(appCopyPath, "package.json"), import_path2.default.join(appRootPath, "package.json"), "file");
406
+ }
407
+ await execShellCommand(`npm --prefix ${appRootPath} i --legacy-peer-deps --omit=dev --no-package-lock`);
408
+ await import_fs_extra.default.outputFile(import_path2.default.join(outputPath, ".gitignore"), `index.html
409
+ assets/`);
410
+ if (localBuild) {
411
+ const replaceAll = (string, target, value) => {
412
+ const regex = new RegExp(target, "g");
413
+ return string.valueOf().replace(regex, value);
414
+ };
415
+ await import_fs_extra.default.outputFile(devHTMLPath, replaceAll(devHTML, "INSERT_OUTPUT_FOLDER_NAME", outputFolder));
371
416
  if (server) {
372
417
  await server.close();
373
418
  }
374
419
  server = await (0, import_vite.createServer)(config);
375
420
  await server.listen();
376
- await server.printUrls();
377
421
  } else {
378
- await import_fs_extra.default.copyFileSync(import_path2.default.join(__dirname, "index.html"), import_path2.default.join(outDir, "index.html"));
379
- await import_fs_extra.default.copySync(prebuildPath, import_path2.default.join(outDir, "assets"));
422
+ await import_fs_extra.default.outputFile(prodHTMLPath, prodHTML);
380
423
  await (0, import_vite.build)(config);
381
- await import_fs_extra.default.rmSync(out);
424
+ }
425
+ if (!node_env) {
426
+ delete process.env.NODE_ENV;
427
+ } else {
428
+ process.env.NODE_ENV = node_env;
382
429
  }
383
430
  };
384
- var loaders = {
385
- ".aac": "file",
386
- ".css": "file",
387
- ".eot": "file",
388
- ".flac": "file",
389
- ".gif": "file",
390
- ".jpeg": "file",
391
- ".jpg": "file",
392
- ".json": "json",
393
- ".mp3": "file",
394
- ".mp4": "file",
395
- ".ogg": "file",
396
- ".otf": "file",
397
- ".png": "file",
398
- ".svg": "file",
399
- ".ttf": "file",
400
- ".wav": "file",
401
- ".webm": "file",
402
- ".webp": "file",
403
- ".woff": "file",
404
- ".woff2": "file",
405
- ".js": "jsx",
406
- ".jsx": "jsx",
407
- ".tsx": "tsx"
408
- };
431
+ function execShellCommand(cmd) {
432
+ const exec = require("child_process").exec;
433
+ return new Promise((resolve, reject) => {
434
+ exec(cmd, (error, stdout, stderr) => {
435
+ if (error) {
436
+ reject(error);
437
+ }
438
+ resolve(stdout ? stdout : stderr);
439
+ });
440
+ });
441
+ }
409
442
  // Annotate the CommonJS export names for ESM import in node:
410
443
  0 && (module.exports = {
411
444
  viteBuild