Skip to content

Commit

Permalink
Merge pull request #39 from plastic-io/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
TonyGermaneri committed Feb 2, 2024
2 parents 339b7be + 1e031bd commit 0db4113
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 13 deletions.
15 changes: 12 additions & 3 deletions packages/Graph/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export default {
},
createGraph(id: string): Graph {
const name = getName();
const now = new Date();
const now = Date.now();
return {
id,
version: 0,
Expand Down Expand Up @@ -468,16 +468,23 @@ export default {
this.graphSnapshot = await graphOrchestrator.dataProviders.graph!.get(graphId);
} catch (err: any) {
// auto create missing graphs
this.isNewGraph = true;
this.graphSnapshot = this.createGraph(graphId);
}
this.graphSnapshotStore.graph = deref(this.graphSnapshot);
graphOrchestrator.dataProviders.graph.subscribe(graphId, async () => {
// this.graphSnapshot = await graphOrchestrator.dataProviders.graph!.get(graphId);
});
// block loading until graph scripts are loaded if any
const scripts = (this.graphSnapshot.properties.scripts || '').replace('\n', ',').split(',');
await this.loadAllScripts(this.graphSnapshot);
// don't allow an opening graph to count as a history change
this.graph = deref(this.graphSnapshot);

// This must be patch to trigger stores to update
this.$patch((state: any) => {
// don't allow an opening graph to count as a history change
state.graph = deref(state.graphSnapshot);
});

this.graphSnapshotStore.$subscribe((mutation: any, state: any) => {
if (this.updatingSnapshotLocally) {
return;
Expand Down Expand Up @@ -670,6 +677,8 @@ export default {
groups: [],
name,
description: "",
createdOn: Date.now(),
lastUpdate: Date.now(),
tags: [],
icon: "mdi-node-rectangle",
positionAbsolute: false,
Expand Down
1 change: 1 addition & 0 deletions packages/Graph/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default () => {
graphSnapshotStore: useGraphSnapshotStore(),
graphSnapshot: null as any,
updatingSnapshotLocally: false,
isNewGraph: false,
rewindVersion: 0,
keys: {} as Record<string, string>,
artifacts: {} as Record<string, any>,
Expand Down
210 changes: 209 additions & 1 deletion packages/Names/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,192 @@ const adjectives = [
"Incalculable",
"Limited",
"Little",
"Abundant",
"Acidic",
"Alive",
"Angry",
"Attractive",
"Bald",
"Beautiful",
"Better",
"Big",
"Bitter",
"Breezy",
"Broad",
"Bumpy",
"Careful",
"Chilly",
"Chubby",
"Clean",
"Clever",
"Cold",
"Colossal",
"Cool",
"Creamy",
"Crooked",
"Cuddly",
"Curved",
"Damaged",
"Damp",
"Dazzling",
"Dead",
"Deep",
"Delicious",
"Dirty",
"Disgusting",
"Drab",
"Dry",
"Easy",
"Elegant",
"Embarrassed",
"Faint",
"Famous",
"Fancy",
"Fat",
"Fierce",
"Fit",
"Flabby",
"Flaky",
"Flat",
"Fluffy",
"Freezing",
"Fresh",
"Gifted",
"Gigantic",
"Glamorous",
"Gorgeous",
"Great",
"Greasy",
"Grumpy",
"Handsome",
"Hallowed",
"Harsh",
"Helpful",
"Helpless",
"High",
"Hissing",
"Hollow",
"Hot",
"Howling",
"Huge",
"Icy",
"Immense",
"Important",
"Incalculable",
"Inexpensive",
"Itchy",
"Jealous",
"Juicy",
"Large",
"Lazy",
"Limited",
"Little",
"Loud",
"Low",
"Magnificent",
"Mammoth",
"Massive",
"Mealy",
"Melodic",
"Microscopic",
"Miniature",
"Moldy",
"Mushy",
"Muscular",
"Mysterious",
"Narrow",
"Nervous",
"Noisy",
"Nutritious",
"Nutty",
"Obnoxious",
"Odd",
"Old-fashioned",
"Panicky",
"Petite",
"Pitiful",
"Plain",
"Plump",
"Poor",
"Powerful",
"Purring",
"Putrid",
"Quaint",
"Quiet",
"Rancid",
"Rapping",
"Rapid",
"Raspy",
"Refined",
"Repulsive",
"Rich",
"Ripe",
"Rotten",
"Rough",
"Round",
"Salty",
"Savory",
"Scary",
"Scrawny",
"Screeching",
"Scruffy",
"Shaggy",
"Shallow",
"Sharp",
"Shapely",
"Short",
"Shrilling",
"Shy",
"Silly",
"Skinny",
"Slimy",
"Slow",
"Small",
"Sour",
"Spicy",
"Spoiled",
"Square",
"Stale",
"Steep",
"Sticky",
"Stocky",
"Straight",
"Strong",
"Sweet",
"Swift",
"Tall",
"Tangy",
"Tart",
"Tasteless",
"Tasty",
"Tender",
"Thankful",
"Thoughtless",
"Thundering",
"Tight",
"Tinkling",
"Tiny",
"Unimportant",
"Uninterested",
"Unkempt",
"Unsightly",
"Uptight",
"Victorious",
"Vast",
"Warm",
"Weak",
"Wet",
"Whale",
"Wailing",
"Whining",
"Whispering",
"Wide",
"Witty",
"Wooden",
"Wonderful",
"Worried",
"Wrong",
"Yummy",
];
const animals = [
"Dog",
Expand Down Expand Up @@ -388,10 +574,32 @@ const animals = [
"Mosquito",
"Grasshopper",
"Beetle",
"Cockroach",
"Centipede",
"Worm",
"Louse",
"Alpaca",
"Bison",
"Cheetah",
"Falcon",
"Iguana",
"Jaguar",
"Lemur",
"Manatee",
"Manatee",
"Pet Rock",
"Orangutan",
"Platypus",
"Quokka",
"Rhinoceros",
"Sloth",
"Tarsier",
"Urial",
"Vulture",
"Warthog",
"Xerus",
"Yak",
"Coral",
"Zebra",
];
const notFoundIcons = [
"mdi-skull",
Expand Down
19 changes: 10 additions & 9 deletions packages/WssDocumentProvider/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class WssDocumentProvider extends EditorModule {
const providerState = {
graph: null as any,
localUpdate: false,
initComplete: false,
subscribed: false,
sentEventIds: [],
};
const orchistratorStore = useOrchistratorStore();
Expand All @@ -36,12 +36,12 @@ export default class WssDocumentProvider extends EditorModule {
if (!state.graph || providerState.localUpdate) {
return;
}
if (!providerState.graph && providerState.initComplete) {
// inital load
providerState.graph = JSON.parse(JSON.stringify(state.graph));
// messages from server
orchistratorStore.dataProviders.graph.subscribe('graph-event-' + providerState.graph.id, async (e: any) => {
if (!providerState.subscribed) {
console.log('subscribe to remote');
providerState.subscribed = true;
orchistratorStore.dataProviders.graph.subscribe('graph-event-' + state.graph.id, async (e: any) => {
// apply remote event
console.log('remote event', e);
graphSnapshotStore.$patch((state) => {
providerState.localUpdate = true;
e.forEach((event) => {
Expand All @@ -58,12 +58,13 @@ export default class WssDocumentProvider extends EditorModule {
providerState.localUpdate = false;
});
});
return;
}
if (mutation.type !== 'patch function' && providerState.initComplete) {
if (!providerState.graph && !state.isNewGraph) {
providerState.graph = JSON.parse(JSON.stringify(state.graph));
}
if (mutation.type !== 'patch function') {
return;
}
providerState.initComplete = true;
const changes = diff(providerState.graph || {}, JSON.parse(JSON.stringify(state.graph)));
if (changes) {
providerState.graph = JSON.parse(JSON.stringify(state.graph));
Expand Down

0 comments on commit 0db4113

Please sign in to comment.