Skip to content

Commit

Permalink
feat: basic support for react-pdf morpher
Browse files Browse the repository at this point in the history
  • Loading branch information
Darío Javier Cravero committed Sep 7, 2019
1 parent ec36a36 commit 249d578
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ensure-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions morph/react-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default ({
getSystemImport,
local,
localSupported,
reactNativeLibraryImport = 'react-native',
track,
view,
viewsById,
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions morph/react-pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import reactNativeMorph from './react-native.js'

export default options =>
reactNativeMorph({
...options,
reactNativeLibraryImport: '@react-pdf/renderer',
})
6 changes: 5 additions & 1 deletion morph/react/get-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions morphers.js
Original file line number Diff line number Diff line change
@@ -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,
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@viewstools/morph",
"version": "19.8.2",
"version": "19.9.0",
"description": "Views language morpher",
"main": "index.js",
"type": "module",
Expand Down

0 comments on commit 249d578

Please sign in to comment.