@tinacms/app 1.0.4 → 1.0.5

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.
Files changed (102) hide show
  1. package/appFiles/node_modules/.package-lock.json +16 -16
  2. package/appFiles/node_modules/@babel/generator/lib/buffer.js +1 -16
  3. package/appFiles/node_modules/@babel/generator/lib/buffer.js.map +1 -1
  4. package/appFiles/node_modules/@babel/generator/lib/generators/base.js +0 -2
  5. package/appFiles/node_modules/@babel/generator/lib/generators/base.js.map +1 -1
  6. package/appFiles/node_modules/@babel/generator/lib/generators/classes.js +0 -6
  7. package/appFiles/node_modules/@babel/generator/lib/generators/classes.js.map +1 -1
  8. package/appFiles/node_modules/@babel/generator/lib/generators/expressions.js +1 -6
  9. package/appFiles/node_modules/@babel/generator/lib/generators/expressions.js.map +1 -1
  10. package/appFiles/node_modules/@babel/generator/lib/generators/flow.js +0 -2
  11. package/appFiles/node_modules/@babel/generator/lib/generators/flow.js.map +1 -1
  12. package/appFiles/node_modules/@babel/generator/lib/generators/methods.js +4 -11
  13. package/appFiles/node_modules/@babel/generator/lib/generators/methods.js.map +1 -1
  14. package/appFiles/node_modules/@babel/generator/lib/generators/modules.js +0 -1
  15. package/appFiles/node_modules/@babel/generator/lib/generators/modules.js.map +1 -1
  16. package/appFiles/node_modules/@babel/generator/lib/generators/statements.js +0 -3
  17. package/appFiles/node_modules/@babel/generator/lib/generators/statements.js.map +1 -1
  18. package/appFiles/node_modules/@babel/generator/lib/generators/types.js +1 -5
  19. package/appFiles/node_modules/@babel/generator/lib/generators/types.js.map +1 -1
  20. package/appFiles/node_modules/@babel/generator/lib/generators/typescript.js +2 -4
  21. package/appFiles/node_modules/@babel/generator/lib/generators/typescript.js.map +1 -1
  22. package/appFiles/node_modules/@babel/generator/lib/index.js +0 -6
  23. package/appFiles/node_modules/@babel/generator/lib/index.js.map +1 -1
  24. package/appFiles/node_modules/@babel/generator/lib/node/index.js +0 -1
  25. package/appFiles/node_modules/@babel/generator/lib/node/index.js.map +1 -1
  26. package/appFiles/node_modules/@babel/generator/lib/node/parentheses.js +3 -14
  27. package/appFiles/node_modules/@babel/generator/lib/node/parentheses.js.map +1 -1
  28. package/appFiles/node_modules/@babel/generator/lib/node/whitespace.js +1 -15
  29. package/appFiles/node_modules/@babel/generator/lib/node/whitespace.js.map +1 -1
  30. package/appFiles/node_modules/@babel/generator/lib/printer.js +5 -45
  31. package/appFiles/node_modules/@babel/generator/lib/printer.js.map +1 -1
  32. package/appFiles/node_modules/@babel/generator/lib/source-map.js +0 -4
  33. package/appFiles/node_modules/@babel/generator/lib/source-map.js.map +1 -1
  34. package/appFiles/node_modules/@babel/generator/package.json +2 -2
  35. package/appFiles/node_modules/@babel/parser/lib/index.js +147 -673
  36. package/appFiles/node_modules/@babel/parser/lib/index.js.map +1 -1
  37. package/appFiles/node_modules/@babel/parser/package.json +1 -1
  38. package/appFiles/node_modules/@babel/runtime/helpers/applyDecs2203.js +170 -167
  39. package/appFiles/node_modules/@babel/runtime/helpers/applyDecs2203R.js +188 -0
  40. package/appFiles/node_modules/@babel/runtime/helpers/esm/applyDecs2203.js +170 -167
  41. package/appFiles/node_modules/@babel/runtime/helpers/esm/applyDecs2203R.js +187 -0
  42. package/appFiles/node_modules/@babel/runtime/package.json +10 -1
  43. package/appFiles/node_modules/@babel/traverse/lib/context.js +2 -14
  44. package/appFiles/node_modules/@babel/traverse/lib/context.js.map +1 -1
  45. package/appFiles/node_modules/@babel/traverse/lib/index.js +1 -4
  46. package/appFiles/node_modules/@babel/traverse/lib/index.js.map +1 -1
  47. package/appFiles/node_modules/@babel/traverse/lib/path/ancestry.js +0 -19
  48. package/appFiles/node_modules/@babel/traverse/lib/path/ancestry.js.map +1 -1
  49. package/appFiles/node_modules/@babel/traverse/lib/path/comments.js +0 -2
  50. package/appFiles/node_modules/@babel/traverse/lib/path/comments.js.map +1 -1
  51. package/appFiles/node_modules/@babel/traverse/lib/path/context.js +5 -21
  52. package/appFiles/node_modules/@babel/traverse/lib/path/context.js.map +1 -1
  53. package/appFiles/node_modules/@babel/traverse/lib/path/conversion.js +6 -30
  54. package/appFiles/node_modules/@babel/traverse/lib/path/conversion.js.map +1 -1
  55. package/appFiles/node_modules/@babel/traverse/lib/path/evaluation.js +14 -20
  56. package/appFiles/node_modules/@babel/traverse/lib/path/evaluation.js.map +1 -1
  57. package/appFiles/node_modules/@babel/traverse/lib/path/family.js +3 -9
  58. package/appFiles/node_modules/@babel/traverse/lib/path/family.js.map +1 -1
  59. package/appFiles/node_modules/@babel/traverse/lib/path/index.js +1 -6
  60. package/appFiles/node_modules/@babel/traverse/lib/path/index.js.map +1 -1
  61. package/appFiles/node_modules/@babel/traverse/lib/path/inference/index.js +1 -9
  62. package/appFiles/node_modules/@babel/traverse/lib/path/inference/index.js.map +1 -1
  63. package/appFiles/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js +1 -13
  64. package/appFiles/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js.map +1 -1
  65. package/appFiles/node_modules/@babel/traverse/lib/path/inference/inferers.js +2 -5
  66. package/appFiles/node_modules/@babel/traverse/lib/path/inference/inferers.js.map +1 -1
  67. package/appFiles/node_modules/@babel/traverse/lib/path/introspection.js +16 -62
  68. package/appFiles/node_modules/@babel/traverse/lib/path/introspection.js.map +1 -1
  69. package/appFiles/node_modules/@babel/traverse/lib/path/lib/hoister.js +1 -22
  70. package/appFiles/node_modules/@babel/traverse/lib/path/lib/hoister.js.map +1 -1
  71. package/appFiles/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js +1 -7
  72. package/appFiles/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js.map +1 -1
  73. package/appFiles/node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js +0 -2
  74. package/appFiles/node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js.map +1 -1
  75. package/appFiles/node_modules/@babel/traverse/lib/path/lib/virtual-types.js +0 -1
  76. package/appFiles/node_modules/@babel/traverse/lib/path/lib/virtual-types.js.map +1 -1
  77. package/appFiles/node_modules/@babel/traverse/lib/path/modification.js +7 -24
  78. package/appFiles/node_modules/@babel/traverse/lib/path/modification.js.map +1 -1
  79. package/appFiles/node_modules/@babel/traverse/lib/path/removal.js +0 -1
  80. package/appFiles/node_modules/@babel/traverse/lib/path/removal.js.map +1 -1
  81. package/appFiles/node_modules/@babel/traverse/lib/path/replacement.js +2 -16
  82. package/appFiles/node_modules/@babel/traverse/lib/path/replacement.js.map +1 -1
  83. package/appFiles/node_modules/@babel/traverse/lib/scope/binding.js +1 -6
  84. package/appFiles/node_modules/@babel/traverse/lib/scope/binding.js.map +1 -1
  85. package/appFiles/node_modules/@babel/traverse/lib/scope/index.js +9 -53
  86. package/appFiles/node_modules/@babel/traverse/lib/scope/index.js.map +1 -1
  87. package/appFiles/node_modules/@babel/traverse/lib/scope/lib/renamer.js +4 -8
  88. package/appFiles/node_modules/@babel/traverse/lib/scope/lib/renamer.js.map +1 -1
  89. package/appFiles/node_modules/@babel/traverse/lib/visitors.js +2 -23
  90. package/appFiles/node_modules/@babel/traverse/lib/visitors.js.map +1 -1
  91. package/appFiles/node_modules/@babel/traverse/package.json +2 -2
  92. package/appFiles/node_modules/css-to-react-native/README.md +4 -2
  93. package/appFiles/node_modules/css-to-react-native/index.js +13 -6
  94. package/appFiles/node_modules/css-to-react-native/package.json +2 -1
  95. package/appFiles/node_modules/css-to-react-native/src/__tests__/fontVariant.js +8 -0
  96. package/appFiles/node_modules/css-to-react-native/src/transforms/fontVariant.js +14 -0
  97. package/appFiles/node_modules/css-to-react-native/src/transforms/index.js +5 -7
  98. package/appFiles/src/fields/rich-text/monaco/index.tsx +12 -10
  99. package/appFiles/src/fields/rich-text/monaco/mdx.js +41 -35
  100. package/appFiles/src/lib/machines/document-machine.ts +1 -1
  101. package/dist/index.js +1 -1
  102. package/package.json +5 -4
@@ -1 +1 @@
1
- {"version":3,"names":["DEPRECATED_KEYS","FLIPPED_ALIAS_KEYS","TYPES","isVirtualType","type","virtualTypes","explode","visitor","_exploded","nodeType","Object","keys","shouldIgnoreKey","parts","split","length","fns","part","verify","__esModule","ensureEntranceObjects","ensureCallbackArrays","wrapCheck","types","mergePair","aliases","deprecatedKey","console","trace","alias","existing","_verified","Error","validateVisitorMethods","indexOf","visitors","visitorKey","path","val","concat","fn","TypeError","merge","states","wrapper","rootVisitor","i","state","visitorType","wrapWithStateOrWrapper","nodeVisitor","oldVisitor","newVisitor","key","Array","isArray","map","newFn","call","toString","obj","enter","exit","apply","arguments","dest","src"],"sources":["../src/visitors.ts"],"sourcesContent":["import * as virtualTypes from \"./path/lib/virtual-types\";\nimport { DEPRECATED_KEYS, FLIPPED_ALIAS_KEYS, TYPES } from \"@babel/types\";\nimport type { NodePath, Visitor } from \"./index\";\n\ntype VIRTUAL_TYPES = keyof typeof virtualTypes;\nfunction isVirtualType(type: string): type is VIRTUAL_TYPES {\n return type in virtualTypes;\n}\n\n/**\n * explode() will take a visitor object with all of the various shorthands\n * that we support, and validates & normalizes it into a common format, ready\n * to be used in traversal\n *\n * The various shorthands are:\n * * `Identifier() { ... }` -> `Identifier: { enter() { ... } }`\n * * `\"Identifier|NumericLiteral\": { ... }` -> `Identifier: { ... }, NumericLiteral: { ... }`\n * * Aliases in `@babel/types`: e.g. `Property: { ... }` -> `ObjectProperty: { ... }, ClassProperty: { ... }`\n *\n * Other normalizations are:\n * * Visitors of virtual types are wrapped, so that they are only visited when\n * their dynamic check passes\n * * `enter` and `exit` functions are wrapped in arrays, to ease merging of\n * visitors\n */\nexport function explode(visitor: Visitor) {\n if (visitor._exploded) return visitor;\n visitor._exploded = true;\n\n // normalise pipes\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n const parts: Array<string> = nodeType.split(\"|\");\n if (parts.length === 1) continue;\n\n const fns = visitor[nodeType];\n delete visitor[nodeType];\n\n for (const part of parts) {\n // @ts-expect-error part will be verified by `verify` later\n visitor[part] = fns;\n }\n }\n\n // verify data structure\n verify(visitor);\n\n // make sure there's no __esModule type since this is because we're using loose mode\n // and it sets __esModule to be enumerable on all modules :(\n // @ts-expect-error ESModule interop\n delete visitor.__esModule;\n\n // ensure visitors are objects\n ensureEntranceObjects(visitor);\n\n // ensure enter/exit callbacks are arrays\n ensureCallbackArrays(visitor);\n\n // add type wrappers\n for (const nodeType of Object.keys(visitor)) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n if (!isVirtualType(nodeType)) continue;\n\n // wrap all the functions\n const fns = visitor[nodeType];\n for (const type of Object.keys(fns)) {\n // @ts-expect-error manipulating visitors\n fns[type] = wrapCheck(nodeType, fns[type]);\n }\n\n // clear it from the visitor\n delete visitor[nodeType];\n\n const types = virtualTypes[nodeType];\n if (types !== null) {\n for (const type of types) {\n // merge the visitor if necessary or just put it back in\n if (visitor[type]) {\n mergePair(visitor[type], fns);\n } else {\n // @ts-expect-error Expression produces too complex union\n visitor[type] = fns;\n }\n }\n } else {\n mergePair(visitor, fns);\n }\n }\n\n // add aliases\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n const fns = visitor[nodeType];\n\n let aliases = FLIPPED_ALIAS_KEYS[nodeType];\n\n const deprecatedKey = DEPRECATED_KEYS[nodeType];\n if (deprecatedKey) {\n console.trace(\n `Visitor defined for ${nodeType} but it has been renamed to ${deprecatedKey}`,\n );\n aliases = [deprecatedKey];\n }\n\n if (!aliases) continue;\n\n // clear it from the visitor\n delete visitor[nodeType];\n\n for (const alias of aliases) {\n const existing = visitor[alias];\n if (existing) {\n mergePair(existing, fns);\n } else {\n // @ts-expect-error Expression produces a union type that is too complex to represent.\n visitor[alias] = { ...fns };\n }\n }\n }\n\n for (const nodeType of Object.keys(visitor)) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n ensureCallbackArrays(\n // @ts-expect-error nodeType must present in visitor after previous validations\n visitor[nodeType],\n );\n }\n\n return visitor;\n}\n\nexport function verify(visitor: Visitor) {\n if (visitor._verified) return;\n\n if (typeof visitor === \"function\") {\n throw new Error(\n \"You passed `traverse()` a function when it expected a visitor object, \" +\n \"are you sure you didn't mean `{ enter: Function }`?\",\n );\n }\n\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (nodeType === \"enter\" || nodeType === \"exit\") {\n validateVisitorMethods(nodeType, visitor[nodeType]);\n }\n\n if (shouldIgnoreKey(nodeType)) continue;\n\n if (TYPES.indexOf(nodeType) < 0) {\n throw new Error(\n `You gave us a visitor for the node type ${nodeType} but it's not a valid type`,\n );\n }\n\n const visitors = visitor[nodeType];\n if (typeof visitors === \"object\") {\n for (const visitorKey of Object.keys(visitors)) {\n if (visitorKey === \"enter\" || visitorKey === \"exit\") {\n // verify that it just contains functions\n validateVisitorMethods(\n `${nodeType}.${visitorKey}`,\n visitors[visitorKey],\n );\n } else {\n throw new Error(\n \"You passed `traverse()` a visitor object with the property \" +\n `${nodeType} that has the invalid property ${visitorKey}`,\n );\n }\n }\n }\n }\n\n visitor._verified = true;\n}\n\nfunction validateVisitorMethods(\n path: string,\n val: any,\n): asserts val is Function | Function[] {\n const fns = [].concat(val);\n for (const fn of fns) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\n `Non-function found defined in ${path} with type ${typeof fn}`,\n );\n }\n }\n}\n\nexport function merge<State>(visitors: Visitor<State>[]): Visitor<State>;\nexport function merge(\n visitors: Visitor<unknown>[],\n states?: any[],\n wrapper?: Function | null,\n): Visitor<unknown>;\nexport function merge(\n visitors: any[],\n states: any[] = [],\n wrapper?: Function | null,\n) {\n const rootVisitor: Visitor = {};\n\n for (let i = 0; i < visitors.length; i++) {\n const visitor = visitors[i];\n const state = states[i];\n\n explode(visitor);\n\n for (const type of Object.keys(visitor) as (keyof Visitor)[]) {\n let visitorType = visitor[type];\n\n // if we have state or wrapper then overload the callbacks to take it\n if (state || wrapper) {\n visitorType = wrapWithStateOrWrapper(visitorType, state, wrapper);\n }\n\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n const nodeVisitor = (rootVisitor[type] ||= {});\n mergePair(nodeVisitor, visitorType);\n }\n }\n\n return rootVisitor;\n}\n\nfunction wrapWithStateOrWrapper<State>(\n oldVisitor: Visitor<State>,\n state: State,\n wrapper?: Function | null,\n) {\n const newVisitor: Visitor = {};\n\n for (const key of Object.keys(oldVisitor) as (keyof Visitor<State>)[]) {\n let fns = oldVisitor[key];\n\n // not an enter/exit array of callbacks\n if (!Array.isArray(fns)) continue;\n\n // @ts-expect-error manipulating visitors\n fns = fns.map(function (fn) {\n let newFn = fn;\n\n if (state) {\n newFn = function (path: NodePath) {\n return fn.call(state, path, state);\n };\n }\n\n if (wrapper) {\n // @ts-expect-error Fixme: document state.key\n newFn = wrapper(state.key, key, newFn);\n }\n\n // Override toString in case this function is printed, we want to print the wrapped function, same as we do in `wrapCheck`\n if (newFn !== fn) {\n newFn.toString = () => fn.toString();\n }\n\n return newFn;\n });\n\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n newVisitor[key] = fns;\n }\n\n return newVisitor;\n}\n\nfunction ensureEntranceObjects(obj: Visitor) {\n for (const key of Object.keys(obj) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(key)) continue;\n\n const fns = obj[key];\n if (typeof fns === \"function\") {\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n obj[key] = { enter: fns };\n }\n }\n}\n\nfunction ensureCallbackArrays(obj: Visitor) {\n // @ts-expect-error normalizing enter property\n if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];\n // @ts-expect-error normalizing exit property\n if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];\n}\n\nfunction wrapCheck(nodeType: VIRTUAL_TYPES, fn: Function) {\n const newFn = function (this: unknown, path: NodePath) {\n if (path[`is${nodeType}`]()) {\n return fn.apply(this, arguments);\n }\n };\n newFn.toString = () => fn.toString();\n return newFn;\n}\n\nfunction shouldIgnoreKey(\n key: string,\n): key is\n | \"enter\"\n | \"exit\"\n | \"shouldSkip\"\n | \"denylist\"\n | \"noScope\"\n | \"skipKeys\"\n | \"blacklist\" {\n // internal/hidden key\n if (key[0] === \"_\") return true;\n\n // ignore function keys\n if (key === \"enter\" || key === \"exit\" || key === \"shouldSkip\") return true;\n\n // ignore other options\n if (\n key === \"denylist\" ||\n key === \"noScope\" ||\n key === \"skipKeys\" ||\n // TODO: Remove in Babel 8\n key === \"blacklist\"\n ) {\n return true;\n }\n\n return false;\n}\n\nfunction mergePair(dest: any, src: any) {\n for (const key of Object.keys(src)) {\n dest[key] = [].concat(dest[key] || [], src[key]);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAA0E;EAAjEA,eAAe;EAAEC,kBAAkB;EAAEC;AAAK;AAInD,SAASC,aAAa,CAACC,IAAY,EAAyB;EAC1D,OAAOA,IAAI,IAAIC,YAAY;AAC7B;;AAkBO,SAASC,OAAO,CAACC,OAAgB,EAAE;EACxC,IAAIA,OAAO,CAACC,SAAS,EAAE,OAAOD,OAAO;EACrCA,OAAO,CAACC,SAAS,GAAG,IAAI;;EAGxB,KAAK,MAAMC,QAAQ,IAAIC,MAAM,CAACC,IAAI,CAACJ,OAAO,CAAC,EAAuB;IAChE,IAAIK,eAAe,CAACH,QAAQ,CAAC,EAAE;IAE/B,MAAMI,KAAoB,GAAGJ,QAAQ,CAACK,KAAK,CAAC,GAAG,CAAC;IAChD,IAAID,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IAExB,MAAMC,GAAG,GAAGT,OAAO,CAACE,QAAQ,CAAC;IAC7B,OAAOF,OAAO,CAACE,QAAQ,CAAC;IAExB,KAAK,MAAMQ,IAAI,IAAIJ,KAAK,EAAE;MAExBN,OAAO,CAACU,IAAI,CAAC,GAAGD,GAAG;IACrB;EACF;;EAGAE,MAAM,CAACX,OAAO,CAAC;;EAKf,OAAOA,OAAO,CAACY,UAAU;;EAGzBC,qBAAqB,CAACb,OAAO,CAAC;;EAG9Bc,oBAAoB,CAACd,OA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GAAG,KAAK,MAAM,IAAIA,GAAG,KAAK,YAAY,EAAE,OAAO,IAAI;;EAG1E,IACEA,GAAG,KAAK,UAAU,IAClBA,GAAG,KAAK,SAAS,IACjBA,GAAG,KAAK,UAAU;EAElBA,GAAG,KAAK,WAAW,EACnB;IACA,OAAO,IAAI;EACb;EAEA,OAAO,KAAK;AACd;AAEA,SAAS7B,SAAS,CAACyC,IAAS,EAAEC,GAAQ,EAAE;EACtC,KAAK,MAAMb,GAAG,IAAI3C,MAAM,CAACC,IAAI,CAACuD,GAAG,CAAC,EAAE;IAClCD,IAAI,CAACZ,GAAG,CAAC,GAAG,EAAE,CAACd,MAAM,CAAC0B,IAAI,CAACZ,GAAG,CAAC,IAAI,EAAE,EAAEa,GAAG,CAACb,GAAG,CAAC,CAAC;EAClD;AACF"}
1
+ {"version":3,"names":["DEPRECATED_KEYS","FLIPPED_ALIAS_KEYS","TYPES","isVirtualType","type","virtualTypes","explode","visitor","_exploded","nodeType","Object","keys","shouldIgnoreKey","parts","split","length","fns","part","verify","__esModule","ensureEntranceObjects","ensureCallbackArrays","wrapCheck","types","mergePair","aliases","deprecatedKey","console","trace","alias","existing","_verified","Error","validateVisitorMethods","indexOf","visitors","visitorKey","path","val","concat","fn","TypeError","merge","states","wrapper","rootVisitor","i","state","visitorType","wrapWithStateOrWrapper","nodeVisitor","oldVisitor","newVisitor","key","Array","isArray","map","newFn","call","toString","obj","enter","exit","apply","arguments","dest","src"],"sources":["../src/visitors.ts"],"sourcesContent":["import * as virtualTypes from \"./path/lib/virtual-types\";\nimport { DEPRECATED_KEYS, FLIPPED_ALIAS_KEYS, TYPES } from \"@babel/types\";\nimport type { NodePath, Visitor } from \"./index\";\n\ntype VIRTUAL_TYPES = keyof typeof virtualTypes;\nfunction isVirtualType(type: string): type is VIRTUAL_TYPES {\n return type in virtualTypes;\n}\n\n/**\n * explode() will take a visitor object with all of the various shorthands\n * that we support, and validates & normalizes it into a common format, ready\n * to be used in traversal\n *\n * The various shorthands are:\n * * `Identifier() { ... }` -> `Identifier: { enter() { ... } }`\n * * `\"Identifier|NumericLiteral\": { ... }` -> `Identifier: { ... }, NumericLiteral: { ... }`\n * * Aliases in `@babel/types`: e.g. `Property: { ... }` -> `ObjectProperty: { ... }, ClassProperty: { ... }`\n *\n * Other normalizations are:\n * * Visitors of virtual types are wrapped, so that they are only visited when\n * their dynamic check passes\n * * `enter` and `exit` functions are wrapped in arrays, to ease merging of\n * visitors\n */\nexport function explode(visitor: Visitor) {\n if (visitor._exploded) return visitor;\n visitor._exploded = true;\n\n // normalise pipes\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n const parts: Array<string> = nodeType.split(\"|\");\n if (parts.length === 1) continue;\n\n const fns = visitor[nodeType];\n delete visitor[nodeType];\n\n for (const part of parts) {\n // @ts-expect-error part will be verified by `verify` later\n visitor[part] = fns;\n }\n }\n\n // verify data structure\n verify(visitor);\n\n // make sure there's no __esModule type since this is because we're using loose mode\n // and it sets __esModule to be enumerable on all modules :(\n // @ts-expect-error ESModule interop\n delete visitor.__esModule;\n\n // ensure visitors are objects\n ensureEntranceObjects(visitor);\n\n // ensure enter/exit callbacks are arrays\n ensureCallbackArrays(visitor);\n\n // add type wrappers\n for (const nodeType of Object.keys(visitor)) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n if (!isVirtualType(nodeType)) continue;\n\n // wrap all the functions\n const fns = visitor[nodeType];\n for (const type of Object.keys(fns)) {\n // @ts-expect-error manipulating visitors\n fns[type] = wrapCheck(nodeType, fns[type]);\n }\n\n // clear it from the visitor\n delete visitor[nodeType];\n\n const types = virtualTypes[nodeType];\n if (types !== null) {\n for (const type of types) {\n // merge the visitor if necessary or just put it back in\n if (visitor[type]) {\n mergePair(visitor[type], fns);\n } else {\n // @ts-expect-error Expression produces too complex union\n visitor[type] = fns;\n }\n }\n } else {\n mergePair(visitor, fns);\n }\n }\n\n // add aliases\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n const fns = visitor[nodeType];\n\n let aliases = FLIPPED_ALIAS_KEYS[nodeType];\n\n const deprecatedKey = DEPRECATED_KEYS[nodeType];\n if (deprecatedKey) {\n console.trace(\n `Visitor defined for ${nodeType} but it has been renamed to ${deprecatedKey}`,\n );\n aliases = [deprecatedKey];\n }\n\n if (!aliases) continue;\n\n // clear it from the visitor\n delete visitor[nodeType];\n\n for (const alias of aliases) {\n const existing = visitor[alias];\n if (existing) {\n mergePair(existing, fns);\n } else {\n // @ts-expect-error Expression produces a union type that is too complex to represent.\n visitor[alias] = { ...fns };\n }\n }\n }\n\n for (const nodeType of Object.keys(visitor)) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n ensureCallbackArrays(\n // @ts-expect-error nodeType must present in visitor after previous validations\n visitor[nodeType],\n );\n }\n\n return visitor;\n}\n\nexport function verify(visitor: Visitor) {\n if (visitor._verified) return;\n\n if (typeof visitor === \"function\") {\n throw new Error(\n \"You passed `traverse()` a function when it expected a visitor object, \" +\n \"are you sure you didn't mean `{ enter: Function }`?\",\n );\n }\n\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (nodeType === \"enter\" || nodeType === \"exit\") {\n validateVisitorMethods(nodeType, visitor[nodeType]);\n }\n\n if (shouldIgnoreKey(nodeType)) continue;\n\n if (TYPES.indexOf(nodeType) < 0) {\n throw new Error(\n `You gave us a visitor for the node type ${nodeType} but it's not a valid type`,\n );\n }\n\n const visitors = visitor[nodeType];\n if (typeof visitors === \"object\") {\n for (const visitorKey of Object.keys(visitors)) {\n if (visitorKey === \"enter\" || visitorKey === \"exit\") {\n // verify that it just contains functions\n validateVisitorMethods(\n `${nodeType}.${visitorKey}`,\n visitors[visitorKey],\n );\n } else {\n throw new Error(\n \"You passed `traverse()` a visitor object with the property \" +\n `${nodeType} that has the invalid property ${visitorKey}`,\n );\n }\n }\n }\n }\n\n visitor._verified = true;\n}\n\nfunction validateVisitorMethods(\n path: string,\n val: any,\n): asserts val is Function | Function[] {\n const fns = [].concat(val);\n for (const fn of fns) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\n `Non-function found defined in ${path} with type ${typeof fn}`,\n );\n }\n }\n}\n\nexport function merge<State>(visitors: Visitor<State>[]): Visitor<State>;\nexport function merge(\n visitors: Visitor<unknown>[],\n states?: any[],\n wrapper?: Function | null,\n): Visitor<unknown>;\nexport function merge(\n visitors: any[],\n states: any[] = [],\n wrapper?: Function | null,\n) {\n const rootVisitor: Visitor = {};\n\n for (let i = 0; i < visitors.length; i++) {\n const visitor = visitors[i];\n const state = states[i];\n\n explode(visitor);\n\n for (const type of Object.keys(visitor) as (keyof Visitor)[]) {\n let visitorType = visitor[type];\n\n // if we have state or wrapper then overload the callbacks to take it\n if (state || wrapper) {\n visitorType = wrapWithStateOrWrapper(visitorType, state, wrapper);\n }\n\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n const nodeVisitor = (rootVisitor[type] ||= {});\n mergePair(nodeVisitor, visitorType);\n }\n }\n\n return rootVisitor;\n}\n\nfunction wrapWithStateOrWrapper<State>(\n oldVisitor: Visitor<State>,\n state: State,\n wrapper?: Function | null,\n) {\n const newVisitor: Visitor = {};\n\n for (const key of Object.keys(oldVisitor) as (keyof Visitor<State>)[]) {\n let fns = oldVisitor[key];\n\n // not an enter/exit array of callbacks\n if (!Array.isArray(fns)) continue;\n\n // @ts-expect-error manipulating visitors\n fns = fns.map(function (fn) {\n let newFn = fn;\n\n if (state) {\n newFn = function (path: NodePath) {\n return fn.call(state, path, state);\n };\n }\n\n if (wrapper) {\n // @ts-expect-error Fixme: document state.key\n newFn = wrapper(state.key, key, newFn);\n }\n\n // Override toString in case this function is printed, we want to print the wrapped function, same as we do in `wrapCheck`\n if (newFn !== fn) {\n newFn.toString = () => fn.toString();\n }\n\n return newFn;\n });\n\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n newVisitor[key] = fns;\n }\n\n return newVisitor;\n}\n\nfunction ensureEntranceObjects(obj: Visitor) {\n for (const key of Object.keys(obj) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(key)) continue;\n\n const fns = obj[key];\n if (typeof fns === \"function\") {\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n obj[key] = { enter: fns };\n }\n }\n}\n\nfunction ensureCallbackArrays(obj: Visitor) {\n // @ts-expect-error normalizing enter property\n if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];\n // @ts-expect-error normalizing exit property\n if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];\n}\n\nfunction wrapCheck(nodeType: VIRTUAL_TYPES, fn: Function) {\n const newFn = function (this: unknown, path: NodePath) {\n if (path[`is${nodeType}`]()) {\n return fn.apply(this, arguments);\n }\n };\n newFn.toString = () => fn.toString();\n return newFn;\n}\n\nfunction shouldIgnoreKey(\n key: string,\n): key is\n | \"enter\"\n | \"exit\"\n | \"shouldSkip\"\n | \"denylist\"\n | \"noScope\"\n | \"skipKeys\"\n | \"blacklist\" {\n // internal/hidden key\n if (key[0] === \"_\") return true;\n\n // ignore function keys\n if (key === \"enter\" || key === \"exit\" || key === \"shouldSkip\") return true;\n\n // ignore other options\n if (\n key === \"denylist\" ||\n key === \"noScope\" ||\n key === \"skipKeys\" ||\n // TODO: Remove in Babel 8\n key === \"blacklist\"\n ) {\n return true;\n }\n\n return false;\n}\n\nfunction mergePair(dest: any, src: any) {\n for (const key of Object.keys(src)) {\n dest[key] = [].concat(dest[key] || [], src[key]);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAA0E;EAAjEA,eAAe;EAAEC,kBAAkB;EAAEC;AAAK;AAInD,SAASC,aAAa,CAACC,IAAY,EAAyB;EAC1D,OAAOA,IAAI,IAAIC,YAAY;AAC7B;AAkBO,SAASC,OAAO,CAACC,OAAgB,EAAE;EACxC,IAAIA,OAAO,CAACC,SAAS,EAAE,OAAOD,OAAO;EACrCA,OAAO,CAACC,SAAS,GAAG,IAAI;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AG,CAACE,IAAI,GAAG,CAACF,GAAG,CAACE,IAAI,CAAC;AACjE;AAEA,SAASxC,SAAS,CAACb,QAAuB,EAAE+B,EAAY,EAAE;EACxD,MAAMiB,KAAK,GAAG,UAAyBpB,IAAc,EAAE;IACrD,IAAIA,IAAI,CAAE,KAAI5B,QAAS,EAAC,CAAC,EAAE,EAAE;MAC3B,OAAO+B,EAAE,CAACuB,KAAK,CAAC,IAAI,EAAEC,SAAS,CAAC;IAClC;EACF,CAAC;EACDP,KAAK,CAACE,QAAQ,GAAG,MAAMnB,EAAE,CAACmB,QAAQ,EAAE;EACpC,OAAOF,KAAK;AACd;AAEA,SAAS7C,eAAe,CACtByC,GAAW,EAQG;EAEd,IAAIA,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,OAAO,IAAI;EAG/B,IAAIA,GAAG,KAAK,OAAO,IAAIA,GAAG,KAAK,MAAM,IAAIA,GAAG,KAAK,YAAY,EAAE,OAAO,IAAI;EAG1E,IACEA,GAAG,KAAK,UAAU,IAClBA,GAAG,KAAK,SAAS,IACjBA,GAAG,KAAK,UAAU,IAElBA,GAAG,KAAK,WAAW,EACnB;IACA,OAAO,IAAI;EACb;EAEA,OAAO,KAAK;AACd;AAEA,SAAS7B,SAAS,CAACyC,IAAS,EAAEC,GAAQ,EAAE;EACtC,KAAK,MAAMb,GAAG,IAAI3C,MAAM,CAACC,IAAI,CAACuD,GAAG,CAAC,EAAE;IAClCD,IAAI,CAACZ,GAAG,CAAC,GAAG,EAAE,CAACd,MAAM,CAAC0B,IAAI,CAACZ,GAAG,CAAC,IAAI,EAAE,EAAEa,GAAG,CAACb,GAAG,CAAC,CAAC;EAClD;AACF"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/traverse",
3
- "version": "7.20.8",
3
+ "version": "7.20.13",
4
4
  "description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
5
5
  "author": "The Babel Team (https://babel.dev/team)",
6
6
  "homepage": "https://babel.dev/docs/en/next/babel-traverse",
@@ -22,7 +22,7 @@
22
22
  "@babel/helper-function-name": "^7.19.0",
23
23
  "@babel/helper-hoist-variables": "^7.18.6",
24
24
  "@babel/helper-split-export-declaration": "^7.18.6",
25
- "@babel/parser": "^7.20.7",
25
+ "@babel/parser": "^7.20.13",
26
26
  "@babel/types": "^7.20.7",
27
27
  "debug": "^4.1.0",
28
28
  "globals": "^11.1.0"
@@ -2,6 +2,8 @@
2
2
 
3
3
  Converts CSS text to a React Native stylesheet object.
4
4
 
5
+ [Try it here](https://csstox.surge.sh)
6
+
5
7
  ```css
6
8
  font-size: 18px;
7
9
  line-height: 24px;
@@ -32,7 +34,7 @@ transform: translate(10px, 5px) scale(5);
32
34
  fontVariant: ['small-caps'],
33
35
  // Fixes backwards transform order
34
36
  transform: [
35
- { translateY: 10 },
37
+ { translateY: 5 },
36
38
  { translateX: 10 },
37
39
  { scale: 5 },
38
40
  ]
@@ -84,7 +86,7 @@ transform([
84
86
  ]); // => { fontFamily: 'Helvetica', ... }
85
87
  ```
86
88
 
87
- We don't provide a way to get these style tuples in this library, so you'll need to do that yourself. I expect most people will use postCSS or another CSS parser. You should try avoid getting these with `string.split`, as that has a lot of edge cases (colons and semi-colons apearing in comments etc.)
89
+ We don't provide a way to get these style tuples in this library, so you'll need to do that yourself. I expect most people will use postCSS or another CSS parser. You should try avoid getting these with `string.split`, as that has a lot of edge cases (colons and semi-colons appearing in comments etc.)
88
90
 
89
91
  For implementors, there is also a few extra APIs available.
90
92
 
@@ -435,6 +435,19 @@ var font = function font(tokenStream) {
435
435
  return out;
436
436
  };
437
437
 
438
+ var fontVariant = function fontVariant(tokenStream) {
439
+ var values = [tokenStream.expect(IDENT)];
440
+
441
+ while (tokenStream.hasTokens()) {
442
+ tokenStream.expect(SPACE);
443
+ values.push(tokenStream.expect(IDENT));
444
+ }
445
+
446
+ return {
447
+ fontVariant: values
448
+ };
449
+ };
450
+
438
451
  var ALIGN_CONTENT = regExpToken(/(flex-(?:start|end)|center|stretch|space-(?:between|around))/);
439
452
  var JUSTIFY_CONTENT = regExpToken(/(flex-(?:start|end)|center|space-(?:between|around|evenly))/);
440
453
 
@@ -640,12 +653,6 @@ var padding = directionFactory({
640
653
  prefix: 'padding'
641
654
  });
642
655
 
643
- var fontVariant = function fontVariant(tokenStream) {
644
- return {
645
- fontVariant: [tokenStream.expect(IDENT)]
646
- };
647
- };
648
-
649
656
  var fontWeight = function fontWeight(tokenStream) {
650
657
  return {
651
658
  fontWeight: tokenStream.expect(WORD) // Also match numbers as strings
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "css-to-react-native",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Convert CSS text to a React Native stylesheet object",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "scripts": {
7
8
  "build": "rollup ./src/index.js -o index.js --f cjs && babel index.js -o index.js",
8
9
  "test": "jest",
@@ -5,3 +5,11 @@ it('transforms font variant as an array', () => {
5
5
  fontVariant: ['tabular-nums'],
6
6
  })
7
7
  })
8
+
9
+ it('transforms multiple font variant as an array', () => {
10
+ expect(
11
+ transformCss([['font-variant', 'tabular-nums oldstyle-nums']])
12
+ ).toEqual({
13
+ fontVariant: ['tabular-nums', 'oldstyle-nums'],
14
+ })
15
+ })
@@ -0,0 +1,14 @@
1
+ import { SPACE, IDENT } from '../tokenTypes'
2
+
3
+ export default tokenStream => {
4
+ const values = [tokenStream.expect(IDENT)]
5
+
6
+ while (tokenStream.hasTokens()) {
7
+ tokenStream.expect(SPACE)
8
+ values.push(tokenStream.expect(IDENT))
9
+ }
10
+
11
+ return {
12
+ fontVariant: values,
13
+ }
14
+ }
@@ -1,11 +1,10 @@
1
1
  import {
2
- IDENT,
3
- WORD,
2
+ AUTO,
4
3
  COLOR,
5
4
  LENGTH,
6
- UNSUPPORTED_LENGTH_UNIT,
7
5
  PERCENT,
8
- AUTO,
6
+ UNSUPPORTED_LENGTH_UNIT,
7
+ WORD,
9
8
  } from '../tokenTypes'
10
9
  import border from './border'
11
10
  import boxShadow from './boxShadow'
@@ -13,6 +12,7 @@ import flex from './flex'
13
12
  import flexFlow from './flexFlow'
14
13
  import font from './font'
15
14
  import fontFamily from './fontFamily'
15
+ import fontVariant from './fontVariant'
16
16
  import placeContent from './placeContent'
17
17
  import textDecoration from './textDecoration'
18
18
  import textDecorationLine from './textDecorationLine'
@@ -39,9 +39,7 @@ const margin = directionFactory({
39
39
  prefix: 'margin',
40
40
  })
41
41
  const padding = directionFactory({ prefix: 'padding' })
42
- const fontVariant = tokenStream => ({
43
- fontVariant: [tokenStream.expect(IDENT)],
44
- })
42
+
45
43
  const fontWeight = tokenStream => ({
46
44
  fontWeight: tokenStream.expect(WORD), // Also match numbers as strings
47
45
  })
@@ -91,15 +91,16 @@ export const RawEditor = (props: RichTextType) => {
91
91
  React.useEffect(() => {
92
92
  // @ts-ignore no access to the rich-text type from this package
93
93
  const parsedValue = parseMDX(value, field, (value) => value)
94
- if (parsedValue.children[0]) {
95
- if (parsedValue.children[0].type === 'invalid_markdown') {
96
- const invalidMarkdown = parsedValue.children[0]
97
- setError(invalidMarkdown)
98
- return
99
- }
94
+ if (
95
+ parsedValue.children[0] &&
96
+ parsedValue.children[0].type === 'invalid_markdown'
97
+ ) {
98
+ const invalidMarkdown = parsedValue.children[0]
99
+ setError(invalidMarkdown)
100
+ } else {
101
+ setError(null)
100
102
  }
101
103
  props.input.onChange(parsedValue)
102
- setError(null)
103
104
  }, [JSON.stringify(debouncedValue)])
104
105
 
105
106
  React.useEffect(() => {
@@ -197,15 +198,16 @@ export const RawEditor = (props: RichTextType) => {
197
198
  fontSize: 14,
198
199
  lineHeight: 2,
199
200
  formatOnPaste: true,
200
- lineNumbers: 'off',
201
+ lineNumbers: 'on',
202
+ lineNumbersMinChars: 2,
201
203
  formatOnType: true,
202
204
  fixedOverflowWidgets: true,
203
205
  // Takes too much horizontal space for iframe
204
206
  folding: false,
205
207
  renderLineHighlight: 'none',
206
208
  scrollbar: {
207
- verticalScrollbarSize: 1,
208
- horizontalScrollbarSize: 1,
209
+ verticalScrollbarSize: 4,
210
+ horizontalScrollbarSize: 4,
209
211
  // https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
210
212
  alwaysConsumeMouseWheel: false,
211
213
  },
@@ -30454,29 +30454,6 @@ function mdxJsxElement(node, field, imageCallback) {
30454
30454
  children: [{ type: "text", text: "" }]
30455
30455
  };
30456
30456
  }
30457
- if (template.match) {
30458
- const firstChild = node?.children[0];
30459
- if (firstChild?.type === "inlineCode") {
30460
- const value = firstChild.value;
30461
- if (node.type === "mdxJsxFlowElement") {
30462
- return {
30463
- type: node.type,
30464
- name: node.name,
30465
- children: [{ type: "text", text: "" }],
30466
- props: { text: value }
30467
- };
30468
- } else {
30469
- return {
30470
- type: node.type,
30471
- name: node.name,
30472
- children: [{ type: "text", text: "" }],
30473
- props: { text: value }
30474
- };
30475
- }
30476
- } else {
30477
- throw new Error(`Unable to parse value for template match pattern - start: ${template.match.start}, end: ${template.match.end}`);
30478
- }
30479
- }
30480
30457
  const props = extractAttributes(node.attributes, template.fields, imageCallback);
30481
30458
  const childField = template.fields.find((field2) => field2.name === "children");
30482
30459
  if (childField) {
@@ -30806,6 +30783,17 @@ var RichTextParseError = class extends Error {
30806
30783
  }
30807
30784
  };
30808
30785
 
30786
+ // src/parse/parseShortcode.ts
30787
+ function parseShortcode(preprocessedString, template) {
30788
+ const match = template.match;
30789
+ const unkeyedAttributes = !!template.fields.find((t) => t.name === "_value");
30790
+ const hasChildren = !!template.fields.find((t) => t.name == "children");
30791
+ const replacement = `<${template.name} ${unkeyedAttributes ? '_value="$1"' : "$1"}>${hasChildren ? "$2" : "\n"}</${template.name}>`;
30792
+ const endRegex = `((?:.|\\n)*)${match.start}\\s/\\s*${match.name || template.name}[\\s]*${match.end}`;
30793
+ const regex = `${match.start}\\s*${match.name || template.name}[\\s]+${unkeyedAttributes ? `['"]?(.*?)['"]?` : "(.*?)"}[\\s]*${match.end}${hasChildren ? endRegex : ""}`;
30794
+ return replaceAll(preprocessedString, regex, replacement);
30795
+ }
30796
+
30809
30797
  // src/parse/index.ts
30810
30798
  var markdownToAst = (value, field) => {
30811
30799
  const templatesWithMatchers = field.templates?.filter((template) => template.match);
@@ -30816,8 +30804,7 @@ var markdownToAst = (value, field) => {
30816
30804
  }
30817
30805
  if (template.match) {
30818
30806
  if (preprocessedString) {
30819
- preprocessedString = replaceAll(preprocessedString, template.match.start, `<${template.name}>\``);
30820
- preprocessedString = replaceAll(preprocessedString, template.match.end, `\`</${template.name}>`);
30807
+ preprocessedString = parseShortcode(preprocessedString, template);
30821
30808
  }
30822
30809
  }
30823
30810
  });
@@ -30828,6 +30815,7 @@ var markdownToAst = (value, field) => {
30828
30815
  }
30829
30816
  return tree;
30830
30817
  } catch (e) {
30818
+ console.error("error parsing file: ", e);
30831
30819
  throw new RichTextParseError(e, e.position);
30832
30820
  }
30833
30821
  };
@@ -31048,12 +31036,20 @@ ${val}
31048
31036
  }
31049
31037
  });
31050
31038
  if (template.match) {
31051
- if (attributes[0] && typeof attributes[0].value === "string") {
31052
- return {
31053
- attributes: [],
31054
- children: [{ type: "inlineCode", value: attributes[0].value }]
31055
- };
31056
- }
31039
+ return {
31040
+ attributes,
31041
+ children: children && children.length ? children : [
31042
+ {
31043
+ type: "paragraph",
31044
+ children: [
31045
+ {
31046
+ type: "text",
31047
+ value: ""
31048
+ }
31049
+ ]
31050
+ }
31051
+ ]
31052
+ };
31057
31053
  }
31058
31054
  return { attributes, children };
31059
31055
  }
@@ -31267,6 +31263,19 @@ var cleanNode = (node, mark) => {
31267
31263
  return cleanedNode;
31268
31264
  };
31269
31265
 
31266
+ // src/stringify/stringifyShortcode.ts
31267
+ function stringifyShortcode(preprocessedString, template) {
31268
+ const match = template.match;
31269
+ const unkeyedAttributes = !!template.fields.find((t) => t.name == "_value");
31270
+ const regex = `<[\\s]*${template.name}[\\s]*${unkeyedAttributes ? "(?:_value=(.*?))?" : "(.+?)?"}[\\s]*>[\\s]*((?:.|
31271
+ )*?)[\\s]*</[\\s]*${template.name}[\\s]*>`;
31272
+ const closingRegex = `
31273
+ $2
31274
+ ${match.start} /${match.name || template.name} ${match.end}`;
31275
+ const replace = `${match.start} ${match.name || template.name} $1 ${match.end}${template.fields.find((t) => t.name == "children") ? closingRegex : ""}`;
31276
+ return replaceAll(preprocessedString, regex, replace);
31277
+ }
31278
+
31270
31279
  // src/stringify/index.ts
31271
31280
  var stringifyMDX = (value, field, imageCallback) => {
31272
31281
  if (!value) {
@@ -31291,10 +31300,7 @@ var stringifyMDX = (value, field, imageCallback) => {
31291
31300
  throw new Error("Global templates are not supported");
31292
31301
  }
31293
31302
  if (template.match) {
31294
- preprocessedString = replaceAll(preprocessedString, `<${template.name}>[
31295
- \r\\s]*\``, `${template.match.start} `);
31296
- preprocessedString = replaceAll(preprocessedString, `\`[
31297
- \r\\s]*</${template.name}>`, ` ${template.match.end}`);
31303
+ preprocessedString = stringifyShortcode(preprocessedString, template);
31298
31304
  }
31299
31305
  });
31300
31306
  return preprocessedString;
@@ -208,7 +208,7 @@ export const documentMachine =
208
208
  const onSubmit = async (payload: Record<string, unknown>) => {
209
209
  try {
210
210
  const mutationString = `#graphql
211
- mutation UpdateDocument($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
211
+ mutation UpdateDocument($collection: String!, $relativePath: String!, $params: DocumentUpdateMutation!) {
212
212
  updateDocument(collection: $collection, relativePath: $relativePath, params: $params) {
213
213
  __typename
214
214
  }
package/dist/index.js CHANGED
@@ -396,7 +396,7 @@ var viteBuild = async ({
396
396
  },
397
397
  resolve: {
398
398
  alias,
399
- dedupe: ["graphql"]
399
+ dedupe: process.env.MONOREPO_DEV ? ["graphql", "tinacms", "@tinacms/toolkit"] : ["graphql"]
400
400
  },
401
401
  build: {
402
402
  sourcemap: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/app",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "main": "dist/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -36,9 +36,10 @@
36
36
  "@types/fs-extra": "^9.0.1",
37
37
  "@types/react": "17.0.2",
38
38
  "@types/react-dom": "17.0.2",
39
- "@tinacms/scripts": "1.0.0",
40
- "tinacms": "1.1.2",
41
- "@tinacms/mdx": "1.0.4",
39
+ "@tinacms/scripts": "1.0.1",
40
+ "tinacms": "1.1.4",
41
+ "@tinacms/toolkit": "1.3.0",
42
+ "@tinacms/mdx": "1.1.1",
42
43
  "jest": "^27.0.6"
43
44
  },
44
45
  "dependencies": {