commit 0c6686f5a02b17f7a1bb267677009d03fd62baa6 Author: Leon van Kammen Date: Tue Sep 30 13:20:59 2025 +0200 initial commit diff --git a/README.awk b/README.awk new file mode 100755 index 0000000..ff30545 --- /dev/null +++ b/README.awk @@ -0,0 +1,41 @@ +#!/usr/bin/env -S awk -f +# a no-nonsense source-to-markdown generator which scans for: +# +# /** +# * # foo +# * +# * this is markdown $(cat bar.md) +# */ +# +# var foo; // comment with 2 leading spaces is markdown too $(date) +# +# easily refactorable to hash-based languages (py/bash/perl/lua e.g.) +# by changing the regexes +# + +BEGIN{ + # printf README.md until '# Component List' + system("grep -B9999 '# Functions' README.md") + print "" +} + +/\$(?![\(|"])/ { cmd=$0; + gsub(/^.*\$\(/,"",cmd); + gsub(/\).*/,"",cmd); + cmd | getline stdout; close(cmd); + sub(/\$\(.*\)/,stdout); + } +/\/\*\*/ { doc=1; sub(/^.*\/\*/,""); } +doc && /\*\// { doc=0; + sub(/[[:space:]]*\*\/.*/,""); + sub(/^[[:space:]]*\*[[:space:]]?/,""); + print + } +doc && /^[[:space:]]*\*/ { sub(/^[[:space:]]*\*[[:space:]]?/,""); + print + } +#!doc && /\/\/ / { sub(".*// ",""); +# sub("# ","\n# "); +# sub("> ","\n> "); +# print +# } diff --git a/README.md b/README.md new file mode 100644 index 0000000..fdc492d --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +XR Fragment utilities +===================== + +These are helper functions to make 3D (javascript) viewers XR Fragment compatible. + + +See function list below + +> this README.md is generated by running `echo "$(./README.awk *.js)" > README.md` + +# Function list diff --git a/level0.js b/level0.js new file mode 100644 index 0000000..e1a124e --- /dev/null +++ b/level0.js @@ -0,0 +1,24 @@ +import * as http from './scheme/http.js' +import * as xrf from './scheme/http.js' + +function defaultSchemes(){ + return {http,xrf} +} + +async function pollSideCarFiles(urlString, opts){ + + opts = {} + opts.scheme = opts.scheme || defaultSchemes() + let p = [] + const sext = [".png",".ogg",".vtt",".json"] + ext = urlString.lastIndexOf('.') + + for( let i in ext) p.push( + new Promise( (resolve,reject) => { + fetch( urlString.replace(ext, sext[i] ), { method:'HEAD'} ) + }) + ) + await Promise.all(p) +} + +export {pollSideCarFiles} diff --git a/level0.test.js b/level0.test.js new file mode 100644 index 0000000..b0c0ea7 --- /dev/null +++ b/level0.test.js @@ -0,0 +1,6 @@ +import * as level0 from './level0.js' +import { expect, test } from "bun:test"; + +test("2 + 2", () => { + expect(2 + 2).toBe(4); +}); diff --git a/scheme/http.js b/scheme/http.js new file mode 100644 index 0000000..039e039 --- /dev/null +++ b/scheme/http.js @@ -0,0 +1,10 @@ +const profile = { + type: "http" +} + +const fetchApi = fetch + +export { + profile, + fetchApi +} diff --git a/scheme/xrf.js b/scheme/xrf.js new file mode 100644 index 0000000..039e039 --- /dev/null +++ b/scheme/xrf.js @@ -0,0 +1,10 @@ +const profile = { + type: "http" +} + +const fetchApi = fetch + +export { + profile, + fetchApi +}