Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Link Langauges #413

Merged
merged 40 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
78ebdcc
add current code for socket signaling
jdeepee Sep 26, 2023
cfccdaa
add new socket logic
jdeepee Sep 26, 2023
4abb84e
add the rest of socket-signaling logic
jdeepee Oct 6, 2023
10de1dd
dont init new socket between language calls
jdeepee Oct 10, 2023
b2237bc
wake the event loop future on each poll
jdeepee Oct 10, 2023
931c191
cleanup
jdeepee Oct 10, 2023
6aea1c4
add back old holochain only link language
jdeepee Oct 10, 2023
e3827dd
Added cetralized link language with partial implementation
fayeed Oct 11, 2023
f852bd8
Added link callback when sync is called
fayeed Oct 11, 2023
2f9547b
Pulls from when the agent joins the socket room
fayeed Oct 11, 2023
c2d620b
add logic for adding other agents
jdeepee Oct 11, 2023
72b50e5
cleanup link language implementation
jdeepee Oct 11, 2023
bbcc85b
Link language updated to use signals
fayeed Oct 11, 2023
b702d34
add the remaining logic for the link lang
jdeepee Oct 11, 2023
4b32361
add missing build files
jdeepee Oct 11, 2023
80ac041
add mutex logic to live signals
jdeepee Oct 11, 2023
5c04847
add some fixes to link lang
jdeepee Oct 12, 2023
0799bdc
add some more logging
jdeepee Oct 12, 2023
b932f35
add some more logging
jdeepee Oct 12, 2023
ff761ed
add more logging to link language error throws
jdeepee Oct 12, 2023
2274a8f
fix current revision handling in link language
jdeepee Oct 12, 2023
b06485a
add the callback logic for events
jdeepee Oct 12, 2023
985d059
improve error logging for link lang call timeouts
jdeepee Oct 12, 2023
719c632
remove mutex and improve flow of commit function
jdeepee Oct 12, 2023
a1c42a8
rename centralized link language & add to seed proto
jdeepee Oct 12, 2023
ae5e4df
fix bug in test setup
jdeepee Oct 12, 2023
fde5b51
enable disabled tests again
jdeepee Oct 12, 2023
48e2edb
add console.dir() method to rust-executor utils
jdeepee Oct 12, 2023
6053a60
Fixed the issue with circular json
fayeed Oct 13, 2023
3270ced
use https for secure connection
fayeed Oct 13, 2023
bca2800
Merge branch 'centralized-link-language' of github.com:perspect3vism/…
jdeepee Oct 13, 2023
f19ff39
dont every reject a promise in link language try/catches
jdeepee Oct 13, 2023
9f687e8
use axiod instead of custom http function
jdeepee Oct 13, 2023
d20d95e
fix up parsing of result from getting current revision
jdeepee Oct 13, 2023
54dad75
add the telepresence implementation to the centralized link language
jdeepee Oct 14, 2023
43e1f15
revert p diff sync test target to holochain only language
jdeepee Oct 16, 2023
81c9211
add new mainnet seed with new link languages
jdeepee Oct 16, 2023
662c102
Merge branch 'dev' into centralized-link-language
jdeepee Oct 19, 2023
3448f42
add missing dna.js file in p diff sync socket signaling
jdeepee Oct 19, 2023
20dff3f
add dna.js in bundle to .gitignore
jdeepee Oct 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions bootstrap-languages/centralized-p-diff-sync/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.cargo
target
hc-dna/workdir/perspective-diff-sync.dna
hc-dna/zomes/tests/node_modules
hc-dna/zomes/tests/out.log
node_modules
.hc*
perspect-diff-sync.dna
*.log
.turbo

*.js
*.js.map
!rollup.config*
!.dna.js
!integration-test.js
!customHttpDownloader.js

.ad4m-test
ad4m-test-*
3 changes: 3 additions & 0 deletions bootstrap-languages/centralized-p-diff-sync/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Perspective Diff Sync

Git like holochain syncing DNA for sharing of mutation to a shared perspective.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
let setup = ({onResolve, onLoad}) => {
onResolve({filter: /^https:\/\/github.com/}, resolveFile)
onResolve({filter: /.*/, namespace: 'http-fetch'}, resolveUrl)
onLoad({filter: /.*/, namespace: 'http-fetch'}, loadSource)
}

let resolveFile = ({path}) => {
return {
path: path,
namespace: 'http-fetch'
}
}

export let resolveUrl = ({path, importer}) => {
return {
path: new URL(path, importer).href,
namespace: 'imports'
}
}

export let loadSource = async ({path}) => {
let source;
if (path.includes('perspect3vism')) {
const commit = path.split("#");

const url = `${commit[0].replace("https://github.com", "https://raw.githubusercontent.com")}/${commit[1]}/lib/bundle.js`

path = url;
}

source = await fetch(path)

if (!source.ok) {
let message = `GET ${path} failed: status ${source.status}`
throw new Error(message)
}

let contents = await source.text()
let pattern = /\/\/# sourceMappingURL=(\S+)/
let match = contents.match(pattern)
if (match) {
let url = new URL(match[1], source.url)
let dataurl = await loadMap(url)
let comment = `//# sourceMappingURL=${dataurl}`
contents = contents.replace(pattern, comment)
}



let {pathname} = new URL(source.url)
let loader = pathname.match(/[^.]+$/)[0]

loader = loader === 'mjs' ? 'js' : loader
return {contents, loader}
}

let loadMap = async url => {
let map = await fetch(url)
let type = map.headers.get('content-type').replace(/\s/g, '')
let buffer = await map.arrayBuffer()
let blob = new Blob([buffer], {type})
let reader = new FileReader()
return new Promise(cb => {
reader.onload = e => cb(e.target.result)
reader.readAsDataURL(blob)
})
}

export default {
name: "custom-http-fetch",
setup
};
39 changes: 39 additions & 0 deletions bootstrap-languages/centralized-p-diff-sync/esbuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as esbuild from "https://deno.land/x/[email protected]/mod.js";
// Import the WASM build on platforms where running subprocesses is not
// permitted, such as Deno Deploy, or when running without `--allow-run`.
// import * as esbuild from "https://deno.land/x/[email protected]/wasm.js";

import { denoPlugins } from "https://deno.land/x/[email protected]/mod.ts";
import { loadSource, resolveUrl } from "./customHttpDownloader.js";

const result = await esbuild.build({
plugins: [
{
name: `buffer-alias`,
setup(build) {
build.onResolve({ filter: new RegExp(`^buffer$`) }, (args) => {
return { path: `https://deno.land/[email protected]/node/buffer.ts`, namespace: 'imports' };
});

build.onResolve({filter: /.*/, namespace: 'imports'}, resolveUrl)

build.onLoad({filter: /.*/, namespace: 'imports'}, (args) => {
return loadSource(args)
})
},
},
...denoPlugins()
],
entryPoints: ['index.ts'],
outfile: 'build/bundle.js',
bundle: true,
platform: 'node',
target: 'deno1.32.4',
format: 'esm',
globalName: 'centralized.perspective.diff.sync.language',
charset: 'ascii',
legalComments: 'inline'
});
console.log(result.outputFiles);

esbuild.stop();
34 changes: 34 additions & 0 deletions bootstrap-languages/centralized-p-diff-sync/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Address, Language, Interaction, HolochainLanguageDelegate, LanguageContext, AgentService } from "https://esm.sh/@perspect3vism/[email protected]";
import { LinkAdapter } from "./linksAdapter.ts";
import { TelepresenceAdapterImplementation } from "./telepresenceAdapter.ts";
import { io } from "https://esm.sh/[email protected]";

function interactions(expression: Address): Interaction[] {
return [];
}

//!@ad4m-template-variable
const name = "centralized-perspective-diff-sync";

//!@ad4m-template-variable
const uid = "centralized-perspective-diff-sync-uuid";

export default async function create(context: LanguageContext): Promise<Language> {
let socketClient = io("https://socket.ad4m.dev", {
transports: ['websocket', 'polling'],
autoConnect: true,
query: { did: context.agent.did, linkLanguageUUID: uid }
});
console.log("Created socket connection");

const linksAdapter = new LinkAdapter(context, uid, socketClient);
const telepresenceAdapter = new TelepresenceAdapterImplementation(context, uid, socketClient);

//@ts-ignore
return {
name,
linksAdapter,
interactions,
telepresenceAdapter
} as Language;
}
20 changes: 20 additions & 0 deletions bootstrap-languages/centralized-p-diff-sync/integration-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { spawnLinkAgent } = require("@perspect3vism/ad4m-test/helpers");

describe("Link", () => {
it("Create Link", async () => {
const agent = await spawnLinkAgent();

const all = await agent.queryLinks({});

expect(all.length).toBe(0)

const link = await agent.addLink({source:"root", predicate: "soic://test", target:"QmYVsrMpiFmV9S7bTWNAkUzSqjRJskQ8g4TWKKwKrHAPqL://QmSsCCtXMDAZXMpyiNLzwjGEU4hLmhG7fphidhEEodQ4Wy"})

const all1 = await agent.queryLinks({});

expect(all1.length).toBe(1)
expect(all1[0].data.source).toBe(link.data.source)
expect(all1[0].data.predicate).toBe(link.data.predicate)
expect(all1[0].data.target).toBe(link.data.target)
});
})
Loading