@tachybase/module-pdf 0.23.8

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 (135) hide show
  1. package/.turbo/turbo-build.log +15 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/PdfInstruction.d.ts +107 -0
  6. package/dist/client/index.d.ts +10 -0
  7. package/dist/client/index.js +239 -0
  8. package/dist/externalVersion.js +11 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +39 -0
  11. package/dist/node_modules/@babel/core/LICENSE +22 -0
  12. package/dist/node_modules/@babel/core/cjs-proxy.cjs +68 -0
  13. package/dist/node_modules/@babel/core/lib/config/cache-contexts.js +3 -0
  14. package/dist/node_modules/@babel/core/lib/config/caching.js +261 -0
  15. package/dist/node_modules/@babel/core/lib/config/config-chain.js +469 -0
  16. package/dist/node_modules/@babel/core/lib/config/config-descriptors.js +190 -0
  17. package/dist/node_modules/@babel/core/lib/config/files/configuration.js +287 -0
  18. package/dist/node_modules/@babel/core/lib/config/files/import.cjs +6 -0
  19. package/dist/node_modules/@babel/core/lib/config/files/index-browser.js +58 -0
  20. package/dist/node_modules/@babel/core/lib/config/files/index.js +78 -0
  21. package/dist/node_modules/@babel/core/lib/config/files/module-types.js +195 -0
  22. package/dist/node_modules/@babel/core/lib/config/files/package.js +61 -0
  23. package/dist/node_modules/@babel/core/lib/config/files/plugins.js +229 -0
  24. package/dist/node_modules/@babel/core/lib/config/files/types.js +3 -0
  25. package/dist/node_modules/@babel/core/lib/config/files/utils.js +36 -0
  26. package/dist/node_modules/@babel/core/lib/config/full.js +312 -0
  27. package/dist/node_modules/@babel/core/lib/config/helpers/config-api.js +84 -0
  28. package/dist/node_modules/@babel/core/lib/config/helpers/deep-array.js +23 -0
  29. package/dist/node_modules/@babel/core/lib/config/helpers/environment.js +12 -0
  30. package/dist/node_modules/@babel/core/lib/config/index.js +93 -0
  31. package/dist/node_modules/@babel/core/lib/config/item.js +67 -0
  32. package/dist/node_modules/@babel/core/lib/config/partial.js +158 -0
  33. package/dist/node_modules/@babel/core/lib/config/pattern-to-regex.js +38 -0
  34. package/dist/node_modules/@babel/core/lib/config/plugin.js +33 -0
  35. package/dist/node_modules/@babel/core/lib/config/printer.js +113 -0
  36. package/dist/node_modules/@babel/core/lib/config/resolve-targets-browser.js +41 -0
  37. package/dist/node_modules/@babel/core/lib/config/resolve-targets.js +61 -0
  38. package/dist/node_modules/@babel/core/lib/config/util.js +31 -0
  39. package/dist/node_modules/@babel/core/lib/config/validation/option-assertions.js +277 -0
  40. package/dist/node_modules/@babel/core/lib/config/validation/options.js +189 -0
  41. package/dist/node_modules/@babel/core/lib/config/validation/plugins.js +67 -0
  42. package/dist/node_modules/@babel/core/lib/config/validation/removed.js +68 -0
  43. package/dist/node_modules/@babel/core/lib/errors/config-error.js +18 -0
  44. package/dist/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js +98 -0
  45. package/dist/node_modules/@babel/core/lib/gensync-utils/async.js +90 -0
  46. package/dist/node_modules/@babel/core/lib/gensync-utils/fs.js +31 -0
  47. package/dist/node_modules/@babel/core/lib/gensync-utils/functional.js +58 -0
  48. package/dist/node_modules/@babel/core/lib/index.js +227 -0
  49. package/dist/node_modules/@babel/core/lib/parse.js +47 -0
  50. package/dist/node_modules/@babel/core/lib/parser/index.js +79 -0
  51. package/dist/node_modules/@babel/core/lib/parser/util/missing-plugin-helper.js +339 -0
  52. package/dist/node_modules/@babel/core/lib/tools/build-external-helpers.js +144 -0
  53. package/dist/node_modules/@babel/core/lib/transform-ast.js +50 -0
  54. package/dist/node_modules/@babel/core/lib/transform-file-browser.js +23 -0
  55. package/dist/node_modules/@babel/core/lib/transform-file.js +40 -0
  56. package/dist/node_modules/@babel/core/lib/transform.js +49 -0
  57. package/dist/node_modules/@babel/core/lib/transformation/block-hoist-plugin.js +84 -0
  58. package/dist/node_modules/@babel/core/lib/transformation/file/babel-7-helpers.cjs +4 -0
  59. package/dist/node_modules/@babel/core/lib/transformation/file/file.js +214 -0
  60. package/dist/node_modules/@babel/core/lib/transformation/file/generate.js +84 -0
  61. package/dist/node_modules/@babel/core/lib/transformation/file/merge-map.js +37 -0
  62. package/dist/node_modules/@babel/core/lib/transformation/index.js +92 -0
  63. package/dist/node_modules/@babel/core/lib/transformation/normalize-file.js +129 -0
  64. package/dist/node_modules/@babel/core/lib/transformation/normalize-opts.js +59 -0
  65. package/dist/node_modules/@babel/core/lib/transformation/plugin-pass.js +50 -0
  66. package/dist/node_modules/@babel/core/lib/transformation/util/clone-deep.js +36 -0
  67. package/dist/node_modules/@babel/core/lib/vendor/import-meta-resolve.js +1043 -0
  68. package/dist/node_modules/@babel/core/node_modules/.bin/json5 +17 -0
  69. package/dist/node_modules/@babel/core/node_modules/.bin/parser +17 -0
  70. package/dist/node_modules/@babel/core/node_modules/.bin/semver +17 -0
  71. package/dist/node_modules/@babel/core/package.json +1 -0
  72. package/dist/node_modules/@babel/core/src/config/files/index-browser.ts +113 -0
  73. package/dist/node_modules/@babel/core/src/config/files/index.ts +29 -0
  74. package/dist/node_modules/@babel/core/src/config/resolve-targets-browser.ts +40 -0
  75. package/dist/node_modules/@babel/core/src/config/resolve-targets.ts +56 -0
  76. package/dist/node_modules/@babel/core/src/transform-file-browser.ts +31 -0
  77. package/dist/node_modules/@babel/core/src/transform-file.ts +55 -0
  78. package/dist/node_modules/@react-pdf/renderer/index.d.ts +590 -0
  79. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.cjs +4558 -0
  80. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.d.cts +590 -0
  81. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.d.ts +590 -0
  82. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.js +4505 -0
  83. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.cjs +10 -0
  84. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.d.cts +590 -0
  85. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.d.ts +590 -0
  86. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.js +10 -0
  87. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.cjs +40 -0
  88. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.d.cts +590 -0
  89. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.d.ts +590 -0
  90. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.js +4393 -0
  91. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.min.cjs +10 -0
  92. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.min.d.cts +590 -0
  93. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.min.d.ts +590 -0
  94. package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.min.js +10 -0
  95. package/dist/node_modules/@react-pdf/renderer/package.json +1 -0
  96. package/dist/node_modules/fs-extra/LICENSE +15 -0
  97. package/dist/node_modules/fs-extra/lib/copy/copy-sync.js +161 -0
  98. package/dist/node_modules/fs-extra/lib/copy/copy.js +177 -0
  99. package/dist/node_modules/fs-extra/lib/copy/index.js +7 -0
  100. package/dist/node_modules/fs-extra/lib/empty/index.js +39 -0
  101. package/dist/node_modules/fs-extra/lib/ensure/file.js +66 -0
  102. package/dist/node_modules/fs-extra/lib/ensure/index.js +23 -0
  103. package/dist/node_modules/fs-extra/lib/ensure/link.js +64 -0
  104. package/dist/node_modules/fs-extra/lib/ensure/symlink-paths.js +101 -0
  105. package/dist/node_modules/fs-extra/lib/ensure/symlink-type.js +34 -0
  106. package/dist/node_modules/fs-extra/lib/ensure/symlink.js +67 -0
  107. package/dist/node_modules/fs-extra/lib/fs/index.js +140 -0
  108. package/dist/node_modules/fs-extra/lib/index.js +1 -0
  109. package/dist/node_modules/fs-extra/lib/json/index.js +16 -0
  110. package/dist/node_modules/fs-extra/lib/json/jsonfile.js +11 -0
  111. package/dist/node_modules/fs-extra/lib/json/output-json-sync.js +12 -0
  112. package/dist/node_modules/fs-extra/lib/json/output-json.js +12 -0
  113. package/dist/node_modules/fs-extra/lib/mkdirs/index.js +14 -0
  114. package/dist/node_modules/fs-extra/lib/mkdirs/make-dir.js +27 -0
  115. package/dist/node_modules/fs-extra/lib/mkdirs/utils.js +21 -0
  116. package/dist/node_modules/fs-extra/lib/move/index.js +7 -0
  117. package/dist/node_modules/fs-extra/lib/move/move-sync.js +55 -0
  118. package/dist/node_modules/fs-extra/lib/move/move.js +59 -0
  119. package/dist/node_modules/fs-extra/lib/output-file/index.js +31 -0
  120. package/dist/node_modules/fs-extra/lib/path-exists/index.js +12 -0
  121. package/dist/node_modules/fs-extra/lib/remove/index.js +17 -0
  122. package/dist/node_modules/fs-extra/lib/util/stat.js +158 -0
  123. package/dist/node_modules/fs-extra/lib/util/utimes.js +36 -0
  124. package/dist/node_modules/fs-extra/package.json +1 -0
  125. package/dist/server/PdfInstruction.d.ts +10 -0
  126. package/dist/server/PdfInstruction.js +108 -0
  127. package/dist/server/index.d.ts +2 -0
  128. package/dist/server/index.js +53 -0
  129. package/dist/server/plugin.d.ts +11 -0
  130. package/dist/server/plugin.js +102 -0
  131. package/dist/server/services/font-manager.d.ts +6 -0
  132. package/dist/server/services/font-manager.js +199 -0
  133. package/package.json +32 -0
  134. package/server.d.ts +2 -0
  135. package/server.js +1 -0
@@ -0,0 +1,27 @@
1
+ 'use strict'
2
+ const fs = require('../fs')
3
+ const { checkPath } = require('./utils')
4
+
5
+ const getMode = options => {
6
+ const defaults = { mode: 0o777 }
7
+ if (typeof options === 'number') return options
8
+ return ({ ...defaults, ...options }).mode
9
+ }
10
+
11
+ module.exports.makeDir = async (dir, options) => {
12
+ checkPath(dir)
13
+
14
+ return fs.mkdir(dir, {
15
+ mode: getMode(options),
16
+ recursive: true
17
+ })
18
+ }
19
+
20
+ module.exports.makeDirSync = (dir, options) => {
21
+ checkPath(dir)
22
+
23
+ return fs.mkdirSync(dir, {
24
+ mode: getMode(options),
25
+ recursive: true
26
+ })
27
+ }
@@ -0,0 +1,21 @@
1
+ // Adapted from https://github.com/sindresorhus/make-dir
2
+ // Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+ // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6
+ 'use strict'
7
+ const path = require('path')
8
+
9
+ // https://github.com/nodejs/node/issues/8987
10
+ // https://github.com/libuv/libuv/pull/1088
11
+ module.exports.checkPath = function checkPath (pth) {
12
+ if (process.platform === 'win32') {
13
+ const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''))
14
+
15
+ if (pathHasInvalidWinCharacters) {
16
+ const error = new Error(`Path contains invalid characters: ${pth}`)
17
+ error.code = 'EINVAL'
18
+ throw error
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ const u = require('universalify').fromPromise
4
+ module.exports = {
5
+ move: u(require('./move')),
6
+ moveSync: require('./move-sync')
7
+ }
@@ -0,0 +1,55 @@
1
+ 'use strict'
2
+
3
+ const fs = require('graceful-fs')
4
+ const path = require('path')
5
+ const copySync = require('../copy').copySync
6
+ const removeSync = require('../remove').removeSync
7
+ const mkdirpSync = require('../mkdirs').mkdirpSync
8
+ const stat = require('../util/stat')
9
+
10
+ function moveSync (src, dest, opts) {
11
+ opts = opts || {}
12
+ const overwrite = opts.overwrite || opts.clobber || false
13
+
14
+ const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts)
15
+ stat.checkParentPathsSync(src, srcStat, dest, 'move')
16
+ if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest))
17
+ return doRename(src, dest, overwrite, isChangingCase)
18
+ }
19
+
20
+ function isParentRoot (dest) {
21
+ const parent = path.dirname(dest)
22
+ const parsedPath = path.parse(parent)
23
+ return parsedPath.root === parent
24
+ }
25
+
26
+ function doRename (src, dest, overwrite, isChangingCase) {
27
+ if (isChangingCase) return rename(src, dest, overwrite)
28
+ if (overwrite) {
29
+ removeSync(dest)
30
+ return rename(src, dest, overwrite)
31
+ }
32
+ if (fs.existsSync(dest)) throw new Error('dest already exists.')
33
+ return rename(src, dest, overwrite)
34
+ }
35
+
36
+ function rename (src, dest, overwrite) {
37
+ try {
38
+ fs.renameSync(src, dest)
39
+ } catch (err) {
40
+ if (err.code !== 'EXDEV') throw err
41
+ return moveAcrossDevice(src, dest, overwrite)
42
+ }
43
+ }
44
+
45
+ function moveAcrossDevice (src, dest, overwrite) {
46
+ const opts = {
47
+ overwrite,
48
+ errorOnExist: true,
49
+ preserveTimestamps: true
50
+ }
51
+ copySync(src, dest, opts)
52
+ return removeSync(src)
53
+ }
54
+
55
+ module.exports = moveSync
@@ -0,0 +1,59 @@
1
+ 'use strict'
2
+
3
+ const fs = require('../fs')
4
+ const path = require('path')
5
+ const { copy } = require('../copy')
6
+ const { remove } = require('../remove')
7
+ const { mkdirp } = require('../mkdirs')
8
+ const { pathExists } = require('../path-exists')
9
+ const stat = require('../util/stat')
10
+
11
+ async function move (src, dest, opts = {}) {
12
+ const overwrite = opts.overwrite || opts.clobber || false
13
+
14
+ const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, 'move', opts)
15
+
16
+ await stat.checkParentPaths(src, srcStat, dest, 'move')
17
+
18
+ // If the parent of dest is not root, make sure it exists before proceeding
19
+ const destParent = path.dirname(dest)
20
+ const parsedParentPath = path.parse(destParent)
21
+ if (parsedParentPath.root !== destParent) {
22
+ await mkdirp(destParent)
23
+ }
24
+
25
+ return doRename(src, dest, overwrite, isChangingCase)
26
+ }
27
+
28
+ async function doRename (src, dest, overwrite, isChangingCase) {
29
+ if (!isChangingCase) {
30
+ if (overwrite) {
31
+ await remove(dest)
32
+ } else if (await pathExists(dest)) {
33
+ throw new Error('dest already exists.')
34
+ }
35
+ }
36
+
37
+ try {
38
+ // Try w/ rename first, and try copy + remove if EXDEV
39
+ await fs.rename(src, dest)
40
+ } catch (err) {
41
+ if (err.code !== 'EXDEV') {
42
+ throw err
43
+ }
44
+ await moveAcrossDevice(src, dest, overwrite)
45
+ }
46
+ }
47
+
48
+ async function moveAcrossDevice (src, dest, overwrite) {
49
+ const opts = {
50
+ overwrite,
51
+ errorOnExist: true,
52
+ preserveTimestamps: true
53
+ }
54
+
55
+ await copy(src, dest, opts)
56
+ return remove(src)
57
+ }
58
+
59
+ module.exports = move
@@ -0,0 +1,31 @@
1
+ 'use strict'
2
+
3
+ const u = require('universalify').fromPromise
4
+ const fs = require('../fs')
5
+ const path = require('path')
6
+ const mkdir = require('../mkdirs')
7
+ const pathExists = require('../path-exists').pathExists
8
+
9
+ async function outputFile (file, data, encoding = 'utf-8') {
10
+ const dir = path.dirname(file)
11
+
12
+ if (!(await pathExists(dir))) {
13
+ await mkdir.mkdirs(dir)
14
+ }
15
+
16
+ return fs.writeFile(file, data, encoding)
17
+ }
18
+
19
+ function outputFileSync (file, ...args) {
20
+ const dir = path.dirname(file)
21
+ if (!fs.existsSync(dir)) {
22
+ mkdir.mkdirsSync(dir)
23
+ }
24
+
25
+ fs.writeFileSync(file, ...args)
26
+ }
27
+
28
+ module.exports = {
29
+ outputFile: u(outputFile),
30
+ outputFileSync
31
+ }
@@ -0,0 +1,12 @@
1
+ 'use strict'
2
+ const u = require('universalify').fromPromise
3
+ const fs = require('../fs')
4
+
5
+ function pathExists (path) {
6
+ return fs.access(path).then(() => true).catch(() => false)
7
+ }
8
+
9
+ module.exports = {
10
+ pathExists: u(pathExists),
11
+ pathExistsSync: fs.existsSync
12
+ }
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+ const fs = require('graceful-fs')
4
+ const u = require('universalify').fromCallback
5
+
6
+ function remove (path, callback) {
7
+ fs.rm(path, { recursive: true, force: true }, callback)
8
+ }
9
+
10
+ function removeSync (path) {
11
+ fs.rmSync(path, { recursive: true, force: true })
12
+ }
13
+
14
+ module.exports = {
15
+ remove: u(remove),
16
+ removeSync
17
+ }
@@ -0,0 +1,158 @@
1
+ 'use strict'
2
+
3
+ const fs = require('../fs')
4
+ const path = require('path')
5
+ const u = require('universalify').fromPromise
6
+
7
+ function getStats (src, dest, opts) {
8
+ const statFunc = opts.dereference
9
+ ? (file) => fs.stat(file, { bigint: true })
10
+ : (file) => fs.lstat(file, { bigint: true })
11
+ return Promise.all([
12
+ statFunc(src),
13
+ statFunc(dest).catch(err => {
14
+ if (err.code === 'ENOENT') return null
15
+ throw err
16
+ })
17
+ ]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
18
+ }
19
+
20
+ function getStatsSync (src, dest, opts) {
21
+ let destStat
22
+ const statFunc = opts.dereference
23
+ ? (file) => fs.statSync(file, { bigint: true })
24
+ : (file) => fs.lstatSync(file, { bigint: true })
25
+ const srcStat = statFunc(src)
26
+ try {
27
+ destStat = statFunc(dest)
28
+ } catch (err) {
29
+ if (err.code === 'ENOENT') return { srcStat, destStat: null }
30
+ throw err
31
+ }
32
+ return { srcStat, destStat }
33
+ }
34
+
35
+ async function checkPaths (src, dest, funcName, opts) {
36
+ const { srcStat, destStat } = await getStats(src, dest, opts)
37
+ if (destStat) {
38
+ if (areIdentical(srcStat, destStat)) {
39
+ const srcBaseName = path.basename(src)
40
+ const destBaseName = path.basename(dest)
41
+ if (funcName === 'move' &&
42
+ srcBaseName !== destBaseName &&
43
+ srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
44
+ return { srcStat, destStat, isChangingCase: true }
45
+ }
46
+ throw new Error('Source and destination must not be the same.')
47
+ }
48
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
49
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
50
+ }
51
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
52
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
53
+ }
54
+ }
55
+
56
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
57
+ throw new Error(errMsg(src, dest, funcName))
58
+ }
59
+
60
+ return { srcStat, destStat }
61
+ }
62
+
63
+ function checkPathsSync (src, dest, funcName, opts) {
64
+ const { srcStat, destStat } = getStatsSync(src, dest, opts)
65
+
66
+ if (destStat) {
67
+ if (areIdentical(srcStat, destStat)) {
68
+ const srcBaseName = path.basename(src)
69
+ const destBaseName = path.basename(dest)
70
+ if (funcName === 'move' &&
71
+ srcBaseName !== destBaseName &&
72
+ srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
73
+ return { srcStat, destStat, isChangingCase: true }
74
+ }
75
+ throw new Error('Source and destination must not be the same.')
76
+ }
77
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
78
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
79
+ }
80
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
81
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
82
+ }
83
+ }
84
+
85
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
86
+ throw new Error(errMsg(src, dest, funcName))
87
+ }
88
+ return { srcStat, destStat }
89
+ }
90
+
91
+ // recursively check if dest parent is a subdirectory of src.
92
+ // It works for all file types including symlinks since it
93
+ // checks the src and dest inodes. It starts from the deepest
94
+ // parent and stops once it reaches the src parent or the root path.
95
+ async function checkParentPaths (src, srcStat, dest, funcName) {
96
+ const srcParent = path.resolve(path.dirname(src))
97
+ const destParent = path.resolve(path.dirname(dest))
98
+ if (destParent === srcParent || destParent === path.parse(destParent).root) return
99
+
100
+ let destStat
101
+ try {
102
+ destStat = await fs.stat(destParent, { bigint: true })
103
+ } catch (err) {
104
+ if (err.code === 'ENOENT') return
105
+ throw err
106
+ }
107
+
108
+ if (areIdentical(srcStat, destStat)) {
109
+ throw new Error(errMsg(src, dest, funcName))
110
+ }
111
+
112
+ return checkParentPaths(src, srcStat, destParent, funcName)
113
+ }
114
+
115
+ function checkParentPathsSync (src, srcStat, dest, funcName) {
116
+ const srcParent = path.resolve(path.dirname(src))
117
+ const destParent = path.resolve(path.dirname(dest))
118
+ if (destParent === srcParent || destParent === path.parse(destParent).root) return
119
+ let destStat
120
+ try {
121
+ destStat = fs.statSync(destParent, { bigint: true })
122
+ } catch (err) {
123
+ if (err.code === 'ENOENT') return
124
+ throw err
125
+ }
126
+ if (areIdentical(srcStat, destStat)) {
127
+ throw new Error(errMsg(src, dest, funcName))
128
+ }
129
+ return checkParentPathsSync(src, srcStat, destParent, funcName)
130
+ }
131
+
132
+ function areIdentical (srcStat, destStat) {
133
+ return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
134
+ }
135
+
136
+ // return true if dest is a subdir of src, otherwise false.
137
+ // It only checks the path strings.
138
+ function isSrcSubdir (src, dest) {
139
+ const srcArr = path.resolve(src).split(path.sep).filter(i => i)
140
+ const destArr = path.resolve(dest).split(path.sep).filter(i => i)
141
+ return srcArr.every((cur, i) => destArr[i] === cur)
142
+ }
143
+
144
+ function errMsg (src, dest, funcName) {
145
+ return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`
146
+ }
147
+
148
+ module.exports = {
149
+ // checkPaths
150
+ checkPaths: u(checkPaths),
151
+ checkPathsSync,
152
+ // checkParent
153
+ checkParentPaths: u(checkParentPaths),
154
+ checkParentPathsSync,
155
+ // Misc
156
+ isSrcSubdir,
157
+ areIdentical
158
+ }
@@ -0,0 +1,36 @@
1
+ 'use strict'
2
+
3
+ const fs = require('../fs')
4
+ const u = require('universalify').fromPromise
5
+
6
+ async function utimesMillis (path, atime, mtime) {
7
+ // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
8
+ const fd = await fs.open(path, 'r+')
9
+
10
+ let closeErr = null
11
+
12
+ try {
13
+ await fs.futimes(fd, atime, mtime)
14
+ } finally {
15
+ try {
16
+ await fs.close(fd)
17
+ } catch (e) {
18
+ closeErr = e
19
+ }
20
+ }
21
+
22
+ if (closeErr) {
23
+ throw closeErr
24
+ }
25
+ }
26
+
27
+ function utimesMillisSync (path, atime, mtime) {
28
+ const fd = fs.openSync(path, 'r+')
29
+ fs.futimesSync(fd, atime, mtime)
30
+ return fs.closeSync(fd)
31
+ }
32
+
33
+ module.exports = {
34
+ utimesMillis: u(utimesMillis),
35
+ utimesMillisSync
36
+ }
@@ -0,0 +1 @@
1
+ {"name":"fs-extra","version":"11.2.0","description":"fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.","engines":{"node":">=14.14"},"homepage":"https://github.com/jprichardson/node-fs-extra","repository":{"type":"git","url":"https://github.com/jprichardson/node-fs-extra"},"keywords":["fs","file","file system","copy","directory","extra","mkdirp","mkdir","mkdirs","recursive","json","read","write","extra","delete","remove","touch","create","text","output","move","promise"],"author":"JP Richardson <jprichardson@gmail.com>","license":"MIT","dependencies":{"graceful-fs":"^4.2.0","jsonfile":"^6.0.1","universalify":"^2.0.0"},"devDependencies":{"klaw":"^2.1.1","klaw-sync":"^3.0.2","minimist":"^1.1.1","mocha":"^10.1.0","nyc":"^15.0.0","proxyquire":"^2.0.1","read-dir-files":"^0.1.1","standard":"^17.0.0"},"main":"./lib/index.js","exports":{".":"./lib/index.js","./esm":"./lib/esm.mjs"},"files":["lib/","!lib/**/__tests__/"],"scripts":{"lint":"standard","test-find":"find ./lib/**/__tests__ -name *.test.js | xargs mocha","test":"npm run lint && npm run unit && npm run unit-esm","unit":"nyc node test.js","unit-esm":"node test.mjs"},"sideEffects":false,"_lastModified":"2024-12-22T16:07:57.429Z"}
@@ -0,0 +1,10 @@
1
+ import { FlowNodeModel, Instruction, Processor } from '@tachybase/module-workflow';
2
+ export declare class PdfInstruction extends Instruction {
3
+ run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
4
+ result: void;
5
+ status: 1;
6
+ } | {
7
+ result: any;
8
+ status: -2;
9
+ }>;
10
+ }
@@ -0,0 +1,108 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var PdfInstruction_exports = {};
19
+ __export(PdfInstruction_exports, {
20
+ PdfInstruction: () => PdfInstruction
21
+ });
22
+ module.exports = __toCommonJS(PdfInstruction_exports);
23
+ var import_node_vm = require("node:vm");
24
+ var import_module_workflow = require("@tachybase/module-workflow");
25
+ var import_core = require("@babel/core");
26
+ class PdfInstruction extends import_module_workflow.Instruction {
27
+ async run(node, input, processor) {
28
+ const { sourceArray, type, code = "", model } = node.config;
29
+ let data = {};
30
+ switch ((sourceArray || []).length) {
31
+ case 0: {
32
+ data = {};
33
+ break;
34
+ }
35
+ case 1: {
36
+ const keyName = sourceArray[0]["keyName"];
37
+ const sourcePath = sourceArray[0]["sourcePath"];
38
+ const rawData = processor.getParsedValue(sourcePath, node.id);
39
+ if (keyName) {
40
+ data = {
41
+ [keyName]: rawData
42
+ };
43
+ } else {
44
+ data = rawData;
45
+ }
46
+ break;
47
+ }
48
+ default: {
49
+ data = sourceArray.reduce(
50
+ (cookedData, { keyName, sourcePath }) => ({
51
+ ...cookedData,
52
+ [keyName]: processor.getParsedValue(sourcePath, node.id)
53
+ }),
54
+ {}
55
+ );
56
+ }
57
+ }
58
+ try {
59
+ const { httpContext } = processor.options;
60
+ const myresult = (0, import_core.transform)(code, {
61
+ sourceType: "module",
62
+ filename: "a.tsx",
63
+ presets: [
64
+ [
65
+ "@babel/preset-env",
66
+ {
67
+ modules: "commonjs",
68
+ targets: {
69
+ node: "current"
70
+ }
71
+ }
72
+ ],
73
+ "@babel/preset-react",
74
+ "@babel/preset-typescript"
75
+ ]
76
+ }).code;
77
+ const compiledCode = myresult;
78
+ const script = new import_node_vm.Script(compiledCode);
79
+ const defaultFunction = async (event, context) => {
80
+ };
81
+ const sandbox = {
82
+ module: {},
83
+ exports: { default: defaultFunction },
84
+ require,
85
+ console
86
+ };
87
+ (0, import_node_vm.createContext)(sandbox);
88
+ script.runInContext(sandbox);
89
+ const func = sandbox.exports.default;
90
+ const result = await func(data, {
91
+ httpContext
92
+ });
93
+ return {
94
+ result,
95
+ status: import_module_workflow.JOB_STATUS.RESOLVED
96
+ };
97
+ } catch (err) {
98
+ return {
99
+ result: err.toString(),
100
+ status: import_module_workflow.JOB_STATUS.ERROR
101
+ };
102
+ }
103
+ }
104
+ }
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ PdfInstruction
108
+ });
@@ -0,0 +1,2 @@
1
+ export { default } from './plugin';
2
+ export { Document, Page, Text, View, StyleSheet, Image, renderToStream, Font } from '@react-pdf/renderer';
@@ -0,0 +1,53 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var server_exports = {};
29
+ __export(server_exports, {
30
+ Document: () => import_renderer.Document,
31
+ Font: () => import_renderer.Font,
32
+ Image: () => import_renderer.Image,
33
+ Page: () => import_renderer.Page,
34
+ StyleSheet: () => import_renderer.StyleSheet,
35
+ Text: () => import_renderer.Text,
36
+ View: () => import_renderer.View,
37
+ default: () => import_plugin.default,
38
+ renderToStream: () => import_renderer.renderToStream
39
+ });
40
+ module.exports = __toCommonJS(server_exports);
41
+ var import_plugin = __toESM(require("./plugin"));
42
+ var import_renderer = require("@react-pdf/renderer");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ Document,
46
+ Font,
47
+ Image,
48
+ Page,
49
+ StyleSheet,
50
+ Text,
51
+ View,
52
+ renderToStream
53
+ });
@@ -0,0 +1,11 @@
1
+ import { Plugin } from '@tachybase/server';
2
+ export declare class ModulePdfServer extends Plugin {
3
+ afterAdd(): Promise<void>;
4
+ beforeLoad(): Promise<void>;
5
+ load(): Promise<void>;
6
+ install(): Promise<void>;
7
+ afterEnable(): Promise<void>;
8
+ afterDisable(): Promise<void>;
9
+ remove(): Promise<void>;
10
+ }
11
+ export default ModulePdfServer;