Skip to content
Permalink
Browse files

feat: basic support for react-pdf morpher

  • Loading branch information...
dariocravero committed Sep 7, 2019
1 parent ec36a36 commit 249d578a191132c4d54bf49a5e9fccf7fac875b2
Showing with 20 additions and 3 deletions.
  1. +1 −0 cli.js
  2. +1 −1 ensure-flow.js
  3. +1 −0 fonts.js
  4. +2 −0 morph/react-native.js
  5. +7 −0 morph/react-pdf.js
  6. +5 −1 morph/react/get-dependencies.js
  7. +2 −0 morphers.js
  8. +1 −1 package.json
1 cli.js
@@ -51,6 +51,7 @@ let wait = time => new Promise(resolve => setTimeout(resolve, time))
--as target platform
react-dom (default)
react-native
react-pdf
--clean clean the autogenerated .view.js files
--local default local language, defaults to English (en)
--tools use with Views Tools, defauls to true when
@@ -8,7 +8,7 @@ function ensureFirstStoryIsOn(flow, key, stories) {
if (!stories.has(key)) return

let story = flow.get(key)
if (story.stories.size > 0) {
if (story && story.stories.size > 0) {
let index = 0
for (let id of story.stories) {
if (index === 0 || !story.isSeparate) {
@@ -9,6 +9,7 @@ import relativise from './relativise.js'
let morphFont = {
'react-dom': morphFontAsReactDom,
'react-native': morphFontAsReactNative,
'react-pdf': morphFontAsReactNative,
}

export async function ensureFontsDirectory(src) {
@@ -23,6 +23,7 @@ export default ({
getSystemImport,
local,
localSupported,
reactNativeLibraryImport = 'react-native',
track,
view,
viewsById,
@@ -75,6 +76,7 @@ export default ({
testIdKey: 'testID',
testIds: {},
track,
reactNativeLibraryImport,
usedBlockNames: { [finalName]: 1, AutoSizer: 1, Column: 1, Table: 1 },
uses: [],
use(block, isLazy = false) {
@@ -0,0 +1,7 @@
import reactNativeMorph from './react-native.js'

export default options =>
reactNativeMorph({
...options,
reactNativeLibraryImport: '@react-pdf/renderer',
})
@@ -126,7 +126,11 @@ export default (state, getImport) => {
}

if (usesNative.length > 0) {
dependencies.push(`import { ${usesNative.join(', ')} } from 'react-native'`)
dependencies.push(
`import { ${usesNative.join(', ')} } from '${
state.reactNativeLibraryImport
}'`
)
}

if (state.track) {
@@ -1,7 +1,9 @@
import reactDom from './morph/react-dom.js'
import reactNative from './morph/react-native.js'
import reactPdf from './morph/react-pdf.js'

export default {
'react-dom': reactDom,
'react-native': reactNative,
'react-pdf': reactPdf,
}
@@ -1,6 +1,6 @@
{
"name": "@viewstools/morph",
"version": "19.8.2",
"version": "19.9.0",
"description": "Views language morpher",
"main": "index.js",
"type": "module",

0 comments on commit 249d578

Please sign in to comment.
You can’t perform that action at this time.