Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1ea9074
first pass at getting multiple agents working with ad4m-test
jdeepee Mar 8, 2023
3c38d7c
remove old dead functions
jdeepee Mar 8, 2023
2e19c48
push current set of changes for ad4m-test (still a bit broken)
jdeepee Mar 9, 2023
fe93b4c
Added new helper functions to help with agent syncing
fayeed Mar 14, 2023
01aa9a2
link test updated with the new helper
fayeed Mar 14, 2023
da354ae
Added a max retry to agent sync function
fayeed Mar 15, 2023
607b757
Merge branch 'dev' into multiple-agents-ad4m-test-link-langs
jdeepee Mar 28, 2023
3220a90
first pass at link language sync using callbacks in ad4m-test
jdeepee Mar 28, 2023
7cde92f
Merge branch 'dev' into multiple-agents-ad4m-test-link-langs
jdeepee Mar 30, 2023
5a1b4a0
Merge branch 'dev' into multiple-agents-ad4m-test-link-langs
jdeepee Mar 30, 2023
f6ba88f
have executor and test runner use local bootstrap languages
jdeepee Mar 30, 2023
a78b4a6
local-language added
fayeed Mar 31, 2023
922e27a
local neighbourhood language added
fayeed Mar 31, 2023
3cefd0e
note ipfs language added
fayeed Mar 31, 2023
01e2d16
get-language script updated
fayeed Mar 31, 2023
53733a9
removed post install command updated
fayeed Mar 31, 2023
2d10e86
.npmignore updated
fayeed Mar 31, 2023
bf5b6cf
remove node-sass
jdeepee Mar 31, 2023
68254ab
dont error missing tests on new languages
jdeepee Mar 31, 2023
c61ad92
have executor use the new local languages
jdeepee Mar 31, 2023
20fd696
copy languages in test-runner after build
jdeepee Mar 31, 2023
6bd6452
remove icon rollup on ipfs lang
jdeepee Mar 31, 2023
b7a6320
use local ad4m for new languages
jdeepee Mar 31, 2023
22743f8
add new language to build-languages script
jdeepee Mar 31, 2023
bbc4277
add missing local-language build
jdeepee Mar 31, 2023
ea96670
update ipfs-core-types
jdeepee Mar 31, 2023
76833ae
use consistent typescript versions & get build working correctly
jdeepee Mar 31, 2023
d9f654c
remove get-languages from post build since it turbo is not running ta…
jdeepee Mar 31, 2023
bc012bf
update rollup config for local language
fayeed Apr 3, 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lodash": "^4.17.19",
"tape-promise": "^4.0.0",
"ts-node": "^10.8.0",
"typescript": "^4.2.4"
"typescript": "^4.6.2"
},
"devDependencies": {
"@types/tape-promise": "^4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion bootstrap-languages/agent-language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"svelte-check": "^1.0.0",
"svelte-preprocess": "^4.0.0",
"tslib": "^2.0.0",
"typescript": "^4.2.4",
"typescript": "^4.6.2",
"xmlhttprequest": "^1.8.0"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lodash": "^4.17.19",
"tape-promise": "^4.0.0",
"ts-node": "^10.8.0",
"typescript": "^4.2.4"
"typescript": "^4.6.2"
},
"devDependencies": {
"@types/faker": "^5.5.3",
Expand Down
2 changes: 1 addition & 1 deletion bootstrap-languages/direct-message-language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"rollup-plugin-terser": "^7.0.0",
"run-script-os": "^1.1.6",
"tslib": "^2.0.0",
"typescript": "^4.2.4"
"typescript": "^4.6.2"
},
"dependencies": {
"@types/node": "^18.0.0"
Expand Down
2 changes: 1 addition & 1 deletion bootstrap-languages/file-storage/hc-dna/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"tape-promise": "^4.0.0",
"ts-node": "^10.8.0",
"@types/node": "^14.0.14",
"typescript": "^4.2.4"
"typescript": "^4.6.2"
},
"devDependencies": {
"@types/faker": "^5.5.3",
Expand Down
2 changes: 1 addition & 1 deletion bootstrap-languages/file-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"svelte-check": "^1.0.0",
"svelte-preprocess": "^4.0.0",
"tslib": "^2.0.0",
"typescript": "^4.2.4",
"typescript": "^4.6.2",
"uint8arrays": "^3.0.0",
"run-script-os": "^1.1.6"
}
Expand Down
2 changes: 1 addition & 1 deletion bootstrap-languages/language-language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"svelte-check": "^1.0.0",
"svelte-preprocess": "^4.0.0",
"tslib": "^2.0.0",
"typescript": "^4.2.4"
"typescript": "^4.6.2"
},
"dependencies": {
"@types/node": "^18.0.0",
Expand Down
5 changes: 5 additions & 0 deletions bootstrap-languages/local-language-persistence/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
*.js
*.js.map
!rollup.config.js
build
3 changes: 3 additions & 0 deletions bootstrap-languages/local-language-persistence/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Language: languages

This is used as a "mock" language for ad4m-executor tests and should not be used for any other purpose
26 changes: 26 additions & 0 deletions bootstrap-languages/local-language-persistence/adapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Address, Expression, ExpressionAdapter, PublicSharing, LanguageContext } from "@perspect3vism/ad4m";
import { PutAdapter } from "./putAdapter";
import fs from "fs";
import path from "path";

export default class Adapter implements ExpressionAdapter {
putAdapter: PublicSharing;
#storagePath: string;

constructor(context: LanguageContext) {
this.putAdapter = new PutAdapter(context);
//@ts-ignore
if ("storagePath" in context.customSettings) { this.#storagePath = context.customSettings["storagePath"] } else { this.#storagePath = "./src/tst-tmp/languages" };
}

async get(address: Address): Promise<void | Expression> {
const metaPath = path.join(this.#storagePath, `meta-${address}.json`)
if (fs.existsSync(metaPath)) {
const metaFile = JSON.parse(fs.readFileSync(metaPath).toString());
console.log("Found meta file info", metaFile);
return metaFile
} else {
return null
}
}
}
21 changes: 21 additions & 0 deletions bootstrap-languages/local-language-persistence/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Address, Agent, Language, HolochainLanguageDelegate, LanguageContext, Interaction, ExpressionUI } from "@perspect3vism/ad4m";
import LangAdapter from "./languageAdapter";
import Adapter from "./adapter";

export const name = "languages";

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

export default async function create(context: LanguageContext): Promise<Language> {
const expressionAdapter = new Adapter(context);
const languageAdapter = new LangAdapter(context);

return {
name,
expressionAdapter,
languageAdapter,
interactions,
} as Language;
}
21 changes: 21 additions & 0 deletions bootstrap-languages/local-language-persistence/languageAdapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Address, LanguageAdapter, PublicSharing, LanguageContext } from "@perspect3vism/ad4m";
import path from "path";
import fs from "fs";

export default class LangAdapter implements LanguageAdapter {
putAdapter: PublicSharing;
#storagePath: string;

constructor(context: LanguageContext) {
//@ts-ignore
if ("storagePath" in context.customSettings) { this.#storagePath = context.customSettings["storagePath"] } else { this.#storagePath = "./src/tst-tmp/languages" };
}

async getLanguageSource(address: Address): Promise<string> {
const bundlePath = path.join(this.#storagePath, `bundle-${address}.js`);
if (fs.existsSync(bundlePath)) {
const metaFile = fs.readFileSync(bundlePath).toString();
return metaFile
}
}
}
38 changes: 38 additions & 0 deletions bootstrap-languages/local-language-persistence/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@perspect3vism/local-language-language",
"version": "0.0.10",
"description": "An AD4M Language for storing of language bundles on IPFS",
"main": "index.js",
"scripts": {
"test": "echo \"No tests for local language language\"",
"build": "tsc && rollup -c",
"dev": "tsc && rollup -c -w"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@perspect3vism/ad4m": "*",
"@perspect3vism/rollup-plugin-dna": "^0.0.2",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-typescript": "^4.0.0",
"@tsconfig/svelte": "^1.0.0",
"ipfs-core-types": "0.10.1",
"rollup": "^2.3.4",
"rollup-plugin-postcss": "^3.1.8",
"rollup-plugin-string": "^3.0.0",
"rollup-plugin-svelte": "^6.0.0",
"rollup-plugin-terser": "^7.0.0",
"svelte": "^3.0.0",
"svelte-check": "^1.0.0",
"svelte-preprocess": "^4.0.0",
"tslib": "^2.0.0",
"typescript": "^4.6.2"
},
"dependencies": {
"@types/node": "^14.14.37",
"debug": "^4.3.2",
"path": "^0.12.7"
}
}
43 changes: 43 additions & 0 deletions bootstrap-languages/local-language-persistence/putAdapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { Address, AgentService, PublicSharing, LanguageContext, LanguageLanguageInput} from "@perspect3vism/ad4m";
import type { IPFS } from "ipfs-core-types";
import path from "path";
import fs from "fs";

export default function sleep(ms: number): Promise<any> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

export class PutAdapter implements PublicSharing {
#agent: AgentService;
#IPFS: IPFS;
#storagePath: string;

constructor(context: LanguageContext) {
this.#agent = context.agent;
this.#IPFS = context.IPFS;
// @ts-ignore
if ("storagePath" in context.customSettings) { this.#storagePath = context.customSettings["storagePath"] } else { this.#storagePath = "./src/tst-tmp/languages" };
}

async createPublic(language: LanguageLanguageInput): Promise<Address> {
const ipfsAddress = await this.#IPFS.add(
{ content: language.bundle.toString()},
{ onlyHash: true},
);
// @ts-ignore
const hash = ipfsAddress.cid.toString();

if(hash != language.meta.address)
throw new Error(`Language Persistence: Can't store language. Address stated in meta differs from actual file\nWanted: ${language.meta.address}\nGot: ${hash}`)

const agent = this.#agent;
const expression = agent.createSignedExpression(language.meta);
const metaPath = path.join(this.#storagePath, `meta-${hash}.json`);
const bundlePath = path.join(this.#storagePath, `bundle-${hash}.js`);
console.log("Writing meta & bundle path: ", metaPath, bundlePath);
fs.writeFileSync(metaPath, JSON.stringify(expression));
fs.writeFileSync(bundlePath, language.bundle.toString());

return hash as Address;
}
}
62 changes: 62 additions & 0 deletions bootstrap-languages/local-language-persistence/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import svelte from "rollup-plugin-svelte";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
//import { terser } from 'rollup-plugin-terser';
import sveltePreprocess from "svelte-preprocess";
import postcss from "rollup-plugin-postcss";
import { string } from "rollup-plugin-string";
import json from "@rollup/plugin-json";

const production = !process.env.ROLLUP_WATCH;

export default {
input: "index.js",
output: {
sourcemap: true,
format: "cjs",
name: "NoteIpfs",
file: "build/bundle.js",
},
plugins: [
string({
include: "build/*.js",
}),
svelte({
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file - better for performance
//css: css => {
// css.write('bundle.css');
//},
preprocess: sveltePreprocess(),
}),

// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: false,
dedupe: ["svelte"],
}),
commonjs(),
postcss({
extract: true,
minimize: true,
use: [
[
"sass",
{
includePaths: ["./src/ui/theme", "./node_modules"],
},
],
],
}),
json()
],
watch: {
clearScreen: false,
},
};
28 changes: 28 additions & 0 deletions bootstrap-languages/local-language-persistence/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Svelte",
"compilerOptions": {
"moduleResolution": "node",
"target": "es2017",
/**
Svelte Preprocess cannot figure out whether you have a value or a type, so tell TypeScript
to enforce using `import type` instead of `import` for Types.
*/
"importsNotUsedAsValues": "error",
"isolatedModules": true,
/**
To have warnings/errors of the Svelte compiler at the correct position,
enable source maps by default.
*/
"sourceMap": true,
/** Requests the runtime types from the svelte modules by default. Needed for TS files or else you get errors. */
"types": ["svelte", "node"],

"strict": false,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["*.ts"],
"exclude": ["node_modules/*", "__sapper__/*", "public/*"],
}
Loading