Skip to content

Commit

Permalink
Deno refactor layout
Browse files Browse the repository at this point in the history
  • Loading branch information
rajsite committed Jul 21, 2024
1 parent c4bdb0e commit c6dddf9
Show file tree
Hide file tree
Showing 42 changed files with 44 additions and 56 deletions.
10 changes: 5 additions & 5 deletions Deno/Deno.gwebproject
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<SourceFile Checksum="284ECB48F9F16EF81BE8761A20B5E978772933537BB3ADAEEA36CB5DD531431970C8996AE6A99DC248129FA36CC5449DF25D28E739481EA7929B63EE43800FAB" xmlns="http://www.ni.com/PlatformFramework">
<SourceFile Checksum="8A8C4B4F6976547BC07097251D4804737C7E55AB71171FCF5442C7FD3FFFF6D382ED96968F8C0925F518BD9E38B26933885A4B09F699F951FE506D068813A2ED" xmlns="http://www.ni.com/PlatformFramework">
<SourceModelFeatureSet>
<ParsableNamespace AssemblyFileVersion="9.5.0.49854" FeatureSetName="GComponentFeatureSet" Name="http://www.ni.com/GComponent.xsd" OldestCompatibleVersion="9.0.0.0" Version="9.0.0.49152" />
<ParsableNamespace AssemblyFileVersion="9.5.0.49854" FeatureSetName="Common language components" Name="http://www.ni.com/MocCommon" OldestCompatibleVersion="8.1.0.49152" Version="8.1.0.49152" />
Expand Down Expand Up @@ -80,8 +80,8 @@
<p2:ComponentConfigurationReferenceDependencySource Id="67bd9a6e78e642ad93fc849b15a16089" Target="DebugTools.gcomp::Configuration1" />
<p2:ComponentConfigurationReferenceDependencySource Id="678f46a65c8343e1b2dc19c1a545b339" Target="Base64.gcomp::Configuration1" />
<p2:ComponentConfigurationReferenceDependencySource Id="a2bb5f8ad8114b17930a0a0441e117e6" Target="Client.gcomp::Configuration1" />
<p2:ComponentConfigurationReferenceDependencySource Id="6225f1617304135ae44c1e95ca2a3a6" Target="Deno.gcomp::Configuration1" />
<p2:ComponentConfigurationReferenceDependencySource Id="45a5365b34744df3a319230e819a13b2" Target="DenoHTTP.gcomp::Configuration1" />
<p2:ComponentConfigurationReferenceDependencySource Id="98bea1f51193471d851f8188b6cbf945" Target="Deno.gcomp::Configuration1" />
<p2:ComponentConfigurationReferenceDependencySource Id="c107e80a848d431c87d2bebcd70fba6a" Target="DenoHTTP.gcomp::Configuration1" />
</p2:BuildSpecificationDefinition>
<EmbeddedDefinitionReference Id="32" ModelDefinitionType="PackageReferencesDefinition" Name="ProjectReferences">
<PackageReferencesDefinition />
Expand Down Expand Up @@ -124,8 +124,8 @@
<SourceFileReference Bindings="ContentKind_{http://www.ni.com/Builders/SystemDesigner/SystemModel}Process.LibraryComponent,{http://www.ni.com/SystemDesigner/EnvoyManagement}ProcessBackedEnvoyServiceMetaFactory,ComponentMoC,{http://www.ni.com/GComponent.xsd}ComponentBaseType_Library,EnvoyManager" Id="bde5ffdcdc4d4afebb184dcbb6a3f9fb" ModelDefinitionType="ComponentDefinition" Name="DebugTools.gcomp" StoragePath="..\DebugTools\DebugTools.gcomp\DebugTools.gcomp" />
<SourceFileReference Bindings="ContentKind_{http://www.ni.com/Builders/SystemDesigner/SystemModel}Process.LibraryComponent,{http://www.ni.com/SystemDesigner/EnvoyManagement}ProcessBackedEnvoyServiceMetaFactory,ComponentMoC,{http://www.ni.com/GComponent.xsd}ComponentBaseType_Library,EnvoyManager" Id="26ea7a5f0a1447deab1f31f2600e63db" ModelDefinitionType="ComponentDefinition" Name="Base64.gcomp" StoragePath="..\File\Base64.gcomp\Base64.gcomp" />
<SourceFileReference Bindings="EnvoyManager,ComponentMoC,{http://www.ni.com/GComponent.xsd}ComponentBaseType_Application,{http://www.ni.com/SystemDesigner/EnvoyManagement}ProcessBackedEnvoyServiceMetaFactory,ContentKind_{http://www.ni.com/Builders/SystemDesigner/SystemModel}Process.ApplicationComponent" Id="bdbc51eab9b84fca9d2d1210d30cbfeb" ModelDefinitionType="ComponentDefinition" Name="Client.gcomp" StoragePath="Client.gcomp\Client.gcomp" />
<SourceFileReference Bindings="ContentKind_{http://www.ni.com/Builders/SystemDesigner/SystemModel}Process.LibraryComponent,{http://www.ni.com/SystemDesigner/EnvoyManagement}ProcessBackedEnvoyServiceMetaFactory,ComponentMoC,{http://www.ni.com/GComponent.xsd}ComponentBaseType_Library,EnvoyManager" Id="eff9d8db21cd49b397f0c6c71e13f2ce" ModelDefinitionType="ComponentDefinition" Name="Deno.gcomp" StoragePath="Packages\GWeb\Deno.gcomp\Deno.gcomp" />
<SourceFileReference Bindings="ContentKind_{http://www.ni.com/Builders/SystemDesigner/SystemModel}Process.LibraryComponent,{http://www.ni.com/SystemDesigner/EnvoyManagement}ProcessBackedEnvoyServiceMetaFactory,ComponentMoC,{http://www.ni.com/GComponent.xsd}ComponentBaseType_Library,EnvoyManager" Id="75c7d63e4d82406fa4e75faa395b333a" ModelDefinitionType="ComponentDefinition" Name="DenoHTTP.gcomp" StoragePath="Packages\GWeb\DenoHTTP.gcomp\DenoHTTP.gcomp" />
<SourceFileReference Bindings="ContentKind_{http://www.ni.com/Builders/SystemDesigner/SystemModel}Process.LibraryComponent,{http://www.ni.com/SystemDesigner/EnvoyManagement}ProcessBackedEnvoyServiceMetaFactory,ComponentMoC,{http://www.ni.com/GComponent.xsd}ComponentBaseType_Library,EnvoyManager" Id="d7b0fc7db348473a8779dd82634392d2" ModelDefinitionType="ComponentDefinition" Name="Deno.gcomp" StoragePath="Library\Components\Deno.gcomp\Deno.gcomp" />
<SourceFileReference Bindings="ContentKind_{http://www.ni.com/Builders/SystemDesigner/SystemModel}Process.LibraryComponent,{http://www.ni.com/SystemDesigner/EnvoyManagement}ProcessBackedEnvoyServiceMetaFactory,ComponentMoC,{http://www.ni.com/GComponent.xsd}ComponentBaseType_Library,EnvoyManager" Id="9c6eef9b2b144dc7b3a9f8493659864f" ModelDefinitionType="ComponentDefinition" Name="DenoHTTP.gcomp" StoragePath="Library\Components\DenoHTTP.gcomp\DenoHTTP.gcomp" />
</NameScopingEnvoy>
</NameScopingEnvoy>
</EmbeddedDefinitionReference>
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions Deno/Library/Components/Deno.gcomp/Support/Deno.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '../../../../Library/Support/Deno/deno.ts';
1 change: 1 addition & 0 deletions Deno/Library/Components/DenoHTTP.gcomp/Support/DenoHTTP.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '../../../../Library/Support/DenoHTTP/deno-http.ts';
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions Deno/Library/Support/Runtime/runtime-helper.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { runViaCodeLines } from "./runtime-helper.ts";

Deno.test(async function runtimeHelperHelloWorld() {
await runViaCodeLines(['start(dv(VirtualInstrument (clump(Println("Hello, sky. I can fly")))))']);
});
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { XMLHttpRequest } from '@kitsonk/xhr';
import '@kitsonk/xhr';
import './Support/node_modules/webvi-websockets/source/main.js';
import vireoHelpers from './Support/node_modules/vireo/source/core/vireo.loader.wasm32-unknown-emscripten.release.js';
import { vireoDataUrl } from "./Support/vireo-data-url.js";

async function createInstance () {
const customGlobalWithBuiltins = Object.create(globalThis);
// TODO Currently the global is mutated to include NationalInstrumentsWebSockets based on the webvi-websockets import style
// customGlobalWithBuiltins.NationalInstrumentsWebSockets = webviWebsockets(WebSocket);

// @ts-ignore TODO deno doesn't understand default exports?
const vireo = await vireoHelpers.createInstance({
wasmUrl: vireoDataUrl
});

vireo.javaScriptInvoke.registerCustomGlobal(customGlobalWithBuiltins);
vireo.httpClient.setXMLHttpRequestImplementation(XMLHttpRequest);

const notSupportedError = () => {
throw new Error('Unsupported on this target');
};
Expand Down Expand Up @@ -52,7 +45,7 @@ declare namespace globalThis {
let vireoHelpers: unknown;
}

export async function run(viaCode: string) {
async function run(viaCode: string) {
if (globalThis.vireoInstance || globalThis.vireoHelpers) {
throw new Error('Vireo already instantiated globally');
}
Expand All @@ -64,3 +57,8 @@ export async function run(viaCode: string) {
globalThis.vireoHelpers = vireoHelpers;
await vireo.eggShell.executeSlicesUntilClumpsFinished();
}

export async function runViaCodeLines(viaCodeLines: string[]) {
const viaCode = viaCodeLines.join('\n');
await run(viaCode);
}
9 changes: 0 additions & 9 deletions Deno/Packages/BuildTools/all-typescript-packages.ts

This file was deleted.

1 change: 0 additions & 1 deletion Deno/Packages/GWeb/Deno.gcomp/Support/Deno.js

This file was deleted.

1 change: 0 additions & 1 deletion Deno/Packages/GWeb/DenoHTTP.gcomp/Support/DenoHTTP.js

This file was deleted.

5 changes: 0 additions & 5 deletions Deno/Packages/TypeScript/Runtime/runtime-helper.test.ts

This file was deleted.

9 changes: 9 additions & 0 deletions Deno/Support/all-typescript-packages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Package to reference all modules with deno imports
// to use with vendoring / lock file creation

import './make-main.ts';
import './make-vireo-dataurl.ts';
import '../Library/Support/Deno/deno.ts';
import '../Library/Support/DenoHTTP/deno-http.ts';
import '../Library/Support/Runtime/runtime-helper.ts';
import '../Library/Support/Runtime/runtime-helper.test.ts';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DOMParser, Element, Node } from '@b-fuze/deno-dom/wasm';

// Assumes main.html is at the root of the WebApp build output
const htmlUrl = new URL('../../Builds/Server_Default Web Server/main.html', import.meta.url);
const htmlUrl = new URL('../Builds/Server_Default Web Server/main.html', import.meta.url);

interface ExtractedUrls {
vireoSource: string;
Expand All @@ -26,21 +26,13 @@ function createMainContent (extractedUrls: ExtractedUrls, viaCode: string) {
.map(url => url.startsWith('.') ? url : `./${url}`)
.map(url => `import '${url}';`)
.join('\n');
const viaCodeLines = viaCode
.split('\n')
// A JSON encoded string becomes a valid JavaScript string literal
// we insert that string literal directly in the generated JS
// and because it is a valid literal we don't JSON.parse it
.map(line => JSON.stringify(line));
const viaCodeLines = JSON.stringify(viaCode.split('\n'), undefined, 4);
const mainTemplate = `
${formattedScriptSources}
import {run} from '../../Packages/TypeScript/Runtime/runtime-helper.ts';
const viaCode = viaCodeLines().join('\\n');
await run(viaCode);
import { runViaCodeLines } from '../../Library/Support/Runtime/runtime-helper.ts';
await runViaCodeLines(viaCodeLines());
function viaCodeLines () {
return [
${viaCodeLines.join(',\n')}
];
return ${viaCodeLines};
}
`;
const main = mainTemplate.split('\n')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

const vireoUrl = new URL('../TypeScript/Runtime/Support/node_modules/vireo/dist/wasm32-unknown-emscripten/release/vireo.core.wasm', import.meta.url);
const vireoUrl = new URL('../Library/Support/Runtime/Support/node_modules/vireo/dist/wasm32-unknown-emscripten/release/vireo.core.wasm', import.meta.url);
const data = await Deno.readFile(vireoUrl);
const encodedData = encode(data);
const vireoDataUrlContents = `export const vireoDataUrl = 'data:application/wasm;base64,${encodedData}';`;
const vireoDataUrlContentsPath = new URL('../TypeScript/Runtime/Support/vireo-data-url.js', import.meta.url);
const vireoDataUrlContentsPath = new URL('../Library/Support/Runtime/Support/vireo-data-url.js', import.meta.url);

function encode (data: Uint8Array) {
let binaryString = '';
Expand Down
20 changes: 9 additions & 11 deletions Deno/deno.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{
"tasks": {
"start": "deno task env && deno task build && deno task start:typescript",
"start:typescript": "deno run -A \"./Builds/Server_Default Web Server/main.ts\"",
"start": "deno task env && deno task build && deno task start:run",
"start:run": "deno run -A \"./Builds/Server_Default Web Server/main.ts\"",
"build": "deno task env && deno task build:client && deno task build:server",
"build:client": "deno task build:client:gweb",
"build:client:gweb": "\"C:/Program Files/National Instruments/G Web Development Software/gwebcli.exe\" build-application -p ./Deno.gwebproject -t \"Default Web Server\" -n Client.gcomp",
"build:server": "deno task build:server:gweb && deno task build:server:typescript",
"build:server:gweb": "\"C:/Program Files/National Instruments/G Web Development Software/gwebcli.exe\" build-application -p ./Deno.gwebproject -t \"Default Web Server\" -n Server.gcomp",
"build:server:typescript": "deno run -A ./Packages/BuildTools/make-main.ts",
"build:client": "deno task gweb:build -n Client.gcomp",
"build:server": "deno task gweb:build -n Server.gcomp && deno run -A ./Support/make-main.ts",
"publish": "deno task env && deno task build && deno task publish:deployctl",
"publish:deployctl": "deployctl deploy --import-map=./deno.json",
"env": "export DENO_TLS_CA_STORE=mozilla,system",
"tool:rebuild-vireo-data-url": "deno run -A ./Packages/BuildTools/make-vireo-dataurl.ts",
"gweb:build": "\"C:/Program Files/National Instruments/G Web Development Software/gwebcli.exe\" build-application -p ./Deno.gwebproject -t \"Default Web Server\"",
"tool:rebuild-vireo-data-url": "deno run -A ./Support/make-vireo-dataurl.ts",
"tool:deno-test": "deno test -A",
"tool:deno-compile": "deno task env && deno task build && deno compile -A \"./Builds/Server_Default Web Server/main.ts\"",
"tool:deno-cache": "deno cache ./Packages/BuildTools/all-typescript-packages.ts"
"tool:deno-cache": "deno cache ./Support/all-typescript-packages.ts"
},
"imports": {
"@b-fuze/deno-dom": "jsr:@b-fuze/deno-dom@^0.1.47",
Expand All @@ -27,9 +25,9 @@
"include": [
"deno.json",
"./Builds/**/*",
"./Packages/TypeScript/**/*",
"./Library/Support/**/*",
"./Builds/**/node_modules/*",
"./Packages/TypeScript/**/node_modules/*"
"./Library/Support/**/node_modules/*"
],
"entrypoint": "Builds\\Server_Default Web Server\\main.ts"
}
Expand Down

0 comments on commit c6dddf9

Please sign in to comment.