nx 19.5.0-canary.20240704-28939dd → 19.5.0-canary.20240706-4ae16b3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,108 @@
1
+ import {
2
+ instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync,
3
+ getDefaultContext as __emnapiGetDefaultContext,
4
+ WASI as __WASI,
5
+ createOnMessage as __wasmCreateOnMessageForFsProxy,
6
+ } from '@napi-rs/wasm-runtime'
7
+
8
+ import __wasmUrl from './nx.wasm32-wasi.wasm?url'
9
+
10
+ const __wasi = new __WASI({
11
+ version: 'preview1',
12
+ })
13
+
14
+ const __emnapiContext = __emnapiGetDefaultContext()
15
+
16
+ const __sharedMemory = new WebAssembly.Memory({
17
+ initial: 16384,
18
+ maximum: 32768,
19
+ shared: true,
20
+ })
21
+
22
+ const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
23
+
24
+ const {
25
+ instance: __napiInstance,
26
+ module: __wasiModule,
27
+ napiModule: __napiModule,
28
+ } = __emnapiInstantiateNapiModuleSync(__wasmFile, {
29
+ context: __emnapiContext,
30
+ asyncWorkPoolSize: 4,
31
+ wasi: __wasi,
32
+ onCreateWorker() {
33
+ const worker = new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), {
34
+ type: 'module',
35
+ })
36
+
37
+ return worker
38
+ },
39
+ overwriteImports(importObject) {
40
+ importObject.env = {
41
+ ...importObject.env,
42
+ ...importObject.napi,
43
+ ...importObject.emnapi,
44
+ memory: __sharedMemory,
45
+ }
46
+ return importObject
47
+ },
48
+ beforeInit({ instance }) {
49
+ __napi_rs_initialize_modules(instance)
50
+ },
51
+ })
52
+
53
+ function __napi_rs_initialize_modules(__napiInstance) {
54
+ __napiInstance.exports['__napi_register__expand_outputs_0']?.()
55
+ __napiInstance.exports['__napi_register__get_files_for_outputs_1']?.()
56
+ __napiInstance.exports['__napi_register__remove_2']?.()
57
+ __napiInstance.exports['__napi_register__copy_3']?.()
58
+ __napiInstance.exports['__napi_register__hash_array_4']?.()
59
+ __napiInstance.exports['__napi_register__hash_file_5']?.()
60
+ __napiInstance.exports['__napi_register__ImportResult_struct_6']?.()
61
+ __napiInstance.exports['__napi_register__find_imports_7']?.()
62
+ __napiInstance.exports['__napi_register__transfer_project_graph_8']?.()
63
+ __napiInstance.exports['__napi_register__ExternalNode_struct_9']?.()
64
+ __napiInstance.exports['__napi_register__Target_struct_10']?.()
65
+ __napiInstance.exports['__napi_register__Project_struct_11']?.()
66
+ __napiInstance.exports['__napi_register__ProjectGraph_struct_12']?.()
67
+ __napiInstance.exports['__napi_register__HashPlanner_struct_13']?.()
68
+ __napiInstance.exports['__napi_register__HashPlanner_impl_17']?.()
69
+ __napiInstance.exports['__napi_register__HashDetails_struct_18']?.()
70
+ __napiInstance.exports['__napi_register__HasherOptions_struct_19']?.()
71
+ __napiInstance.exports['__napi_register__TaskHasher_struct_20']?.()
72
+ __napiInstance.exports['__napi_register__TaskHasher_impl_23']?.()
73
+ __napiInstance.exports['__napi_register__Task_struct_24']?.()
74
+ __napiInstance.exports['__napi_register__TaskTarget_struct_25']?.()
75
+ __napiInstance.exports['__napi_register__TaskGraph_struct_26']?.()
76
+ __napiInstance.exports['__napi_register__FileData_struct_27']?.()
77
+ __napiInstance.exports['__napi_register__InputsInput_struct_28']?.()
78
+ __napiInstance.exports['__napi_register__FileSetInput_struct_29']?.()
79
+ __napiInstance.exports['__napi_register__RuntimeInput_struct_30']?.()
80
+ __napiInstance.exports['__napi_register__EnvironmentInput_struct_31']?.()
81
+ __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_32']?.()
82
+ __napiInstance.exports['__napi_register__DepsOutputsInput_struct_33']?.()
83
+ __napiInstance.exports['__napi_register__NxJson_struct_34']?.()
84
+ __napiInstance.exports['__napi_register__WorkspaceContext_struct_35']?.()
85
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_44']?.()
86
+ __napiInstance.exports['__napi_register__WorkspaceErrors_45']?.()
87
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_46']?.()
88
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_47']?.()
89
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_48']?.()
90
+ __napiInstance.exports['__napi_register__FileMap_struct_49']?.()
91
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_50']?.()
92
+ __napiInstance.exports['__napi_register__IS_WASM_51']?.()
93
+ }
94
+ export const HashPlanner = __napiModule.exports.HashPlanner
95
+ export const ImportResult = __napiModule.exports.ImportResult
96
+ export const TaskHasher = __napiModule.exports.TaskHasher
97
+ export const WorkspaceContext = __napiModule.exports.WorkspaceContext
98
+ export const copy = __napiModule.exports.copy
99
+ export const expandOutputs = __napiModule.exports.expandOutputs
100
+ export const findImports = __napiModule.exports.findImports
101
+ export const getFilesForOutputs = __napiModule.exports.getFilesForOutputs
102
+ export const hashArray = __napiModule.exports.hashArray
103
+ export const hashFile = __napiModule.exports.hashFile
104
+ export const IS_WASM = __napiModule.exports.IS_WASM
105
+ export const remove = __napiModule.exports.remove
106
+ export const testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
107
+ export const transferProjectGraph = __napiModule.exports.transferProjectGraph
108
+ export const WorkspaceErrors = __napiModule.exports.WorkspaceErrors
@@ -0,0 +1,139 @@
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ const __nodeFs = require('node:fs')
7
+ const __nodePath = require('node:path')
8
+ const { WASI: __nodeWASI } = require('node:wasi')
9
+ const { Worker } = require('node:worker_threads')
10
+
11
+ const {
12
+ instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync,
13
+ getDefaultContext: __emnapiGetDefaultContext,
14
+ createOnMessage: __wasmCreateOnMessageForFsProxy,
15
+ } = require('@napi-rs/wasm-runtime')
16
+
17
+ const __rootDir = __nodePath.parse(process.cwd()).root
18
+
19
+ const __wasi = new __nodeWASI({
20
+ version: 'preview1',
21
+ env: process.env,
22
+ preopens: {
23
+ [__rootDir]: __rootDir,
24
+ }
25
+ })
26
+
27
+ const __emnapiContext = __emnapiGetDefaultContext()
28
+
29
+ const __sharedMemory = new WebAssembly.Memory({
30
+ initial: 16384,
31
+ maximum: 32768,
32
+ shared: true,
33
+ })
34
+
35
+ let __wasmFilePath = __nodePath.join(__dirname, 'nx.wasm32-wasi.wasm')
36
+ const __wasmDebugFilePath = __nodePath.join(__dirname, 'nx.wasm32-wasi.debug.wasm')
37
+
38
+ if (__nodeFs.existsSync(__wasmDebugFilePath)) {
39
+ __wasmFilePath = __wasmDebugFilePath
40
+ } else if (!__nodeFs.existsSync(__wasmFilePath)) {
41
+ try {
42
+ __wasmFilePath = __nodePath.resolve('@nx/nx-wasm32-wasi')
43
+ } catch {
44
+ throw new Error('Cannot find nx.wasm32-wasi.wasm file, and @nx/nx-wasm32-wasi package is not installed.')
45
+ }
46
+ }
47
+
48
+ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), {
49
+ context: __emnapiContext,
50
+ asyncWorkPoolSize: (function() {
51
+ const threadsSizeFromEnv = Number(process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ?? process.env.UV_THREADPOOL_SIZE)
52
+ // NaN > 0 is false
53
+ if (threadsSizeFromEnv > 0) {
54
+ return threadsSizeFromEnv
55
+ } else {
56
+ return 4
57
+ }
58
+ })(),
59
+ wasi: __wasi,
60
+ onCreateWorker() {
61
+ const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), {
62
+ env: process.env,
63
+ execArgv: ['--experimental-wasi-unstable-preview1'],
64
+ })
65
+ worker.onmessage = ({ data }) => {
66
+ __wasmCreateOnMessageForFsProxy(__nodeFs)(data)
67
+ }
68
+ return worker
69
+ },
70
+ overwriteImports(importObject) {
71
+ importObject.env = {
72
+ ...importObject.env,
73
+ ...importObject.napi,
74
+ ...importObject.emnapi,
75
+ memory: __sharedMemory,
76
+ }
77
+ return importObject
78
+ },
79
+ beforeInit({ instance }) {
80
+ __napi_rs_initialize_modules(instance)
81
+ }
82
+ })
83
+
84
+ function __napi_rs_initialize_modules(__napiInstance) {
85
+ __napiInstance.exports['__napi_register__expand_outputs_0']?.()
86
+ __napiInstance.exports['__napi_register__get_files_for_outputs_1']?.()
87
+ __napiInstance.exports['__napi_register__remove_2']?.()
88
+ __napiInstance.exports['__napi_register__copy_3']?.()
89
+ __napiInstance.exports['__napi_register__hash_array_4']?.()
90
+ __napiInstance.exports['__napi_register__hash_file_5']?.()
91
+ __napiInstance.exports['__napi_register__ImportResult_struct_6']?.()
92
+ __napiInstance.exports['__napi_register__find_imports_7']?.()
93
+ __napiInstance.exports['__napi_register__transfer_project_graph_8']?.()
94
+ __napiInstance.exports['__napi_register__ExternalNode_struct_9']?.()
95
+ __napiInstance.exports['__napi_register__Target_struct_10']?.()
96
+ __napiInstance.exports['__napi_register__Project_struct_11']?.()
97
+ __napiInstance.exports['__napi_register__ProjectGraph_struct_12']?.()
98
+ __napiInstance.exports['__napi_register__HashPlanner_struct_13']?.()
99
+ __napiInstance.exports['__napi_register__HashPlanner_impl_17']?.()
100
+ __napiInstance.exports['__napi_register__HashDetails_struct_18']?.()
101
+ __napiInstance.exports['__napi_register__HasherOptions_struct_19']?.()
102
+ __napiInstance.exports['__napi_register__TaskHasher_struct_20']?.()
103
+ __napiInstance.exports['__napi_register__TaskHasher_impl_23']?.()
104
+ __napiInstance.exports['__napi_register__Task_struct_24']?.()
105
+ __napiInstance.exports['__napi_register__TaskTarget_struct_25']?.()
106
+ __napiInstance.exports['__napi_register__TaskGraph_struct_26']?.()
107
+ __napiInstance.exports['__napi_register__FileData_struct_27']?.()
108
+ __napiInstance.exports['__napi_register__InputsInput_struct_28']?.()
109
+ __napiInstance.exports['__napi_register__FileSetInput_struct_29']?.()
110
+ __napiInstance.exports['__napi_register__RuntimeInput_struct_30']?.()
111
+ __napiInstance.exports['__napi_register__EnvironmentInput_struct_31']?.()
112
+ __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_32']?.()
113
+ __napiInstance.exports['__napi_register__DepsOutputsInput_struct_33']?.()
114
+ __napiInstance.exports['__napi_register__NxJson_struct_34']?.()
115
+ __napiInstance.exports['__napi_register__WorkspaceContext_struct_35']?.()
116
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_44']?.()
117
+ __napiInstance.exports['__napi_register__WorkspaceErrors_45']?.()
118
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_46']?.()
119
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_47']?.()
120
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_48']?.()
121
+ __napiInstance.exports['__napi_register__FileMap_struct_49']?.()
122
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_50']?.()
123
+ __napiInstance.exports['__napi_register__IS_WASM_51']?.()
124
+ }
125
+ module.exports.HashPlanner = __napiModule.exports.HashPlanner
126
+ module.exports.ImportResult = __napiModule.exports.ImportResult
127
+ module.exports.TaskHasher = __napiModule.exports.TaskHasher
128
+ module.exports.WorkspaceContext = __napiModule.exports.WorkspaceContext
129
+ module.exports.copy = __napiModule.exports.copy
130
+ module.exports.expandOutputs = __napiModule.exports.expandOutputs
131
+ module.exports.findImports = __napiModule.exports.findImports
132
+ module.exports.getFilesForOutputs = __napiModule.exports.getFilesForOutputs
133
+ module.exports.hashArray = __napiModule.exports.hashArray
134
+ module.exports.hashFile = __napiModule.exports.hashFile
135
+ module.exports.IS_WASM = __napiModule.exports.IS_WASM
136
+ module.exports.remove = __napiModule.exports.remove
137
+ module.exports.testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
138
+ module.exports.transferProjectGraph = __napiModule.exports.transferProjectGraph
139
+ module.exports.WorkspaceErrors = __napiModule.exports.WorkspaceErrors
Binary file
@@ -0,0 +1,32 @@
1
+ import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
2
+
3
+ const handler = new MessageHandler({
4
+ onLoad({ wasmModule, wasmMemory }) {
5
+ const wasi = new WASI({
6
+ print: function () {
7
+ // eslint-disable-next-line no-console
8
+ console.log.apply(console, arguments)
9
+ },
10
+ printErr: function() {
11
+ // eslint-disable-next-line no-console
12
+ console.error.apply(console, arguments)
13
+ },
14
+ })
15
+ return instantiateNapiModuleSync(wasmModule, {
16
+ childThread: true,
17
+ wasi,
18
+ overwriteImports(importObject) {
19
+ importObject.env = {
20
+ ...importObject.env,
21
+ ...importObject.napi,
22
+ ...importObject.emnapi,
23
+ memory: wasmMemory,
24
+ }
25
+ },
26
+ })
27
+ },
28
+ })
29
+
30
+ globalThis.onmessage = function (e) {
31
+ handler.handle(e)
32
+ }
@@ -0,0 +1,63 @@
1
+ import fs from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import { parse } from "node:path";
4
+ import { WASI } from "node:wasi";
5
+ import { parentPort, Worker } from "node:worker_threads";
6
+
7
+ const require = createRequire(import.meta.url);
8
+
9
+ const { instantiateNapiModuleSync, MessageHandler, getDefaultContext } = require("@napi-rs/wasm-runtime");
10
+
11
+ if (parentPort) {
12
+ parentPort.on("message", (data) => {
13
+ globalThis.onmessage({ data });
14
+ });
15
+ }
16
+
17
+ Object.assign(globalThis, {
18
+ self: globalThis,
19
+ require,
20
+ Worker,
21
+ importScripts: function (f) {
22
+ ;(0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f);
23
+ },
24
+ postMessage: function (msg) {
25
+ if (parentPort) {
26
+ parentPort.postMessage(msg);
27
+ }
28
+ },
29
+ });
30
+
31
+ const emnapiContext = getDefaultContext();
32
+
33
+ const __rootDir = parse(process.cwd()).root;
34
+
35
+ const handler = new MessageHandler({
36
+ onLoad({ wasmModule, wasmMemory }) {
37
+ const wasi = new WASI({
38
+ version: 'preview1',
39
+ env: process.env,
40
+ preopens: {
41
+ [__rootDir]: __rootDir,
42
+ },
43
+ });
44
+
45
+ return instantiateNapiModuleSync(wasmModule, {
46
+ childThread: true,
47
+ wasi,
48
+ context: emnapiContext,
49
+ overwriteImports(importObject) {
50
+ importObject.env = {
51
+ ...importObject.env,
52
+ ...importObject.napi,
53
+ ...importObject.emnapi,
54
+ memory: wasmMemory
55
+ };
56
+ },
57
+ });
58
+ },
59
+ });
60
+
61
+ globalThis.onmessage = function (e) {
62
+ handler.handle(e);
63
+ };
@@ -9,12 +9,12 @@ import { LoadedNxPlugin } from '../plugins/internal-api';
9
9
  * @param nxJson
10
10
  */
11
11
  export declare function retrieveWorkspaceFiles(workspaceRoot: string, projectRootMap: Record<string, string>): Promise<{
12
- allWorkspaceFiles: import("nx/src/devkit-exports").FileData[];
12
+ allWorkspaceFiles: import("../file-utils").FileData[];
13
13
  fileMap: {
14
14
  projectFileMap: ProjectFiles;
15
- nonProjectFiles: import("nx/src/native").FileData[];
15
+ nonProjectFiles: import("../../native").FileData[];
16
16
  };
17
- rustReferences: import("nx/src/native").NxWorkspaceFilesExternals;
17
+ rustReferences: import("../../native").NxWorkspaceFilesExternals;
18
18
  }>;
19
19
  /**
20
20
  * Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
@@ -139,6 +139,9 @@ function messageToCode(message) {
139
139
  }
140
140
  }
141
141
  function supportedPtyPlatform() {
142
+ if (native_1.IS_WASM) {
143
+ return false;
144
+ }
142
145
  if (process.platform !== 'win32') {
143
146
  return true;
144
147
  }
@@ -1,4 +1,4 @@
1
- export declare function findCycle(taskGraph: {
1
+ export declare function findCycle(graph: {
2
2
  dependencies: Record<string, string[]>;
3
3
  }): string[] | null;
4
4
  export declare function makeAcyclic(graph: {
@@ -14,13 +14,13 @@ function _findCycle(graph, id, visited, path) {
14
14
  }
15
15
  return null;
16
16
  }
17
- function findCycle(taskGraph) {
17
+ function findCycle(graph) {
18
18
  const visited = {};
19
- for (const t of Object.keys(taskGraph.dependencies)) {
19
+ for (const t of Object.keys(graph.dependencies)) {
20
20
  visited[t] = false;
21
21
  }
22
- for (const t of Object.keys(taskGraph.dependencies)) {
23
- const cycle = _findCycle(taskGraph, t, visited, [t]);
22
+ for (const t of Object.keys(graph.dependencies)) {
23
+ const cycle = _findCycle(graph, t, visited, [t]);
24
24
  if (cycle)
25
25
  return cycle;
26
26
  }