@tinacms/app 0.0.25 → 0.0.26

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.
@@ -120,6 +120,9 @@ export const queryMachine =
120
120
  }
121
121
  | {
122
122
  type: 'FIELD_CHANGE'
123
+ }
124
+ | {
125
+ type: 'EDIT_MODE'
123
126
  },
124
127
  },
125
128
  id: '(machine)',
@@ -13,12 +13,12 @@ limitations under the License.
13
13
  import React from 'react'
14
14
  import { useMachine } from '@xstate/react'
15
15
  import { queryMachine, initialContext } from './lib/machines/query-machine'
16
- import { useCMS, defineStaticConfig } from 'tinacms'
16
+ import { useCMS, defineConfig } from 'tinacms'
17
17
 
18
- type Config = Parameters<typeof defineStaticConfig>[0]
18
+ type Config = Parameters<typeof defineConfig>[0]
19
19
 
20
20
  type PostMessage = {
21
- type: 'open' | 'close'
21
+ type: 'open' | 'close' | 'isEditMode'
22
22
  id: string
23
23
  data: object
24
24
  }
@@ -97,6 +97,13 @@ const QueryMachine = (props: {
97
97
 
98
98
  React.useEffect(() => {
99
99
  if (props.iframeRef.current) {
100
+ window.addEventListener('message', (event: MessageEvent<PostMessage>) => {
101
+ if (event?.data?.type === 'isEditMode') {
102
+ props.iframeRef?.current?.contentWindow?.postMessage({
103
+ type: 'tina:editMode',
104
+ })
105
+ }
106
+ })
100
107
  send({ type: 'IFRAME_MOUNTED', value: props.iframeRef.current })
101
108
  if (props.payload.type === 'open') {
102
109
  send({ type: 'ADD_QUERY', value: props.payload })
package/dist/index.js CHANGED
@@ -326,6 +326,7 @@ var prodHTML = `<!DOCTYPE html>
326
326
 
327
327
  // src/index.ts
328
328
  var server;
329
+ var hasCopiedFiles = false;
329
330
  var viteBuild = async ({
330
331
  rootPath,
331
332
  outputFolder,
@@ -336,7 +337,7 @@ var viteBuild = async ({
336
337
  const local = l;
337
338
  const localBuild = l;
338
339
  const node_env = JSON.stringify(process.env.NODE_ENV);
339
- const generatedPath = import_path2.default.join(rootPath, ".tina/__generated__");
340
+ const generatedPath = import_path2.default.join(rootPath, ".tina", "__generated__");
340
341
  const outputPath = import_path2.default.join(rootPath, publicFolder, outputFolder);
341
342
  const appCopyPath = import_path2.default.join(__dirname, "..", "appFiles");
342
343
  const appRootPath = import_path2.default.join(generatedPath, "app");
@@ -365,6 +366,10 @@ var viteBuild = async ({
365
366
  },
366
367
  logLevel: "silent"
367
368
  };
369
+ if (!hasCopiedFiles) {
370
+ import_fs_extra.default.remove(import_path2.default.join(generatedPath, "prebuild"));
371
+ import_fs_extra.default.remove(import_path2.default.join(generatedPath, "app"));
372
+ }
368
373
  await (0, import_vite.build)(prebuildConfig);
369
374
  const alias = {
370
375
  TINA_IMPORT: configPrebuildPath
@@ -398,26 +403,30 @@ var viteBuild = async ({
398
403
  },
399
404
  logLevel: "silent"
400
405
  };
401
- if (process.env.MONOREPO_DEV) {
402
- console.warn("Using monorepo dev mode, source files will be symlinked");
403
- await import_fs_extra.default.createSymlink(appCopyPath, appRootPath, "dir");
404
- } else {
405
- await import_fs_extra.default.copy(appCopyPath, appRootPath);
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
406
+ if (!hasCopiedFiles) {
407
+ if (process.env.MONOREPO_DEV) {
408
+ console.warn("Using monorepo dev mode, source files will be symlinked");
409
+ await import_fs_extra.default.createSymlink(appCopyPath, appRootPath, "dir");
410
+ } else {
411
+ await import_fs_extra.default.copy(appCopyPath, appRootPath);
412
+ }
413
+ await execShellCommand(`npm --prefix ${appRootPath} i --legacy-peer-deps --omit=dev --no-package-lock`);
414
+ await import_fs_extra.default.outputFile(import_path2.default.join(outputPath, ".gitignore"), `index.html
409
415
  assets/`);
416
+ }
410
417
  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));
416
- if (server) {
417
- await server.close();
418
+ if (!hasCopiedFiles) {
419
+ const replaceAll = (string, target, value) => {
420
+ const regex = new RegExp(target, "g");
421
+ return string.valueOf().replace(regex, value);
422
+ };
423
+ await import_fs_extra.default.outputFile(devHTMLPath, replaceAll(devHTML, "INSERT_OUTPUT_FOLDER_NAME", outputFolder));
424
+ }
425
+ if (!server) {
426
+ server = await (0, import_vite.createServer)(config);
427
+ await server.listen();
418
428
  }
419
- server = await (0, import_vite.createServer)(config);
420
- await server.listen();
429
+ hasCopiedFiles = true;
421
430
  } else {
422
431
  await import_fs_extra.default.outputFile(prodHTMLPath, prodHTML);
423
432
  await (0, import_vite.build)(config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/app",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "main": "dist/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -37,8 +37,8 @@
37
37
  "@types/react": "17.0.2",
38
38
  "@types/react-dom": "17.0.2",
39
39
  "@tinacms/scripts": "0.51.3",
40
- "tinacms": "0.69.21",
41
- "@tinacms/mdx": "0.61.14",
40
+ "tinacms": "0.70.0",
41
+ "@tinacms/mdx": "0.61.15",
42
42
  "jest": "^27.0.6"
43
43
  },
44
44
  "dependencies": {