pinokiod 7.1.78 → 7.1.80

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.
package/kernel/shell.js CHANGED
@@ -16,6 +16,7 @@ const sudo = require("sudo-prompt-programfiles-x86");
16
16
  const unparse = require('yargs-unparser-custom-flag');
17
17
  const Util = require('./util')
18
18
  const Environment = require('./environment')
19
+ const { applyWindowsNodePackageManagerEnv } = require('./windows_node_package_manager_env')
19
20
  const ShellParser = require('./shell_parser')
20
21
  const AnsiStreamTracker = require('./ansi_stream_tracker')
21
22
  const ShellStateSync = require('./shell_state_sync')
@@ -179,10 +180,6 @@ class Shell {
179
180
  this.env.CONDA_SHORTCUTS = 0
180
181
  this.env.CONDA_CONSOLE = 'json'
181
182
 
182
- if (this.platform === "win32") {
183
- this.env.npm_config_symlink = "false"
184
- }
185
-
186
183
  // this.env.TCELL_MINIMIZE=1
187
184
  this.env.CMAKE_OBJECT_PATH_MAX = 1024
188
185
  this.env.PYTORCH_ENABLE_MPS_FALLBACK = 1
@@ -305,6 +302,12 @@ class Shell {
305
302
  delete this.env[key]
306
303
  }
307
304
  }
305
+
306
+ if (this.platform === "win32") {
307
+ await applyWindowsNodePackageManagerEnv(this.env, {
308
+ targetPath: params && params.path ? params.path : this.kernel.homedir,
309
+ })
310
+ }
308
311
  }
309
312
  isCmdShell(shellName=this.shell) {
310
313
  const name = (shellName || '').toLowerCase()
@@ -0,0 +1,92 @@
1
+ const fs = require('fs')
2
+ const os = require('os')
3
+ const path = require('path')
4
+
5
+ const windowsDirectoryLinkCache = new Map()
6
+
7
+ async function findExistingAncestor(targetPath) {
8
+ let current = path.resolve(targetPath)
9
+ while (true) {
10
+ const exists = await fs.promises.access(current, fs.constants.F_OK).then(() => true).catch(() => false)
11
+ if (exists) {
12
+ return current
13
+ }
14
+ const parent = path.dirname(current)
15
+ if (!parent || parent === current) {
16
+ return null
17
+ }
18
+ current = parent
19
+ }
20
+ }
21
+
22
+ async function windowsDirectoryLinksWork(targetPath) {
23
+ const ancestor = await findExistingAncestor(targetPath || os.homedir())
24
+ if (!ancestor) {
25
+ return true
26
+ }
27
+
28
+ const cacheKey = path.parse(path.resolve(ancestor)).root.toLowerCase()
29
+ if (windowsDirectoryLinkCache.has(cacheKey)) {
30
+ return windowsDirectoryLinkCache.get(cacheKey)
31
+ }
32
+
33
+ const probePromise = (async () => {
34
+ let probeDir = null
35
+ try {
36
+ probeDir = await fs.promises.mkdtemp(path.join(ancestor, ".pinokio-link-probe-"))
37
+ const sourceDir = path.resolve(probeDir, "source")
38
+ const linkDir = path.resolve(probeDir, "link")
39
+ await fs.promises.mkdir(sourceDir)
40
+ await fs.promises.symlink(path.resolve(sourceDir), linkDir, "junction")
41
+ return true
42
+ } catch (_) {
43
+ return false
44
+ } finally {
45
+ if (probeDir) {
46
+ await fs.promises.rm(probeDir, { recursive: true, force: true }).catch(() => {})
47
+ }
48
+ }
49
+ })()
50
+
51
+ windowsDirectoryLinkCache.set(cacheKey, probePromise)
52
+ return probePromise
53
+ }
54
+
55
+ function getFirstDefinedEnv(env, keys) {
56
+ for (const key of keys) {
57
+ const value = env[key]
58
+ if (typeof value === "string" && value.trim()) {
59
+ return value.trim()
60
+ }
61
+ }
62
+ return null
63
+ }
64
+
65
+ async function applyWindowsNodePackageManagerEnv(env, options = {}) {
66
+ delete env.npm_config_symlink
67
+ delete env.NPM_CONFIG_SYMLINK
68
+ delete env.pnpm_config_symlink
69
+ delete env.PNPM_CONFIG_SYMLINK
70
+
71
+ const explicitNodeLinker = getFirstDefinedEnv(env, [
72
+ "npm_config_node_linker",
73
+ "NPM_CONFIG_NODE_LINKER",
74
+ "pnpm_config_node_linker",
75
+ "PNPM_CONFIG_NODE_LINKER",
76
+ ])
77
+ if (explicitNodeLinker) {
78
+ return
79
+ }
80
+
81
+ const targetPath = options.targetPath || os.homedir()
82
+ if (await windowsDirectoryLinksWork(targetPath)) {
83
+ return
84
+ }
85
+
86
+ env.npm_config_node_linker = "hoisted"
87
+ env.NPM_CONFIG_NODE_LINKER = "hoisted"
88
+ }
89
+
90
+ module.exports = {
91
+ applyWindowsNodePackageManagerEnv,
92
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "7.1.78",
3
+ "version": "7.1.80",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -773,6 +773,7 @@
773
773
  if ('fontFamily' in parsed && typeof parsed.fontFamily !== 'string') {
774
774
  delete parsed.fontFamily;
775
775
  }
776
+ delete parsed.lineHeight;
776
777
  if ('theme' in parsed) {
777
778
  parsed.theme = this.sanitizeTheme(parsed.theme);
778
779
  if (!parsed.theme || !Object.keys(parsed.theme).length) {
@@ -819,14 +820,39 @@
819
820
  }
820
821
 
821
822
  safeGetOption(term, option) {
822
- if (!term || typeof term.getOption !== 'function') {
823
+ if (!term) {
823
824
  return undefined;
824
825
  }
825
- try {
826
- return term.getOption(option);
827
- } catch (_) {
828
- return undefined;
826
+ if (term.options && Object.prototype.hasOwnProperty.call(term.options, option)) {
827
+ try {
828
+ return term.options[option];
829
+ } catch (_) {}
829
830
  }
831
+ if (typeof term.getOption === 'function') {
832
+ try {
833
+ return term.getOption(option);
834
+ } catch (_) {}
835
+ }
836
+ return undefined;
837
+ }
838
+
839
+ applyOption(term, key, value) {
840
+ if (!term) {
841
+ return false;
842
+ }
843
+ if (term.options) {
844
+ try {
845
+ term.options[key] = value;
846
+ return true;
847
+ } catch (_) {}
848
+ }
849
+ if (typeof term.setOption === 'function') {
850
+ try {
851
+ term.setOption(key, value);
852
+ return true;
853
+ } catch (_) {}
854
+ }
855
+ return false;
830
856
  }
831
857
 
832
858
  register(term, meta) {
@@ -936,33 +962,23 @@
936
962
  }
937
963
 
938
964
  applyNumericOption(term, key, value) {
939
- if (typeof term.setOption === 'function') {
940
- try {
941
- term.setOption(key, value);
942
- } catch (_) {}
943
- }
965
+ this.applyOption(term, key, value);
944
966
  if (term.element && term.element.style) {
945
- const cssValue = `${value}px`;
967
+ term.element.style.removeProperty(`--${key}`);
946
968
  if (key === 'fontSize') {
947
- term.element.style.setProperty('--font-size', cssValue);
948
- term.element.style.fontSize = cssValue;
969
+ term.element.style.fontSize = '';
949
970
  } else {
950
- term.element.style.setProperty(`--${key}`, cssValue);
951
- term.element.style[key] = cssValue;
971
+ term.element.style[key] = '';
952
972
  }
953
973
  }
954
974
  }
955
975
 
956
976
  applyStringOption(term, key, value) {
957
- if (typeof term.setOption === 'function') {
958
- try {
959
- term.setOption(key, value);
960
- } catch (_) {}
961
- }
977
+ this.applyOption(term, key, value);
962
978
  if (term.element && term.element.style) {
963
- term.element.style.setProperty(`--${key}`, value);
979
+ term.element.style.removeProperty(`--${key}`);
964
980
  if (key === 'fontFamily') {
965
- term.element.style.fontFamily = value;
981
+ term.element.style.fontFamily = '';
966
982
  }
967
983
  }
968
984
  }
@@ -983,6 +999,7 @@
983
999
  }
984
1000
  this.savePreferences();
985
1001
  this.applyAll();
1002
+ this.requestForceResize({ source: 'terminal-font-family' });
986
1003
  this.syncMenus();
987
1004
  }
988
1005
 
@@ -999,16 +1016,23 @@
999
1016
  }
1000
1017
  this.savePreferences();
1001
1018
  this.applyAll();
1019
+ this.requestForceResize({ source: 'terminal-font-size' });
1002
1020
  this.syncMenus();
1003
1021
  }
1004
1022
 
1005
1023
  resetPreferences() {
1024
+ const hadGeometryPreferences = Boolean(
1025
+ typeof this.preferences.fontFamily === 'string' && this.preferences.fontFamily.trim()
1026
+ ) || isFiniteNumber(this.preferences.fontSize);
1006
1027
  delete this.preferences.fontFamily;
1007
1028
  delete this.preferences.fontSize;
1008
1029
  delete this.preferences.theme;
1009
1030
  this.currentFontFamily = '';
1010
1031
  this.savePreferences();
1011
1032
  this.applyAll();
1033
+ if (hadGeometryPreferences) {
1034
+ this.requestForceResize({ source: 'terminal-reset' });
1035
+ }
1012
1036
  this.syncMenus();
1013
1037
  }
1014
1038
 
@@ -1062,39 +1086,7 @@
1062
1086
  }
1063
1087
 
1064
1088
  updateGlobalStylesFromPreferences() {
1065
- if (typeof document === 'undefined') {
1066
- return;
1067
- }
1068
- const family = typeof this.preferences.fontFamily === 'string' ? this.preferences.fontFamily.trim() : '';
1069
- const size = isFiniteNumber(this.preferences.fontSize) ? this.preferences.fontSize : null;
1070
- if (!family && !size) {
1071
- this.removeStyleElement();
1072
- return;
1073
- }
1074
- const style = this.ensureStyleElement();
1075
- if (!style) {
1076
- return;
1077
- }
1078
- const selectors = [
1079
- '.xterm',
1080
- '.xterm .xterm-rows',
1081
- '.xterm .xterm-rows span',
1082
- '.xterm .xterm-text-layer',
1083
- '.xterm .xterm-text-layer canvas',
1084
- '.xterm .xterm-cursor-layer',
1085
- '.xterm .xterm-char-measure-element'
1086
- ];
1087
- const declarations = [];
1088
- if (family) {
1089
- declarations.push(`font-family: ${family} !important`);
1090
- }
1091
- if (size) {
1092
- declarations.push(`font-size: ${size}px !important`);
1093
- }
1094
- const nextCss = `${selectors.join(', ')} { ${declarations.join('; ')}; }`;
1095
- if (style.textContent !== nextCss) {
1096
- style.textContent = nextCss;
1097
- }
1089
+ this.removeStyleElement();
1098
1090
  }
1099
1091
 
1100
1092
  sanitizeTheme(raw, allowUnknown) {
@@ -1193,16 +1185,7 @@
1193
1185
  return;
1194
1186
  }
1195
1187
  const nextTheme = Object.assign({}, theme);
1196
- let applied = false;
1197
- if (typeof term.setOption === 'function') {
1198
- try {
1199
- term.setOption('theme', nextTheme);
1200
- applied = true;
1201
- } catch (_) {}
1202
- } else if (term.options) {
1203
- term.options.theme = nextTheme;
1204
- applied = true;
1205
- }
1188
+ const applied = this.applyOption(term, 'theme', nextTheme);
1206
1189
 
1207
1190
  const element = term.element;
1208
1191
  if (element && element.style) {
@@ -1759,6 +1742,7 @@
1759
1742
  positionMenu();
1760
1743
  };
1761
1744
 
1745
+ sizeInput.addEventListener('input', handleSizeChange);
1762
1746
  sizeInput.addEventListener('change', handleSizeChange);
1763
1747
  sizeInput.addEventListener('blur', handleSizeChange);
1764
1748
 
@@ -5288,7 +5288,6 @@ header.navheader .mode-selector .community-mode-toggle {
5288
5288
  </a>
5289
5289
  <%})%>
5290
5290
  </div>
5291
- <div class='active-nested-path hidden' id='active-nested-path'></div>
5292
5291
  </div>
5293
5292
  <div class='menu-actions'>
5294
5293
  <% if (type === 'run') { %>
@@ -7185,7 +7184,6 @@ const rerenderMenuSection = (container, html) => {
7185
7184
  }
7186
7185
 
7187
7186
  if (!target) {
7188
- activeNestedFocusMenu = null
7189
7187
  syncActiveNestedPath()
7190
7188
  browserPopoutSurface.hide()
7191
7189
  document.querySelector(".container").classList.remove("active")
@@ -7219,7 +7217,6 @@ const rerenderMenuSection = (container, html) => {
7219
7217
  el.classList.remove("selected")
7220
7218
  })
7221
7219
  target.classList.add("selected")
7222
- activeNestedFocusMenu = null
7223
7220
  syncActiveNestedPath({ selectedLink: target })
7224
7221
  if (skipPersistedSelection && target.hasAttribute('data-default')) {
7225
7222
  ignorePersistedSelection = false
@@ -8055,162 +8052,7 @@ const rerenderMenuSection = (container, html) => {
8055
8052
 
8056
8053
  const getSubmenu = (menu) => getDirectChild(menu, ".submenu")
8057
8054
  const getToggle = (menu) => getDirectChild(menu, ".reveal")
8058
- const activeNestedPathRoot = document.getElementById("active-nested-path")
8059
- const activeNestedProxyMap = new WeakMap()
8060
- let activeNestedFocusMenu = null
8061
-
8062
- const getNestedMenuChain = (node) => {
8063
- if (!node) {
8064
- return []
8065
- }
8066
- let current = node
8067
- if (!current.classList || !current.classList.contains("nested-menu")) {
8068
- current = current.closest(".nested-menu")
8069
- }
8070
- const chain = []
8071
- while (current) {
8072
- chain.unshift(current)
8073
- current = current.parentElement ? current.parentElement.closest(".nested-menu") : null
8074
- }
8075
- return chain
8076
- }
8077
-
8078
- const sanitizeActiveNestedProxy = (proxy) => {
8079
- if (!proxy) {
8080
- return null
8081
- }
8082
- proxy.removeAttribute("id")
8083
- proxy.classList.remove("frame-link", "selected", "tab-link-popover-host")
8084
- proxy.classList.add("active-nested-proxy")
8085
- proxy.setAttribute("data-active-nested-proxy", "true")
8086
- proxy.querySelectorAll(".tab-link-popover-trigger").forEach((node) => {
8087
- node.remove()
8088
- })
8089
- return proxy
8090
- }
8091
-
8092
- const buildActiveNestedProxy = (child, isCurrent) => {
8093
- if (!child) {
8094
- return null
8095
- }
8096
- let proxy
8097
- if (child.classList && child.classList.contains("nested-menu")) {
8098
- const toggle = getToggle(child)
8099
- if (!toggle) {
8100
- return null
8101
- }
8102
- proxy = toggle.cloneNode(true)
8103
- } else {
8104
- proxy = child.cloneNode(true)
8105
- }
8106
- sanitizeActiveNestedProxy(proxy)
8107
- if (child.classList && child.classList.contains("nested-menu")) {
8108
- const loader = proxy.querySelector(".loader")
8109
- if (loader) {
8110
- loader.innerHTML = `<i class="fa-solid ${isCurrent ? "fa-angle-down" : "fa-angle-right"}"></i>`
8111
- }
8112
- }
8113
- proxy.classList.toggle("is-current", Boolean(isCurrent))
8114
- activeNestedProxyMap.set(proxy, child)
8115
- return proxy
8116
- }
8117
-
8118
- const syncActiveNestedPath = ({ selectedLink = null } = {}) => {
8119
- if (!activeNestedPathRoot) {
8120
- return
8121
- }
8122
- if (activeNestedFocusMenu && !activeNestedFocusMenu.isConnected) {
8123
- activeNestedFocusMenu = null
8124
- }
8125
- const currentSelectedLink = (selectedLink && selectedLink.isConnected)
8126
- ? selectedLink
8127
- : document.querySelector("aside .frame-link.selected")
8128
- const chain = activeNestedFocusMenu
8129
- ? getNestedMenuChain(activeNestedFocusMenu)
8130
- : getNestedMenuChain(currentSelectedLink)
8131
-
8132
- activeNestedPathRoot.replaceChildren()
8133
-
8134
- if (!chain.length) {
8135
- activeNestedPathRoot.classList.add("hidden")
8136
- if (window.PinokioMenuScrollHints && typeof window.PinokioMenuScrollHints.update === "function") {
8137
- window.PinokioMenuScrollHints.update()
8138
- }
8139
- return
8140
- }
8141
-
8142
- chain.forEach((menu, index) => {
8143
- const submenu = getSubmenu(menu)
8144
- if (!submenu) {
8145
- return
8146
- }
8147
- const row = document.createElement("div")
8148
- row.className = "m active-nested-row"
8149
- row.dataset.activeNestedLevel = String(index)
8150
- const nextMenu = chain[index + 1] || null
8151
-
8152
- Array.from(submenu.children).forEach((child) => {
8153
- let isCurrent = false
8154
- if (child.classList && child.classList.contains("nested-menu")) {
8155
- isCurrent = child === nextMenu || (!nextMenu && currentSelectedLink ? child.contains(currentSelectedLink) : false)
8156
- } else {
8157
- isCurrent = child === currentSelectedLink
8158
- }
8159
- const proxy = buildActiveNestedProxy(child, isCurrent)
8160
- if (proxy) {
8161
- row.appendChild(proxy)
8162
- }
8163
- })
8164
-
8165
- if (row.childElementCount > 0) {
8166
- activeNestedPathRoot.appendChild(row)
8167
- }
8168
- })
8169
-
8170
- if (!activeNestedPathRoot.childElementCount) {
8171
- activeNestedPathRoot.classList.add("hidden")
8172
- if (window.PinokioMenuScrollHints && typeof window.PinokioMenuScrollHints.update === "function") {
8173
- window.PinokioMenuScrollHints.update()
8174
- }
8175
- return
8176
- }
8177
-
8178
- activeNestedPathRoot.classList.remove("hidden")
8179
- const currentProxy = activeNestedPathRoot.querySelector(".active-nested-proxy.is-current")
8180
- if (currentProxy && typeof currentProxy.scrollIntoView === "function") {
8181
- currentProxy.scrollIntoView({
8182
- block: "nearest",
8183
- inline: "nearest"
8184
- })
8185
- }
8186
- if (window.PinokioMenuScrollHints && typeof window.PinokioMenuScrollHints.update === "function") {
8187
- window.PinokioMenuScrollHints.update()
8188
- }
8189
- }
8190
-
8191
- if (activeNestedPathRoot) {
8192
- activeNestedPathRoot.addEventListener("click", (event) => {
8193
- const proxy = event.target.closest("[data-active-nested-proxy='true']")
8194
- if (!proxy || !activeNestedPathRoot.contains(proxy)) {
8195
- return
8196
- }
8197
- const source = activeNestedProxyMap.get(proxy)
8198
- if (!source || !source.isConnected) {
8199
- return
8200
- }
8201
- event.preventDefault()
8202
- event.stopPropagation()
8203
- if (source.classList && source.classList.contains("nested-menu")) {
8204
- activeNestedFocusMenu = source
8205
- syncActiveNestedPath()
8206
- return
8207
- }
8208
- activeNestedFocusMenu = null
8209
- if (typeof source.click === "function") {
8210
- source.click()
8211
- }
8212
- })
8213
- }
8055
+ const syncActiveNestedPath = () => {}
8214
8056
 
8215
8057
  renderSelection()
8216
8058