-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 327b4a6
Showing
214 changed files
with
1,452 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Blazor File System Access</title> | ||
<script type="text/javascript"> | ||
// Single Page Apps for GitHub Pages | ||
// MIT License | ||
// https://github.com/rafgraph/spa-github-pages | ||
// This script takes the current url and converts the path and query | ||
// string into just a query string, and then redirects the browser | ||
// to the new url with only a query string and hash fragment | ||
|
||
// If you're creating a Project Pages site and NOT using a custom domain, | ||
// then set pathSegmentsToKeep to 1 (enterprise users may need to set it to > 1). | ||
// This way the code will only replace the route part of the path, and not | ||
// the real directory in which the app resides, for example: | ||
// https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes | ||
// https://username.github.io/repo-name/?/one/two&a=b~and~c=d#qwe | ||
// Otherwise, leave pathSegmentsToKeep as 0. | ||
var pathSegmentsToKeep = 1; | ||
|
||
var l = window.location; | ||
l.replace( | ||
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + | ||
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + | ||
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + | ||
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + | ||
l.hash | ||
); | ||
|
||
</script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
145 changes: 145 additions & 0 deletions
145
KristofferStrube.Blazor.FileSystemAccess.WasmExample.styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* /Shared/MainLayout.razor.rz.scp.css */ | ||
.page[b-pcstz3rrvh] { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
main[b-pcstz3rrvh] { | ||
flex: 1; | ||
} | ||
|
||
.sidebar[b-pcstz3rrvh] { | ||
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); | ||
} | ||
|
||
.top-row[b-pcstz3rrvh] { | ||
background-color: #f7f7f7; | ||
border-bottom: 1px solid #d6d5d5; | ||
justify-content: flex-end; | ||
height: 3.5rem; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.top-row[b-pcstz3rrvh] a, .top-row[b-pcstz3rrvh] .btn-link { | ||
white-space: nowrap; | ||
margin-left: 1.5rem; | ||
text-decoration: none; | ||
} | ||
|
||
.top-row[b-pcstz3rrvh] a:hover, .top-row[b-pcstz3rrvh] .btn-link:hover { | ||
text-decoration: underline; | ||
} | ||
|
||
.top-row[b-pcstz3rrvh] a:first-child { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
@media (max-width: 640.98px) { | ||
.top-row:not(.auth)[b-pcstz3rrvh] { | ||
display: none; | ||
} | ||
|
||
.top-row.auth[b-pcstz3rrvh] { | ||
justify-content: space-between; | ||
} | ||
|
||
.top-row[b-pcstz3rrvh] a, .top-row[b-pcstz3rrvh] .btn-link { | ||
margin-left: 0; | ||
} | ||
} | ||
|
||
@media (min-width: 641px) { | ||
.page[b-pcstz3rrvh] { | ||
flex-direction: row; | ||
} | ||
|
||
.sidebar[b-pcstz3rrvh] { | ||
width: 250px; | ||
height: 100vh; | ||
position: sticky; | ||
top: 0; | ||
} | ||
|
||
.top-row[b-pcstz3rrvh] { | ||
position: sticky; | ||
top: 0; | ||
z-index: 1; | ||
} | ||
|
||
.top-row.auth[b-pcstz3rrvh] a:first-child { | ||
flex: 1; | ||
text-align: right; | ||
width: 0; | ||
} | ||
|
||
.top-row[b-pcstz3rrvh], article[b-pcstz3rrvh] { | ||
padding-left: 2rem !important; | ||
padding-right: 1.5rem !important; | ||
} | ||
} | ||
/* /Shared/NavMenu.razor.rz.scp.css */ | ||
.navbar-toggler[b-wn4wfaaxq2] { | ||
background-color: rgba(255, 255, 255, 0.1); | ||
} | ||
|
||
.top-row[b-wn4wfaaxq2] { | ||
height: 3.5rem; | ||
background-color: rgba(0,0,0,0.4); | ||
} | ||
|
||
.navbar-brand[b-wn4wfaaxq2] { | ||
font-size: 1.1rem; | ||
} | ||
|
||
.oi[b-wn4wfaaxq2] { | ||
width: 2rem; | ||
font-size: 1.1rem; | ||
vertical-align: text-top; | ||
top: -2px; | ||
} | ||
|
||
.nav-item[b-wn4wfaaxq2] { | ||
font-size: 0.9rem; | ||
padding-bottom: 0.5rem; | ||
} | ||
|
||
.nav-item:first-of-type[b-wn4wfaaxq2] { | ||
padding-top: 1rem; | ||
} | ||
|
||
.nav-item:last-of-type[b-wn4wfaaxq2] { | ||
padding-bottom: 1rem; | ||
} | ||
|
||
.nav-item[b-wn4wfaaxq2] a { | ||
color: #d7d7d7; | ||
border-radius: 4px; | ||
height: 3rem; | ||
display: flex; | ||
align-items: center; | ||
line-height: 3rem; | ||
} | ||
|
||
.nav-item[b-wn4wfaaxq2] a.active { | ||
background-color: rgba(255,255,255,0.25); | ||
color: white; | ||
} | ||
|
||
.nav-item[b-wn4wfaaxq2] a:hover { | ||
background-color: rgba(255,255,255,0.1); | ||
color: white; | ||
} | ||
|
||
@media (min-width: 641px) { | ||
.navbar-toggler[b-wn4wfaaxq2] { | ||
display: none; | ||
} | ||
|
||
.collapse[b-wn4wfaaxq2] { | ||
/* Never collapse the sidebar for wide screens */ | ||
display: block; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
_content/KristofferStrube.Blazor.FileAPI/KristofferStrube.Blazor.FileAPI.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export function getAttribute(object, attribute) { return object[attribute]; } | ||
|
||
export function arrayBuffer(buffer) { | ||
var bytes = new Uint8Array(buffer); | ||
return bytes; | ||
} | ||
|
||
export function constructBlob(blobParts, options) { | ||
return new Blob(blobParts, options); | ||
} | ||
|
||
export function constructFile(blobParts, fileName, options) { | ||
return new File(blobParts, fileName, options); | ||
} | ||
|
||
export function constructFileReader() { | ||
return new FileReader(); | ||
} | ||
|
||
export function registerEventHandlersAsync(objRef, jSInstance) { | ||
jSInstance.addEventListener('loadstart', (e) => objRef.invokeMethodAsync('InvokeOnLoadStartAsync', DotNet.createJSObjectReference(e))); | ||
jSInstance.addEventListener('progress', (e) => objRef.invokeMethodAsync('InvokeOnProgressAsync', DotNet.createJSObjectReference(e))); | ||
jSInstance.addEventListener('load', (e) => objRef.invokeMethodAsync('InvokeOnLoadAsync', DotNet.createJSObjectReference(e))); | ||
jSInstance.addEventListener('abort', (e) => objRef.invokeMethodAsync('InvokeOnAbortAsync', DotNet.createJSObjectReference(e))); | ||
jSInstance.addEventListener('error', (e) => objRef.invokeMethodAsync('InvokeOnErrorAsync', DotNet.createJSObjectReference(e))); | ||
jSInstance.addEventListener('loadend', (e) => objRef.invokeMethodAsync('InvokeOnLoadEndAsync', DotNet.createJSObjectReference(e))); | ||
} | ||
|
||
export function registerEventHandlers(objRef, jSInstance) { | ||
jSInstance.addEventListener('loadstart', (e) => objRef.invokeMethod('InvokeOnLoadStart', DotNet.createJSObjectReference(e))); | ||
jSInstance.addEventListener('progress', (e) => objRef.invokeMethod('InvokeOnProgress', DotNet.createJSObjectReference(e))); | ||
jSInstance.addEventListener('load', (e) => objRef.invokeMethod('InvokeOnLoad', DotNet.createJSObjectReference(e))); | ||
jSInstance.addEventListener('abort', (e) => objRef.invokeMethod('InvokeOnAbort', DotNet.createJSObjectReference(e))); | ||
jSInstance.addEventListener('error', (e) => objRef.invokeMethod('InvokeOnError', DotNet.createJSObjectReference(e))); | ||
jSInstance.addEventListener('loadend', (e) => objRef.invokeMethod('InvokeOnLoadEnd', DotNet.createJSObjectReference(e))); | ||
} | ||
|
||
export function isArrayBuffer(fileReader) { | ||
return (fileReader.result instanceof ArrayBuffer) | ||
} |
22 changes: 22 additions & 0 deletions
22
_content/KristofferStrube.Blazor.FileSystem/KristofferStrube.Blazor.FileSystem.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export function size(array) { return array.length; } | ||
|
||
export function getAttribute(object, attribute) { return object[attribute]; } | ||
|
||
export async function arrayFrom(values) { | ||
var res = [] | ||
for await (let value of values) { | ||
res.push(value); | ||
} | ||
return res; | ||
} | ||
|
||
export function WriteBlobWriteParams(fileSystemWritableFileStream, writeParams, blob) { | ||
writeParams.data = blob; | ||
fileSystemWritableFileStream.write(writeParams); | ||
} | ||
|
||
export async function arrayBuffer(blob) { | ||
var buffer = await blob.arrayBuffer(); | ||
var bytes = new Uint8Array(buffer); | ||
return bytes; | ||
} |
22 changes: 22 additions & 0 deletions
22
...tent/KristofferStrube.Blazor.FileSystemAccess/KristofferStrube.Blazor.FileSystemAccess.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export function size(array) { return array.length; } | ||
|
||
export function getAttribute(object, attribute) { return object[attribute]; } | ||
|
||
export async function arrayFrom(values) { | ||
var res = [] | ||
for await (let value of values) { | ||
res.push(value); | ||
} | ||
return res; | ||
} | ||
|
||
export function WriteBlobWriteParams(fileSystemWritableFileStream, writeParams, blob) { | ||
writeParams.data = blob; | ||
fileSystemWritableFileStream.write(writeParams); | ||
} | ||
|
||
export async function arrayBuffer(blob) { | ||
var buffer = await blob.arrayBuffer(); | ||
var bytes = new Uint8Array(buffer); | ||
return bytes; | ||
} |
121 changes: 121 additions & 0 deletions
121
_content/KristofferStrube.Blazor.Streams/KristofferStrube.Blazor.Streams.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
export function getAttribute(object, attribute) { return object[attribute]; } | ||
|
||
export function setAttribute(object, attribute, value) { return object[attribute] = value; } | ||
|
||
export function elementAt(array, index) { return array.at(index); } | ||
|
||
export function constructReadableStreamDefaultReader(stream) { | ||
return new ReadableStreamDefaultReader(stream); | ||
} | ||
|
||
export function constructReadableStreamBYOBReader(stream) { | ||
return new ReadableStreamBYOBReader(stream); | ||
} | ||
|
||
export function constructReadableWritablePair(readable, writable) { | ||
return { readable: readable, writable: writable }; | ||
} | ||
|
||
export function constructReadableStream(underlyingSource, strategy) { | ||
if (underlyingSource == null) { | ||
if (strategy == null) { | ||
return new ReadableStream(); | ||
} | ||
return new ReadableStream(null, queueingStrategy(strategy)); | ||
} | ||
var source = { | ||
start(controller) { | ||
underlyingSource.objRef.invokeMethodAsync('InvokeStart', DotNet.createJSObjectReference(controller)); | ||
}, | ||
pull(controller) { | ||
underlyingSource.objRef.invokeMethodAsync('InvokePull', DotNet.createJSObjectReference(controller)); | ||
}, | ||
cancel() { | ||
underlyingSource.objRef.invokeMethodAsync('InvokeCancel'); | ||
}, | ||
}; | ||
if (strategy == null) { | ||
return new ReadableStream(source); | ||
} | ||
return new ReadableStream(source, queueingStrategy(strategy)); | ||
} | ||
|
||
export function constructWritableStream(underlyingSink, strategy) { | ||
if (underlyingSink == null) { | ||
return new WritableStream(null, queueingStrategy(strategy)); | ||
} | ||
var sink = { | ||
start(controller) { | ||
underlyingSink.objRef.invokeMethodAsync('InvokeStart', DotNet.createJSObjectReference(controller)); | ||
}, | ||
write(chunk, controller) { | ||
underlyingSink.objRef.invokeMethodAsync('InvokeWrite', DotNet.createJSObjectReference(chunk), DotNet.createJSObjectReference(controller)); | ||
}, | ||
close() { | ||
underlyingSink.objRef.invokeMethodAsync('InvokeClose'); | ||
}, | ||
abort() { | ||
underlyingSink.objRef.invokeMethodAsync('InvokeAbort'); | ||
}, | ||
}; | ||
return new WritableStream(sink, queueingStrategy(strategy)); | ||
} | ||
|
||
export function constructTransformStream(underlyingSink, writableStrategy, readableStrategy) { | ||
if (underlyingSink == null) { | ||
return new TransformStream(null, queueingStrategy(writableStrategy), queueingStrategy(readableStrategy)); | ||
} | ||
var sink = { | ||
start(controller) { | ||
underlyingSink.objRef.invokeMethodAsync('InvokeStart', DotNet.createJSObjectReference(controller)); | ||
}, | ||
write(chunk, controller) { | ||
underlyingSink.objRef.invokeMethodAsync('InvokeWrite', DotNet.createJSObjectReference(chunk), DotNet.createJSObjectReference(controller)); | ||
}, | ||
close() { | ||
underlyingSink.objRef.invokeMethodAsync('InvokeClose'); | ||
}, | ||
abort() { | ||
underlyingSink.objRef.invokeMethodAsync('InvokeAbort'); | ||
}, | ||
}; | ||
return new TransformStream(sink, queueingStrategy(writableStrategy), queueingStrategy(readableStrategy)); | ||
} | ||
|
||
function queueingStrategy(strategy) { | ||
if (strategy == null) { | ||
return {}; | ||
} | ||
if (strategy instanceof ByteLengthQueuingStrategy || strategy instanceof CountQueuingStrategy) { | ||
return strategy; | ||
} | ||
return { | ||
highWaterMark: strategy.highWaterMark, | ||
size: (chunk) => strategy.objRef.invokeMethod('InvokeSize', DotNet.createJSObjectReference(chunk)) | ||
}; | ||
} | ||
|
||
export function constructWritableStreamDefaultReader(stream) { | ||
return new WritableStreamDefaultReader(stream); | ||
} | ||
|
||
export function constructByteLengthQueuingStrategy(init) { | ||
return new ByteLengthQueuingStrategy(init); | ||
} | ||
|
||
export function constructCountQueuingStrategy(init) { | ||
return new CountQueuingStrategy(init); | ||
} | ||
|
||
export function constructByteArray(size) { | ||
return new Uint8Array(size); | ||
} | ||
|
||
export function byteArray(object) { | ||
var bytes = new Uint8Array(object); | ||
return bytes; | ||
} | ||
|
||
export function valueOf(object) { | ||
return object; | ||
} |
Oops, something went wrong.