initPromise in main.ts (#6285)
* initPromise in main.ts Signed-off-by: Jess Frazelle <github@jessfraz.com> * move initPromise so dep tree doesnt shit the bed Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -20,7 +20,7 @@ import type {
|
|||||||
} from '@src/editor/plugins/lsp/types'
|
} from '@src/editor/plugins/lsp/types'
|
||||||
import { LspWorker } from '@src/editor/plugins/lsp/types'
|
import { LspWorker } from '@src/editor/plugins/lsp/types'
|
||||||
import Worker from '@src/editor/plugins/lsp/worker.ts?worker'
|
import Worker from '@src/editor/plugins/lsp/worker.ts?worker'
|
||||||
import { wasmUrl } from '@src/lang/wasm'
|
import { wasmUrl } from '@src/lang/wasmUtils'
|
||||||
import { PROJECT_ENTRYPOINT } from '@src/lib/constants'
|
import { PROJECT_ENTRYPOINT } from '@src/lib/constants'
|
||||||
import { isDesktop } from '@src/lib/isDesktop'
|
import { isDesktop } from '@src/lib/isDesktop'
|
||||||
import { PATHS } from '@src/lib/paths'
|
import { PATHS } from '@src/lib/paths'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { processMemory } from '@src/components/ModelingSidebar/ModelingPanes/MemoryPane'
|
import { processMemory } from '@src/components/ModelingSidebar/ModelingPanes/MemoryPane'
|
||||||
import { assertParse, initPromise } from '@src/lang/wasm'
|
import { assertParse } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -7,7 +7,7 @@ import ModalContainer from 'react-modal-promise'
|
|||||||
import { Router } from '@src/Router'
|
import { Router } from '@src/Router'
|
||||||
import { ToastUpdate } from '@src/components/ToastUpdate'
|
import { ToastUpdate } from '@src/components/ToastUpdate'
|
||||||
import '@src/index.css'
|
import '@src/index.css'
|
||||||
import { initPromise } from '@src/lang/wasm'
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { AUTO_UPDATER_TOAST_ID } from '@src/lib/constants'
|
import { AUTO_UPDATER_TOAST_ID } from '@src/lib/constants'
|
||||||
import { initializeWindowExceptionHandler } from '@src/lib/exceptions'
|
import { initializeWindowExceptionHandler } from '@src/lib/exceptions'
|
||||||
import { isDesktop } from '@src/lib/isDesktop'
|
import { isDesktop } from '@src/lib/isDesktop'
|
||||||
|
@ -30,13 +30,8 @@ import type {
|
|||||||
SourceRange,
|
SourceRange,
|
||||||
VariableMap,
|
VariableMap,
|
||||||
} from '@src/lang/wasm'
|
} from '@src/lang/wasm'
|
||||||
import {
|
import { emptyExecState, getKclVersion, parse, recast } from '@src/lang/wasm'
|
||||||
emptyExecState,
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
getKclVersion,
|
|
||||||
initPromise,
|
|
||||||
parse,
|
|
||||||
recast,
|
|
||||||
} from '@src/lang/wasm'
|
|
||||||
import type { ArtifactIndex } from '@src/lib/artifactIndex'
|
import type { ArtifactIndex } from '@src/lib/artifactIndex'
|
||||||
import { buildArtifactIndex } from '@src/lib/artifactIndex'
|
import { buildArtifactIndex } from '@src/lib/artifactIndex'
|
||||||
import {
|
import {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { assertParse, initPromise } from '@src/lang/wasm'
|
import { assertParse } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -4,7 +4,8 @@ import { KCLError } from '@src/lang/errors'
|
|||||||
import { defaultArtifactGraph } from '@src/lang/std/artifactGraph'
|
import { defaultArtifactGraph } from '@src/lang/std/artifactGraph'
|
||||||
import { topLevelRange } from '@src/lang/util'
|
import { topLevelRange } from '@src/lang/util'
|
||||||
import type { Sketch } from '@src/lang/wasm'
|
import type { Sketch } from '@src/lang/wasm'
|
||||||
import { assertParse, initPromise, sketchFromKclValue } from '@src/lang/wasm'
|
import { assertParse, sketchFromKclValue } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -5,7 +5,8 @@ import { ARG_INDEX_FIELD, LABELED_ARG_FIELD } from '@src/lang/queryAstConstants'
|
|||||||
import { getNodePathFromSourceRange } from '@src/lang/queryAstNodePathUtils'
|
import { getNodePathFromSourceRange } from '@src/lang/queryAstNodePathUtils'
|
||||||
import { topLevelRange } from '@src/lang/util'
|
import { topLevelRange } from '@src/lang/util'
|
||||||
import type { Parameter } from '@src/lang/wasm'
|
import type { Parameter } from '@src/lang/wasm'
|
||||||
import { assertParse, initPromise } from '@src/lang/wasm'
|
import { assertParse } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import fs from 'node:fs/promises'
|
import fs from 'node:fs/promises'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
|
||||||
import { assertParse, initPromise } from '@src/lang/wasm'
|
import { assertParse } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
|
|
||||||
// The purpose of these tests is to act as a first line of defense
|
// The purpose of these tests is to act as a first line of defense
|
||||||
|
@ -28,7 +28,8 @@ import { codeRefFromRange } from '@src/lang/std/artifactGraph'
|
|||||||
import type { InputArgKeys, SimplifiedArgDetails } from '@src/lang/std/stdTypes'
|
import type { InputArgKeys, SimplifiedArgDetails } from '@src/lang/std/stdTypes'
|
||||||
import { topLevelRange } from '@src/lang/util'
|
import { topLevelRange } from '@src/lang/util'
|
||||||
import type { Identifier, Literal, LiteralValue } from '@src/lang/wasm'
|
import type { Identifier, Literal, LiteralValue } from '@src/lang/wasm'
|
||||||
import { assertParse, initPromise, recast } from '@src/lang/wasm'
|
import { assertParse, recast } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ import type {
|
|||||||
SourceRange,
|
SourceRange,
|
||||||
VariableDeclarator,
|
VariableDeclarator,
|
||||||
} from '@src/lang/wasm'
|
} from '@src/lang/wasm'
|
||||||
import { assertParse, initPromise, recast } from '@src/lang/wasm'
|
import { assertParse, recast } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import type { Selection, Selections } from '@src/lib/selections'
|
import type { Selection, Selections } from '@src/lib/selections'
|
||||||
import {
|
import {
|
||||||
codeManager,
|
codeManager,
|
||||||
|
@ -24,7 +24,8 @@ import { codeRefFromRange } from '@src/lang/std/artifactGraph'
|
|||||||
import { addCallExpressionsToPipe, addCloseToPipe } from '@src/lang/std/sketch'
|
import { addCallExpressionsToPipe, addCloseToPipe } from '@src/lang/std/sketch'
|
||||||
import { topLevelRange } from '@src/lang/util'
|
import { topLevelRange } from '@src/lang/util'
|
||||||
import type { Identifier, PathToNode } from '@src/lang/wasm'
|
import type { Identifier, PathToNode } from '@src/lang/wasm'
|
||||||
import { assertParse, initPromise, recast } from '@src/lang/wasm'
|
import { assertParse, recast } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { getIdentifiersInProgram } from '@src/lang/queryAst/getIndentifiersInProgram'
|
import { getIdentifiersInProgram } from '@src/lang/queryAst/getIndentifiersInProgram'
|
||||||
import { assertParse, initPromise } from '@src/lang/wasm'
|
import { assertParse } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
|
|
||||||
function identifier(name: string, start: number, end: number) {
|
function identifier(name: string, start: number, end: number) {
|
||||||
return {
|
return {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { getSafeInsertIndex } from '@src/lang/queryAst/getSafeInsertIndex'
|
import { getSafeInsertIndex } from '@src/lang/queryAst/getSafeInsertIndex'
|
||||||
import { assertParse, initPromise } from '@src/lang/wasm'
|
import { assertParse } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await initPromise
|
await initPromise
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { getTagDeclaratorsInProgram } from '@src/lang/queryAst/getTagDeclaratorsInProgram'
|
import { getTagDeclaratorsInProgram } from '@src/lang/queryAst/getTagDeclaratorsInProgram'
|
||||||
import { assertParse, initPromise } from '@src/lang/wasm'
|
import { assertParse } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
|
|
||||||
function tagDeclaratorWithIndex(
|
function tagDeclaratorWithIndex(
|
||||||
value: string,
|
value: string,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
|
|
||||||
import type { Program } from '@src/lang/wasm'
|
import type { Program } from '@src/lang/wasm'
|
||||||
import { assertParse, initPromise, recast } from '@src/lang/wasm'
|
import { assertParse, recast } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -14,7 +14,8 @@ import {
|
|||||||
} from '@src/lang/std/sketch'
|
} from '@src/lang/std/sketch'
|
||||||
import { topLevelRange } from '@src/lang/util'
|
import { topLevelRange } from '@src/lang/util'
|
||||||
import type { CallExpression, CallExpressionKw } from '@src/lang/wasm'
|
import type { CallExpression, CallExpressionKw } from '@src/lang/wasm'
|
||||||
import { assertParse, initPromise, recast } from '@src/lang/wasm'
|
import { assertParse, recast } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
|
|
||||||
|
@ -7,12 +7,8 @@ import {
|
|||||||
} from '@src/lang/std/sketchcombos'
|
} from '@src/lang/std/sketchcombos'
|
||||||
import { topLevelRange } from '@src/lang/util'
|
import { topLevelRange } from '@src/lang/util'
|
||||||
import type { Sketch, SourceRange } from '@src/lang/wasm'
|
import type { Sketch, SourceRange } from '@src/lang/wasm'
|
||||||
import {
|
import { assertParse, recast, sketchFromKclValue } from '@src/lang/wasm'
|
||||||
assertParse,
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
initPromise,
|
|
||||||
recast,
|
|
||||||
sketchFromKclValue,
|
|
||||||
} from '@src/lang/wasm'
|
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@ import {
|
|||||||
} from '@src/lang/std/sketchcombos'
|
} from '@src/lang/std/sketchcombos'
|
||||||
import { findKwArg, topLevelRange } from '@src/lang/util'
|
import { findKwArg, topLevelRange } from '@src/lang/util'
|
||||||
import type { Expr, Program } from '@src/lang/wasm'
|
import type { Expr, Program } from '@src/lang/wasm'
|
||||||
import { assertParse, initPromise, recast } from '@src/lang/wasm'
|
import { assertParse, recast } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import type { Selection, Selections } from '@src/lib/selections'
|
import type { Selection, Selections } from '@src/lib/selections'
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { assertParse, initPromise } from '@src/lang/wasm'
|
import { assertParse } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -2,7 +2,8 @@ import type { Node } from '@rust/kcl-lib/bindings/Node'
|
|||||||
import type { Program } from '@rust/kcl-lib/bindings/Program'
|
import type { Program } from '@rust/kcl-lib/bindings/Program'
|
||||||
|
|
||||||
import type { ParseResult } from '@src/lang/wasm'
|
import type { ParseResult } from '@src/lang/wasm'
|
||||||
import { formatNumber, initPromise, parse } from '@src/lang/wasm'
|
import { formatNumber, parse } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { enginelessExecutor } from '@src/lib/testHelpers'
|
import { enginelessExecutor } from '@src/lib/testHelpers'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ import {
|
|||||||
format_number,
|
format_number,
|
||||||
get_kcl_version,
|
get_kcl_version,
|
||||||
get_tangential_arc_to_info,
|
get_tangential_arc_to_info,
|
||||||
init,
|
|
||||||
is_kcl_empty_or_only_settings,
|
is_kcl_empty_or_only_settings,
|
||||||
is_points_ccw,
|
is_points_ccw,
|
||||||
kcl_lint,
|
kcl_lint,
|
||||||
@ -59,7 +58,6 @@ import {
|
|||||||
parse_project_settings,
|
parse_project_settings,
|
||||||
parse_wasm,
|
parse_wasm,
|
||||||
recast_wasm,
|
recast_wasm,
|
||||||
reloadModule,
|
|
||||||
serialize_configuration,
|
serialize_configuration,
|
||||||
serialize_project_configuration,
|
serialize_project_configuration,
|
||||||
} from '@src/lib/wasm_lib_wrapper'
|
} from '@src/lib/wasm_lib_wrapper'
|
||||||
@ -158,36 +156,6 @@ function firstSourceRange(error: RustKclError): SourceRange {
|
|||||||
: defaultSourceRange()
|
: defaultSourceRange()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const wasmUrl = () => {
|
|
||||||
// For when we're in electron (file based) or web server (network based)
|
|
||||||
// For some reason relative paths don't work as expected. Otherwise we would
|
|
||||||
// just do /wasm_lib_bg.wasm. In particular, the issue arises when the path
|
|
||||||
// is used from within worker.ts.
|
|
||||||
const fullUrl = document.location.protocol.includes('http')
|
|
||||||
? document.location.origin + '/kcl_wasm_lib_bg.wasm'
|
|
||||||
: document.location.protocol +
|
|
||||||
document.location.pathname.split('/').slice(0, -1).join('/') +
|
|
||||||
'/kcl_wasm_lib_bg.wasm'
|
|
||||||
|
|
||||||
return fullUrl
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialise the wasm module.
|
|
||||||
const initialise = async () => {
|
|
||||||
try {
|
|
||||||
await reloadModule()
|
|
||||||
const fullUrl = wasmUrl()
|
|
||||||
const input = await fetch(fullUrl)
|
|
||||||
const buffer = await input.arrayBuffer()
|
|
||||||
return await init({ module_or_path: buffer })
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error initialising WASM', e)
|
|
||||||
return Promise.reject(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const initPromise = initialise()
|
|
||||||
|
|
||||||
const splitErrors = (
|
const splitErrors = (
|
||||||
input: CompilationError[]
|
input: CompilationError[]
|
||||||
): { errors: CompilationError[]; warnings: CompilationError[] } => {
|
): { errors: CompilationError[]; warnings: CompilationError[] } => {
|
||||||
|
@ -2,6 +2,37 @@ import {
|
|||||||
import_file_extensions,
|
import_file_extensions,
|
||||||
relevant_file_extensions,
|
relevant_file_extensions,
|
||||||
} from '@rust/kcl-wasm-lib/pkg/kcl_wasm_lib'
|
} from '@rust/kcl-wasm-lib/pkg/kcl_wasm_lib'
|
||||||
|
import { init, reloadModule } from '@src/lib/wasm_lib_wrapper'
|
||||||
|
|
||||||
|
export const wasmUrl = () => {
|
||||||
|
// For when we're in electron (file based) or web server (network based)
|
||||||
|
// For some reason relative paths don't work as expected. Otherwise we would
|
||||||
|
// just do /wasm_lib_bg.wasm. In particular, the issue arises when the path
|
||||||
|
// is used from within worker.ts.
|
||||||
|
const fullUrl = document.location.protocol.includes('http')
|
||||||
|
? document.location.origin + '/kcl_wasm_lib_bg.wasm'
|
||||||
|
: document.location.protocol +
|
||||||
|
document.location.pathname.split('/').slice(0, -1).join('/') +
|
||||||
|
'/kcl_wasm_lib_bg.wasm'
|
||||||
|
|
||||||
|
return fullUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialise the wasm module.
|
||||||
|
const initialise = async () => {
|
||||||
|
try {
|
||||||
|
await reloadModule()
|
||||||
|
const fullUrl = wasmUrl()
|
||||||
|
const input = await fetch(fullUrl)
|
||||||
|
const buffer = await input.arrayBuffer()
|
||||||
|
return await init({ module_or_path: buffer })
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Error initialising WASM', e)
|
||||||
|
return Promise.reject(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initPromise = initialise()
|
||||||
|
|
||||||
export function importFileExtensions(): string[] {
|
export function importFileExtensions(): string[] {
|
||||||
return import_file_extensions()
|
return import_file_extensions()
|
||||||
|
41
src/lang/wasmUtilsNode.ts
Normal file
41
src/lang/wasmUtilsNode.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { init, reloadModule } from '@src/lib/wasm_lib_wrapper'
|
||||||
|
import fs from 'fs'
|
||||||
|
import fsPromises from 'fs/promises'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
export const wasmUrlNode = () => {
|
||||||
|
// In prod the file will be right next to the compiled js file.
|
||||||
|
const prodPath = path.join(__dirname, 'kcl_wasm_lib_bg.wasm')
|
||||||
|
// Check if the file exists.
|
||||||
|
if (fs.existsSync(prodPath)) {
|
||||||
|
console.log('Found wasm file in prod', prodPath)
|
||||||
|
return prodPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the wasm module from public/kcl_wasm_lib_bg.wasm
|
||||||
|
console.log('Using dev wasm file')
|
||||||
|
const devPath = path.join(
|
||||||
|
__dirname,
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'public',
|
||||||
|
'kcl_wasm_lib_bg.wasm'
|
||||||
|
)
|
||||||
|
console.log('Using dev wasm file', devPath)
|
||||||
|
return devPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialise the wasm module.
|
||||||
|
const initialiseNode = async () => {
|
||||||
|
try {
|
||||||
|
await reloadModule()
|
||||||
|
const fullPath = wasmUrlNode()
|
||||||
|
const buffer = await fsPromises.readFile(fullPath)
|
||||||
|
return await init({ module_or_path: buffer })
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Error initialising WASM', e)
|
||||||
|
return Promise.reject(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initPromiseNode = initialiseNode()
|
@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|||||||
|
|
||||||
import type { Configuration } from '@rust/kcl-lib/bindings/Configuration'
|
import type { Configuration } from '@rust/kcl-lib/bindings/Configuration'
|
||||||
|
|
||||||
import { initPromise } from '@src/lang/wasm'
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { listProjects } from '@src/lib/desktop'
|
import { listProjects } from '@src/lib/desktop'
|
||||||
import type { DeepPartial } from '@src/lib/types'
|
import type { DeepPartial } from '@src/lib/types'
|
||||||
|
|
||||||
|
@ -6,11 +6,10 @@ import type { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfigu
|
|||||||
import { newKclFile } from '@src/lang/project'
|
import { newKclFile } from '@src/lang/project'
|
||||||
import {
|
import {
|
||||||
defaultAppSettings,
|
defaultAppSettings,
|
||||||
initPromise,
|
|
||||||
parseAppSettings,
|
parseAppSettings,
|
||||||
parseProjectSettings,
|
parseProjectSettings,
|
||||||
} from '@src/lang/wasm'
|
} from '@src/lang/wasm'
|
||||||
import { relevantFileExtensions } from '@src/lang/wasmUtils'
|
import { initPromise, relevantFileExtensions } from '@src/lang/wasmUtils'
|
||||||
import {
|
import {
|
||||||
DEFAULT_DEFAULT_LENGTH_UNIT,
|
DEFAULT_DEFAULT_LENGTH_UNIT,
|
||||||
PROJECT_ENTRYPOINT,
|
PROJECT_ENTRYPOINT,
|
||||||
|
@ -3,7 +3,7 @@ import os from 'os'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
import { initPromise } from '@src/lang/wasm'
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import getCurrentProjectFile from '@src/lib/getCurrentProjectFile'
|
import getCurrentProjectFile from '@src/lib/getCurrentProjectFile'
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -4,7 +4,8 @@ import { getNodeFromPath } from '@src/lang/queryAst'
|
|||||||
import { getNodePathFromSourceRange } from '@src/lang/queryAstNodePathUtils'
|
import { getNodePathFromSourceRange } from '@src/lang/queryAstNodePathUtils'
|
||||||
import { topLevelRange } from '@src/lang/util'
|
import { topLevelRange } from '@src/lang/util'
|
||||||
import type { VariableDeclaration } from '@src/lang/wasm'
|
import type { VariableDeclaration } from '@src/lang/wasm'
|
||||||
import { assertParse, initPromise, recast } from '@src/lang/wasm'
|
import { assertParse, recast } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { updateCenterRectangleSketch } from '@src/lib/rectangleTool'
|
import { updateCenterRectangleSketch } from '@src/lib/rectangleTool'
|
||||||
import { trap } from '@src/lib/trap'
|
import { trap } from '@src/lib/trap'
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ import type { ExecState } from '@src/lang/wasm'
|
|||||||
import {
|
import {
|
||||||
errFromErrWithOutputs,
|
errFromErrWithOutputs,
|
||||||
execStateFromRust,
|
execStateFromRust,
|
||||||
initPromise,
|
|
||||||
mockExecStateFromRust,
|
mockExecStateFromRust,
|
||||||
} from '@src/lang/wasm'
|
} from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import type ModelingAppFile from '@src/lib/modelingAppFile'
|
import type ModelingAppFile from '@src/lib/modelingAppFile'
|
||||||
import type { DefaultPlaneStr } from '@src/lib/planes'
|
import type { DefaultPlaneStr } from '@src/lib/planes'
|
||||||
import { defaultPlaneStrToKey } from '@src/lib/planes'
|
import { defaultPlaneStrToKey } from '@src/lib/planes'
|
||||||
|
@ -3,7 +3,8 @@ import { expect } from 'vitest'
|
|||||||
import { getNodePathFromSourceRange } from '@src/lang/queryAstNodePathUtils'
|
import { getNodePathFromSourceRange } from '@src/lang/queryAstNodePathUtils'
|
||||||
import type { Artifact } from '@src/lang/std/artifactGraph'
|
import type { Artifact } from '@src/lang/std/artifactGraph'
|
||||||
import type { ArtifactGraph, SourceRange } from '@src/lang/wasm'
|
import type { ArtifactGraph, SourceRange } from '@src/lang/wasm'
|
||||||
import { assertParse, initPromise } from '@src/lang/wasm'
|
import { assertParse } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import type { ArtifactIndex } from '@src/lib/artifactIndex'
|
import type { ArtifactIndex } from '@src/lib/artifactIndex'
|
||||||
import { buildArtifactIndex } from '@src/lib/artifactIndex'
|
import { buildArtifactIndex } from '@src/lib/artifactIndex'
|
||||||
import type { Selection } from '@src/lib/selections'
|
import type { Selection } from '@src/lib/selections'
|
||||||
|
@ -7,12 +7,12 @@ import { TEST } from '@src/env'
|
|||||||
import {
|
import {
|
||||||
defaultAppSettings,
|
defaultAppSettings,
|
||||||
defaultProjectSettings,
|
defaultProjectSettings,
|
||||||
initPromise,
|
|
||||||
parseAppSettings,
|
parseAppSettings,
|
||||||
parseProjectSettings,
|
parseProjectSettings,
|
||||||
serializeConfiguration,
|
serializeConfiguration,
|
||||||
serializeProjectConfiguration,
|
serializeProjectConfiguration,
|
||||||
} from '@src/lang/wasm'
|
} from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
import { mouseControlsToCameraSystem } from '@src/lib/cameraControls'
|
import { mouseControlsToCameraSystem } from '@src/lib/cameraControls'
|
||||||
import { BROWSER_PROJECT_NAME } from '@src/lib/constants'
|
import { BROWSER_PROJECT_NAME } from '@src/lib/constants'
|
||||||
import {
|
import {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import type { Coords2d } from '@src/lang/std/sketch'
|
import type { Coords2d } from '@src/lang/std/sketch'
|
||||||
import { initPromise, isPointsCCW } from '@src/lang/wasm'
|
import { isPointsCCW } from '@src/lang/wasm'
|
||||||
|
import { initPromise } from '@src/lang/wasmUtils'
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await initPromise
|
await initPromise
|
||||||
|
@ -28,6 +28,7 @@ import {
|
|||||||
getPathOrUrlFromArgs,
|
getPathOrUrlFromArgs,
|
||||||
parseCLIArgs,
|
parseCLIArgs,
|
||||||
} from '@src/commandLineArgs'
|
} from '@src/commandLineArgs'
|
||||||
|
import { initPromiseNode } from '@src/lang/wasmUtilsNode'
|
||||||
import { ZOO_STUDIO_PROTOCOL } from '@src/lib/constants'
|
import { ZOO_STUDIO_PROTOCOL } from '@src/lib/constants'
|
||||||
import getCurrentProjectFile from '@src/lib/getCurrentProjectFile'
|
import getCurrentProjectFile from '@src/lib/getCurrentProjectFile'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
@ -512,6 +513,7 @@ app.on('ready', () => {
|
|||||||
const getProjectPathAtStartup = async (
|
const getProjectPathAtStartup = async (
|
||||||
filePath?: string
|
filePath?: string
|
||||||
): Promise<string | null> => {
|
): Promise<string | null> => {
|
||||||
|
await initPromiseNode
|
||||||
// If we are in development mode, we don't want to load a project at
|
// If we are in development mode, we don't want to load a project at
|
||||||
// startup.
|
// startup.
|
||||||
// Since the args passed are always '.'
|
// Since the args passed are always '.'
|
||||||
|
Reference in New Issue
Block a user