-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
11 changed files
with
112 additions
and
110 deletions.
There are no files selected for viewing
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
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
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
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
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,8 @@ | ||
export async function weave(textNodes, host) { | ||
return (await Promise.all(textNodes.map(async (path, idx) => { | ||
if (idx % 2 === 0) | ||
return path; | ||
const { getVal } = await import('./getVal.js'); | ||
return await getVal({ host }, path); | ||
}))).join(''); | ||
} |
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,7 @@ | ||
export async function weave(textNodes: string[], host: any){ | ||
return (await Promise.all(textNodes.map(async (path, idx) => { | ||
if(idx % 2 === 0) return path; | ||
const {getVal} = await import ('./getVal.js'); | ||
return await getVal({host}, path) as string; | ||
}))).join(''); | ||
} |
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 |
---|---|---|
@@ -1,8 +1,44 @@ | ||
export async function weave(textNodes, host) { | ||
return (await Promise.all(textNodes.map(async (path, idx) => { | ||
if (idx % 2 === 0) | ||
return path; | ||
const { getVal } = await import('./getVal.js'); | ||
return await getVal({ host }, path); | ||
}))).join(''); | ||
const values = new Map(); | ||
export async function weave(schema) { | ||
return new Weave(schema); | ||
} | ||
export async function when(guid) { | ||
if (values.has(guid)) | ||
return values.get(guid); | ||
const { waitForEvent } = await import('./waitForEvent.js'); | ||
await waitForEvent(window, guid); | ||
return values.get(guid); | ||
} | ||
export class Weave { | ||
schema; | ||
constructor(schema) { | ||
this.schema = schema; | ||
} | ||
#into; | ||
async into(guid) { | ||
if (values.has(guid)) | ||
return; | ||
this.#into = guid; | ||
const objToPipe = await this.#draw(); | ||
values.set(guid, objToPipe); | ||
window.dispatchEvent(new Event(guid.toString())); | ||
} | ||
async #draw() { | ||
return new Promise(async (resolve, reject) => { | ||
const { draw } = await import('../XV/draw.js'); | ||
const drawn = await draw(this.schema); | ||
if (this.#isComplete(drawn)) { | ||
resolve(drawn); | ||
return; | ||
} | ||
throw 'NI'; | ||
}); | ||
} | ||
#isComplete(obj) { | ||
for (const key in this.schema) { | ||
if (obj[key] === undefined || obj[key] === null) | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,46 @@ | ||
export async function weave(textNodes: string[], host: any){ | ||
return (await Promise.all(textNodes.map(async (path, idx) => { | ||
if(idx % 2 === 0) return path; | ||
const {getVal} = await import ('./getVal.js'); | ||
return await getVal({host}, path) as string; | ||
}))).join(''); | ||
import { USLMapping } from '../ts-refs/trans-render/XV/types.js'; | ||
|
||
const values: Map<string | number | symbol, any> = new Map(); | ||
|
||
export async function weave(schema: USLMapping){ | ||
return new Weave(schema); | ||
} | ||
|
||
export async function when(guid: string){ | ||
if(values.has(guid)) return values.get(guid); | ||
const {waitForEvent} = await import('./waitForEvent.js'); | ||
await waitForEvent(window, guid); | ||
return values.get(guid); | ||
} | ||
|
||
export class Weave { | ||
constructor(public schema: USLMapping){} | ||
#into: string | number | symbol | undefined; | ||
async into(guid: string | number | symbol){ | ||
if(values.has(guid)) return; | ||
this.#into = guid; | ||
|
||
const objToPipe = await this.#draw(); | ||
values.set(guid, objToPipe); | ||
window.dispatchEvent(new Event(guid.toString())); | ||
} | ||
|
||
async #draw() : Promise<any>{ | ||
return new Promise(async (resolve, reject) => { | ||
const {draw} = await import('../XV/draw.js'); | ||
const drawn = await draw(this.schema); | ||
if(this.#isComplete(drawn)){ | ||
resolve(drawn); | ||
return; | ||
} | ||
throw 'NI'; | ||
}); | ||
} | ||
|
||
#isComplete(obj: any){ | ||
for(const key in this.schema){ | ||
if(obj[key] === undefined || obj[key] === null) return false; | ||
} | ||
return true; | ||
} | ||
} |
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