@brianmsm/quarto-bento 0.0.0-stage → 0.1.0

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 (122) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -2
  3. package/bin/qbento-npm.mjs +62 -0
  4. package/distribution/LICENSE +21 -0
  5. package/distribution/PACKAGING.md +59 -0
  6. package/distribution/bin/qbento +5 -0
  7. package/distribution/bin/qbento.cmd +4 -0
  8. package/distribution/manifest.json +720 -0
  9. package/distribution/runtime/LICENSE +21 -0
  10. package/distribution/runtime/_extensions/qbento/_extension.yml +24 -0
  11. package/distribution/runtime/_extensions/qbento/capture.lua +21 -0
  12. package/distribution/runtime/_extensions/qbento/guard.lua +7 -0
  13. package/distribution/runtime/_extensions/qbento/post.ts +2 -0
  14. package/distribution/runtime/_extensions/qbento/pre.ts +2 -0
  15. package/distribution/runtime/_extensions/qbento/producer-activation.js +129 -0
  16. package/distribution/runtime/src/bridge/browser.js +168 -0
  17. package/distribution/runtime/src/bridge/isolation.ts +55 -0
  18. package/distribution/runtime/src/browser/chromium.ts +218 -0
  19. package/distribution/runtime/src/cli.ts +219 -0
  20. package/distribution/runtime/src/core/agent.ts +565 -0
  21. package/distribution/runtime/src/core/annotations.ts +384 -0
  22. package/distribution/runtime/src/core/capture.ts +203 -0
  23. package/distribution/runtime/src/core/component-actions.ts +550 -0
  24. package/distribution/runtime/src/core/component-frames.ts +59 -0
  25. package/distribution/runtime/src/core/component-sync.ts +290 -0
  26. package/distribution/runtime/src/core/design-diagnostics.ts +78 -0
  27. package/distribution/runtime/src/core/design-registry.ts +287 -0
  28. package/distribution/runtime/src/core/graph-relations.ts +354 -0
  29. package/distribution/runtime/src/core/graph-scope.ts +63 -0
  30. package/distribution/runtime/src/core/graph-sync.ts +228 -0
  31. package/distribution/runtime/src/core/io.ts +27 -0
  32. package/distribution/runtime/src/core/kpi-appearance.ts +205 -0
  33. package/distribution/runtime/src/core/layouts.ts +245 -0
  34. package/distribution/runtime/src/core/project.ts +759 -0
  35. package/distribution/runtime/src/core/reconcile.ts +384 -0
  36. package/distribution/runtime/src/core/recovery.ts +1255 -0
  37. package/distribution/runtime/src/core/slide-actions.ts +158 -0
  38. package/distribution/runtime/src/core/source-scope.ts +50 -0
  39. package/distribution/runtime/src/core/sync.ts +2423 -0
  40. package/distribution/runtime/src/core/widgets.ts +300 -0
  41. package/distribution/runtime/src/integration/install.ts +98 -0
  42. package/distribution/runtime/src/integration/invocation.ts +100 -0
  43. package/distribution/runtime/src/integration/quarto.ts +457 -0
  44. package/distribution/runtime/src/render/assets.ts +66 -0
  45. package/distribution/runtime/src/render/capture.lua +8 -0
  46. package/distribution/runtime/src/render/chart.ts +165 -0
  47. package/distribution/runtime/src/render/components.ts +199 -0
  48. package/distribution/runtime/src/render/design.ts +820 -0
  49. package/distribution/runtime/src/render/diagnostics.ts +36 -0
  50. package/distribution/runtime/src/render/graphs.ts +747 -0
  51. package/distribution/runtime/src/render/html.ts +82 -0
  52. package/distribution/runtime/src/render/images.ts +268 -0
  53. package/distribution/runtime/src/render/inline.ts +259 -0
  54. package/distribution/runtime/src/render/kpi.ts +385 -0
  55. package/distribution/runtime/src/render/lists.ts +183 -0
  56. package/distribution/runtime/src/render/math.ts +413 -0
  57. package/distribution/runtime/src/render/measure.ts +185 -0
  58. package/distribution/runtime/src/render/native-layout.ts +174 -0
  59. package/distribution/runtime/src/render/producer-capture.ts +319 -0
  60. package/distribution/runtime/src/render/producer-environment.R +49 -0
  61. package/distribution/runtime/src/render/producer-environment.ts +96 -0
  62. package/distribution/runtime/src/render/producer-profile.R +91 -0
  63. package/distribution/runtime/src/render/producer-site-profile.R +18 -0
  64. package/distribution/runtime/src/render/project.ts +1806 -0
  65. package/distribution/runtime/src/render/quarto.ts +127 -0
  66. package/distribution/runtime/src/render/registry.ts +233 -0
  67. package/distribution/runtime/src/render/resources.ts +292 -0
  68. package/distribution/runtime/src/render/shell.ts +110 -0
  69. package/distribution/runtime/src/render/source-inline.ts +169 -0
  70. package/distribution/runtime/src/render/table.ts +220 -0
  71. package/distribution/runtime/src/render/text-overflow.ts +208 -0
  72. package/distribution/runtime/src/render/types.ts +71 -0
  73. package/distribution/runtime/src/render/validate.ts +572 -0
  74. package/distribution/runtime/src/rich/project.ts +117 -0
  75. package/distribution/runtime/src/rich/table.ts +374 -0
  76. package/distribution/runtime/src/source/annotations.ts +490 -0
  77. package/distribution/runtime/src/source/attributes.ts +415 -0
  78. package/distribution/runtime/src/source/chart.ts +165 -0
  79. package/distribution/runtime/src/source/code-language.ts +277 -0
  80. package/distribution/runtime/src/source/component-insertion.ts +160 -0
  81. package/distribution/runtime/src/source/deletion.ts +278 -0
  82. package/distribution/runtime/src/source/graphs.ts +517 -0
  83. package/distribution/runtime/src/source/identities.ts +256 -0
  84. package/distribution/runtime/src/source/identity-id.ts +6 -0
  85. package/distribution/runtime/src/source/image.ts +50 -0
  86. package/distribution/runtime/src/source/kpi.ts +196 -0
  87. package/distribution/runtime/src/source/mod.ts +876 -0
  88. package/distribution/runtime/src/source/notes.ts +308 -0
  89. package/distribution/runtime/src/source/structure.ts +647 -0
  90. package/distribution/runtime/src/source/table.ts +290 -0
  91. package/distribution/runtime/src/source/text-conversion.ts +146 -0
  92. package/distribution/runtime/src/state/components.ts +281 -0
  93. package/distribution/runtime/src/state/graphs.ts +200 -0
  94. package/distribution/runtime/src/state/json.ts +162 -0
  95. package/distribution/runtime/src/state/merge.ts +1034 -0
  96. package/distribution/runtime/src/state/mod.ts +5 -0
  97. package/distribution/runtime/src/state/store.ts +226 -0
  98. package/distribution/runtime/src/state/types.ts +151 -0
  99. package/distribution/runtime/src/studio/client.js +790 -0
  100. package/distribution/runtime/src/studio/components.js +188 -0
  101. package/distribution/runtime/src/studio/index.html +278 -0
  102. package/distribution/runtime/src/studio/layouts.js +170 -0
  103. package/distribution/runtime/src/studio/registry.js +283 -0
  104. package/distribution/runtime/src/studio/relations.js +169 -0
  105. package/distribution/runtime/src/studio/server.ts +433 -0
  106. package/distribution/runtime/src/widgets/deck.ts +39 -0
  107. package/distribution/runtime/src/widgets/plotly.ts +354 -0
  108. package/distribution/runtime/src/widgets/presenter.ts +367 -0
  109. package/distribution/runtime/src/widgets/snapshot.ts +116 -0
  110. package/distribution/runtime/vendor/bento/FONT_NOTICES.md +49 -0
  111. package/distribution/runtime/vendor/bento/LICENSE +21 -0
  112. package/distribution/runtime/vendor/bento/THIRD_PARTY_NOTICES.md +51 -0
  113. package/distribution/runtime/vendor/bento/font-licenses/fraunces-OFL.txt +93 -0
  114. package/distribution/runtime/vendor/bento/font-licenses/instrument-sans-OFL.txt +93 -0
  115. package/distribution/runtime/vendor/bento/pin.json +69 -0
  116. package/distribution/runtime/vendor/bento/provenance/slides.package-lock.json +1928 -0
  117. package/distribution/runtime/vendor/bento/provenance/slides.package.json +28 -0
  118. package/distribution/runtime/vendor/bento/runtime-dependencies.json +244 -0
  119. package/distribution/runtime/vendor/bento/runtime-licenses.json +4038 -0
  120. package/distribution/runtime/vendor/bento/shell.html +269 -0
  121. package/distribution/runtime/vendor/bento/slides.schema.json +2379 -0
  122. package/package.json +40 -4
@@ -0,0 +1,91 @@
1
+ # Per-process compatibility adapter; the original QMD and knitr options are intact.
2
+ local({
3
+ profile_set <- Sys.getenv('QBENTO_ORIGINAL_R_PROFILE_SET') == '1'
4
+ profile_value <- Sys.getenv('QBENTO_ORIGINAL_R_PROFILE_USER')
5
+ if (profile_set) Sys.setenv(R_PROFILE_USER=profile_value) else Sys.unsetenv('R_PROFILE_USER')
6
+ selected <- if (profile_set) profile_value else {
7
+ local_profile <- file.path(getwd(), '.Rprofile')
8
+ if (file.exists(local_profile)) local_profile else file.path(path.expand('~'), '.Rprofile')
9
+ }
10
+ if (nzchar(selected) && file.exists(selected)) sys.source(selected, envir=.GlobalEnv)
11
+
12
+ manifest <- jsonlite::fromJSON(Sys.getenv('QBENTO_PRODUCER_MANIFEST'), simplifyVector=FALSE)
13
+ ns <- asNamespace('knitr')
14
+ original <- get('call_block',ns)
15
+ if (!identical(names(formals(original)), 'block')) stop('UNSUPPORTED_KNITR_PRODUCER_ADAPTER: expected call_block(block)')
16
+ active <- FALSE
17
+ expected_input <- NULL
18
+ expected_dir <- NULL
19
+ resolve_expected_input <- function() {
20
+ if (!is.null(expected_input)) return(invisible(NULL))
21
+ if (!('rmarkdown' %in% loadedNamespaces())) {
22
+ stop('UNSUPPORTED_RMARKDOWN_PATH_ADAPTER: the rmarkdown namespace is not loaded while knitting; Quarto must load its render engine before producer chunks run')
23
+ }
24
+ rmarkdown_ns <- asNamespace('rmarkdown')
25
+ file_name_without_shell_chars <- get0(
26
+ 'file_name_without_shell_chars',
27
+ envir=rmarkdown_ns,
28
+ inherits=FALSE,
29
+ ifnotfound=NULL
30
+ )
31
+ if (!is.function(file_name_without_shell_chars) ||
32
+ !identical(names(formals(file_name_without_shell_chars)), 'file')) {
33
+ stop('UNSUPPORTED_RMARKDOWN_PATH_ADAPTER: this rmarkdown version does not expose the expected file_name_without_shell_chars(file) mapping; verify the installed Quarto/rmarkdown integration before rendering')
34
+ }
35
+ mapped_input <- tryCatch(
36
+ file_name_without_shell_chars(manifest$input),
37
+ error=function(error) error
38
+ )
39
+ if (inherits(mapped_input, 'error') || !is.character(mapped_input) ||
40
+ length(mapped_input)!=1L || is.na(mapped_input) || !nzchar(mapped_input) ||
41
+ !identical(dirname(mapped_input), dirname(manifest$input))) {
42
+ stop('UNSUPPORTED_RMARKDOWN_PATH_ADAPTER: rmarkdown did not map the original input to one filename in its original directory; verify the installed Quarto/rmarkdown integration before rendering')
43
+ }
44
+ expected_input <<- tryCatch(
45
+ normalizePath(mapped_input, mustWork=TRUE),
46
+ error=function(error) NULL
47
+ )
48
+ expected_dir <<- tryCatch(
49
+ normalizePath(dirname(manifest$input), mustWork=TRUE),
50
+ error=function(error) NULL
51
+ )
52
+ if (is.null(expected_input) || is.null(expected_dir)) {
53
+ expected_input <<- NULL
54
+ expected_dir <<- NULL
55
+ stop('UNSUPPORTED_RMARKDOWN_PATH_ADAPTER: the normalized input or original directory is unavailable; verify Quarto input staging before rendering')
56
+ }
57
+ invisible(NULL)
58
+ }
59
+ adapter <- function(block) {
60
+ input <- knitr::current_input(dir=TRUE)
61
+ resolve_expected_input()
62
+ resolved_input <- if (is.character(input) && length(input)==1L &&
63
+ !is.na(input) && nzchar(input)) {
64
+ tryCatch(normalizePath(input, mustWork=TRUE), error=function(error) NULL)
65
+ } else NULL
66
+ if (active || is.null(resolved_input) ||
67
+ !identical(dirname(resolved_input), expected_dir) ||
68
+ !identical(resolved_input, expected_input)) {
69
+ stop("UNMAPPED_PRODUCER_RECEIPT: nested or foreign knit input needs an explicit execution adapter")
70
+ }
71
+ active <<- TRUE
72
+ on.exit(active <<- FALSE)
73
+ label <- block$params$label
74
+ candidates <- Filter(function(chunk) identical(chunk$label,label),manifest$chunks)
75
+ if (length(candidates)!=1L) stop('UNMAPPED_PRODUCER_RECEIPT: original parsed chunk has no unique source identity')
76
+ chunk <- candidates[[1L]]
77
+ code <- paste(as.character(knitr::knit_code$get(label)),collapse='\n')
78
+ if (!identical(chunk$code,code)) stop('UNMAPPED_PRODUCER_RECEIPT: parsed chunk body differs from original source')
79
+ output <- original(block)
80
+ if (!is.character(output) || length(output)!=1L) stop('INVALID_PRODUCER_OUTPUT: expected one Markdown result')
81
+ if (!nzchar(output)) return(output)
82
+ runs <- regmatches(output,gregexpr('(?m)^:{3,}',output,perl=TRUE))[[1L]]
83
+ fence <- paste(rep(':',max(c(3L,nchar(runs)))+1L),collapse='')
84
+ token <- paste(manifest$nonce,chunk$index,sep=':')
85
+ cat(jsonlite::toJSON(token,auto_unbox=TRUE),'\n',file=manifest$outputReceiptPath,append=TRUE)
86
+ paste0('\n',fence,' {.qbento-execution qbento-producer-proof="',token,'"}\n\n',output,'\n',fence,'\n')
87
+ }
88
+ unlockBinding('call_block',ns)
89
+ assign('call_block',adapter,ns)
90
+ lockBinding('call_block',ns)
91
+ })
@@ -0,0 +1,18 @@
1
+ # Chain the original site profile before selecting the user profile. A site
2
+ # profile may itself change R_PROFILE_USER; that selection must remain effective.
3
+ local({
4
+ site_set <- Sys.getenv('QBENTO_ORIGINAL_R_SITE_SET') == '1'
5
+ site_value <- Sys.getenv('QBENTO_ORIGINAL_R_SITE')
6
+ if (site_set) Sys.setenv(R_PROFILE=site_value) else Sys.unsetenv('R_PROFILE')
7
+ user_set <- Sys.getenv('QBENTO_ORIGINAL_R_PROFILE_SET') == '1'
8
+ user_value <- Sys.getenv('QBENTO_ORIGINAL_R_PROFILE_USER')
9
+ if (user_set) Sys.setenv(R_PROFILE_USER=user_value) else Sys.unsetenv('R_PROFILE_USER')
10
+ selected <- if (site_set) site_value else file.path(R.home('etc'), 'Rprofile.site')
11
+ if (nzchar(selected) && file.exists(selected)) sys.source(selected, envir=.GlobalEnv)
12
+ effective <- Sys.getenv('R_PROFILE_USER', unset=NA_character_)
13
+ Sys.setenv(
14
+ QBENTO_ORIGINAL_R_PROFILE_SET=if (is.na(effective)) '0' else '1',
15
+ QBENTO_ORIGINAL_R_PROFILE_USER=if (is.na(effective)) '' else effective,
16
+ R_PROFILE_USER=Sys.getenv('QBENTO_PRODUCER_PROFILE')
17
+ )
18
+ })