SpawnGen Studio f0ac219 (the GitHub Pages AOT build, base href /) (part 2)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +4 -0
- README.md +43 -5
- SpawnDev.SpawnJS.zrbbeqadpn.lib.module.js +1537 -0
- SpawnDev.SpawnJS.zrbbeqadpn.lib.module.js.br +0 -0
- SpawnDev.SpawnJS.zrbbeqadpn.lib.module.js.gz +3 -0
- _framework/System.Text.Encodings.Web.tji6rumfic.wasm +3 -0
- _framework/System.Text.Encodings.Web.tji6rumfic.wasm.br +0 -0
- _framework/System.Text.Encodings.Web.tji6rumfic.wasm.gz +3 -0
- _framework/System.Text.Json.wmn8nrdgsp.wasm +3 -0
- _framework/System.Text.Json.wmn8nrdgsp.wasm.br +3 -0
- _framework/System.Text.Json.wmn8nrdgsp.wasm.gz +3 -0
- _framework/System.Text.RegularExpressions.5f6os8d0wv.wasm +3 -0
- _framework/System.Text.RegularExpressions.5f6os8d0wv.wasm.br +3 -0
- _framework/System.Text.RegularExpressions.5f6os8d0wv.wasm.gz +3 -0
- _framework/System.Threading.Tasks.Parallel.r9rdy25k8s.wasm +3 -0
- _framework/System.Threading.Tasks.Parallel.r9rdy25k8s.wasm.br +0 -0
- _framework/System.Threading.Tasks.Parallel.r9rdy25k8s.wasm.gz +3 -0
- _framework/System.Threading.Thread.u9w6y2s95v.wasm +3 -0
- _framework/System.Threading.Thread.u9w6y2s95v.wasm.br +0 -0
- _framework/System.Threading.Thread.u9w6y2s95v.wasm.gz +3 -0
- _framework/System.Threading.cqof8b7mz4.wasm +3 -0
- _framework/System.Threading.cqof8b7mz4.wasm.br +0 -0
- _framework/System.Threading.cqof8b7mz4.wasm.gz +3 -0
- _framework/System.Xml.Linq.6wuwtpojma.wasm +3 -0
- _framework/System.Xml.Linq.6wuwtpojma.wasm.br +0 -0
- _framework/System.Xml.Linq.6wuwtpojma.wasm.gz +3 -0
- _framework/System.Xml.XDocument.amngb6ohpq.wasm +3 -0
- _framework/System.Xml.XDocument.amngb6ohpq.wasm.br +0 -0
- _framework/System.Xml.XDocument.amngb6ohpq.wasm.gz +3 -0
- css/app.css +334 -0
- css/app.css.br +0 -0
- css/app.css.gz +3 -0
- examples/depth.json +27 -0
- examples/depth.json.br +0 -0
- examples/depth.json.gz +3 -0
- examples/detect.json +58 -0
- examples/detect.json.br +0 -0
- examples/detect.json.gz +3 -0
- examples/example.png +3 -0
- examples/example_inpaint.png +3 -0
- examples/flux2-klein-edit.json +34 -0
- examples/flux2-klein-edit.json.br +0 -0
- examples/flux2-klein-edit.json.gz +3 -0
- examples/flux2-klein.json +24 -0
- examples/flux2-klein.json.br +0 -0
- examples/flux2-klein.json.gz +3 -0
- examples/flux3-klein.json +24 -0
- examples/flux3-klein.json.br +0 -0
- examples/flux3-klein.json.gz +3 -0
- examples/hires-fix.json +124 -0
.gitattributes
CHANGED
|
@@ -54,3 +54,7 @@ _framework/SpawnGen.Nodes.ML.ula38wzxn6.wasm.br filter=lfs diff=lfs merge=lfs -t
|
|
| 54 |
_framework/SpawnGen.Studio.dobkx6cxzg.wasm.br filter=lfs diff=lfs merge=lfs -text
|
| 55 |
_framework/System.Private.CoreLib.jxzjjd418f.wasm.br filter=lfs diff=lfs merge=lfs -text
|
| 56 |
_framework/System.Private.Xml.u94bl2dvp8.wasm.br filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
_framework/SpawnGen.Studio.dobkx6cxzg.wasm.br filter=lfs diff=lfs merge=lfs -text
|
| 55 |
_framework/System.Private.CoreLib.jxzjjd418f.wasm.br filter=lfs diff=lfs merge=lfs -text
|
| 56 |
_framework/System.Private.Xml.u94bl2dvp8.wasm.br filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
_framework/System.Text.Json.wmn8nrdgsp.wasm.br filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
_framework/System.Text.RegularExpressions.5f6os8d0wv.wasm.br filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
examples/example.png filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
examples/example_inpaint.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,10 +1,48 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
|
|
|
| 7 |
pinned: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: SpawnGen
|
| 3 |
+
emoji: 🧩
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: static
|
| 7 |
+
app_file: index.html
|
| 8 |
pinned: false
|
| 9 |
+
license: mit
|
| 10 |
+
short_description: ComfyUI-style node graphs, run on your GPU in the browser
|
| 11 |
+
tags:
|
| 12 |
+
- webgpu
|
| 13 |
+
- comfyui
|
| 14 |
+
- node-graph
|
| 15 |
+
- text-to-image
|
| 16 |
+
- text-to-video
|
| 17 |
+
- image-to-video
|
| 18 |
+
- image-to-3d
|
| 19 |
+
- blazor
|
| 20 |
+
models:
|
| 21 |
+
- stabilityai/sd-turbo
|
| 22 |
+
- stabilityai/sdxl-turbo
|
| 23 |
+
- LostBeard/FLUX.2-klein-4B-q4-ILGPU
|
| 24 |
+
- LostBeard/flux-3-image-klein-q4-ILGPU
|
| 25 |
+
- Lightricks/LTX-2
|
| 26 |
+
- Comfy-Org/Z-Image-Turbo
|
| 27 |
+
- Comfy-Org/ltx-2
|
| 28 |
+
- onnx-community/depth-anything-v2-small
|
| 29 |
+
- onnx-community/Kokoro-82M-v1.0-ONNX
|
| 30 |
+
- istupakov/parakeet-tdt-0.6b-v3-onnx
|
| 31 |
+
- briaai/RMBG-1.4
|
| 32 |
+
- Xenova/movenet-singlepose-lightning
|
| 33 |
+
- salim4n/yolov8n-detect-onnx
|
| 34 |
+
- Qwen/Qwen3-4B
|
| 35 |
---
|
| 36 |
|
| 37 |
+
# SpawnGen
|
| 38 |
+
|
| 39 |
+
A ComfyUI-class node-graph studio written in C#, running **entirely in your browser on your GPU** (WebGPU): no server does the inference.
|
| 40 |
+
ComfyUI workflows and templates open and run as they do in ComfyUI; models download on first use (from Hugging Face) and stay cached in
|
| 41 |
+
the browser.
|
| 42 |
+
|
| 43 |
+
- **Examples**: text to image (SD-Turbo, SD 1.5, FLUX.2 / FLUX 3 Klein), image to image, inpainting, text to video and picture to video
|
| 44 |
+
(LTX-Video 2B), image to 3D (TRELLIS.2), depth, pose and object detection, background removal, speech.
|
| 45 |
+
- **Templates**: ComfyUI's template catalog, each marked with what this browser can run.
|
| 46 |
+
- Needs a browser with WebGPU (Chrome or Edge). Large models need a GPU with enough memory; the first run downloads the weights.
|
| 47 |
+
|
| 48 |
+
Source: [github.com/LostBeard/SpawnGen](https://github.com/LostBeard/SpawnGen) (MIT). Built on SpawnDev.ILGPU and SpawnDev.ILGPU.ML.
|
SpawnDev.SpawnJS.zrbbeqadpn.lib.module.js
ADDED
|
@@ -0,0 +1,1537 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'strict';
|
| 2 |
+
|
| 3 |
+
// SpawnJSInterop - the Javascript half of SpawnJS.
|
| 4 |
+
//
|
| 5 |
+
// Architecture: every JS value that .Net needs to reference is kept in an id-keyed table
|
| 6 |
+
// (spawnJSObjects) and addressed from .Net by that numeric id. .Net never receives a live JS object
|
| 7 |
+
// handle (no Microsoft JSObject), only ids and primitives - which is what lets the .Net side avoid
|
| 8 |
+
// JSObject and its disposal quirk entirely. .Net "holds" a value (spawnJSObjectHold -> id) and later
|
| 9 |
+
// "releases" it (spawnJSObjectRelease) so it can be garbage-collected.
|
| 10 |
+
//
|
| 11 |
+
// Negative ids are reserved sentinels resolved without a table lookup:
|
| 12 |
+
// -1 globalThis, -2 undefined, -3 null, -4 the spawnJSObjects table, SpawnJSInterop.
|
| 13 |
+
//
|
| 14 |
+
// Calls flow through _spawnJSInteropCall (sync) / _spawnJSInteropCallAsync (async). The whole call - which static
|
| 15 |
+
// method here, the returnType code (see ReturnType.cs), every argument - is written by .Net onto its call tape
|
| 16 |
+
// (JSTape.cs) in .Net memory and crosses ONCE: the call reads it straight off the WASM heap and writes the result
|
| 17 |
+
// back over the same frame. Each call carries its dotnetId and frame address, so nothing here is shared between
|
| 18 |
+
// .Net instances beyond this class.
|
| 19 |
+
(function () {
|
| 20 |
+
if (globalThis.SpawnJSInterop) return;
|
| 21 |
+
class SpawnJSInterop {
|
| 22 |
+
// enables verbose logging
|
| 23 |
+
static verbose = globalThis.spawnJSInteropVerbose;
|
| 24 |
+
// ArrayBufferView constructors
|
| 25 |
+
static HeapViewCtors = [
|
| 26 |
+
globalThis.BigInt64Array, // 0: BigInt64Array
|
| 27 |
+
globalThis.BigUint64Array, // 1: BigUInt64Array
|
| 28 |
+
globalThis.Float16Array, // 2: Float16Array
|
| 29 |
+
globalThis.Float32Array, // 3: Float32Array
|
| 30 |
+
globalThis.Float64Array, // 4: Float64Array
|
| 31 |
+
globalThis.Int16Array, // 5: Int16Array
|
| 32 |
+
globalThis.Int32Array, // 6: Int32Array
|
| 33 |
+
globalThis.Int8Array, // 7: Int8Array
|
| 34 |
+
globalThis.Uint16Array, // 8: Uint16Array
|
| 35 |
+
globalThis.Uint32Array, // 9: Uint32Array
|
| 36 |
+
globalThis.Uint8Array, // 10: Uint8Array
|
| 37 |
+
globalThis.Uint8ClampedArray, // 11: Uint8ClampedArray
|
| 38 |
+
globalThis.DataView // 12: DataView
|
| 39 |
+
];
|
| 40 |
+
static _revivers = [];
|
| 41 |
+
static _replacers = [];
|
| 42 |
+
// method names for index based calling as an alternative to string
|
| 43 |
+
static _methodMapNames = [];
|
| 44 |
+
// methods mapped by index for index based calling as an alternative to string
|
| 45 |
+
static _methodMap = [];
|
| 46 |
+
// The id -> JS value table. Holds every value .Net currently references.
|
| 47 |
+
static spawnJSObjects = {};
|
| 48 |
+
// Monotonic id source; never reused, so a stale .Net id can never collide with a live value.
|
| 49 |
+
static _sjsObjectIdNext = 0;
|
| 50 |
+
// .Net Wasm app instance infos
|
| 51 |
+
static _instances = {};
|
| 52 |
+
// .Net callbacks
|
| 53 |
+
static _callbacks = {};
|
| 54 |
+
static _detachedSentinelId = null;
|
| 55 |
+
// static constructor
|
| 56 |
+
static {
|
| 57 |
+
// SpawnJSInterop.registerReviver('__reviverTest', (key, value) => {
|
| 58 |
+
// if (SpawnJSInterop.verbose) console.log('[SpawnJSInterop] reviver test', key, value);
|
| 59 |
+
// return value;
|
| 60 |
+
// });
|
| 61 |
+
// SpawnJSInterop.registerReplacer('__replacerTest', (key, value) => {
|
| 62 |
+
// if (SpawnJSInterop.verbose) console.log('[SpawnJSInterop] replacer test', key, value);
|
| 63 |
+
// return value;
|
| 64 |
+
// });
|
| 65 |
+
SpawnJSInterop.refreshMethodMap();
|
| 66 |
+
// detachedHeap sentinel
|
| 67 |
+
this._detachedSentinelId = setInterval(() => SpawnJSInterop.detachedEventCheck(), 500);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
// JSImports
|
| 71 |
+
// Methods accessed via JSImport only send and recieve basic
|
| 72 |
+
// data types and are used to support the marshalling framework
|
| 73 |
+
// that allows working with much more advanced data types.
|
| 74 |
+
|
| 75 |
+
// JSImport
|
| 76 |
+
// double _registerInstance(
|
| 77 |
+
// JSObject dotnetInstance,
|
| 78 |
+
// [JSMarshalAs<JSType.Function>] Action onMethodAdded,
|
| 79 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.String>>] Action<double, string> onAsyncResolvedVoid,
|
| 80 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.Number, JSType.String>>] Action<double, double, string> onAsyncResolvedDouble,
|
| 81 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.Boolean, JSType.String>>] Action<double, bool, string> onAsyncResolvedBool,
|
| 82 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.String, JSType.String>>] Action<double, string, string> onAsyncResolvedString,
|
| 83 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.Any, JSType.String>>] Action<double, object, string> onAsyncResolvedDoubleNullable,
|
| 84 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.Any, JSType.String>>] Action<double, object, string> onAsyncResolvedBooleanNullable,
|
| 85 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.Number, JSType.String>>] Action<double, int, string> onAsyncResolvedInt32,
|
| 86 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.Any, JSType.String>>] Action<double, object, string> onAsyncResolvedInt32Nullable,
|
| 87 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.Number>>] Action<long, long> onDetachedHeap,
|
| 88 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.Number, JSType.Number>>] Action<double, double, double> onCallback,
|
| 89 |
+
// [JSMarshalAs<JSType.Function<JSType.Number, JSType.Number, JSType.String>>] Action<double, int, string> onAsyncResolvedTape)
|
| 90 |
+
static _registerInstance(
|
| 91 |
+
dotnet,
|
| 92 |
+
onMethodAdded,
|
| 93 |
+
resolveVoid,
|
| 94 |
+
resolveDouble,
|
| 95 |
+
resolveBoolean,
|
| 96 |
+
resolveString,
|
| 97 |
+
resolveDoubleNullable,
|
| 98 |
+
resolveBooleanNullable,
|
| 99 |
+
resolveInt32,
|
| 100 |
+
resolveInt32Nullable,
|
| 101 |
+
onDetachedHeap,
|
| 102 |
+
handleCallback,
|
| 103 |
+
resolveTape
|
| 104 |
+
) {
|
| 105 |
+
if (!dotnet) throw new Error('dotnet not set');
|
| 106 |
+
var instanceInfo = SpawnJSInterop._getInstaceFromDotNet(dotnet);
|
| 107 |
+
if (instanceInfo) return instanceInfo.dotnetId;
|
| 108 |
+
|
| 109 |
+
var dotnetId = SpawnJSInterop.spawnJSObjectHold(dotnet);
|
| 110 |
+
|
| 111 |
+
// attach the heap buffer to instanceInfo so it can be monitored for detach events
|
| 112 |
+
var heapBuffer = SpawnJSInterop.wasmMemoryBuffer(dotnet);
|
| 113 |
+
|
| 114 |
+
var instanceInfo = { heapBuffer, dotnet, dotnetId, onMethodAdded, resolveVoid, resolveDouble, resolveBoolean, resolveString, resolveDoubleNullable, resolveBooleanNullable, resolveInt32, resolveInt32Nullable, handleCallback, onDetachedHeap, resolveTape };
|
| 115 |
+
SpawnJSInterop._instances[dotnetId] = instanceInfo;
|
| 116 |
+
|
| 117 |
+
instanceInfo.heapBufferSize = heapBuffer.byteLength;
|
| 118 |
+
instanceInfo.getHeap = () => {
|
| 119 |
+
if (instanceInfo.heapBuffer.detached) {
|
| 120 |
+
if (SpawnJSInterop.verbose) console.log(`Detached heap detected for: ${dotnetId}`);
|
| 121 |
+
// get the new heap buffer
|
| 122 |
+
instanceInfo.heapBuffer = SpawnJSInterop.wasmMemoryBuffer(dotnet);
|
| 123 |
+
const oldSize = instanceInfo.heapBufferSize;
|
| 124 |
+
instanceInfo.heapBufferSize = instanceInfo.heapBuffer.byteLength;
|
| 125 |
+
// notify the instance
|
| 126 |
+
instanceInfo.onDetachedHeap(oldSize, instanceInfo.heapBuffer.byteLength);
|
| 127 |
+
}
|
| 128 |
+
return instanceInfo.heapBuffer;
|
| 129 |
+
};
|
| 130 |
+
|
| 131 |
+
if (SpawnJSInterop.verbose) console.log('[SpawnJSInterop] Instance registered', instanceInfo);
|
| 132 |
+
return dotnetId;
|
| 133 |
+
}
|
| 134 |
+
// Call tape value tags - JSTape.Tag* in JSTape.cs must match
|
| 135 |
+
static TapeTag = { Undefined: 0, Null: 1, Number: 2, Boolean: 3, String: 4, Ref: 5, Callback: 6, Absent: 8, Object: 9, Shape: 10, Array: 11, Numbers: 12, HeapView: 13, Record: 14, Revive: 15 };
|
| 136 |
+
// TagNumbers kinds - JSTape.NumberKind must match
|
| 137 |
+
static TapeNumberCtors = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array];
|
| 138 |
+
// what a member written as TagAbsent reads as: the property is not assigned
|
| 139 |
+
static _tapeAbsent = Object.freeze({});
|
| 140 |
+
|
| 141 |
+
// Main .Net to JS entrypoint (synchronous)
|
| 142 |
+
// The frame at address holds the whole call (see JSTape.cs). The result is written back over the frame and
|
| 143 |
+
// the return value is its byte length - or minus the bytes it needs when it does not fit in capacity, in
|
| 144 |
+
// which case it is kept on the instance for _spawnJSInteropCallResult.
|
| 145 |
+
// JSImport
|
| 146 |
+
// int _spawnJSInteropCall(double dotnetId, double address, int length, int capacity);
|
| 147 |
+
static _spawnJSInteropCall(dotnetId, address, length, capacity) {
|
| 148 |
+
// no detachedEventCheck(): _tapeViews checks this instance's heap, and walking every OTHER instance on
|
| 149 |
+
// every call was redundant - each is checked on its own calls and by the 500 ms timer
|
| 150 |
+
var instance = SpawnJSInterop.getInstace(dotnetId);
|
| 151 |
+
var call = SpawnJSInterop._tapeReadCall(instance, address, length, dotnetId);
|
| 152 |
+
var ret = call.target(...call.args);
|
| 153 |
+
ret = SpawnJSInterop.replaceValue(null, ret, false);
|
| 154 |
+
return SpawnJSInterop._tapeWriteResult(instance, call.returnType, ret, address, capacity);
|
| 155 |
+
}
|
| 156 |
+
// The result that did not fit behind its frame
|
| 157 |
+
// JSImport
|
| 158 |
+
// int _spawnJSInteropCallResult(double dotnetId, double address, int capacity);
|
| 159 |
+
static _spawnJSInteropCallResult(dotnetId, address, capacity) {
|
| 160 |
+
var instance = SpawnJSInterop.getInstace(dotnetId);
|
| 161 |
+
var bytes = instance.tapePendingResult;
|
| 162 |
+
instance.tapePendingResult = undefined;
|
| 163 |
+
if (!bytes) throw new Error('SpawnJSInterop: no tape result is being held');
|
| 164 |
+
if (bytes.byteLength > capacity) throw new Error(`SpawnJSInterop: a held tape result of ${bytes.byteLength} bytes does not fit in ${capacity}`);
|
| 165 |
+
var views = SpawnJSInterop._tapeViews(instance, address + bytes.byteLength);
|
| 166 |
+
new Uint8Array(views.buffer, address, bytes.byteLength).set(bytes);
|
| 167 |
+
return bytes.byteLength;
|
| 168 |
+
}
|
| 169 |
+
// Main .Net to JS entrypoint (asynchronous)
|
| 170 |
+
// Reads the frame and starts the call before returning, because .Net releases the frame as soon as this returns.
|
| 171 |
+
// Returns 1 when the frame was read and the call started, 0 when it could not be read - that failure has already
|
| 172 |
+
// gone to the resolver, so the awaiting Task fails rather than hanging.
|
| 173 |
+
// JSImport
|
| 174 |
+
// int _spawnJSInteropCallAsync(double dotnetId, double asyncCallId, double address, int length);
|
| 175 |
+
static _spawnJSInteropCallAsync(dotnetId, asyncCallId, address, length) {
|
| 176 |
+
var instance = SpawnJSInterop.getInstace(dotnetId);
|
| 177 |
+
var returnType = SpawnJSInterop._tapeViews(instance, address + length).f64[(address >>> 3) + 1];
|
| 178 |
+
var call;
|
| 179 |
+
try {
|
| 180 |
+
call = SpawnJSInterop._tapeReadCall(instance, address, length, dotnetId);
|
| 181 |
+
} catch (ex) {
|
| 182 |
+
SpawnJSInterop._resolveAsync(instance, returnType, asyncCallId, null, SpawnJSInterop.errorToString(ex));
|
| 183 |
+
return 0;
|
| 184 |
+
}
|
| 185 |
+
SpawnJSInterop._runAsync(instance, returnType, asyncCallId, call);
|
| 186 |
+
return 1;
|
| 187 |
+
}
|
| 188 |
+
static async _runAsync(instance, returnType, asyncCallId, call) {
|
| 189 |
+
var error = null;
|
| 190 |
+
var ret = null;
|
| 191 |
+
var heldBytes = -1;
|
| 192 |
+
try {
|
| 193 |
+
ret = call.target(...call.args);
|
| 194 |
+
ret = await ret;
|
| 195 |
+
ret = SpawnJSInterop.replaceValue(null, ret, false);
|
| 196 |
+
if (returnType > 10) {
|
| 197 |
+
// a composite schema: encoded here and held; .Net fetches it with _spawnJSInteropCallResult
|
| 198 |
+
heldBytes = SpawnJSInterop._tapeHoldResult(instance, SpawnJSInterop._tapeSchema(instance, returnType), ret);
|
| 199 |
+
} else {
|
| 200 |
+
// prepare using returnType
|
| 201 |
+
ret = SpawnJSInterop._serializeToNet(returnType, ret);
|
| 202 |
+
}
|
| 203 |
+
} catch (ex) {
|
| 204 |
+
error = SpawnJSInterop.errorToString(ex);
|
| 205 |
+
ret = null;
|
| 206 |
+
}
|
| 207 |
+
if (heldBytes >= 0) instance.resolveTape(asyncCallId, heldBytes, null);
|
| 208 |
+
else SpawnJSInterop._resolveAsync(instance, returnType, asyncCallId, ret, error);
|
| 209 |
+
}
|
| 210 |
+
static _resolveAsync(instance, returnType, asyncCallId, ret, error) {
|
| 211 |
+
if (returnType > 10) {
|
| 212 |
+
// a composite schema that failed: nothing is held
|
| 213 |
+
instance.resolveTape(asyncCallId, 0, error ?? 'SpawnJSInterop: the call produced no result');
|
| 214 |
+
return;
|
| 215 |
+
}
|
| 216 |
+
switch (returnType) {
|
| 217 |
+
case 0: // void
|
| 218 |
+
instance.resolveVoid(asyncCallId, error);
|
| 219 |
+
break;
|
| 220 |
+
case 1: // Double
|
| 221 |
+
instance.resolveDouble(asyncCallId, ret, error);
|
| 222 |
+
break;
|
| 223 |
+
case 2: // Boolean
|
| 224 |
+
instance.resolveBoolean(asyncCallId, ret, error);
|
| 225 |
+
break;
|
| 226 |
+
case 3: // DoubleNullable
|
| 227 |
+
instance.resolveDoubleNullable(asyncCallId, ret, error);
|
| 228 |
+
break;
|
| 229 |
+
case 4: // BooleanNullable
|
| 230 |
+
instance.resolveBooleanNullable(asyncCallId, ret, error);
|
| 231 |
+
break;
|
| 232 |
+
case 5: // String
|
| 233 |
+
instance.resolveString(asyncCallId, ret, error);
|
| 234 |
+
break;
|
| 235 |
+
case 6: // SpawnJSObject
|
| 236 |
+
instance.resolveDouble(asyncCallId, ret, error);
|
| 237 |
+
break;
|
| 238 |
+
case 7: // SpawnJSObjectNonNullable
|
| 239 |
+
instance.resolveDouble(asyncCallId, ret, error);
|
| 240 |
+
break;
|
| 241 |
+
case 8: // Json
|
| 242 |
+
instance.resolveString(asyncCallId, ret, error);
|
| 243 |
+
break;
|
| 244 |
+
case 9: // Int32
|
| 245 |
+
instance.resolveInt32(asyncCallId, ret, error);
|
| 246 |
+
break;
|
| 247 |
+
case 10: // Int32Nullable
|
| 248 |
+
instance.resolveInt32Nullable(asyncCallId, ret, error);
|
| 249 |
+
break;
|
| 250 |
+
default:
|
| 251 |
+
throw new Error(`Unsupported returnType ${returnType}`);
|
| 252 |
+
break;
|
| 253 |
+
}
|
| 254 |
+
}
|
| 255 |
+
// The heap views a tape is read through. Kept on the instance - never a page global - and rebuilt when the
|
| 256 |
+
// heap buffer changes: growth detaches it, and a shared (threaded) heap's buffer does not detach but can be
|
| 257 |
+
// shorter than the memory, so end is checked too.
|
| 258 |
+
static _tapeViews(instance, end) {
|
| 259 |
+
var buffer = instance.getHeap();
|
| 260 |
+
if (buffer.byteLength < end) {
|
| 261 |
+
buffer = instance.heapBuffer = SpawnJSInterop.wasmMemoryBuffer(instance.dotnet);
|
| 262 |
+
instance.heapBufferSize = buffer.byteLength;
|
| 263 |
+
}
|
| 264 |
+
var views = instance.tapeViews;
|
| 265 |
+
if (!views || views.buffer !== buffer) {
|
| 266 |
+
views = instance.tapeViews = { buffer, f64: new Float64Array(buffer), i32: new Int32Array(buffer), u16: new Uint16Array(buffer) };
|
| 267 |
+
}
|
| 268 |
+
return views;
|
| 269 |
+
}
|
| 270 |
+
// Reads a call frame: header, then one tagged value per argument, each passed through the revivers as the
|
| 271 |
+
// v2 argument array was.
|
| 272 |
+
static _tapeReadCall(instance, address, length, dotnetId) {
|
| 273 |
+
var views = SpawnJSInterop._tapeViews(instance, address + length);
|
| 274 |
+
var f64 = views.f64;
|
| 275 |
+
var p = address >>> 3;
|
| 276 |
+
var methodIndex = f64[p];
|
| 277 |
+
var returnType = f64[p + 1];
|
| 278 |
+
var argCount = f64[p + 2];
|
| 279 |
+
// one reader per call: a nested call (a reviver can run .Net) gets its own
|
| 280 |
+
var reader = { instance, dotnetId, address, length, views, p: p + 3 };
|
| 281 |
+
var args = new Array(argCount);
|
| 282 |
+
for (var i = 0; i < argCount; i++) {
|
| 283 |
+
var value = SpawnJSInterop._tapeRead(reader);
|
| 284 |
+
args[i] = SpawnJSInterop.reviveValue(i, value === SpawnJSInterop._tapeAbsent ? undefined : value, false);
|
| 285 |
+
}
|
| 286 |
+
// then the definitions of any schema the result is written by (JSTape.WriteSchemaDefinitions)
|
| 287 |
+
var end = (address + length) >>> 3;
|
| 288 |
+
while (reader.p < end) SpawnJSInterop._tapeReadSchemaDefinition(reader);
|
| 289 |
+
var target = SpawnJSInterop._methodMap[methodIndex];
|
| 290 |
+
if (!target) throw new Error(`SpawnJSInterop: no method at index ${methodIndex}`);
|
| 291 |
+
return { target, returnType, args };
|
| 292 |
+
}
|
| 293 |
+
// Reads one tagged value at reader.p and advances it. Object members and array elements go through the
|
| 294 |
+
// revivers with their key, as v2's per-property set did.
|
| 295 |
+
static _tapeRead(reader) {
|
| 296 |
+
// a reviver can run .Net (a heap view refresh reports the detach), which can grow the heap
|
| 297 |
+
if (reader.views.buffer.detached) reader.views = SpawnJSInterop._tapeViews(reader.instance, reader.address + reader.length);
|
| 298 |
+
var f64 = reader.views.f64;
|
| 299 |
+
var tag = f64[reader.p++];
|
| 300 |
+
switch (tag) {
|
| 301 |
+
case 0: return undefined;
|
| 302 |
+
case 1: return null;
|
| 303 |
+
case 2: return f64[reader.p++];
|
| 304 |
+
case 3: return f64[reader.p++] !== 0;
|
| 305 |
+
case 4: return SpawnJSInterop._tapeReadChars(reader);
|
| 306 |
+
case 5: return SpawnJSInterop.spawnJSObjectGet(f64[reader.p++]);
|
| 307 |
+
case 6: {
|
| 308 |
+
var callbackId = f64[reader.p++];
|
| 309 |
+
var once = f64[reader.p++] !== 0;
|
| 310 |
+
// the schemas its arguments are written by (defined after this frame's arguments when new)
|
| 311 |
+
var argumentCount = f64[reader.p++];
|
| 312 |
+
var argumentSchemas = new Array(argumentCount);
|
| 313 |
+
for (var i = 0; i < argumentCount; i++) argumentSchemas[i] = f64[reader.p++];
|
| 314 |
+
return SpawnJSInterop._callbackFunction(reader.dotnetId, callbackId, once, argumentSchemas);
|
| 315 |
+
}
|
| 316 |
+
case 8: return SpawnJSInterop._tapeAbsent;
|
| 317 |
+
case 9: {
|
| 318 |
+
var names = reader.instance.tapeShapes?.[f64[reader.p]];
|
| 319 |
+
if (!names) throw new Error(`SpawnJSInterop: unknown tape shape ${f64[reader.p]}`);
|
| 320 |
+
reader.p++;
|
| 321 |
+
var obj = {};
|
| 322 |
+
for (var i = 0; i < names.length; i++) {
|
| 323 |
+
var value = SpawnJSInterop._tapeRead(reader);
|
| 324 |
+
if (value !== SpawnJSInterop._tapeAbsent) obj[names[i]] = SpawnJSInterop.reviveValue(names[i], value, false);
|
| 325 |
+
}
|
| 326 |
+
return obj;
|
| 327 |
+
}
|
| 328 |
+
case 10: {
|
| 329 |
+
// a shape definition - kept per instance, since each runtime numbers its own - then the value it
|
| 330 |
+
// precedes. The same definition can arrive again until .Net knows a call carrying it completed.
|
| 331 |
+
var shapeId = f64[reader.p++];
|
| 332 |
+
var count = f64[reader.p++];
|
| 333 |
+
var names = new Array(count);
|
| 334 |
+
for (var i = 0; i < count; i++) names[i] = SpawnJSInterop._tapeReadChars(reader);
|
| 335 |
+
(reader.instance.tapeShapes ??= [])[shapeId] = names;
|
| 336 |
+
return SpawnJSInterop._tapeRead(reader);
|
| 337 |
+
}
|
| 338 |
+
case 11: {
|
| 339 |
+
var count = f64[reader.p++];
|
| 340 |
+
var array = new Array(count);
|
| 341 |
+
for (var i = 0; i < count; i++) {
|
| 342 |
+
var value = SpawnJSInterop._tapeRead(reader);
|
| 343 |
+
array[i] = SpawnJSInterop.reviveValue(i, value === SpawnJSInterop._tapeAbsent ? undefined : value, false);
|
| 344 |
+
}
|
| 345 |
+
return array;
|
| 346 |
+
}
|
| 347 |
+
case 12: {
|
| 348 |
+
var ctor = SpawnJSInterop.TapeNumberCtors[f64[reader.p++]];
|
| 349 |
+
var count = f64[reader.p++];
|
| 350 |
+
var view = new ctor(reader.views.buffer, reader.p * 8, count);
|
| 351 |
+
reader.p += (count * ctor.BYTES_PER_ELEMENT + 7) >>> 3;
|
| 352 |
+
// a plain Array, as element-by-element writing produced; a TypedArray stays opt in
|
| 353 |
+
return Array.from(view);
|
| 354 |
+
}
|
| 355 |
+
case 14: {
|
| 356 |
+
var count = reader.views.f64[reader.p++];
|
| 357 |
+
var record = {};
|
| 358 |
+
for (var i = 0; i < count; i++) {
|
| 359 |
+
var key = SpawnJSInterop._tapeReadChars(reader);
|
| 360 |
+
var value = SpawnJSInterop._tapeRead(reader);
|
| 361 |
+
record[key] = SpawnJSInterop.reviveValue(key, value === SpawnJSInterop._tapeAbsent ? undefined : value, false);
|
| 362 |
+
}
|
| 363 |
+
return record;
|
| 364 |
+
}
|
| 365 |
+
case 15: {
|
| 366 |
+
var reviver = SpawnJSInterop._methodMap[reader.views.f64[reader.p++]];
|
| 367 |
+
if (!reviver) throw new Error('SpawnJSInterop: tape reviver not found');
|
| 368 |
+
// (key, value, directCall) - the v2 property reviver convention; there is no property key here
|
| 369 |
+
return reviver(null, SpawnJSInterop._tapeRead(reader), true);
|
| 370 |
+
}
|
| 371 |
+
case 13: {
|
| 372 |
+
var f = reader.views.f64;
|
| 373 |
+
var viewType = f[reader.p], offset = f[reader.p + 1], count = f[reader.p + 2], copy = f[reader.p + 3] !== 0;
|
| 374 |
+
reader.p += 4;
|
| 375 |
+
return SpawnJSInterop._heapView(reader.dotnetId, viewType, offset, count, copy);
|
| 376 |
+
}
|
| 377 |
+
default: throw new Error(`SpawnJSInterop: unknown tape tag ${tag} at cell ${reader.p - 1}`);
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
// length, then UTF-16 code units padded to a cell
|
| 381 |
+
static _tapeReadChars(reader) {
|
| 382 |
+
var length = reader.views.f64[reader.p++];
|
| 383 |
+
var value = SpawnJSInterop._tapeString(reader.views.u16, reader.p * 4, length);
|
| 384 |
+
reader.p += (length + 3) >>> 2;
|
| 385 |
+
return value;
|
| 386 |
+
}
|
| 387 |
+
// String.fromCharCode keeps every UTF-16 code unit exactly - a lone surrogate included, which a TextDecoder
|
| 388 |
+
// would replace. Chunked, because apply() has an argument count limit.
|
| 389 |
+
static _tapeString(u16, index, length) {
|
| 390 |
+
if (length <= 1024) return String.fromCharCode.apply(null, u16.subarray(index, index + length));
|
| 391 |
+
var parts = [];
|
| 392 |
+
for (var i = 0; i < length; i += 1024) {
|
| 393 |
+
parts.push(String.fromCharCode.apply(null, u16.subarray(index + i, index + Math.min(i + 1024, length))));
|
| 394 |
+
}
|
| 395 |
+
return parts.join('');
|
| 396 |
+
}
|
| 397 |
+
// ---- results: written back by the schema .Net reads them with (JSSchema.cs, JSTapeReader.cs) ----
|
| 398 |
+
// Ids 0-10 are the built-in ReturnType kinds; composite schemas are defined per instance, after a call's arguments.
|
| 399 |
+
static _builtinSchemas = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(kind => Object.freeze({ kind }));
|
| 400 |
+
// thrown by a writer over .Net memory that is out of room (only a string can be; it is written again)
|
| 401 |
+
static _tapeOverflow = Object.freeze({ tapeOverflow: true });
|
| 402 |
+
static _tapeSchema(instance, id) {
|
| 403 |
+
if (id <= 10) return SpawnJSInterop._builtinSchemas[id];
|
| 404 |
+
var schema = instance.tapeSchemas?.[id];
|
| 405 |
+
if (!schema) throw new Error(`SpawnJSInterop: unknown tape schema ${id}`);
|
| 406 |
+
return schema;
|
| 407 |
+
}
|
| 408 |
+
// TagSchema, id, kind, then per kind - member / element schemas are ids, resolved when a value is written, so a
|
| 409 |
+
// schema can refer to one defined after it, or to itself
|
| 410 |
+
static _tapeReadSchemaDefinition(reader) {
|
| 411 |
+
if (reader.views.buffer.detached) reader.views = SpawnJSInterop._tapeViews(reader.instance, reader.address + reader.length);
|
| 412 |
+
var f64 = reader.views.f64;
|
| 413 |
+
var tag = f64[reader.p++];
|
| 414 |
+
if (tag !== 16) throw new Error(`SpawnJSInterop: expected a tape schema definition, found tag ${tag}`);
|
| 415 |
+
var id = f64[reader.p++];
|
| 416 |
+
var schema = { kind: f64[reader.p++] };
|
| 417 |
+
switch (schema.kind) {
|
| 418 |
+
case 16: {
|
| 419 |
+
var count = f64[reader.p++];
|
| 420 |
+
schema.names = new Array(count);
|
| 421 |
+
for (var i = 0; i < count; i++) schema.names[i] = SpawnJSInterop._tapeReadChars(reader);
|
| 422 |
+
schema.members = new Array(count);
|
| 423 |
+
for (var i = 0; i < count; i++) schema.members[i] = reader.views.f64[reader.p++];
|
| 424 |
+
break;
|
| 425 |
+
}
|
| 426 |
+
case 20: {
|
| 427 |
+
var count = f64[reader.p++];
|
| 428 |
+
schema.members = new Array(count);
|
| 429 |
+
for (var i = 0; i < count; i++) schema.members[i] = f64[reader.p++];
|
| 430 |
+
break;
|
| 431 |
+
}
|
| 432 |
+
case 17: case 19: schema.element = f64[reader.p++]; break;
|
| 433 |
+
case 18: schema.numberKind = f64[reader.p++]; break;
|
| 434 |
+
}
|
| 435 |
+
(reader.instance.tapeSchemas ??= [])[id] = schema;
|
| 436 |
+
}
|
| 437 |
+
// Writes a call's result back over its own frame. A built-in kind goes straight into .Net memory (only a string
|
| 438 |
+
// can outgrow the frame's segment); a composite is written into Javascript memory first, then copied - it can
|
| 439 |
+
// hold references and run getters, so it is written exactly once. A result that does not fit is held for
|
| 440 |
+
// _spawnJSInteropCallResult, and the return value is minus its size.
|
| 441 |
+
static _tapeWriteResult(instance, schemaId, ret, address, capacity) {
|
| 442 |
+
var schema = SpawnJSInterop._tapeSchema(instance, schemaId);
|
| 443 |
+
if (schema.kind === 0) return 0;
|
| 444 |
+
if (schemaId <= 10) {
|
| 445 |
+
var views = SpawnJSInterop._tapeViews(instance, address + capacity);
|
| 446 |
+
var w = { buffer: views.buffer, f64: views.f64, i32: views.i32, u16: views.u16, p: address >>> 3, end: (address + capacity) >>> 3, scratch: false };
|
| 447 |
+
try {
|
| 448 |
+
SpawnJSInterop._tapeEncode(instance, w, schema, ret);
|
| 449 |
+
return (w.p - (address >>> 3)) * 8;
|
| 450 |
+
} catch (ex) {
|
| 451 |
+
if (ex !== SpawnJSInterop._tapeOverflow) throw ex;
|
| 452 |
+
}
|
| 453 |
+
}
|
| 454 |
+
var s = SpawnJSInterop._tapeScratchWriter(instance);
|
| 455 |
+
try {
|
| 456 |
+
SpawnJSInterop._tapeEncode(instance, s, schema, ret);
|
| 457 |
+
var bytes = s.p * 8;
|
| 458 |
+
if (bytes <= capacity) {
|
| 459 |
+
var heap = SpawnJSInterop._tapeViews(instance, address + bytes);
|
| 460 |
+
new Uint8Array(heap.buffer, address, bytes).set(new Uint8Array(s.buffer, 0, bytes));
|
| 461 |
+
return bytes;
|
| 462 |
+
}
|
| 463 |
+
instance.tapePendingResult = new Uint8Array(s.buffer.slice(0, bytes));
|
| 464 |
+
return -bytes;
|
| 465 |
+
} finally {
|
| 466 |
+
SpawnJSInterop._tapeScratchRelease(instance, s);
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
// encodes a result and holds it for _spawnJSInteropCallResult; returns its size
|
| 470 |
+
static _tapeHoldResult(instance, schema, value) {
|
| 471 |
+
var s = SpawnJSInterop._tapeScratchWriter(instance);
|
| 472 |
+
try {
|
| 473 |
+
SpawnJSInterop._tapeEncode(instance, s, schema, value);
|
| 474 |
+
instance.tapePendingResult = new Uint8Array(s.buffer.slice(0, s.p * 8));
|
| 475 |
+
return s.p * 8;
|
| 476 |
+
} finally {
|
| 477 |
+
SpawnJSInterop._tapeScratchRelease(instance, s);
|
| 478 |
+
}
|
| 479 |
+
}
|
| 480 |
+
// Javascript-side result buffers, pooled per instance (a nested call's result uses its own)
|
| 481 |
+
static _tapeScratchWriter(instance) {
|
| 482 |
+
var w = instance.tapeScratch?.pop();
|
| 483 |
+
if (!w) {
|
| 484 |
+
w = { scratch: true, p: 0 };
|
| 485 |
+
SpawnJSInterop._tapeScratchResize(w, 512);
|
| 486 |
+
}
|
| 487 |
+
w.p = 0;
|
| 488 |
+
return w;
|
| 489 |
+
}
|
| 490 |
+
static _tapeScratchRelease(instance, w) {
|
| 491 |
+
// a very large one is dropped rather than kept for the life of the page
|
| 492 |
+
if (w.end <= 1 << 20) (instance.tapeScratch ??= []).push(w);
|
| 493 |
+
}
|
| 494 |
+
static _tapeScratchResize(w, cells) {
|
| 495 |
+
var buffer = new ArrayBuffer(cells * 8);
|
| 496 |
+
if (w.buffer) new Uint8Array(buffer).set(new Uint8Array(w.buffer, 0, w.p * 8));
|
| 497 |
+
w.buffer = buffer;
|
| 498 |
+
w.f64 = new Float64Array(buffer);
|
| 499 |
+
w.i32 = new Int32Array(buffer);
|
| 500 |
+
w.u16 = new Uint16Array(buffer);
|
| 501 |
+
w.end = cells;
|
| 502 |
+
}
|
| 503 |
+
static _tapeNeed(w, cells) {
|
| 504 |
+
if (w.p + cells <= w.end) return;
|
| 505 |
+
if (!w.scratch) throw SpawnJSInterop._tapeOverflow;
|
| 506 |
+
SpawnJSInterop._tapeScratchResize(w, Math.max(w.end * 2, w.p + cells));
|
| 507 |
+
}
|
| 508 |
+
// One value by its schema. The built-in kinds convert exactly as v2's typed returns did: null/undefined read
|
| 509 |
+
// as 0 / false, a number is stored through a Float64Array (ToNumber) and an int through an Int32Array (ToInt32).
|
| 510 |
+
// A composite reads each member / element with that member's schema - what v2's per-property Get<T> read.
|
| 511 |
+
static _tapeEncode(instance, w, schema, v) {
|
| 512 |
+
var isNull = v === null || v === undefined;
|
| 513 |
+
switch (schema.kind) {
|
| 514 |
+
case 0: return;
|
| 515 |
+
case 1:
|
| 516 |
+
SpawnJSInterop._tapeNeed(w, 1);
|
| 517 |
+
w.f64[w.p++] = isNull ? 0 : v;
|
| 518 |
+
return;
|
| 519 |
+
case 2:
|
| 520 |
+
SpawnJSInterop._tapeNeed(w, 1);
|
| 521 |
+
w.f64[w.p++] = v ? 1 : 0;
|
| 522 |
+
return;
|
| 523 |
+
case 3:
|
| 524 |
+
if (isNull) { SpawnJSInterop._tapeNeed(w, 1); w.f64[w.p++] = 1; return; }
|
| 525 |
+
SpawnJSInterop._tapeNeed(w, 2);
|
| 526 |
+
w.f64[w.p++] = 2;
|
| 527 |
+
w.f64[w.p++] = v;
|
| 528 |
+
return;
|
| 529 |
+
case 4:
|
| 530 |
+
if (isNull) { SpawnJSInterop._tapeNeed(w, 1); w.f64[w.p++] = 1; return; }
|
| 531 |
+
SpawnJSInterop._tapeNeed(w, 2);
|
| 532 |
+
w.f64[w.p++] = 3;
|
| 533 |
+
w.f64[w.p++] = v ? 1 : 0;
|
| 534 |
+
return;
|
| 535 |
+
case 5:
|
| 536 |
+
if (!isNull && typeof v !== 'string') v = Object(v).toString();
|
| 537 |
+
SpawnJSInterop._tapeEncodeString(w, isNull ? null : v);
|
| 538 |
+
return;
|
| 539 |
+
case 6: case 7:
|
| 540 |
+
SpawnJSInterop._tapeNeed(w, 1);
|
| 541 |
+
w.f64[w.p++] = SpawnJSInterop.spawnJSObjectHold(v);
|
| 542 |
+
return;
|
| 543 |
+
case 8:
|
| 544 |
+
SpawnJSInterop._tapeEncodeString(w, JSON.stringify(v));
|
| 545 |
+
return;
|
| 546 |
+
case 9:
|
| 547 |
+
SpawnJSInterop._tapeNeed(w, 1);
|
| 548 |
+
w.i32[w.p * 2] = isNull ? 0 : v;
|
| 549 |
+
w.p++;
|
| 550 |
+
return;
|
| 551 |
+
case 10:
|
| 552 |
+
if (isNull) { SpawnJSInterop._tapeNeed(w, 1); w.f64[w.p++] = 1; return; }
|
| 553 |
+
SpawnJSInterop._tapeNeed(w, 2);
|
| 554 |
+
w.f64[w.p] = 2;
|
| 555 |
+
w.i32[(w.p + 1) * 2] = v;
|
| 556 |
+
w.p += 2;
|
| 557 |
+
return;
|
| 558 |
+
case 16: {
|
| 559 |
+
if (isNull) { SpawnJSInterop._tapeNeed(w, 1); w.f64[w.p++] = 1; return; }
|
| 560 |
+
SpawnJSInterop._tapeNeed(w, 1);
|
| 561 |
+
w.f64[w.p++] = 9;
|
| 562 |
+
var names = schema.names, members = schema.members;
|
| 563 |
+
for (var i = 0; i < names.length; i++) SpawnJSInterop._tapeEncode(instance, w, SpawnJSInterop._tapeSchema(instance, members[i]), v[names[i]]);
|
| 564 |
+
return;
|
| 565 |
+
}
|
| 566 |
+
case 17: {
|
| 567 |
+
if (isNull) { SpawnJSInterop._tapeNeed(w, 1); w.f64[w.p++] = 1; return; }
|
| 568 |
+
var count = Number(v.length) || 0;
|
| 569 |
+
SpawnJSInterop._tapeNeed(w, 2);
|
| 570 |
+
w.f64[w.p++] = 11;
|
| 571 |
+
w.f64[w.p++] = count;
|
| 572 |
+
var element = SpawnJSInterop._tapeSchema(instance, schema.element);
|
| 573 |
+
for (var i = 0; i < count; i++) SpawnJSInterop._tapeEncode(instance, w, element, v[i]);
|
| 574 |
+
return;
|
| 575 |
+
}
|
| 576 |
+
case 18: {
|
| 577 |
+
if (isNull) { SpawnJSInterop._tapeNeed(w, 1); w.f64[w.p++] = 1; return; }
|
| 578 |
+
var count = Number(v.length) || 0;
|
| 579 |
+
var int32 = schema.numberKind === 9;
|
| 580 |
+
var cells = int32 ? (count + 1) >>> 1 : count;
|
| 581 |
+
SpawnJSInterop._tapeNeed(w, 2 + cells);
|
| 582 |
+
w.f64[w.p++] = 12;
|
| 583 |
+
w.f64[w.p++] = count;
|
| 584 |
+
// element by element, not typedArray.set(): an undefined element must read as 0, as Get<T> read it
|
| 585 |
+
if (int32) {
|
| 586 |
+
var view = new Int32Array(w.buffer, w.p * 8, count);
|
| 587 |
+
for (var i = 0; i < count; i++) { var e = v[i]; view[i] = e === null || e === undefined ? 0 : e; }
|
| 588 |
+
} else {
|
| 589 |
+
var view = new Float64Array(w.buffer, w.p * 8, count);
|
| 590 |
+
for (var i = 0; i < count; i++) { var e = v[i]; view[i] = e === null || e === undefined ? 0 : e; }
|
| 591 |
+
}
|
| 592 |
+
w.p += cells;
|
| 593 |
+
return;
|
| 594 |
+
}
|
| 595 |
+
case 19: {
|
| 596 |
+
if (isNull) { SpawnJSInterop._tapeNeed(w, 1); w.f64[w.p++] = 1; return; }
|
| 597 |
+
// own enumerable keys - inherited ones belong to the prototype chain, not the record
|
| 598 |
+
var keys = Object.keys(v);
|
| 599 |
+
SpawnJSInterop._tapeNeed(w, 2);
|
| 600 |
+
w.f64[w.p++] = 14;
|
| 601 |
+
w.f64[w.p++] = keys.length;
|
| 602 |
+
var element = SpawnJSInterop._tapeSchema(instance, schema.element);
|
| 603 |
+
for (var i = 0; i < keys.length; i++) {
|
| 604 |
+
SpawnJSInterop._tapeEncodeChars(w, keys[i]);
|
| 605 |
+
SpawnJSInterop._tapeEncode(instance, w, element, v[keys[i]]);
|
| 606 |
+
}
|
| 607 |
+
return;
|
| 608 |
+
}
|
| 609 |
+
case 20: {
|
| 610 |
+
if (isNull) { SpawnJSInterop._tapeNeed(w, 1); w.f64[w.p++] = 1; return; }
|
| 611 |
+
var members = schema.members;
|
| 612 |
+
SpawnJSInterop._tapeNeed(w, 2);
|
| 613 |
+
w.f64[w.p++] = 11;
|
| 614 |
+
w.f64[w.p++] = members.length;
|
| 615 |
+
for (var i = 0; i < members.length; i++) SpawnJSInterop._tapeEncode(instance, w, SpawnJSInterop._tapeSchema(instance, members[i]), v[i]);
|
| 616 |
+
return;
|
| 617 |
+
}
|
| 618 |
+
case 21: {
|
| 619 |
+
if (isNull) { SpawnJSInterop._tapeNeed(w, 1); w.f64[w.p++] = 1; return; }
|
| 620 |
+
var bytes = v instanceof ArrayBuffer ? new Uint8Array(v)
|
| 621 |
+
: ArrayBuffer.isView(v) ? new Uint8Array(v.buffer, v.byteOffset, v.byteLength)
|
| 622 |
+
: null;
|
| 623 |
+
if (!bytes) throw new TypeError('SpawnJSInterop: expected an ArrayBuffer or ArrayBufferView');
|
| 624 |
+
var cells = (bytes.length + 7) >>> 3;
|
| 625 |
+
SpawnJSInterop._tapeNeed(w, 2 + cells);
|
| 626 |
+
w.f64[w.p++] = 12;
|
| 627 |
+
w.f64[w.p++] = bytes.length;
|
| 628 |
+
new Uint8Array(w.buffer, w.p * 8, bytes.length).set(bytes);
|
| 629 |
+
w.p += cells;
|
| 630 |
+
return;
|
| 631 |
+
}
|
| 632 |
+
}
|
| 633 |
+
throw new Error(`SpawnJSInterop: unsupported tape schema kind ${schema.kind}`);
|
| 634 |
+
}
|
| 635 |
+
// null, or tag, length, UTF-16 code units
|
| 636 |
+
static _tapeEncodeString(w, value) {
|
| 637 |
+
if (value === null || value === undefined) {
|
| 638 |
+
SpawnJSInterop._tapeNeed(w, 1);
|
| 639 |
+
w.f64[w.p++] = 1;
|
| 640 |
+
return;
|
| 641 |
+
}
|
| 642 |
+
SpawnJSInterop._tapeNeed(w, 1);
|
| 643 |
+
w.f64[w.p++] = 4;
|
| 644 |
+
SpawnJSInterop._tapeEncodeChars(w, value);
|
| 645 |
+
}
|
| 646 |
+
// length, UTF-16 code units padded to a cell
|
| 647 |
+
static _tapeEncodeChars(w, value) {
|
| 648 |
+
var length = value.length;
|
| 649 |
+
SpawnJSInterop._tapeNeed(w, 1 + ((length + 3) >>> 2));
|
| 650 |
+
w.f64[w.p++] = length;
|
| 651 |
+
var u16 = w.u16;
|
| 652 |
+
var index = w.p * 4;
|
| 653 |
+
for (var i = 0; i < length; i++) u16[index + i] = value.charCodeAt(i);
|
| 654 |
+
w.p += (length + 3) >>> 2;
|
| 655 |
+
}
|
| 656 |
+
// refreshes the method map by looking for any new methods and adds them
|
| 657 |
+
// JSImport
|
| 658 |
+
// string[] _refreshMethodMap();
|
| 659 |
+
static refreshMethodMap() {
|
| 660 |
+
var changed = false;
|
| 661 |
+
var keys = Reflect.ownKeys(SpawnJSInterop);
|
| 662 |
+
for (const pName of keys) {
|
| 663 |
+
if (SpawnJSInterop._methodMapNames.indexOf(pName) !== -1) continue;
|
| 664 |
+
var propVal = SpawnJSInterop[pName];
|
| 665 |
+
if (typeof propVal === 'function') {
|
| 666 |
+
var fn = propVal.bind(SpawnJSInterop);
|
| 667 |
+
changed = true;
|
| 668 |
+
SpawnJSInterop._methodMap.push(fn);
|
| 669 |
+
SpawnJSInterop._methodMapNames.push(pName);
|
| 670 |
+
if (pName.indexOf('__reviver') === 0) {
|
| 671 |
+
SpawnJSInterop._revivers.push(fn);
|
| 672 |
+
} else if (pName.indexOf('__replacer') === 0) {
|
| 673 |
+
SpawnJSInterop._replacers.push(fn);
|
| 674 |
+
}
|
| 675 |
+
}
|
| 676 |
+
}
|
| 677 |
+
if (changed) {
|
| 678 |
+
// notify existing instances
|
| 679 |
+
for (const dotnetIdExisting in SpawnJSInterop._instances) {
|
| 680 |
+
if (Object.hasOwn(SpawnJSInterop._instances, dotnetIdExisting)) {
|
| 681 |
+
var existingInfo = SpawnJSInterop._instances[dotnetIdExisting];
|
| 682 |
+
try {
|
| 683 |
+
existingInfo.onMethodAdded();
|
| 684 |
+
} catch { }
|
| 685 |
+
}
|
| 686 |
+
}
|
| 687 |
+
}
|
| 688 |
+
return SpawnJSInterop._methodMapNames;
|
| 689 |
+
}
|
| 690 |
+
// JSImport
|
| 691 |
+
// void _releaseCallback(double dotnetId, double callbackId);
|
| 692 |
+
static releaseCallback(dotnetId, callbackId) {
|
| 693 |
+
var callbackIdPair = `${dotnetId}_${callbackId}`;
|
| 694 |
+
delete SpawnJSInterop._callbacks[callbackIdPair];
|
| 695 |
+
}
|
| 696 |
+
// removes the object from the hold and returns it
|
| 697 |
+
// JSImport
|
| 698 |
+
// void SpawnJSObjectRelease(double sjsId);
|
| 699 |
+
// bool SpawnJSObjectReleaseBoolean(double sjsId);
|
| 700 |
+
// double SpawnJSObjectReleaseDouble(double sjsId);
|
| 701 |
+
// int SpawnJSObjectReleaseInt32(double sjsId);
|
| 702 |
+
// bool? SpawnJSObjectReleaseBooleanNullable(double sjsId);
|
| 703 |
+
// int? SpawnJSObjectReleaseInt32Nullable(double sjsId);
|
| 704 |
+
// double? SpawnJSObjectReleaseDoubleNullable(double sjsId);
|
| 705 |
+
static spawnJSObjectRelease(sjsId) {
|
| 706 |
+
var ret = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 707 |
+
delete SpawnJSInterop.spawnJSObjects[sjsId];
|
| 708 |
+
if (SpawnJSInterop.verbose) console.log('spawnJSObjectRelease. Count:', Object.keys(SpawnJSInterop.spawnJSObjects).length, 'Id:', sjsId);
|
| 709 |
+
return ret;
|
| 710 |
+
}
|
| 711 |
+
// removes the object from the hold, JSON.stringifies it and returns it
|
| 712 |
+
// JSImport
|
| 713 |
+
// string SpawnJSObjectReleaseJson(double sjsId);
|
| 714 |
+
static spawnJSObjectReleaseAsJson(sjsId) {
|
| 715 |
+
var ret = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 716 |
+
delete SpawnJSInterop.spawnJSObjects[sjsId];
|
| 717 |
+
return JSON.stringify(ret);
|
| 718 |
+
}
|
| 719 |
+
// returns true if the item id exists in the hold
|
| 720 |
+
// JSImport
|
| 721 |
+
// bool SpawnJSObjectHoldExists(double sjsId);
|
| 722 |
+
static spawnJSObjectHoldExists(sjsId) {
|
| 723 |
+
switch (sjsId) {
|
| 724 |
+
case -1: return true;
|
| 725 |
+
case -2: return true;
|
| 726 |
+
case -3: return true;
|
| 727 |
+
case -4: return true;
|
| 728 |
+
case -5: return true;
|
| 729 |
+
}
|
| 730 |
+
return sjsId in SpawnJSInterop.spawnJSObjects;
|
| 731 |
+
}
|
| 732 |
+
// returns string
|
| 733 |
+
// JSImport
|
| 734 |
+
// string _getTypeInfo(double sjsId);
|
| 735 |
+
static getTypeInfo(sjsId) {
|
| 736 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 737 |
+
var jsClass = Object.prototype.toString.call(obj).split(' ')[1].slice(0, -1);
|
| 738 |
+
var jsType = typeof (obj);
|
| 739 |
+
return `${jsType} ${jsClass}`;
|
| 740 |
+
}
|
| 741 |
+
|
| 742 |
+
// **************************************************************************************
|
| 743 |
+
// SpawnJSObjectReference imports
|
| 744 |
+
// Note: only `string key` imports shown. Also exists: `double key`, `int key`
|
| 745 |
+
// **************************************************************************************
|
| 746 |
+
|
| 747 |
+
// property info
|
| 748 |
+
// returns string or null if the property was not found
|
| 749 |
+
// JSImport
|
| 750 |
+
// string _propertyTypeInfo(double sjsId, string key);
|
| 751 |
+
static propertyTypeInfo(sjsId, key) {
|
| 752 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 753 |
+
var { parent, propertyName, shortCircuit } = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 754 |
+
if (shortCircuit) return null;
|
| 755 |
+
if (!SpawnJSInterop._in(propertyName, parent)) return null;
|
| 756 |
+
var value = parent[propertyName];
|
| 757 |
+
var jsClass = Object.prototype.toString.call(value).split(' ')[1].slice(0, -1);
|
| 758 |
+
var jsType = typeof (value);
|
| 759 |
+
return `${jsType} ${jsClass}`;
|
| 760 |
+
}
|
| 761 |
+
// deletes property
|
| 762 |
+
// JSImport
|
| 763 |
+
// bool _propertyDelete(double sjsId, string key);
|
| 764 |
+
static propertyDelete(sjsId, key) {
|
| 765 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 766 |
+
if (obj === void 0 || obj === null) throw new Error('obj null or undefined');
|
| 767 |
+
var { parent, propertyName, shortCircuit } = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 768 |
+
if (shortCircuit) return true;
|
| 769 |
+
return delete parent[propertyName];
|
| 770 |
+
}
|
| 771 |
+
// returns bool if the key is in the target
|
| 772 |
+
// JSImport
|
| 773 |
+
// bool _propertyIn(double sjsId, string key);
|
| 774 |
+
static propertyIn(sjsId, key) {
|
| 775 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 776 |
+
if (obj === void 0 || obj === null) throw new Error('obj null or undefined');
|
| 777 |
+
var { parent, propertyName, shortCircuit } = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 778 |
+
if (shortCircuit) return false;
|
| 779 |
+
return SpawnJSInterop._in(propertyName, parent);
|
| 780 |
+
}
|
| 781 |
+
// get a property
|
| 782 |
+
// InteropCall (dispatched through the call tape)
|
| 783 |
+
static propertyGet(sjsId, key) {
|
| 784 |
+
var ret = undefined;
|
| 785 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 786 |
+
var pathInfo = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 787 |
+
if (pathInfo.shortCircuit) return ret;
|
| 788 |
+
if (typeof pathInfo.target === 'function') {
|
| 789 |
+
ret = pathInfo.target.bind(pathInfo.parent);
|
| 790 |
+
} else {
|
| 791 |
+
ret = pathInfo.target;
|
| 792 |
+
}
|
| 793 |
+
return ret;
|
| 794 |
+
}
|
| 795 |
+
// set property
|
| 796 |
+
// InteropCall (dispatched through the call tape)
|
| 797 |
+
static propertySet(sjsId, key, value) {
|
| 798 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 799 |
+
if (obj === void 0 || obj === null) throw new Error('obj null or undefined');
|
| 800 |
+
var { parent, propertyName, shortCircuit } = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 801 |
+
if (shortCircuit) return;
|
| 802 |
+
// revivers
|
| 803 |
+
value = SpawnJSInterop.reviveValue(propertyName, value, false);
|
| 804 |
+
parent[propertyName] = value;
|
| 805 |
+
}
|
| 806 |
+
// A view of - or with copy, a copy of - .Net memory. A live view carries its _heapViewInfo so the heap view
|
| 807 |
+
// reviver can rebuild it after the heap grows. Built when the tape reads a TagHeapView.
|
| 808 |
+
static _heapView(dotnetId, viewType, offset, length, copy) {
|
| 809 |
+
// create the heapView meta data
|
| 810 |
+
var heapViewInfo = { dotnetId, viewType, offset, length, copy };
|
| 811 |
+
// viewType is an INDEX into HeapViewCtors, and index 0 (BigInt64Array) is a real value - a
|
| 812 |
+
// falsy check would read it as "missing" and silently rewrite it. The default is the
|
| 813 |
+
// Uint8Array index, not its name: this value is used as an index, never as a lookup key.
|
| 814 |
+
if (heapViewInfo.viewType === undefined || heapViewInfo.viewType === null) heapViewInfo.viewType = 10;
|
| 815 |
+
heapViewInfo.instance = SpawnJSInterop.getInstace(heapViewInfo.dotnetId);
|
| 816 |
+
heapViewInfo.dotnet = SpawnJSInterop.spawnJSObjectGet(heapViewInfo.dotnetId);
|
| 817 |
+
heapViewInfo.sizeHistory = [];
|
| 818 |
+
heapViewInfo.ctor = SpawnJSInterop.getArrayBufferViewConstructor(heapViewInfo.viewType);
|
| 819 |
+
// refresh the heapView
|
| 820 |
+
return SpawnJSInterop.heapViewRefresh(heapViewInfo);
|
| 821 |
+
}
|
| 822 |
+
// The Javascript function that invokes a .Net Callback, created once per callback and reused
|
| 823 |
+
// .Net gives each instance a pinned buffer that a callback's arguments are written into before it calls .Net
|
| 824 |
+
// JSImport
|
| 825 |
+
// void _registerInbound(double dotnetId, double address, int cells);
|
| 826 |
+
static _registerInbound(dotnetId, address, cells) {
|
| 827 |
+
// cell 0 carries the offset of the arguments of the callback being called
|
| 828 |
+
SpawnJSInterop.getInstace(dotnetId).inbound = { address, cells, top: 1 };
|
| 829 |
+
}
|
| 830 |
+
// Writes a callback's arguments by their schemas into the instance's inbound buffer, as a stack (a callback can
|
| 831 |
+
// run inside another), and puts their offset in cell 0. Arguments too large for the space left are held for
|
| 832 |
+
// _spawnJSInteropCallResult instead, and cell 0 is minus their size. Returns the top to restore afterwards.
|
| 833 |
+
static _tapeWriteInbound(instance, argumentSchemas, args) {
|
| 834 |
+
var inbound = instance.inbound;
|
| 835 |
+
var top = inbound.top;
|
| 836 |
+
var s = SpawnJSInterop._tapeScratchWriter(instance);
|
| 837 |
+
try {
|
| 838 |
+
for (var i = 0; i < argumentSchemas.length; i++) {
|
| 839 |
+
SpawnJSInterop._tapeEncode(instance, s, SpawnJSInterop._tapeSchema(instance, argumentSchemas[i]), args[i]);
|
| 840 |
+
}
|
| 841 |
+
var views = SpawnJSInterop._tapeViews(instance, inbound.address + inbound.cells * 8);
|
| 842 |
+
var offset;
|
| 843 |
+
if (top + s.p <= inbound.cells) {
|
| 844 |
+
new Uint8Array(views.buffer, inbound.address + top * 8, s.p * 8).set(new Uint8Array(s.buffer, 0, s.p * 8));
|
| 845 |
+
offset = top;
|
| 846 |
+
inbound.top = top + s.p;
|
| 847 |
+
} else {
|
| 848 |
+
instance.tapePendingResult = new Uint8Array(s.buffer.slice(0, s.p * 8));
|
| 849 |
+
offset = -(s.p * 8);
|
| 850 |
+
}
|
| 851 |
+
views.f64[inbound.address >>> 3] = offset;
|
| 852 |
+
} finally {
|
| 853 |
+
SpawnJSInterop._tapeScratchRelease(instance, s);
|
| 854 |
+
}
|
| 855 |
+
return top;
|
| 856 |
+
}
|
| 857 |
+
static _callbackFunction(dotnetId, callbackId, once, argumentSchemas) {
|
| 858 |
+
if (!callbackId || !dotnetId) {
|
| 859 |
+
return null;
|
| 860 |
+
}
|
| 861 |
+
// get callback id that is globally unique
|
| 862 |
+
var callbackIdPair = `${dotnetId}_${callbackId}`;
|
| 863 |
+
// check if it exists and createa new function if not
|
| 864 |
+
var value = SpawnJSInterop._callbacks[callbackIdPair];
|
| 865 |
+
if (!value) {
|
| 866 |
+
value = function (...args) {
|
| 867 |
+
// check if the callback has been removed
|
| 868 |
+
if (!SpawnJSInterop._callbacks[callbackIdPair]) {
|
| 869 |
+
return;
|
| 870 |
+
}
|
| 871 |
+
// get the SpawnJSRuntime instance's method that is used to report the callback
|
| 872 |
+
var instance = SpawnJSInterop.getInstace(dotnetId);
|
| 873 |
+
var { handleCallback } = instance;
|
| 874 |
+
// get argsCnt because after when we call handleCallback .Net will write
|
| 875 |
+
// the return value to at the end of the array after the last argument (index argsCnt)
|
| 876 |
+
// unless the return value should be undefined
|
| 877 |
+
var argsCnt = args.length;
|
| 878 |
+
// get a temporary hold of the args (released after we notify SpawnJSRuntime)
|
| 879 |
+
var argsId = SpawnJSInterop.spawnJSObjectHold(args);
|
| 880 |
+
// ⚠️ try/finally, NOT straight-line. .Net deliberately does not release this slot
|
| 881 |
+
// itself - that would cost an extra crossing per callback - so the ONLY release is
|
| 882 |
+
// here. If handleCallback throws (any exception escaping the .Net handler crosses
|
| 883 |
+
// back through here) a straight-line release is SKIPPED and the args array is
|
| 884 |
+
// stranded in spawnJSObjects for the life of the page. Same for the `once` cleanup:
|
| 885 |
+
// a one-shot callback that threw would never be removed and would keep firing.
|
| 886 |
+
// MEASURED 2026-09-02: dumping the table mid-run in the ML demo showed ~30 stranded
|
| 887 |
+
// empty arrays alongside the retained adapters.
|
| 888 |
+
// the arguments go to .Net memory now, so the call below is the only crossing they need
|
| 889 |
+
var inboundTop = SpawnJSInterop._tapeWriteInbound(instance, argumentSchemas ?? [], args);
|
| 890 |
+
try {
|
| 891 |
+
// notify SpawnJSRuntime with the argsId and the cnt
|
| 892 |
+
handleCallback(callbackId, argsId, argsCnt);
|
| 893 |
+
} finally {
|
| 894 |
+
instance.inbound.top = inboundTop;
|
| 895 |
+
// release the args
|
| 896 |
+
SpawnJSInterop.spawnJSObjectRelease(argsId);
|
| 897 |
+
// if it was a 1 time use callback, release it
|
| 898 |
+
if (once) delete SpawnJSInterop._callbacks[callbackIdPair];
|
| 899 |
+
}
|
| 900 |
+
// return what is in index argsCnt (the designated place .Net will write to if there is a return value)
|
| 901 |
+
return args[argsCnt];
|
| 902 |
+
};
|
| 903 |
+
SpawnJSInterop._callbacks[callbackIdPair] = value;
|
| 904 |
+
}
|
| 905 |
+
return value;
|
| 906 |
+
}
|
| 907 |
+
|
| 908 |
+
// Interop Calls
|
| 909 |
+
// Interop calls are calls made indirectly via _spawnJSInteropCall and _spawnJSInteropCallAsync.
|
| 910 |
+
// Because they go through those methods they can return and recieve any data type the marshallers support
|
| 911 |
+
|
| 912 |
+
// call a property constructor
|
| 913 |
+
// InteropCall
|
| 914 |
+
// SpawnJSObjectReference
|
| 915 |
+
// <double, string, object?[]?, SpawnJSObjectReference>
|
| 916 |
+
static propertyNewApply(sjsId, key, args) {
|
| 917 |
+
var ret = undefined;
|
| 918 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 919 |
+
var pathInfo = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 920 |
+
if (pathInfo.shortCircuit) return ret;
|
| 921 |
+
var ret = !args ? new pathInfo.target() : new pathInfo.target(...args);
|
| 922 |
+
return ret;
|
| 923 |
+
}
|
| 924 |
+
// call a property constructor
|
| 925 |
+
// InteropCall
|
| 926 |
+
// SpawnJSObjectReference
|
| 927 |
+
// <double, string, ..., T>
|
| 928 |
+
static propertyNew(sjsId, key, ...args) {
|
| 929 |
+
var ret = undefined;
|
| 930 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 931 |
+
var pathInfo = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 932 |
+
if (pathInfo.shortCircuit) return ret;
|
| 933 |
+
var ret = !args ? new pathInfo.target() : new pathInfo.target(...args);
|
| 934 |
+
return ret;
|
| 935 |
+
}
|
| 936 |
+
// call a property
|
| 937 |
+
// InteropCall
|
| 938 |
+
// SpawnJSObjectReference
|
| 939 |
+
// <double, string, object?[]?, T>
|
| 940 |
+
static propertyCallApply(sjsId, key, args) {
|
| 941 |
+
var ret = undefined;
|
| 942 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 943 |
+
var pathInfo = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 944 |
+
if (pathInfo.shortCircuit) return ret;
|
| 945 |
+
var ret = pathInfo.target.apply(pathInfo.parent, args);
|
| 946 |
+
if (typeof ret === 'function') {
|
| 947 |
+
ret = ret.bind(pathInfo.parent);
|
| 948 |
+
}
|
| 949 |
+
return ret;
|
| 950 |
+
}
|
| 951 |
+
// call a property
|
| 952 |
+
// InteropCall
|
| 953 |
+
// SpawnJSObjectReference
|
| 954 |
+
// <double, string, ..., T>
|
| 955 |
+
static propertyCall(sjsId, key, ...args) {
|
| 956 |
+
var ret = undefined;
|
| 957 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 958 |
+
var pathInfo = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 959 |
+
if (pathInfo.shortCircuit) return ret;
|
| 960 |
+
var ret = pathInfo.target.apply(pathInfo.parent, args);
|
| 961 |
+
if (typeof ret === 'function') {
|
| 962 |
+
ret = ret.bind(pathInfo.parent);
|
| 963 |
+
}
|
| 964 |
+
return ret;
|
| 965 |
+
}
|
| 966 |
+
// useful when .Net Wasm wants to clonme a JSObjectReference or simply convert from one type to another
|
| 967 |
+
// InteropCall
|
| 968 |
+
// SpawnJSObjectReference
|
| 969 |
+
// <TIn, TResult>
|
| 970 |
+
static returnMe(value) {
|
| 971 |
+
return value;
|
| 972 |
+
}
|
| 973 |
+
// InteropCall
|
| 974 |
+
// ByteArrayMarshaller
|
| 975 |
+
// <double, SpawnJSObjectReference, double, double, double, VoidType>
|
| 976 |
+
static writeArrayBufferViewToHeap(dotnetId, arrayBufferView, srcOffset, destOffset, byteLength) {
|
| 977 |
+
if (!arrayBufferView) throw new Error('writeArrayBufferViewToHeap arrayBufferView is required');
|
| 978 |
+
if (byteLength === 0) return 0;
|
| 979 |
+
var srcLength = arrayBufferView.byteLength;
|
| 980 |
+
if (byteLength == -1) byteLength = srcLength;
|
| 981 |
+
if (byteLength < -1) throw new Error('Invalid byteLength');
|
| 982 |
+
// get the .Net heap
|
| 983 |
+
var instance = SpawnJSInterop.getInstace(dotnetId);
|
| 984 |
+
var buffer = instance.getHeap();
|
| 985 |
+
var bufferView = new Uint8Array(buffer, destOffset, byteLength);
|
| 986 |
+
// get a view of the exact source we want
|
| 987 |
+
var offset = arrayBufferView.byteOffset + srcOffset;
|
| 988 |
+
var sourceView = new Uint8Array(arrayBufferView.buffer, offset, byteLength);
|
| 989 |
+
// copy to the .Net heap
|
| 990 |
+
bufferView.set(sourceView);
|
| 991 |
+
// return the bytes copied
|
| 992 |
+
return byteLength;
|
| 993 |
+
}
|
| 994 |
+
// called using Call<>
|
| 995 |
+
// InteropCall
|
| 996 |
+
// TaskMarshaller
|
| 997 |
+
// <double, int, SpawnJSObjectReference>
|
| 998 |
+
static propertySetNewPromise(sjsId, key) {
|
| 999 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 1000 |
+
if (obj === void 0 || obj === null) throw new Error('obj null or undefined');
|
| 1001 |
+
var { parent, propertyName, shortCircuit } = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 1002 |
+
if (shortCircuit) return;
|
| 1003 |
+
var promise = SpawnJSInterop.newEasyPromise();
|
| 1004 |
+
parent[propertyName] = promise;
|
| 1005 |
+
return promise;
|
| 1006 |
+
}
|
| 1007 |
+
// called using Call<>
|
| 1008 |
+
// InteropCall
|
| 1009 |
+
// TaskMarshaller
|
| 1010 |
+
// <double, string, VoidType>
|
| 1011 |
+
static propertySetResolvedPromise(sjsId, key, value) {
|
| 1012 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 1013 |
+
if (obj === void 0 || obj === null) throw new Error('obj null or undefined');
|
| 1014 |
+
var { parent, propertyName, shortCircuit } = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 1015 |
+
if (shortCircuit) return;
|
| 1016 |
+
parent[propertyName] = Promise.resolve(value);
|
| 1017 |
+
}
|
| 1018 |
+
// called using Call<>
|
| 1019 |
+
// InteropCall
|
| 1020 |
+
// TaskMarshaller
|
| 1021 |
+
// <double, string, string, VoidType>
|
| 1022 |
+
static propertySetRejectedPromise(sjsId, key, value) {
|
| 1023 |
+
var obj = SpawnJSInterop.spawnJSObjectGet(sjsId);
|
| 1024 |
+
if (obj === void 0 || obj === null) throw new Error('obj null or undefined');
|
| 1025 |
+
var { parent, propertyName, shortCircuit } = SpawnJSInterop.pathObjectInfo(obj, key);
|
| 1026 |
+
if (shortCircuit) return;
|
| 1027 |
+
parent[propertyName] = Promise.reject(value);
|
| 1028 |
+
}
|
| 1029 |
+
// InteropCall
|
| 1030 |
+
// SpawnJSRuntime
|
| 1031 |
+
// <double, long>
|
| 1032 |
+
static getHeapSize(dotnetId) {
|
| 1033 |
+
var instance = SpawnJSInterop.getInstace(dotnetId);
|
| 1034 |
+
var buffer = instance.getHeap();
|
| 1035 |
+
return buffer.byteLength;
|
| 1036 |
+
}
|
| 1037 |
+
// full ? strict equality : loose equality
|
| 1038 |
+
// InteropCall
|
| 1039 |
+
// SpawnJSRuntime
|
| 1040 |
+
// <T1, T2, bool, bool>
|
| 1041 |
+
static objectEquals(obj1, obj2, full) {
|
| 1042 |
+
return full ? obj1 === obj2 : obj1 == obj2;
|
| 1043 |
+
}
|
| 1044 |
+
|
| 1045 |
+
static detachedEventCheck() {
|
| 1046 |
+
for (const dotnetIdExisting in SpawnJSInterop._instances) {
|
| 1047 |
+
if (Object.hasOwn(SpawnJSInterop._instances, dotnetIdExisting)) {
|
| 1048 |
+
var instanceInfo = SpawnJSInterop._instances[dotnetIdExisting];
|
| 1049 |
+
instanceInfo.getHeap();
|
| 1050 |
+
}
|
| 1051 |
+
}
|
| 1052 |
+
}
|
| 1053 |
+
static getInstace(dotnetId) {
|
| 1054 |
+
return SpawnJSInterop._instances[dotnetId];
|
| 1055 |
+
}
|
| 1056 |
+
static _getInstaceFromDotNet(dotnet) {
|
| 1057 |
+
for (const dotnetIdExisting in SpawnJSInterop._instances) {
|
| 1058 |
+
if (Object.hasOwn(SpawnJSInterop._instances, dotnetIdExisting)) {
|
| 1059 |
+
var existingInfo = SpawnJSInterop._instances[dotnetIdExisting];
|
| 1060 |
+
if (existingInfo.dotnet == dotnet) {
|
| 1061 |
+
return existingInfo;
|
| 1062 |
+
}
|
| 1063 |
+
}
|
| 1064 |
+
}
|
| 1065 |
+
}
|
| 1066 |
+
static __replacerJson(key, value, directCall) {
|
| 1067 |
+
if (directCall) value = JSON.stringify(value);
|
| 1068 |
+
return value;
|
| 1069 |
+
}
|
| 1070 |
+
static __reviverJson(key, value, directCall) {
|
| 1071 |
+
if (directCall) value = JSON.parse(value);
|
| 1072 |
+
return value;
|
| 1073 |
+
}
|
| 1074 |
+
static _unregisterInstance(dotnetId) {
|
| 1075 |
+
delete SpawnJSInterop._instances[dotnetId];
|
| 1076 |
+
}
|
| 1077 |
+
static _getMappedMethodNames() {
|
| 1078 |
+
return SpawnJSInterop._methodMapNames;
|
| 1079 |
+
}
|
| 1080 |
+
// array of { name, reviver }
|
| 1081 |
+
static registerReplacers(replacers) {
|
| 1082 |
+
var cnt = 0;
|
| 1083 |
+
if (!replacers) return cnt;
|
| 1084 |
+
for (var replacerObj of replacers) {
|
| 1085 |
+
var succ = SpawnJSInterop.registerReplacer(replacerObj.name, replacerObj.replacer);
|
| 1086 |
+
if (succ) cnt++;
|
| 1087 |
+
}
|
| 1088 |
+
return cnt;
|
| 1089 |
+
}
|
| 1090 |
+
static registerReplacer(name, replacer) {
|
| 1091 |
+
if (name.indexOf('__replacer') !== 0) throw new Error('Replacer names must start with __replacer');
|
| 1092 |
+
if (SpawnJSInterop[name]) {
|
| 1093 |
+
// already exists. fail quitely as it could just mean another app loaded that uses the same replacers
|
| 1094 |
+
return false;
|
| 1095 |
+
}
|
| 1096 |
+
SpawnJSInterop[name] = replacer;
|
| 1097 |
+
SpawnJSInterop.refreshMethodMap();
|
| 1098 |
+
return true;
|
| 1099 |
+
}
|
| 1100 |
+
// array of { name, reviver }
|
| 1101 |
+
static registerRevivers(revivers) {
|
| 1102 |
+
var cnt = 0;
|
| 1103 |
+
if (!revivers) return cnt;
|
| 1104 |
+
for (var reviverObj of revivers) {
|
| 1105 |
+
var succ = SpawnJSInterop.registerReviver(reviverObj.name, reviverObj.reviver);
|
| 1106 |
+
if (succ) cnt++;
|
| 1107 |
+
}
|
| 1108 |
+
return cnt;
|
| 1109 |
+
}
|
| 1110 |
+
static registerReviver(name, reviver) {
|
| 1111 |
+
if (name.indexOf('__reviver') !== 0) throw new Error('Reviver names must start with __reviver');
|
| 1112 |
+
if (SpawnJSInterop[name]) {
|
| 1113 |
+
// already exists. fail quitely as it could just mean another app loaded that uses the same revivers
|
| 1114 |
+
return false;
|
| 1115 |
+
}
|
| 1116 |
+
SpawnJSInterop[name] = reviver;
|
| 1117 |
+
SpawnJSInterop.refreshMethodMap();
|
| 1118 |
+
return true;
|
| 1119 |
+
}
|
| 1120 |
+
// puts objectToHold (value of ANY type) into spawnJSObjects and returns the id
|
| 1121 |
+
// the object will stay held until released and it must be released to prevent memory leaks
|
| 1122 |
+
static spawnJSObjectHold(objectToHold) {
|
| 1123 |
+
if (objectToHold === globalThis) return -1;
|
| 1124 |
+
if (objectToHold === undefined) return -2;
|
| 1125 |
+
if (objectToHold === null) return -3;
|
| 1126 |
+
if (objectToHold === SpawnJSInterop.spawnJSObjects) return -4;
|
| 1127 |
+
if (objectToHold === SpawnJSInterop) return -5;
|
| 1128 |
+
var sjsId = ++SpawnJSInterop._sjsObjectIdNext;
|
| 1129 |
+
SpawnJSInterop.spawnJSObjects[sjsId] = objectToHold;
|
| 1130 |
+
if (SpawnJSInterop.verbose) console.log('spawnJSObjectHold. Count:', Object.keys(SpawnJSInterop.spawnJSObjects).length, 'Id:', sjsId, 'Object:', objectToHold);
|
| 1131 |
+
return sjsId;
|
| 1132 |
+
}
|
| 1133 |
+
// get an object from the hold
|
| 1134 |
+
static spawnJSObjectGet(sjsId) {
|
| 1135 |
+
switch (sjsId) {
|
| 1136 |
+
case -1: return globalThis;
|
| 1137 |
+
case -2: return undefined;
|
| 1138 |
+
case -3: return null;
|
| 1139 |
+
case -4: return SpawnJSInterop.spawnJSObjects;
|
| 1140 |
+
case -5: return SpawnJSInterop;
|
| 1141 |
+
}
|
| 1142 |
+
if (!SpawnJSInterop.spawnJSObjectHoldExists(sjsId)) {
|
| 1143 |
+
throw new Error('SpawnJSObjectGet object not found.');
|
| 1144 |
+
}
|
| 1145 |
+
var ret = SpawnJSInterop.spawnJSObjects[sjsId];
|
| 1146 |
+
// passive revive (allows things like refreshing heap views)
|
| 1147 |
+
ret = SpawnJSInterop.reviveValue(null, ret, false);
|
| 1148 |
+
return ret;
|
| 1149 |
+
}// get an obejct from the hold and replace it with a new one
|
| 1150 |
+
static spawnJSObjectGetAndReplace(sjsId, newValue) {
|
| 1151 |
+
switch (sjsId) {
|
| 1152 |
+
case -1: return globalThis;
|
| 1153 |
+
case -2: return undefined;
|
| 1154 |
+
case -3: return null;
|
| 1155 |
+
case -4: return SpawnJSInterop.spawnJSObjects;
|
| 1156 |
+
case -5: return SpawnJSInterop;
|
| 1157 |
+
}
|
| 1158 |
+
if (!SpawnJSInterop.spawnJSObjectHoldExists(sjsId)) {
|
| 1159 |
+
throw new Error('SpawnJSObjectGet object not found.');
|
| 1160 |
+
}
|
| 1161 |
+
var ret = SpawnJSInterop.spawnJSObjects[sjsId];
|
| 1162 |
+
SpawnJSInterop.spawnJSObjects[sjsId] = newValue;
|
| 1163 |
+
return ret;
|
| 1164 |
+
}
|
| 1165 |
+
static heapViewRefresh(heapViewInfo) {
|
| 1166 |
+
var needsCreate = !heapViewInfo.buffer;
|
| 1167 |
+
var needsRefresh = !heapViewInfo.buffer || heapViewInfo.buffer.detached;
|
| 1168 |
+
if (needsRefresh) {
|
| 1169 |
+
var instance = SpawnJSInterop.getInstace(heapViewInfo.dotnetId);
|
| 1170 |
+
heapViewInfo.buffer = instance.getHeap();
|
| 1171 |
+
var value = null;
|
| 1172 |
+
var length = heapViewInfo.length === -1 ? /* entire buffer */ heapViewInfo.buffer.byteLength - heapViewInfo.offset : heapViewInfo.length;
|
| 1173 |
+
if (heapViewInfo.viewType === 13) {
|
| 1174 |
+
// ArrayBuffer requested
|
| 1175 |
+
if (heapViewInfo.copy) {
|
| 1176 |
+
// create a copy
|
| 1177 |
+
value = heapViewInfo.buffer.slice(heapViewInfo.offset, heapViewInfo.offset + length);
|
| 1178 |
+
} else {
|
| 1179 |
+
// can't use offet and length when not copying the heap asn ArrayBuffer view
|
| 1180 |
+
if (heapViewInfo.offset != 0) throw new Error('Offset and length not supported creating an ArrayBuffer heap view without a copy');
|
| 1181 |
+
value = heapViewInfo.buffer;
|
| 1182 |
+
}
|
| 1183 |
+
} else if (heapViewInfo.viewType === 14) {
|
| 1184 |
+
// SharedArrayBuffer requested
|
| 1185 |
+
if (heapViewInfo.copy) {
|
| 1186 |
+
// create a copy
|
| 1187 |
+
var uint8ArrayHeap = new Uint8Array(heapViewInfo.buffer, heapViewInfo.offset, length);
|
| 1188 |
+
value = new globalThis.SharedArrayBuffer(length);
|
| 1189 |
+
var uint8ArrayDest = new Uint8Array(value);
|
| 1190 |
+
value.set(uint8ArrayHeap);
|
| 1191 |
+
} else {
|
| 1192 |
+
// can't get a live SharedArrayBuffer view of the heap
|
| 1193 |
+
throw new Error('Cannot get a live SharedArrayBuffer view of the heap');
|
| 1194 |
+
}
|
| 1195 |
+
} else {
|
| 1196 |
+
// ArrayBufferView (TypedArray or DataView)
|
| 1197 |
+
var liveView = new heapViewInfo.ctor(heapViewInfo.buffer, heapViewInfo.offset, length);
|
| 1198 |
+
value = heapViewInfo.copy ? liveView.slice() : liveView;
|
| 1199 |
+
}
|
| 1200 |
+
// copies do not get (or need) their view refreshed as it will not detach
|
| 1201 |
+
if (!heapViewInfo.copy) value._heapViewInfo = heapViewInfo;
|
| 1202 |
+
heapViewInfo.bufferLength = heapViewInfo.buffer.byteLength;
|
| 1203 |
+
heapViewInfo.sizeHistory.push(heapViewInfo.bufferLength);
|
| 1204 |
+
heapViewInfo.value = value;
|
| 1205 |
+
if (SpawnJSInterop.verbose) {
|
| 1206 |
+
if (!needsCreate) console.log('Heapview refreshed:', heapViewInfo);
|
| 1207 |
+
else console.log('Heapview created:', heapViewInfo);
|
| 1208 |
+
}
|
| 1209 |
+
}
|
| 1210 |
+
return heapViewInfo.value;
|
| 1211 |
+
}
|
| 1212 |
+
static getArrayBufferViewConstructor(viewType) {
|
| 1213 |
+
var ctor = SpawnJSInterop.HeapViewCtors[viewType];
|
| 1214 |
+
if (viewType === 13 || viewType === 14) return null; // ArrayBuffer
|
| 1215 |
+
if (!ctor) throw new Error(`Unsupported or missing ArrayBufferView constructor for enum index: ${viewType}`);
|
| 1216 |
+
return ctor;
|
| 1217 |
+
}
|
| 1218 |
+
static __replacerHeapView(key, value, directCall, reviverConfig) {
|
| 1219 |
+
if (directCall) {
|
| 1220 |
+
if (value && typeof value === 'object' && SpawnJSInterop._in('_heapViewInfo', value)) {
|
| 1221 |
+
// .Net wants HeapViewDescriptor
|
| 1222 |
+
//SpawnJSInterop.heapViewRefresh(heapViewInfo);
|
| 1223 |
+
}
|
| 1224 |
+
}
|
| 1225 |
+
return value;
|
| 1226 |
+
}
|
| 1227 |
+
static __reviverHeapView(key, value, directCall, reviverConfig) {
|
| 1228 |
+
if (!directCall && value && typeof value === 'object' && SpawnJSInterop._in('_heapViewInfo', value)) {
|
| 1229 |
+
// auto-reattach if needed
|
| 1230 |
+
// this allows creating a fresh HeapView if needed on `set` and `call` (with the exception of call reattach only working if the view is in teh root args list. no object walking is done)
|
| 1231 |
+
var heapViewInfo = value._heapViewInfo;
|
| 1232 |
+
value = SpawnJSInterop.heapViewRefresh(heapViewInfo);
|
| 1233 |
+
}
|
| 1234 |
+
return value;
|
| 1235 |
+
}
|
| 1236 |
+
// tape revivers (JSTape.WriteRevived) for a Task that completed before it was written
|
| 1237 |
+
static promiseResolved(key, value) { return Promise.resolve(value); }
|
| 1238 |
+
static promiseRejected(key, value) { return Promise.reject(value); }
|
| 1239 |
+
// create a new Promsie with the resolve and reject methods attached to the promise for easy calling from .Net
|
| 1240 |
+
static newEasyPromise() {
|
| 1241 |
+
var _resolve = null;
|
| 1242 |
+
var _reject = null;
|
| 1243 |
+
var promise = new Promise((resolve, reject) => {
|
| 1244 |
+
_resolve = resolve;
|
| 1245 |
+
_reject = reject;
|
| 1246 |
+
});
|
| 1247 |
+
promise.resolve = _resolve;
|
| 1248 |
+
promise.reject = _reject;
|
| 1249 |
+
return promise
|
| 1250 |
+
}
|
| 1251 |
+
// Reviver used by BigIntegerMarshaller: a BigInteger crosses as its decimal string, because a JS
|
| 1252 |
+
// number cannot hold one exactly, and is revived into a real BigInt here.
|
| 1253 |
+
// Revivers are called as (key, value, directCall) by the tape (TagRevive, JSTape.WriteRevived) - a plain
|
| 1254 |
+
// (value) signature would silently revive the PROPERTY NAME instead of the value.
|
| 1255 |
+
static stringToBigInt(key, value) {
|
| 1256 |
+
if (!globalThis.BigInt) throw new Error('BigInt not supported on this platform');
|
| 1257 |
+
return value === undefined || value === null ? null : globalThis.BigInt(value);
|
| 1258 |
+
}
|
| 1259 |
+
// object constructor names
|
| 1260 |
+
// returns string[]
|
| 1261 |
+
static getConstructorNames(obj) {
|
| 1262 |
+
var constructorNames = [];
|
| 1263 |
+
if (obj === void 0 || obj === null) return constructorNames;
|
| 1264 |
+
var o = obj;
|
| 1265 |
+
var cName;
|
| 1266 |
+
while (1) {
|
| 1267 |
+
o = Object.getPrototypeOf(o);
|
| 1268 |
+
cName = o?.constructor?.name;
|
| 1269 |
+
if (!cName) break;
|
| 1270 |
+
if (constructorNames.indexOf(cName) !== -1) continue;
|
| 1271 |
+
constructorNames.push(cName);
|
| 1272 |
+
}
|
| 1273 |
+
return constructorNames;
|
| 1274 |
+
}
|
| 1275 |
+
// returns string[] of the target's property names.
|
| 1276 |
+
// hasOwnProperty true restricts to the object's own enumerable keys (Object.keys); false walks the
|
| 1277 |
+
// prototype chain too, which is what you need to enumerate a DOM object's API rather than just the
|
| 1278 |
+
// handful of own properties it happens to carry.
|
| 1279 |
+
static objectKeys(target, hasOwnProperty) {
|
| 1280 |
+
if (target === void 0 || target === null) return [];
|
| 1281 |
+
if (hasOwnProperty) return Object.keys(target);
|
| 1282 |
+
var keys = [];
|
| 1283 |
+
for (var key in target) {
|
| 1284 |
+
if (keys.indexOf(key) === -1) keys.push(key);
|
| 1285 |
+
}
|
| 1286 |
+
return keys;
|
| 1287 |
+
}
|
| 1288 |
+
// Pipe the value through each reviver sequentially; a reviver that drops the value (undefined) skips the rest.
|
| 1289 |
+
// A plain loop: this runs for every argument of every call, and reduce() allocated a closure each time.
|
| 1290 |
+
static reviveValue(key, value, directCall) {
|
| 1291 |
+
var revivers = SpawnJSInterop._revivers;
|
| 1292 |
+
for (var i = 0; i < revivers.length && value !== undefined; i++) {
|
| 1293 |
+
value = revivers[i](key, value, directCall); // directCall tells the reviver this is a call revive as opposed to a propertySet revive
|
| 1294 |
+
}
|
| 1295 |
+
return value;
|
| 1296 |
+
}
|
| 1297 |
+
static replaceValue(key, value, directCall) {
|
| 1298 |
+
var replacers = SpawnJSInterop._replacers;
|
| 1299 |
+
for (var i = 0; i < replacers.length && value !== undefined; i++) {
|
| 1300 |
+
value = replacers[i](key, value, directCall);
|
| 1301 |
+
}
|
| 1302 |
+
return value;
|
| 1303 |
+
}
|
| 1304 |
+
// returns the types the object inherits from
|
| 1305 |
+
// returns string[]
|
| 1306 |
+
static getPropertyConstructorNames(parent, key) {
|
| 1307 |
+
return SpawnJSInterop.getConstructorNames(parent[key]);
|
| 1308 |
+
}
|
| 1309 |
+
// converts to an error string or returns a generic error string.
|
| 1310 |
+
// A NAMED error (Error subclasses, DOMException - NotFoundError, NotAllowedError, AbortError ... -
|
| 1311 |
+
// and OverconstrainedError, which often has an EMPTY message) is sent as
|
| 1312 |
+
// "\u0001" + name + "\u0002" + message so .Net can rebuild a JSException with its Name
|
| 1313 |
+
// (JSException.FromInteropError). Only the message used to be sent: the name was lost, and an
|
| 1314 |
+
// empty-message OverconstrainedError from getUserMedia arrived as a blank exception.
|
| 1315 |
+
static errorToString(error) {
|
| 1316 |
+
if (!error) return "Unknown error";
|
| 1317 |
+
if (typeof error === 'string') return error;
|
| 1318 |
+
let name = null;
|
| 1319 |
+
let message = null;
|
| 1320 |
+
if (typeof error === 'object') {
|
| 1321 |
+
try { if (typeof error.name === 'string' && error.name) name = error.name; } catch { }
|
| 1322 |
+
try { if (typeof error.message === 'string') message = error.message; } catch { }
|
| 1323 |
+
if (message === null && !(error instanceof Error)) {
|
| 1324 |
+
try { message = JSON.stringify(error); } catch { message = String(error); }
|
| 1325 |
+
}
|
| 1326 |
+
// OverconstrainedError reports the failing constraint separately
|
| 1327 |
+
try { if (typeof error.constraint === 'string' && error.constraint) message = (message ? message + ' ' : '') + '(constraint: ' + error.constraint + ')'; } catch { }
|
| 1328 |
+
}
|
| 1329 |
+
else {
|
| 1330 |
+
message = String(error);
|
| 1331 |
+
}
|
| 1332 |
+
if (!message) message = name ? '' : 'Unknown error';
|
| 1333 |
+
return name ? '\u0001' + name + '\u0002' + message : message;
|
| 1334 |
+
}
|
| 1335 |
+
// Main .Net to JS entrypoint
|
| 1336 |
+
static async _spawnJSInteropLoadExportsAsync(dotnetId, assemblyName) {
|
| 1337 |
+
var dotnet = SpawnJSInterop.spawnJSObjectGet(dotnetId);
|
| 1338 |
+
var assemblyExports = await dotnet.getAssemblyExports(assemblyName);
|
| 1339 |
+
var spawnJSExports = assemblyName.split('.').reduce((acc, key) => acc[key], assemblyExports);
|
| 1340 |
+
dotnet.spawnJSExports = spawnJSExports;
|
| 1341 |
+
}
|
| 1342 |
+
// prepares the variable for .Net based on returnType
|
| 1343 |
+
static _serializeToNet(returnType, ret) {
|
| 1344 |
+
switch (returnType) {
|
| 1345 |
+
case 0: // void
|
| 1346 |
+
return;
|
| 1347 |
+
case 6: // SpawnJSObject - Number
|
| 1348 |
+
case 7: // SpawnJSObjectNonNullable - Number
|
| 1349 |
+
return SpawnJSInterop.spawnJSObjectHold(ret);
|
| 1350 |
+
case 8: // Json
|
| 1351 |
+
return JSON.stringify(ret);
|
| 1352 |
+
case 1: // Double
|
| 1353 |
+
case 2: // Boolean
|
| 1354 |
+
case 3: // DoubleNullable
|
| 1355 |
+
case 4: // BooleanNullable
|
| 1356 |
+
case 9: // Int32
|
| 1357 |
+
case 10: // Int32Nullable
|
| 1358 |
+
return ret;
|
| 1359 |
+
case 5: // String
|
| 1360 |
+
if (ret && typeof ret !== 'string') {
|
| 1361 |
+
ret = Object(ret).toString();
|
| 1362 |
+
}
|
| 1363 |
+
return ret;
|
| 1364 |
+
}
|
| 1365 |
+
// the default is to return as is
|
| 1366 |
+
return ret;
|
| 1367 |
+
}
|
| 1368 |
+
static wasmMemoryBuffer(dotnet) {
|
| 1369 |
+
var found = SpawnJSInterop.#findWasmMemory(dotnet);
|
| 1370 |
+
if (!found) throw new Error('SpawnJSInterop: could not reach the WebAssembly memory buffer');
|
| 1371 |
+
return found.buffer;
|
| 1372 |
+
}
|
| 1373 |
+
// returns the name of the path the memory buffer was found under, or '' if it was not found
|
| 1374 |
+
static wasmMemoryBufferSource(dotnet) {
|
| 1375 |
+
var found = SpawnJSInterop.#findWasmMemory(dotnet);
|
| 1376 |
+
return found ? found.source : '';
|
| 1377 |
+
}
|
| 1378 |
+
static #findWasmMemory(dotnet) {
|
| 1379 |
+
var rt = dotnet;
|
| 1380 |
+
if (!rt) return null;
|
| 1381 |
+
var candidates = [
|
| 1382 |
+
['Module.HEAPU8.buffer', () => rt.Module?.HEAPU8?.buffer],
|
| 1383 |
+
['Module.wasmMemory.buffer', () => rt.Module?.wasmMemory?.buffer],
|
| 1384 |
+
['localHeapViewU8().buffer', () => rt.localHeapViewU8?.()?.buffer],
|
| 1385 |
+
['getHeapU8().buffer', () => rt.getHeapU8?.()?.buffer],
|
| 1386 |
+
];
|
| 1387 |
+
for (var i = 0; i < candidates.length; i++) {
|
| 1388 |
+
var buffer;
|
| 1389 |
+
try { buffer = candidates[i][1](); } catch (ex) { continue; }
|
| 1390 |
+
if (buffer && typeof buffer.byteLength === 'number' && buffer.byteLength > 0) {
|
| 1391 |
+
return { buffer: buffer, source: candidates[i][0] };
|
| 1392 |
+
}
|
| 1393 |
+
}
|
| 1394 |
+
return null;
|
| 1395 |
+
}
|
| 1396 |
+
// safely checks for a property existence
|
| 1397 |
+
// safely means will not throw, which is needed as simply checking for a
|
| 1398 |
+
// a proeprty can throw an exception (notably on cross-origin windows)
|
| 1399 |
+
static _in(key, obj) {
|
| 1400 |
+
if (obj === null || obj === void 0) return false;
|
| 1401 |
+
try {
|
| 1402 |
+
return key in Object(obj);
|
| 1403 |
+
} catch { }
|
| 1404 |
+
return false;
|
| 1405 |
+
}
|
| 1406 |
+
// returns the path info based on a base object and a property path: `window?.location.href`
|
| 1407 |
+
static pathObjectInfo(rootObject, path) {
|
| 1408 |
+
if (rootObject === null || rootObject === void 0) {
|
| 1409 |
+
// callers must call with the globalThis if they wish to use it as the rootObject.
|
| 1410 |
+
throw new Error('spawnJSInterop.pathObjectInfo error: rootObject cannot be null');
|
| 1411 |
+
}
|
| 1412 |
+
var parent = rootObject;
|
| 1413 |
+
var target;
|
| 1414 |
+
var propertyName;
|
| 1415 |
+
var shortCircuit = false;
|
| 1416 |
+
if (typeof path === 'string' && !(SpawnJSInterop._in(path, parent))) {
|
| 1417 |
+
var parts = path.split('.');
|
| 1418 |
+
propertyName = parts[parts.length - 1];
|
| 1419 |
+
var part;
|
| 1420 |
+
for (var i = 0; i < parts.length - 1; i++) {
|
| 1421 |
+
part = parts[i];
|
| 1422 |
+
if (part[part.length - 1] === '?') {
|
| 1423 |
+
// ? null conditonal found
|
| 1424 |
+
// if parent does not exist allow undefined/null parent instead of throwing exception
|
| 1425 |
+
part = part.substring(0, part.length - 1);
|
| 1426 |
+
parent = parent[part];
|
| 1427 |
+
if (parent === void 0 || parent === null) {
|
| 1428 |
+
shortCircuit = true;
|
| 1429 |
+
break;
|
| 1430 |
+
}
|
| 1431 |
+
}
|
| 1432 |
+
else {
|
| 1433 |
+
parent = parent[part];
|
| 1434 |
+
}
|
| 1435 |
+
}
|
| 1436 |
+
if (!shortCircuit) {
|
| 1437 |
+
target = parent[propertyName];
|
| 1438 |
+
}
|
| 1439 |
+
}
|
| 1440 |
+
else {
|
| 1441 |
+
propertyName = path;
|
| 1442 |
+
target = parent[propertyName];
|
| 1443 |
+
}
|
| 1444 |
+
return {
|
| 1445 |
+
shortCircuit, // bool - true if the pathfinding short circuited due to a null-conditional
|
| 1446 |
+
parent, // any - only null or undefined if short circuited due to a null-conditional
|
| 1447 |
+
propertyName, // any
|
| 1448 |
+
target, // any
|
| 1449 |
+
};
|
| 1450 |
+
}
|
| 1451 |
+
|
| 1452 |
+
// The URL this app was LOADED from - the origin of its own main.* / _framework, NOT the host
|
| 1453 |
+
// page's document.baseURI. Under a CDN load the page and the app live at different URLs, and every
|
| 1454 |
+
// worker entry (main.classic.js / main.module.js / _framework/*) must resolve against the APP's
|
| 1455 |
+
// origin. document.baseURI is a page-coupled Blazor-ism that hands back the page root instead.
|
| 1456 |
+
//
|
| 1457 |
+
// Derived per-runtime from THIS app's OWN dotnetRuntime, so two SpawnJS apps loaded from different
|
| 1458 |
+
// origins on one page each get their own base - a module-scope import.meta.url could not, because
|
| 1459 |
+
// the class-definition guard means app B's lib.module.js body never re-runs.
|
| 1460 |
+
//
|
| 1461 |
+
// Fail-loud multi-candidate, the same shape as #findWasmMemory: the runtime exposes its origin
|
| 1462 |
+
// under different shapes across scopes/versions, so every known shape is tried and the one that
|
| 1463 |
+
// worked is reportable via appBaseUriSource(). Returns '' if none resolve, so the caller can fall
|
| 1464 |
+
// back rather than silently build worker URLs against a wrong base.
|
| 1465 |
+
static appBaseUri(dotnet) {
|
| 1466 |
+
var found = this.#findAppBaseUri(dotnet);
|
| 1467 |
+
return found ? found.uri : '';
|
| 1468 |
+
}
|
| 1469 |
+
// Which candidate produced appBaseUri(), or '' - diagnostic, mirrors wasmMemoryBufferSource().
|
| 1470 |
+
static appBaseUriSource(dotnet) {
|
| 1471 |
+
var found = this.#findAppBaseUri(dotnet);
|
| 1472 |
+
return found ? found.source : '';
|
| 1473 |
+
}
|
| 1474 |
+
static import(src) {
|
| 1475 |
+
return import(src);
|
| 1476 |
+
}
|
| 1477 |
+
// The app-root normalizer, exposed so it is diagnosable and testable directly. The test suite
|
| 1478 |
+
// drives THIS function rather than a copy of the logic, so the production path is what is covered.
|
| 1479 |
+
static appRootFromLoadUrl(raw) {
|
| 1480 |
+
return this.#appRootFromLoadUrl(raw);
|
| 1481 |
+
}
|
| 1482 |
+
// Normalizes a URL some runtime artifact was loaded from into the app root, with a trailing slash.
|
| 1483 |
+
//
|
| 1484 |
+
// Every boot artifact - the runtime entry (dotnet.js / dotnet.<fingerprint>.js) and every resource
|
| 1485 |
+
// in the boot manifest (.wasm/.dll assemblies, ICU .dat/.blat, .pdb symbols) - lives in the app's
|
| 1486 |
+
// framework folder, so the app root is that folder's PARENT. Anything else was loaded from the app
|
| 1487 |
+
// root itself: a bundled entrypoint (main.classic.js / main.module.js) sits beside index.html, and
|
| 1488 |
+
// that is what SpawnDev.SpawnJS.WebWorkers bundles before 2.1.9 reported here.
|
| 1489 |
+
//
|
| 1490 |
+
// The framework folder is identified by WHAT was loaded, never by what the folder is NAMED. It is
|
| 1491 |
+
// "_framework" in a normal publish, but a published app may rename it - WebWorkers'
|
| 1492 |
+
// SpawnJSWebWorkersFrameworkFolderName does exactly that, because a browser extension may not have
|
| 1493 |
+
// a root folder starting with '_'. Matching the literal name returned the framework folder itself
|
| 1494 |
+
// as the app root there, and every URL built on it (worker entrypoints above all) resolved one
|
| 1495 |
+
// level too deep.
|
| 1496 |
+
static #appRootFromLoadUrl(raw) {
|
| 1497 |
+
if (typeof raw !== 'string' || raw.length === 0) return '';
|
| 1498 |
+
if (raw.startsWith('blob:')) return '';
|
| 1499 |
+
var url;
|
| 1500 |
+
try { url = new URL(raw, self?.location?.href); } catch (ex) { return ''; }
|
| 1501 |
+
var segments = url.pathname.split('/'); // leading '' from the root slash
|
| 1502 |
+
var file = segments.pop(); // '' when the url already names a directory
|
| 1503 |
+
// A boot artifact is one level below the app root, whatever its folder is called. Guarded on
|
| 1504 |
+
// length so an artifact served from the origin root cannot walk above it.
|
| 1505 |
+
if (file && this.#isBootArtifact(file) && segments.length > 1) segments.pop();
|
| 1506 |
+
return url.origin + segments.join('/') + '/';
|
| 1507 |
+
}
|
| 1508 |
+
// True for the runtime entry and for boot-manifest resources - the files that only ever live in
|
| 1509 |
+
// the app's framework folder. Deliberately does NOT match a bundled entrypoint (main.*.js), which
|
| 1510 |
+
// sits at the app root.
|
| 1511 |
+
static #isBootArtifact(fileName) {
|
| 1512 |
+
return /^dotnet(\..+)?\.m?js$/i.test(fileName)
|
| 1513 |
+
|| /\.(wasm|dll|dat|blat|pdb)$/i.test(fileName);
|
| 1514 |
+
}
|
| 1515 |
+
static #findAppBaseUri(dotnet) {
|
| 1516 |
+
if (!dotnet) return null;
|
| 1517 |
+
var candidates = [
|
| 1518 |
+
// PROVEN primary (measured across scopes): dotnet.js's own module URL, i.e.
|
| 1519 |
+
// appRoot/_framework/dotnet.<fp>.js - itself import.meta-derived, so it is the real CDN
|
| 1520 |
+
// origin under a CDN load, not the host page. Can be a blob: URL in some worker configs,
|
| 1521 |
+
// which #appRootFromLoadUrl rejects so the resolver falls through to the next candidate.
|
| 1522 |
+
['Module.mainScriptUrlOrBlob', () => dotnet.Module?.mainScriptUrlOrBlob],
|
| 1523 |
+
// Robust backup: every boot resource carries an absolute resolvedUrl (appRoot/_framework/*),
|
| 1524 |
+
// always populated even when mainScriptUrlOrBlob is a blob.
|
| 1525 |
+
['getConfig().resources.assembly[0].resolvedUrl', () => dotnet.getConfig?.()?.resources?.assembly?.[0]?.resolvedUrl],
|
| 1526 |
+
];
|
| 1527 |
+
for (var i = 0; i < candidates.length; i++) {
|
| 1528 |
+
var raw;
|
| 1529 |
+
try { raw = candidates[i][1](); } catch (ex) { continue; }
|
| 1530 |
+
var uri = this.#appRootFromLoadUrl(raw);
|
| 1531 |
+
if (uri) return { uri: uri, source: candidates[i][0] };
|
| 1532 |
+
}
|
| 1533 |
+
return null;
|
| 1534 |
+
}
|
| 1535 |
+
}
|
| 1536 |
+
globalThis.SpawnJSInterop = SpawnJSInterop;
|
| 1537 |
+
})();
|
SpawnDev.SpawnJS.zrbbeqadpn.lib.module.js.br
ADDED
|
Binary file (15.2 kB). View file
|
|
|
SpawnDev.SpawnJS.zrbbeqadpn.lib.module.js.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:39bd9e38c77c0b37385faa786e4a1e5025a4880c3742bd6d6fc1cf62f67f2ad9
|
| 3 |
+
size 17834
|
_framework/System.Text.Encodings.Web.tji6rumfic.wasm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:69f64ac6ed7e59140bf45d7b47104959c49d4838b89e453c972521bfb7b5e66d
|
| 3 |
+
size 30485
|
_framework/System.Text.Encodings.Web.tji6rumfic.wasm.br
ADDED
|
Binary file (9.93 kB). View file
|
|
|
_framework/System.Text.Encodings.Web.tji6rumfic.wasm.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:47dfe8684940a343d51c5312ad13d32fbf3c34ae9f385eb219244998570b3972
|
| 3 |
+
size 11583
|
_framework/System.Text.Json.wmn8nrdgsp.wasm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:58433510b5dd3baafed3a54220e085ac3ef99422e9f492cb51676639daeaf5c4
|
| 3 |
+
size 420117
|
_framework/System.Text.Json.wmn8nrdgsp.wasm.br
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:43916258793e2888d4b16b904b7753dbc0a49a0d1eb318b9914484c39ef9c090
|
| 3 |
+
size 135455
|
_framework/System.Text.Json.wmn8nrdgsp.wasm.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bf29c3c87ce34e38e3a6562131b6084942cacca5e57fc60638cae83caac0d77c
|
| 3 |
+
size 163550
|
_framework/System.Text.RegularExpressions.5f6os8d0wv.wasm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7f3dec4f2c863090cb180b1af1e62713aabe72e71ef152178b494aaccb65d935
|
| 3 |
+
size 260885
|
_framework/System.Text.RegularExpressions.5f6os8d0wv.wasm.br
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c2c7013098e7d46dccddf5664f88b825e98f460a1ecdc7e8f89dfa0fd97807ac
|
| 3 |
+
size 101842
|
_framework/System.Text.RegularExpressions.5f6os8d0wv.wasm.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:30d3ca11d6934059a90adc93ac51e60b86308534addb716bf13c780318a6f265
|
| 3 |
+
size 122597
|
_framework/System.Threading.Tasks.Parallel.r9rdy25k8s.wasm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b13af9af2d26e04585a1fc4814fc6a196b79fe623e09681729141736ed774207
|
| 3 |
+
size 19733
|
_framework/System.Threading.Tasks.Parallel.r9rdy25k8s.wasm.br
ADDED
|
Binary file (8.35 kB). View file
|
|
|
_framework/System.Threading.Tasks.Parallel.r9rdy25k8s.wasm.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8e77df6060ed6a49d91ea1ec03219083907e7ed8061e4c59189dbcfb38451657
|
| 3 |
+
size 9499
|
_framework/System.Threading.Thread.u9w6y2s95v.wasm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e292383613007745731707bfdbc2d5b52715eb81bb3113bb2d3423c4212b89e5
|
| 3 |
+
size 4885
|
_framework/System.Threading.Thread.u9w6y2s95v.wasm.br
ADDED
|
Binary file (1.65 kB). View file
|
|
|
_framework/System.Threading.Thread.u9w6y2s95v.wasm.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a4c1fc9804a86162634657ea4a7f35bb72adc7229ca66b2786664ee312072970
|
| 3 |
+
size 1887
|
_framework/System.Threading.cqof8b7mz4.wasm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0cd19cff440cb608c83167bfc5aff5e1da13901849fdde0eca3b09ddb13637c7
|
| 3 |
+
size 12053
|
_framework/System.Threading.cqof8b7mz4.wasm.br
ADDED
|
Binary file (3.78 kB). View file
|
|
|
_framework/System.Threading.cqof8b7mz4.wasm.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:13d8a007649f28004f91b4c8a05b3711794ce1b742fefd65573b4449a845c81e
|
| 3 |
+
size 4470
|
_framework/System.Xml.Linq.6wuwtpojma.wasm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9a1ae1a9b71d5396d7d72e6d87fda5ecefd14d3c73c48db07034f1269d92aef6
|
| 3 |
+
size 4373
|
_framework/System.Xml.Linq.6wuwtpojma.wasm.br
ADDED
|
Binary file (1.43 kB). View file
|
|
|
_framework/System.Xml.Linq.6wuwtpojma.wasm.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:857ff3a812858d37990991dcdf50d2671be9839ba22f23c8da352461e4c446b6
|
| 3 |
+
size 1628
|
_framework/System.Xml.XDocument.amngb6ohpq.wasm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6ea15d148b0ef6afa70064f23f592c9fed1f677e4cd4e450acde51fc109428b7
|
| 3 |
+
size 4885
|
_framework/System.Xml.XDocument.amngb6ohpq.wasm.br
ADDED
|
Binary file (1.67 kB). View file
|
|
|
_framework/System.Xml.XDocument.amngb6ohpq.wasm.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0ceea4dcb1d4efb35f49bdabe5ac80175cd9f1b83036a7c756a3651b2da46f3d
|
| 3 |
+
size 1879
|
css/app.css
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
:root { --bg-0: #111; --bg-1: #1b1b1b; --bg-2: #232323; --bg-3: #282828; --bg-4: #2d2d2d; --ctl: #3a3a3a; --ctl-hover: #474747; --line: #111; --line-2: #4a4a4a; --fg-strong: #fff; --fg: #ddd; --fg-mid: #b5b5b5; --fg-dim: #8a8a8a; color-scheme: dark; }
|
| 2 |
+
:root[data-theme=light] { --bg-0: #dcdcdc; --bg-1: #ffffff; --bg-2: #e9e9e9; --bg-3: #f3f3f3; --bg-4: #fafafa; --ctl: #e0e0e0; --ctl-hover: #d0d0d0; --line: #c4c4c4; --line-2: #b0b0b0; --fg-strong: #111; --fg: #222; --fg-mid: #4a4a4a; --fg-dim: #6a6a6a; color-scheme: light; }
|
| 3 |
+
html, body, #app { height: 100%; margin: 0; }
|
| 4 |
+
body { background: var(--bg-2); color: var(--fg); font-family: system-ui, "Segoe UI", sans-serif; font-size: 14px; overflow: hidden; }
|
| 5 |
+
.boot { padding: 2rem; color: var(--fg-dim); }
|
| 6 |
+
#blazor-error-ui { background: #5a1d1d; bottom: 0; display: none; left: 0; padding: 0.6rem 1.2rem; position: fixed; width: 100%; z-index: 1000; }
|
| 7 |
+
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
|
| 8 |
+
|
| 9 |
+
.studio { display: flex; flex-direction: column; height: 100%; }
|
| 10 |
+
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 5px; white-space: nowrap; padding: 6px 10px; background: var(--bg-3); border-bottom: 1px solid var(--line); }
|
| 11 |
+
.toolbar .brand { font-weight: 700; letter-spacing: 0.3px; margin-right: 10px; color: var(--fg-strong); }
|
| 12 |
+
.toolbar .sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 4px; }
|
| 13 |
+
.toolbar > * { flex-shrink: 0; }
|
| 14 |
+
.toolbar button .count { display: inline-block; margin-left: 6px; min-width: 16px; padding: 0 5px; border-radius: 8px; background: #fff; color: #2f5fa8; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; }
|
| 15 |
+
.runbar { display: flex; align-items: center; gap: 10px; flex-shrink: 0; height: 26px; padding: 0 10px; background: var(--bg-3); border-top: 1px solid var(--line); font-size: 12px; }
|
| 16 |
+
.runbar .status { flex: 1; min-width: 0; color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
| 17 |
+
.runbar.busy .status { color: var(--fg-strong); }
|
| 18 |
+
.runbar .run-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); flex-shrink: 0; }
|
| 19 |
+
.runbar .run-dot.queued { background: #d9a520; }
|
| 20 |
+
.runbar .run-dot.running { background: #4caf50; animation: run-pulse 1.2s ease-in-out infinite; }
|
| 21 |
+
@keyframes run-pulse { 50% { opacity: 0.35; } }
|
| 22 |
+
.runbar .run-progress { position: relative; width: 240px; height: 8px; flex-shrink: 0; border-radius: 4px; background: var(--bg-0); border: 1px solid var(--line-2); overflow: hidden; }
|
| 23 |
+
.runbar .run-progress > div { height: 100%; background: #4caf50; transition: width 0.3s; }
|
| 24 |
+
.runbar .run-progress.indeterminate > div { position: absolute; transition: none; animation: run-slide 1.4s linear infinite; }
|
| 25 |
+
@keyframes run-slide { from { left: -30%; } to { left: 100%; } }
|
| 26 |
+
.runbar .run-pct { width: 34px; flex-shrink: 0; color: var(--fg-strong); text-align: right; }
|
| 27 |
+
.runbar .queued { flex-shrink: 0; background: #d9a52033; color: var(--fg-strong); border: 1px solid #d9a520; border-radius: 10px; padding: 0 10px; font: inherit; cursor: pointer; line-height: 18px; }
|
| 28 |
+
.runbar .queued:hover { background: #d9a52066; }
|
| 29 |
+
.toolbar button, .toolbar label.button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 4px 9px; cursor: pointer; font: inherit; }
|
| 30 |
+
.toolbar button:hover:not(:disabled), .toolbar label.button:hover { background: var(--ctl-hover); }
|
| 31 |
+
.toolbar button:disabled { opacity: 0.45; cursor: default; }
|
| 32 |
+
.toolbar button.primary { background: #2f5fa8; border-color: #3d73c4; color: #fff; }
|
| 33 |
+
.tabs { display: flex; align-items: flex-end; gap: 2px; padding: 4px 10px 0; background: var(--bg-2); border-bottom: 1px solid var(--line); overflow-x: auto; min-height: 28px; }
|
| 34 |
+
.tabs .tab { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 12px; background: var(--bg-4); color: var(--fg-mid); border: 1px solid var(--line-2); border-bottom: 0; border-radius: 6px 6px 0 0; cursor: pointer; white-space: nowrap; max-width: 220px; user-select: none; }
|
| 35 |
+
.tabs .tab.active { background: var(--bg-1); color: var(--fg-strong); border-color: var(--line-2); }
|
| 36 |
+
.tabs .tab span { overflow: hidden; text-overflow: ellipsis; }
|
| 37 |
+
.tabs .tab input { width: 130px; background: var(--bg-0); color: var(--fg-strong); border: 1px solid #4f8fe8; border-radius: 3px; font: inherit; padding: 0 4px; outline: none; }
|
| 38 |
+
.tabs .tab button { background: none; border: 0; color: var(--fg-dim); cursor: pointer; padding: 0 2px; font-size: 15px; line-height: 1; }
|
| 39 |
+
.tabs .tab button:hover { color: var(--fg-strong); }
|
| 40 |
+
.tabs .newtab { background: none; border: 0; color: var(--fg-mid); cursor: pointer; font-size: 18px; padding: 0 8px 2px; }
|
| 41 |
+
.tabs .newtab:hover { color: var(--fg-strong); }
|
| 42 |
+
.stage { position: relative; flex: 1; min-height: 0; }
|
| 43 |
+
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
|
| 44 |
+
|
| 45 |
+
.toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111c; color: var(--fg-strong); padding: 8px 16px; border-radius: 6px; border: 1px solid var(--line-2); max-width: 70%; pointer-events: none; }
|
| 46 |
+
|
| 47 |
+
.widget-edit { position: absolute; z-index: 5; display: flex; }
|
| 48 |
+
.widget-edit input, .widget-edit select, .widget-edit textarea { flex: 1; min-width: 0; background: var(--bg-1); color: var(--fg-strong); border: 1px solid #4f8fe8; border-radius: 5px; padding: 2px 8px; font: inherit; outline: none; }
|
| 49 |
+
.widget-edit textarea { resize: none; }
|
| 50 |
+
|
| 51 |
+
.templates { width: min(1100px, 94%); height: 80vh; align-self: flex-start; display: flex; flex-direction: column; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 40px #000a; overflow: hidden; }
|
| 52 |
+
.templates .tpl-head { display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--line-2); }
|
| 53 |
+
.templates .tpl-head input { flex: 1; padding: 9px 12px; background: var(--bg-1); color: var(--fg-strong); border: 1px solid var(--line-2); border-radius: 6px; font: inherit; font-size: 15px; outline: none; }
|
| 54 |
+
.templates .tpl-count { color: var(--fg-dim); font-size: 12px; min-width: 30px; text-align: right; }
|
| 55 |
+
.templates .tpl-groups { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
|
| 56 |
+
.templates .tpl-groups button.on { background: #2f5fa8; color: #fff; }
|
| 57 |
+
.templates .tpl-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); grid-auto-rows: max-content; gap: 10px; padding: 10px; align-content: start; }
|
| 58 |
+
.templates .tpl-card { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
|
| 59 |
+
.templates .tpl-card:hover { border-color: #4f8fe8; }
|
| 60 |
+
.templates .tpl-thumb { position: relative; aspect-ratio: 4 / 3; background: var(--bg-0); display: flex; align-items: center; justify-content: center; color: var(--fg-dim); }
|
| 61 |
+
.templates .tpl-thumb img { width: 100%; height: 100%; object-fit: cover; }
|
| 62 |
+
.templates .tpl-show { padding: 6px 10px; background: var(--bg-1); color: var(--fg); border: 1px solid var(--line-2); border-radius: 6px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
|
| 63 |
+
.templates .tpl-show.on { background: var(--accent, #2f6fdb); color: #fff; border-color: transparent; }
|
| 64 |
+
.templates .tpl-badge { position: absolute; top: 6px; right: 6px; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 8px; }
|
| 65 |
+
.templates .tpl-missing { background: #c94040; color: #fff; }
|
| 66 |
+
.templates .tpl-models { background: #3a6ea5; color: #fff; }
|
| 67 |
+
.templates .tpl-ready { background: #2e8b57; color: #fff; }
|
| 68 |
+
.templates .tpl-api { position: absolute; top: 6px; right: 6px; background: #d9a520; color: #111; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 8px; }
|
| 69 |
+
.templates .tpl-title { padding: 6px 8px 2px; color: var(--fg-strong); font-weight: 600; font-size: 13px; }
|
| 70 |
+
.templates .tpl-desc { margin: 0 8px 8px; color: var(--fg-dim); font-size: 12px; line-height: 1.35; max-height: calc(3 * 1.35em); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
| 71 |
+
.templates .tpl-none { color: var(--fg-dim); padding: 20px; }
|
| 72 |
+
.templates .tpl-more { grid-column: 1 / -1; }
|
| 73 |
+
.search-backdrop { position: absolute; inset: 0; z-index: 10; background: rgba(0,0,0,0.35); display: flex; justify-content: center; padding-top: 12vh; }
|
| 74 |
+
.search { width: min(560px, 92%); align-self: flex-start; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 40px #000a; overflow: hidden; }
|
| 75 |
+
.search input { width: 100%; box-sizing: border-box; padding: 12px 14px; background: var(--bg-1); color: var(--fg-strong); border: 0; border-bottom: 1px solid var(--line-2); font: inherit; font-size: 15px; outline: none; }
|
| 76 |
+
.search ul { list-style: none; margin: 0; padding: 4px; max-height: 50vh; overflow-y: auto; }
|
| 77 |
+
.search li { display: flex; justify-content: space-between; padding: 7px 10px; border-radius: 5px; cursor: pointer; }
|
| 78 |
+
.search li.on { background: #2f5fa8; color: #fff; }
|
| 79 |
+
.search li .cat { color: var(--fg-dim); font-size: 12px; }
|
| 80 |
+
.search li.none { color: var(--fg-dim); cursor: default; }
|
| 81 |
+
|
| 82 |
+
.menu { position: absolute; z-index: 20; list-style: none; margin: 0; padding: 4px; min-width: 190px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: 0 8px 28px #000a; }
|
| 83 |
+
.menu li { padding: 6px 12px; border-radius: 4px; cursor: pointer; }
|
| 84 |
+
.menu li:hover { background: #2f5fa8; color: #fff; }
|
| 85 |
+
.menu li.has-sub { position: relative; display: flex; justify-content: space-between; gap: 12px; }
|
| 86 |
+
.menu li.has-sub .arrow { color: inherit; opacity: 0.7; }
|
| 87 |
+
.menu .sub { display: none; left: 100%; top: -5px; color: var(--fg); }
|
| 88 |
+
.menu li.has-sub:hover > .sub, .menu li.has-sub.open > .sub { display: block; }
|
| 89 |
+
.menu.flip .sub { left: auto; right: 100%; }
|
| 90 |
+
.toolbar button.danger { background: #8a2f2f; border-color: #b04545; color: #fff; }
|
| 91 |
+
.toolbar label.check { display: flex; align-items: center; gap: 5px; color: var(--fg-mid); font-size: 12px; margin-left: 4px; cursor: pointer; }
|
| 92 |
+
.toolbar label.check input { accent-color: #4f8fe8; }
|
| 93 |
+
.toolbar label.check input.batch { width: 46px; background: var(--bg-3); color: var(--fg); border: 1px solid var(--line-2); border-radius: 3px; padding: 2px 4px; }
|
| 94 |
+
.toolbar select.engine { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 3px 6px; font: inherit; max-width: 210px; }
|
| 95 |
+
|
| 96 |
+
.toolbar button.on { background: #2f5fa8; border-color: #3d73c4; color: #fff; }
|
| 97 |
+
.toolbar button.on:hover:not(:disabled), .toolbar button.primary:hover:not(:disabled) { background: #3d73c4; }
|
| 98 |
+
.toolbar button.danger:hover:not(:disabled) { background: #a03a3a; }
|
| 99 |
+
.library { position: absolute; left: 0; top: 0; bottom: 0; width: 260px; z-index: 4; display: flex; flex-direction: column; background: var(--bg-2); border-right: 1px solid var(--line); }
|
| 100 |
+
.library .lib-filter { margin: 8px; padding: 6px 10px; background: var(--bg-1); color: var(--fg-strong); border: 1px solid var(--line-2); border-radius: 5px; font: inherit; outline: none; }
|
| 101 |
+
.library .lib-filter:focus { border-color: #4f8fe8; }
|
| 102 |
+
.library .lib-list { flex: 1; overflow-y: auto; padding: 0 6px 8px; user-select: none; }
|
| 103 |
+
.library .lib-cat { padding: 5px 6px; margin-top: 4px; color: var(--fg-mid); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; cursor: pointer; display: flex; justify-content: space-between; }
|
| 104 |
+
.library .lib-cat span { color: var(--fg-dim); }
|
| 105 |
+
.library .lib-node { padding: 5px 10px 5px 18px; border-radius: 4px; cursor: grab; color: var(--fg); }
|
| 106 |
+
.library .lib-node:hover { background: #2f5fa8; color: #fff; }
|
| 107 |
+
.history { position: absolute; right: 0; top: 0; bottom: 0; width: 300px; z-index: 4; display: flex; flex-direction: column; background: var(--bg-2); border-left: 1px solid var(--line); }
|
| 108 |
+
.history .hist-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; color: var(--fg-mid); border-bottom: 1px solid var(--line); }
|
| 109 |
+
.history .hist-head button, .history .hist-actions button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 4px; padding: 2px 10px; cursor: pointer; font: inherit; font-size: 12px; }
|
| 110 |
+
.history .hist-head button:disabled { opacity: 0.45; cursor: default; }
|
| 111 |
+
.history .hist-list { flex: 1; overflow-y: auto; padding: 8px; }
|
| 112 |
+
.history .hist-entry { background: var(--bg-4); border: 1px solid var(--line-2); border-left: 3px solid var(--fg-dim); border-radius: 5px; padding: 6px 8px; margin-bottom: 8px; }
|
| 113 |
+
.history .hist-entry.running { border-left-color: #4f8fe8; }
|
| 114 |
+
.history .hist-entry.done { border-left-color: #4caf6a; }
|
| 115 |
+
.history .hist-entry.failed { border-left-color: #c24a4a; }
|
| 116 |
+
.history .hist-title { font-size: 12px; color: var(--fg); }
|
| 117 |
+
.history .hist-engine { font-size: 11px; color: var(--fg-dim); margin-bottom: 4px; }
|
| 118 |
+
.history .hist-error { font-size: 12px; color: #e08080; margin: 4px 0; word-break: break-word; }
|
| 119 |
+
.history .hist-thumbs { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
|
| 120 |
+
.history .hist-thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 3px; cursor: zoom-in; background: var(--bg-0); }
|
| 121 |
+
.history .hist-none { color: var(--fg-dim); padding: 12px 4px; }
|
| 122 |
+
.lightbox { position: absolute; inset: 0; z-index: 15; background: rgba(0,0,0,0.82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; cursor: zoom-out; }
|
| 123 |
+
.lightbox img { max-width: 90%; max-height: 82%; object-fit: contain; box-shadow: 0 8px 40px #000; }
|
| 124 |
+
.lightbox button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 5px 16px; cursor: pointer; font: inherit; }
|
| 125 |
+
.history .hist-note { font-size: 12px; color: var(--fg-dim); margin: 4px 0; }
|
| 126 |
+
.history .hist-entry.queued { border-left-color: #c9a227; }
|
| 127 |
+
.settings { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); z-index: 12; width: 280px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 40px #000a; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
|
| 128 |
+
.settings .set-head { display: flex; justify-content: space-between; align-items: center; color: var(--fg-strong); font-weight: 600; }
|
| 129 |
+
.settings .set-head button { background: none; border: 0; color: var(--fg-mid); font-size: 18px; cursor: pointer; }
|
| 130 |
+
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--fg); }
|
| 131 |
+
.settings label.row { justify-content: flex-start; }
|
| 132 |
+
.settings select, .settings input[type=number] { background: var(--bg-1); color: var(--fg); border: 1px solid var(--line-2); border-radius: 4px; padding: 3px 6px; font: inherit; }
|
| 133 |
+
.settings input[type=number] { width: 70px; }
|
| 134 |
+
.history .hist-entry audio { width: 100%; height: 32px; margin: 4px 0; }
|
| 135 |
+
.maskeditor { position: fixed; inset: 0; z-index: 100; background: var(--bg-1); display: flex; flex-direction: column; }
|
| 136 |
+
.maskeditor .me-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-3); border-bottom: 1px solid var(--line); color: var(--fg); }
|
| 137 |
+
.maskeditor .me-bar > span:first-child { font-weight: 600; color: var(--fg-strong); margin-right: 8px; }
|
| 138 |
+
.maskeditor .me-bar button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 4px 12px; cursor: pointer; font: inherit; }
|
| 139 |
+
.maskeditor .me-bar button.on { background: #2f5fa8; border-color: #3d73c4; color: #fff; }
|
| 140 |
+
.maskeditor .me-bar button.me-save { background: #2f7a4a; border-color: #3d9a5e; color: #fff; }
|
| 141 |
+
.maskeditor .me-spacer { flex: 1; }
|
| 142 |
+
.maskeditor .me-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 12px; }
|
| 143 |
+
.maskeditor .me-stack { position: relative; max-width: 100%; max-height: 100%; display: flex; }
|
| 144 |
+
.maskeditor .me-stack canvas { max-width: calc(100vw - 24px); max-height: calc(100vh - 90px); object-fit: contain; display: block; }
|
| 145 |
+
.maskeditor .me-mask { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.55; cursor: crosshair; touch-action: none; }
|
| 146 |
+
.models { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); z-index: 12; width: 520px; max-height: 70vh; overflow: hidden; display: flex; flex-direction: column; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 40px #000a; padding: 10px 14px 14px; gap: 8px; }
|
| 147 |
+
.models .set-head { display: flex; justify-content: space-between; align-items: center; color: var(--fg-strong); font-weight: 600; }
|
| 148 |
+
.models .set-head button { background: none; border: 0; color: var(--fg-mid); font-size: 18px; cursor: pointer; }
|
| 149 |
+
.models .model-total { display: flex; justify-content: space-between; align-items: center; color: var(--fg-mid); font-size: 12px; }
|
| 150 |
+
.models button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 4px; padding: 2px 10px; cursor: pointer; font: inherit; font-size: 12px; }
|
| 151 |
+
.models button:disabled { opacity: 0.45; cursor: default; }
|
| 152 |
+
.models .model-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
|
| 153 |
+
.models .model-file { display: flex; align-items: center; gap: 10px; padding: 3px 6px; border-radius: 4px; color: var(--fg); font-size: 12px; }
|
| 154 |
+
.models .model-file:hover { background: var(--bg-4); }
|
| 155 |
+
.models .model-file .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
| 156 |
+
.models .model-file .size { color: var(--fg-dim); white-space: nowrap; }
|
| 157 |
+
.models .model-file.partial .name { color: #c9a227; }
|
| 158 |
+
.models .model-file button { padding: 0 8px; font-size: 14px; }
|
| 159 |
+
.models .model-download { background: var(--bg-4); border: 1px solid var(--line-2); border-radius: 5px; padding: 6px 8px; font-size: 12px; color: var(--fg); }
|
| 160 |
+
.models .model-download .bar { height: 6px; background: var(--bg-1); border-radius: 3px; margin: 4px 0; overflow: hidden; }
|
| 161 |
+
.models .model-download .bar > div { height: 100%; background: #4f8fe8; }
|
| 162 |
+
.models .model-download .sub { color: var(--fg-dim); }
|
| 163 |
+
.glbviewer { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--bg-1); }
|
| 164 |
+
.glbviewer .gv-bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--bg-3); border-bottom: 1px solid var(--line-2); color: var(--fg); font-size: 13px; }
|
| 165 |
+
.glbviewer .gv-title { font-weight: 600; color: var(--fg-strong); }
|
| 166 |
+
.glbviewer .gv-hint { color: var(--fg-dim); font-size: 12px; }
|
| 167 |
+
.glbviewer .gv-spacer { flex: 1; }
|
| 168 |
+
.glbviewer button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 4px; padding: 3px 12px; cursor: pointer; font: inherit; }
|
| 169 |
+
.glbviewer .gv-canvas { flex: 1; width: 100%; min-height: 0; touch-action: none; cursor: grab; }
|
| 170 |
+
.glbviewer .gv-status { position: absolute; left: 12px; bottom: 10px; color: var(--fg-dim); font-size: 12px; pointer-events: none; }
|
| 171 |
+
.glbviewer .gv-status.error { color: #e05555; font-size: 14px; }
|
| 172 |
+
.props { position: absolute; right: 0; top: 0; bottom: 0; width: 320px; z-index: 4; display: flex; flex-direction: column; background: var(--bg-2); border-left: 1px solid var(--line); color: var(--fg); font-size: 13px; }
|
| 173 |
+
.props.beside { right: 300px; }
|
| 174 |
+
.props .props-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; color: var(--fg-mid); border-bottom: 1px solid var(--line); }
|
| 175 |
+
.props .props-head button { background: none; border: 0; color: var(--fg-mid); font-size: 18px; cursor: pointer; }
|
| 176 |
+
.props .props-body { flex: 1; overflow-y: auto; padding: 4px 12px 16px; display: flex; flex-direction: column; gap: 6px; }
|
| 177 |
+
.props .props-none { color: var(--fg-dim); padding: 10px 0; }
|
| 178 |
+
.props .props-title { font-weight: 600; color: var(--fg-strong); margin-top: 6px; }
|
| 179 |
+
.props .props-section { margin-top: 12px; padding-bottom: 3px; border-bottom: 1px solid var(--line-2); color: var(--fg-mid); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
|
| 180 |
+
.props label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
|
| 181 |
+
.props label > span:first-child { color: var(--fg-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
| 182 |
+
.props label.row { justify-content: flex-start; }
|
| 183 |
+
.props label.multi { flex-direction: column; align-items: stretch; gap: 3px; }
|
| 184 |
+
.props input[type=text], .props input[type=number], .props select, .props textarea { width: 170px; box-sizing: border-box; background: var(--bg-1); color: var(--fg); border: 1px solid var(--line-2); border-radius: 4px; padding: 3px 6px; font: inherit; }
|
| 185 |
+
.props label.multi textarea { width: 100%; resize: vertical; }
|
| 186 |
+
.props input:focus, .props select:focus, .props textarea:focus { outline: none; border-color: #4f8fe8; }
|
| 187 |
+
.props .props-kv { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 3px; }
|
| 188 |
+
.props .props-kv > span:first-child { color: var(--fg-mid); white-space: nowrap; }
|
| 189 |
+
.props .props-kv > :last-child { text-align: right; overflow-wrap: anywhere; min-width: 0; }
|
| 190 |
+
.props i { font-style: normal; color: var(--fg-dim); font-size: 11px; margin-left: 4px; }
|
| 191 |
+
.props code { color: var(--fg-dim); font-size: 11px; }
|
| 192 |
+
.props .props-desc { color: var(--fg-dim); font-size: 12px; }
|
| 193 |
+
.props .dim { color: var(--fg-dim); }
|
| 194 |
+
.props .missing { color: #e05555; }
|
| 195 |
+
.props button.link { background: none; border: 0; padding: 0 0 0 6px; color: #4f8fe8; cursor: pointer; font: inherit; text-align: right; max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; margin-left: auto; }
|
| 196 |
+
.props button.link:hover { text-decoration: underline; }
|
| 197 |
+
.crumbs { position: absolute; left: 12px; top: 10px; z-index: 3; display: flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 6px; color: var(--fg-mid); font-size: 13px; }
|
| 198 |
+
.crumbs button { background: none; border: 0; padding: 0; color: #4f8fe8; cursor: pointer; font: inherit; }
|
| 199 |
+
.crumbs button:hover { text-decoration: underline; }
|
| 200 |
+
.crumbs b { color: var(--fg-strong); font-weight: 600; }
|
| 201 |
+
|
| 202 |
+
/* ---- App Mode and the App Builder ---- */
|
| 203 |
+
.app-steps { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 4px; padding: 5px 8px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,0.35); font-size: 13px; }
|
| 204 |
+
.app-steps-title { color: var(--fg-mid); margin-right: 6px; }
|
| 205 |
+
.app-steps button { background: none; border: 1px solid transparent; border-radius: 5px; color: var(--fg-mid); padding: 3px 9px; cursor: pointer; font: inherit; }
|
| 206 |
+
.app-steps button b { display: inline-block; width: 18px; height: 18px; line-height: 18px; border-radius: 50%; background: var(--ctl); color: var(--fg); text-align: center; font-size: 11px; margin-right: 4px; }
|
| 207 |
+
.app-steps button.on { border-color: #3d73c4; color: var(--fg-strong); }
|
| 208 |
+
.app-steps button.on b, .app-steps button.done b { background: #2f5fa8; color: #fff; }
|
| 209 |
+
.app-picks { position: absolute; right: 0; top: 0; bottom: 48px; width: 300px; z-index: 5; display: flex; flex-direction: column; background: var(--bg-2); border-left: 1px solid var(--line); font-size: 13px; }
|
| 210 |
+
.app-picks .set-head, .app-in .set-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; color: var(--fg-strong); font-weight: 600; border-bottom: 1px solid var(--line); }
|
| 211 |
+
.app-in .set-head button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 10px; cursor: pointer; font: inherit; font-weight: normal; }
|
| 212 |
+
.app-hint { padding: 8px 12px; color: var(--fg-dim); font-size: 12px; }
|
| 213 |
+
.app-pick-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 4px; }
|
| 214 |
+
.app-pick { display: flex; align-items: center; gap: 6px; padding: 5px 6px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 5px; }
|
| 215 |
+
.app-pick b { width: 18px; height: 18px; line-height: 18px; border-radius: 50%; background: #4aa8ff; color: #fff; text-align: center; font-size: 11px; flex-shrink: 0; }
|
| 216 |
+
.app-pick span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
| 217 |
+
.app-pick button { background: none; border: 0; color: var(--fg-mid); cursor: pointer; padding: 0 3px; font-size: 14px; }
|
| 218 |
+
.app-pick button:hover { color: var(--fg-strong); }
|
| 219 |
+
.app-default { position: absolute; inset: 0 0 48px 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: var(--bg-2); }
|
| 220 |
+
.app-default h3 { margin: 0; color: var(--fg-strong); }
|
| 221 |
+
.app-default p { margin: 0 0 6px; color: var(--fg-dim); }
|
| 222 |
+
.app-default label { display: flex; gap: 8px; align-items: center; min-width: 160px; }
|
| 223 |
+
.app-builder-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 48px; z-index: 7; display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--bg-3); border-top: 1px solid var(--line); }
|
| 224 |
+
.app-builder-bar .grow { flex: 1; }
|
| 225 |
+
.app-builder-bar button, .app-default button, .app-run-row button, .app-graph, .app-field label.button, .app-progress button, .app-results button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 5px 14px; cursor: pointer; font: inherit; }
|
| 226 |
+
.app-builder-bar button.primary, .app-default button.primary, .app-run-row button.primary { background: #2f5fa8; border-color: #3d73c4; color: #fff; }
|
| 227 |
+
.app-progress button.danger { background: #8a2f2f; border-color: #b04545; color: #fff; }
|
| 228 |
+
.app-builder-bar button:disabled, .app-run-row button:disabled { opacity: 0.5; cursor: default; }
|
| 229 |
+
.appmode { position: absolute; inset: 0; z-index: 5; display: flex; background: var(--bg-1); }
|
| 230 |
+
.appmode.preview { bottom: 48px; }
|
| 231 |
+
.app-out { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
| 232 |
+
.app-progress { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); color: var(--fg-strong); font-size: 13px; }
|
| 233 |
+
.app-progress span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
| 234 |
+
.app-progress .run-progress { position: relative; width: 220px; height: 8px; border-radius: 4px; background: var(--bg-0); border: 1px solid var(--line-2); overflow: hidden; }
|
| 235 |
+
.app-progress .run-progress > div { height: 100%; background: #4caf50; transition: width 0.3s; }
|
| 236 |
+
.app-progress .run-progress.indeterminate > div { position: absolute; transition: none; animation: run-slide 1.4s linear infinite; }
|
| 237 |
+
.app-results { flex: 1; min-height: 0; overflow: auto; display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 14px; padding: 18px; }
|
| 238 |
+
.app-results img { max-width: 100%; max-height: calc(100% - 4px); object-fit: contain; border-radius: 6px; box-shadow: 0 6px 26px rgba(0,0,0,0.4); cursor: zoom-in; }
|
| 239 |
+
.app-results pre { max-width: 100%; white-space: pre-wrap; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 6px; padding: 10px 12px; margin: 0; }
|
| 240 |
+
.app-empty { margin: auto; color: var(--fg-dim); }
|
| 241 |
+
.app-runs { display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; border-top: 1px solid var(--line); background: var(--bg-2); flex-shrink: 0; }
|
| 242 |
+
.app-run { width: 64px; height: 64px; flex-shrink: 0; border-radius: 5px; border: 2px solid var(--line-2); background: var(--bg-3); display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; color: var(--fg-mid); font-size: 12px; }
|
| 243 |
+
.app-run img { width: 100%; height: 100%; object-fit: cover; }
|
| 244 |
+
.app-run.on { border-color: #4aa8ff; }
|
| 245 |
+
.app-run.queued { border-style: dashed; border-color: #d9a520; cursor: default; }
|
| 246 |
+
.app-run.failed { border-color: #b04545; }
|
| 247 |
+
.app-run.running { border-color: #4caf50; }
|
| 248 |
+
.app-in { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; background: var(--bg-2); border-left: 1px solid var(--line); font-size: 13px; }
|
| 249 |
+
.app-in-body { flex: 1; overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 10px; }
|
| 250 |
+
.app-field { display: flex; flex-direction: column; gap: 5px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
|
| 251 |
+
.app-field.missing { color: #e05555; }
|
| 252 |
+
.app-field-node { color: var(--fg-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
|
| 253 |
+
.app-field > label { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
|
| 254 |
+
.app-field > label > span:first-child { color: var(--fg-mid); }
|
| 255 |
+
.app-field > label.row { justify-content: flex-start; }
|
| 256 |
+
.app-field > label.multi { flex-direction: column; align-items: stretch; gap: 3px; }
|
| 257 |
+
.app-field input[type=text], .app-field input[type=number], .app-field select, .app-field textarea { width: 190px; box-sizing: border-box; background: var(--bg-1); color: var(--fg); border: 1px solid var(--line-2); border-radius: 4px; padding: 4px 6px; font: inherit; }
|
| 258 |
+
.app-field > label.multi textarea { width: 100%; resize: vertical; }
|
| 259 |
+
.app-field label.button { align-self: flex-start; }
|
| 260 |
+
.app-picture { max-width: 100%; max-height: 200px; object-fit: contain; border-radius: 5px; align-self: center; }
|
| 261 |
+
.app-run-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
|
| 262 |
+
.app-run-row .batch { width: 60px; background: var(--bg-1); color: var(--fg); border: 1px solid var(--line-2); border-radius: 4px; padding: 3px 5px; font: inherit; }
|
| 263 |
+
.app-run-row button.primary { flex: 1; padding: 8px 14px; font-weight: 600; }
|
| 264 |
+
.app-graph { margin: 0 12px 12px; }
|
| 265 |
+
@media (max-width: 760px) {
|
| 266 |
+
.appmode { flex-direction: column; }
|
| 267 |
+
.app-in { width: auto; max-height: 55%; border-left: 0; border-top: 1px solid var(--line); }
|
| 268 |
+
.app-picks { width: 100%; top: auto; height: 45%; }
|
| 269 |
+
.app-steps { left: 8px; right: 8px; transform: none; flex-wrap: wrap; }
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
/* ---- Workflow library (Workflows / Apps sidebar) and the Save dialog ---- */
|
| 273 |
+
.library.workflows { z-index: 6; } /* above the app view: the library is used from an app too */
|
| 274 |
+
.workflows .wf-tabs { display: flex; gap: 4px; padding: 8px 8px 0; }
|
| 275 |
+
.workflows .wf-tabs button { flex: 1; background: var(--ctl); color: var(--fg-mid); border: 1px solid var(--line-2); border-radius: 5px; padding: 4px 8px; cursor: pointer; font: inherit; }
|
| 276 |
+
.workflows .wf-tabs button.on { background: #2f5fa8; border-color: #3d73c4; color: #fff; }
|
| 277 |
+
.workflows .wf-create { width: 100%; margin: 4px 0; background: var(--ctl); color: var(--fg); border: 1px dashed var(--line-2); border-radius: 5px; padding: 6px; cursor: pointer; font: inherit; }
|
| 278 |
+
.workflows .wf-create:hover { border-color: #4f8fe8; color: var(--fg-strong); }
|
| 279 |
+
.workflows .wf-item { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 4px; cursor: pointer; color: var(--fg); }
|
| 280 |
+
.workflows .wf-item:hover { background: var(--bg-3); }
|
| 281 |
+
.workflows .wf-item.active { background: #2f5fa833; color: var(--fg-strong); }
|
| 282 |
+
.workflows .wf-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
| 283 |
+
.workflows .wf-item small { color: var(--fg-dim); font-size: 11px; white-space: nowrap; }
|
| 284 |
+
.workflows .wf-item button { background: none; border: 0; color: var(--fg-dim); cursor: pointer; padding: 0 3px; font-size: 13px; visibility: hidden; }
|
| 285 |
+
.workflows .wf-item:hover button, .workflows .wf-item.confirm button { visibility: visible; }
|
| 286 |
+
.workflows .wf-item button:hover { color: var(--fg-strong); }
|
| 287 |
+
.workflows .wf-item.confirm { cursor: default; background: var(--bg-3); }
|
| 288 |
+
.workflows .wf-item.confirm button { border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 8px; color: var(--fg); background: var(--ctl); font-size: 12px; }
|
| 289 |
+
.workflows .wf-item.confirm button.danger { background: #8a2f2f; border-color: #b04545; color: #fff; }
|
| 290 |
+
.workflows .wf-app { font-size: 10px; font-weight: 600; text-transform: uppercase; color: #fff; background: #2f5fa8; border-radius: 3px; padding: 0 4px; }
|
| 291 |
+
.workflows .wf-rename { width: 100%; box-sizing: border-box; margin: 2px 0; padding: 4px 8px; background: var(--bg-1); color: var(--fg-strong); border: 1px solid #4f8fe8; border-radius: 4px; font: inherit; outline: none; }
|
| 292 |
+
.workflows .wf-foot { display: flex; align-items: center; gap: 6px; padding: 8px; border-top: 1px solid var(--line); font-size: 12px; }
|
| 293 |
+
.workflows .wf-foot button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 3px 10px; cursor: pointer; font: inherit; }
|
| 294 |
+
.workflows .wf-foot span { color: var(--fg-dim); margin-left: auto; white-space: nowrap; }
|
| 295 |
+
.modal-back { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: #0008; }
|
| 296 |
+
.save-dialog { width: min(420px, calc(100vw - 32px)); box-sizing: border-box; padding: 16px 18px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 40px #000a; display: flex; flex-direction: column; gap: 10px; }
|
| 297 |
+
.save-dialog h3 { margin: 0; color: var(--fg-strong); font-size: 15px; }
|
| 298 |
+
.save-dialog p { margin: 0; color: var(--fg-dim); font-size: 12px; }
|
| 299 |
+
.save-dialog p.warn { color: #e0b040; }
|
| 300 |
+
.save-dialog input { padding: 6px 10px; background: var(--bg-1); color: var(--fg-strong); border: 1px solid var(--line-2); border-radius: 5px; font: inherit; outline: none; }
|
| 301 |
+
.save-dialog input:focus { border-color: #4f8fe8; }
|
| 302 |
+
.save-dialog .row { display: flex; justify-content: flex-end; gap: 8px; }
|
| 303 |
+
.save-dialog button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 5px 14px; cursor: pointer; font: inherit; }
|
| 304 |
+
.save-dialog button.primary { background: #2f5fa8; border-color: #3d73c4; color: #fff; }
|
| 305 |
+
|
| 306 |
+
/* ---- Keyboard shortcuts ---- */
|
| 307 |
+
.settings .set-button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 4px 10px; cursor: pointer; font: inherit; }
|
| 308 |
+
.shortcuts { width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 80px); box-sizing: border-box; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 40px #000a; font-size: 13px; }
|
| 309 |
+
.shortcuts .set-head { display: flex; justify-content: space-between; align-items: center; color: var(--fg-strong); font-weight: 600; }
|
| 310 |
+
.shortcuts .set-head button { background: none; border: 0; color: var(--fg-mid); font-size: 18px; cursor: pointer; }
|
| 311 |
+
.shortcuts .sc-filter { padding: 6px 10px; background: var(--bg-1); color: var(--fg-strong); border: 1px solid var(--line-2); border-radius: 5px; font: inherit; outline: none; }
|
| 312 |
+
.shortcuts .sc-filter:focus { border-color: #4f8fe8; }
|
| 313 |
+
.shortcuts .sc-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
|
| 314 |
+
.shortcuts .sc-row { display: flex; align-items: center; gap: 6px; padding: 4px 4px; border-bottom: 1px solid var(--line); }
|
| 315 |
+
.shortcuts .sc-row.changed .sc-name { color: #7fb4ff; }
|
| 316 |
+
.shortcuts .sc-name { flex: 1; min-width: 0; color: var(--fg); }
|
| 317 |
+
.shortcuts .sc-keys { min-width: 170px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-start; background: none; border: 1px solid transparent; border-radius: 5px; padding: 3px 5px; cursor: pointer; color: var(--fg); font: inherit; }
|
| 318 |
+
.shortcuts .sc-keys:hover { border-color: var(--line-2); }
|
| 319 |
+
.shortcuts .sc-keys.capturing { border-color: #4f8fe8; color: #7fb4ff; outline: none; }
|
| 320 |
+
.shortcuts kbd { background: var(--bg-1); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; font-family: inherit; font-size: 12px; line-height: 18px; color: var(--fg-strong); }
|
| 321 |
+
.shortcuts .sc-none { color: var(--fg-dim); }
|
| 322 |
+
.shortcuts .sc-act { background: none; border: 0; color: var(--fg-mid); cursor: pointer; font-size: 15px; padding: 0 4px; }
|
| 323 |
+
.shortcuts .sc-act:disabled { opacity: 0.3; cursor: default; }
|
| 324 |
+
.shortcuts .sc-foot { display: flex; align-items: center; gap: 10px; color: var(--fg-mid); }
|
| 325 |
+
.shortcuts .sc-foot span { flex: 1; }
|
| 326 |
+
.shortcuts .sc-foot button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 4px 12px; cursor: pointer; font: inherit; }
|
| 327 |
+
|
| 328 |
+
/* ---- Node templates ---- */
|
| 329 |
+
.templates-manage .tpl-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
|
| 330 |
+
.templates-manage .tpl-row { display: flex; gap: 6px; align-items: center; }
|
| 331 |
+
.templates-manage .tpl-row input { flex: 1; }
|
| 332 |
+
.templates-manage .row { align-items: center; }
|
| 333 |
+
.templates-manage .row .grow { flex: 1; }
|
| 334 |
+
.save-dialog label.button { background: var(--ctl); color: var(--fg); border: 1px solid var(--line-2); border-radius: 5px; padding: 5px 14px; cursor: pointer; font: inherit; }
|
css/app.css.br
ADDED
|
Binary file (5.35 kB). View file
|
|
|
css/app.css.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:afde6ce05774eb089e7710c0478fd70b20f14084f1ce417d5653663bf978ad2f
|
| 3 |
+
size 6165
|
examples/depth.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"1": {
|
| 3 |
+
"class_type": "LoadImage",
|
| 4 |
+
"inputs": {
|
| 5 |
+
"image": "example.png"
|
| 6 |
+
}
|
| 7 |
+
},
|
| 8 |
+
"2": {
|
| 9 |
+
"class_type": "DepthAnythingV2",
|
| 10 |
+
"inputs": {
|
| 11 |
+
"image": [
|
| 12 |
+
"1",
|
| 13 |
+
0
|
| 14 |
+
]
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
"3": {
|
| 18 |
+
"class_type": "SaveImage",
|
| 19 |
+
"inputs": {
|
| 20 |
+
"images": [
|
| 21 |
+
"2",
|
| 22 |
+
0
|
| 23 |
+
],
|
| 24 |
+
"filename_prefix": "depth"
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
}
|
examples/depth.json.br
ADDED
|
Binary file (141 Bytes). View file
|
|
|
examples/depth.json.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b456b429afefbea9c7b11d76ce33503643c93365df91ec3549e3409b2e91e958
|
| 3 |
+
size 181
|
examples/detect.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"1": {
|
| 3 |
+
"class_type": "LoadImage",
|
| 4 |
+
"inputs": {
|
| 5 |
+
"image": "example.png"
|
| 6 |
+
}
|
| 7 |
+
},
|
| 8 |
+
"2": {
|
| 9 |
+
"class_type": "ObjectDetection",
|
| 10 |
+
"inputs": {
|
| 11 |
+
"image": [
|
| 12 |
+
"1",
|
| 13 |
+
0
|
| 14 |
+
],
|
| 15 |
+
"confidence": 0.25
|
| 16 |
+
}
|
| 17 |
+
},
|
| 18 |
+
"3": {
|
| 19 |
+
"class_type": "PoseEstimation",
|
| 20 |
+
"inputs": {
|
| 21 |
+
"image": [
|
| 22 |
+
"1",
|
| 23 |
+
0
|
| 24 |
+
],
|
| 25 |
+
"confidence": 0.3,
|
| 26 |
+
"overlay": true
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"4": {
|
| 30 |
+
"class_type": "SaveImage",
|
| 31 |
+
"inputs": {
|
| 32 |
+
"images": [
|
| 33 |
+
"2",
|
| 34 |
+
0
|
| 35 |
+
],
|
| 36 |
+
"filename_prefix": "boxes"
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"5": {
|
| 40 |
+
"class_type": "SaveImage",
|
| 41 |
+
"inputs": {
|
| 42 |
+
"images": [
|
| 43 |
+
"3",
|
| 44 |
+
0
|
| 45 |
+
],
|
| 46 |
+
"filename_prefix": "pose"
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"6": {
|
| 50 |
+
"class_type": "PreviewAny",
|
| 51 |
+
"inputs": {
|
| 52 |
+
"source": [
|
| 53 |
+
"2",
|
| 54 |
+
1
|
| 55 |
+
]
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
}
|
examples/detect.json.br
ADDED
|
Binary file (206 Bytes). View file
|
|
|
examples/detect.json.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d39b88514c0b3b4c66890ae8edf5e8fca59a36af9244aa250e8f992343c994b2
|
| 3 |
+
size 259
|
examples/example.png
ADDED
|
Git LFS Details
|
examples/example_inpaint.png
ADDED
|
Git LFS Details
|
examples/flux2-klein-edit.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"1": {
|
| 3 |
+
"class_type": "LoadImage",
|
| 4 |
+
"inputs": {
|
| 5 |
+
"image": "example.png"
|
| 6 |
+
}
|
| 7 |
+
},
|
| 8 |
+
"2": {
|
| 9 |
+
"class_type": "Flux2Klein",
|
| 10 |
+
"inputs": {
|
| 11 |
+
"prompt": "make the sky a deep orange sunset",
|
| 12 |
+
"width": 512,
|
| 13 |
+
"height": 512,
|
| 14 |
+
"steps": 4,
|
| 15 |
+
"seed": 7,
|
| 16 |
+
"batch_size": 1,
|
| 17 |
+
"weights": "4-bit",
|
| 18 |
+
"reference_images": [
|
| 19 |
+
"1",
|
| 20 |
+
0
|
| 21 |
+
]
|
| 22 |
+
}
|
| 23 |
+
},
|
| 24 |
+
"3": {
|
| 25 |
+
"class_type": "SaveImage",
|
| 26 |
+
"inputs": {
|
| 27 |
+
"images": [
|
| 28 |
+
"2",
|
| 29 |
+
0
|
| 30 |
+
],
|
| 31 |
+
"filename_prefix": "SpawnGen"
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
}
|
examples/flux2-klein-edit.json.br
ADDED
|
Binary file (230 Bytes). View file
|
|
|
examples/flux2-klein-edit.json.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d7461190d032c399cab757b27174ab1cb6b3981de826fe8638d095fa706ea4ed
|
| 3 |
+
size 268
|
examples/flux2-klein.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"1": {
|
| 3 |
+
"class_type": "Flux2Klein",
|
| 4 |
+
"inputs": {
|
| 5 |
+
"prompt": "a photo of a single red apple on a wooden table, soft daylight",
|
| 6 |
+
"width": 512,
|
| 7 |
+
"height": 512,
|
| 8 |
+
"steps": 4,
|
| 9 |
+
"seed": 7,
|
| 10 |
+
"batch_size": 1,
|
| 11 |
+
"weights": "4-bit"
|
| 12 |
+
}
|
| 13 |
+
},
|
| 14 |
+
"2": {
|
| 15 |
+
"class_type": "SaveImage",
|
| 16 |
+
"inputs": {
|
| 17 |
+
"images": [
|
| 18 |
+
"1",
|
| 19 |
+
0
|
| 20 |
+
],
|
| 21 |
+
"filename_prefix": "SpawnGen"
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
}
|
examples/flux2-klein.json.br
ADDED
|
Binary file (227 Bytes). View file
|
|
|
examples/flux2-klein.json.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:66ee331ff69b9e80c6afce6ddf98945e7df169b40af66482318eec0b0f5c144b
|
| 3 |
+
size 247
|
examples/flux3-klein.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"1": {
|
| 3 |
+
"class_type": "Flux3Klein",
|
| 4 |
+
"inputs": {
|
| 5 |
+
"caption": "A photograph of a single glossy red apple resting on a weathered wooden table, soft window light from the left, shallow depth of field, a blurred cream-coloured wall behind.",
|
| 6 |
+
"width": 512,
|
| 7 |
+
"height": 512,
|
| 8 |
+
"steps": 16,
|
| 9 |
+
"seed": 7,
|
| 10 |
+
"batch_size": 1,
|
| 11 |
+
"weights": "4-bit"
|
| 12 |
+
}
|
| 13 |
+
},
|
| 14 |
+
"2": {
|
| 15 |
+
"class_type": "SaveImage",
|
| 16 |
+
"inputs": {
|
| 17 |
+
"images": [
|
| 18 |
+
"1",
|
| 19 |
+
0
|
| 20 |
+
],
|
| 21 |
+
"filename_prefix": "SpawnGen"
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
}
|
examples/flux3-klein.json.br
ADDED
|
Binary file (261 Bytes). View file
|
|
|
examples/flux3-klein.json.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6e34d0dd51671a80e7f1a7b357fe2fa72a49e1b74f219364011013c5c8c68e14
|
| 3 |
+
size 315
|
examples/hires-fix.json
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"1": {
|
| 3 |
+
"class_type": "CheckpointLoaderSimple",
|
| 4 |
+
"inputs": {
|
| 5 |
+
"ckpt_name": "sd_turbo"
|
| 6 |
+
}
|
| 7 |
+
},
|
| 8 |
+
"2": {
|
| 9 |
+
"class_type": "CLIPTextEncode",
|
| 10 |
+
"inputs": {
|
| 11 |
+
"text": "a photo of a red apple on a wooden table",
|
| 12 |
+
"clip": [
|
| 13 |
+
"1",
|
| 14 |
+
1
|
| 15 |
+
]
|
| 16 |
+
}
|
| 17 |
+
},
|
| 18 |
+
"3": {
|
| 19 |
+
"class_type": "CLIPTextEncode",
|
| 20 |
+
"inputs": {
|
| 21 |
+
"text": "",
|
| 22 |
+
"clip": [
|
| 23 |
+
"1",
|
| 24 |
+
1
|
| 25 |
+
]
|
| 26 |
+
}
|
| 27 |
+
},
|
| 28 |
+
"4": {
|
| 29 |
+
"class_type": "EmptyLatentImage",
|
| 30 |
+
"inputs": {
|
| 31 |
+
"width": 256,
|
| 32 |
+
"height": 256,
|
| 33 |
+
"batch_size": 1
|
| 34 |
+
}
|
| 35 |
+
},
|
| 36 |
+
"5": {
|
| 37 |
+
"class_type": "KSampler",
|
| 38 |
+
"inputs": {
|
| 39 |
+
"model": [
|
| 40 |
+
"1",
|
| 41 |
+
0
|
| 42 |
+
],
|
| 43 |
+
"positive": [
|
| 44 |
+
"2",
|
| 45 |
+
0
|
| 46 |
+
],
|
| 47 |
+
"negative": [
|
| 48 |
+
"3",
|
| 49 |
+
0
|
| 50 |
+
],
|
| 51 |
+
"latent_image": [
|
| 52 |
+
"4",
|
| 53 |
+
0
|
| 54 |
+
],
|
| 55 |
+
"seed": 7,
|
| 56 |
+
"steps": 1,
|
| 57 |
+
"cfg": 1,
|
| 58 |
+
"sampler_name": "euler",
|
| 59 |
+
"scheduler": "normal",
|
| 60 |
+
"denoise": 1
|
| 61 |
+
}
|
| 62 |
+
},
|
| 63 |
+
"6": {
|
| 64 |
+
"class_type": "LatentUpscaleBy",
|
| 65 |
+
"inputs": {
|
| 66 |
+
"samples": [
|
| 67 |
+
"5",
|
| 68 |
+
0
|
| 69 |
+
],
|
| 70 |
+
"upscale_method": "bilinear",
|
| 71 |
+
"scale_by": 2
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
"7": {
|
| 75 |
+
"class_type": "KSampler",
|
| 76 |
+
"inputs": {
|
| 77 |
+
"model": [
|
| 78 |
+
"1",
|
| 79 |
+
0
|
| 80 |
+
],
|
| 81 |
+
"positive": [
|
| 82 |
+
"2",
|
| 83 |
+
0
|
| 84 |
+
],
|
| 85 |
+
"negative": [
|
| 86 |
+
"3",
|
| 87 |
+
0
|
| 88 |
+
],
|
| 89 |
+
"latent_image": [
|
| 90 |
+
"6",
|
| 91 |
+
0
|
| 92 |
+
],
|
| 93 |
+
"seed": 8,
|
| 94 |
+
"steps": 2,
|
| 95 |
+
"cfg": 1,
|
| 96 |
+
"sampler_name": "euler",
|
| 97 |
+
"scheduler": "normal",
|
| 98 |
+
"denoise": 0.5
|
| 99 |
+
}
|
| 100 |
+
},
|
| 101 |
+
"8": {
|
| 102 |
+
"class_type": "VAEDecode",
|
| 103 |
+
"inputs": {
|
| 104 |
+
"samples": [
|
| 105 |
+
"7",
|
| 106 |
+
0
|
| 107 |
+
],
|
| 108 |
+
"vae": [
|
| 109 |
+
"1",
|
| 110 |
+
2
|
| 111 |
+
]
|
| 112 |
+
}
|
| 113 |
+
},
|
| 114 |
+
"9": {
|
| 115 |
+
"class_type": "SaveImage",
|
| 116 |
+
"inputs": {
|
| 117 |
+
"images": [
|
| 118 |
+
"8",
|
| 119 |
+
0
|
| 120 |
+
],
|
| 121 |
+
"filename_prefix": "SpawnGen"
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
}
|