Skip to content

Commit

Permalink
Merge pull request #377 from ajthinking/make-set
Browse files Browse the repository at this point in the history
Make set & Lint updates
  • Loading branch information
ajthinking authored Jan 29, 2025
2 parents eb8440c + 6d8b578 commit 88cf75b
Show file tree
Hide file tree
Showing 221 changed files with 989 additions and 938 deletions.
30 changes: 19 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
module.exports = {
'env': {
'browser': true,
'es2021': true
'es2021': true,
},
'overrides': [
{
'env': {
'node': true
'node': true,
},
'files': ['*.ts', '*.tsx', '*.js', '*.jsx'],
'parserOptions': {
'sourceType': 'script'
}
}
'sourceType': 'script',
},
},
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
'ecmaVersion': 'latest',
'sourceType': 'module'
'sourceType': 'module',
},
'plugins': [
'@stylistic',
'react-hooks',
'import'
'import',
],
'rules': {
'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 0, 'maxBOF': 0 }],
Expand All @@ -32,14 +32,22 @@ module.exports = {
'react-hooks/exhaustive-deps': 'warn',
'@stylistic/indent': [
'error',
2
2,
],
'@stylistic/linebreak-style': 'off',
'@stylistic/quotes': [
'error',
'single'
'single',
],
'@stylistic/eol-last': 'off',
'@stylistic/space-infix-ops': ['warn', { 'int32Hint': false }]
}
'@stylistic/space-infix-ops': ['warn', { 'int32Hint': false }],
'@stylistic/comma-dangle': ['error', {
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'always-multiline',
'exports': 'always-multiline',
'functions': 'always-multiline',
}],
'@stylistic/object-curly-spacing': ['error', 'always'],
},
};
4 changes: 2 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineConfig({
devServer: {
framework: 'react',
bundler: 'webpack',
webpackConfig: webpackConfig
webpackConfig: webpackConfig,
},
viewportWidth: 384,
viewportHeight: 216,
Expand All @@ -19,5 +19,5 @@ export default defineConfig({
setupNodeEvents(on, config) {
// implement node event listeners here
},
}
},
});
10 changes: 5 additions & 5 deletions packages/core/src/Application.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('register', () => {
app.register(provider)

expect(app.providers).toMatchObject([
provider
provider,
])
})

Expand All @@ -33,7 +33,7 @@ describe('register', () => {

expect(app.providers).toMatchObject([
provider1,
provider2
provider2,
])
})
})
Expand Down Expand Up @@ -64,13 +64,13 @@ describe('addComputers', () => {
const app = new Application()
const computer = {
name: 'Signal',
run: async function*(_) {}
run: async function*(_) {},
} as Computer;

app.addComputers([computer])

expect(app.getRegistry().computers.Signal).toMatchObject(
computer
computer,
)
})
})
Expand All @@ -82,7 +82,7 @@ describe('descriptions', () => {
app.addComputers([ Signal ])

expect(app.descriptions()).toMatchObject([
{ name: 'Signal' }
{ name: 'Signal' },
])
})
})
10 changes: 5 additions & 5 deletions packages/core/src/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Application {

register(provider: ServiceProvider | ServiceProvider[]) {
this.providers.push(
...(Array.isArray(provider) ? provider : [provider])
...(Array.isArray(provider) ? provider : [provider]),
);

return this;
Expand Down Expand Up @@ -58,17 +58,17 @@ export class Application {

return [
...fromComputers,
...fromNestedNodes
...fromNestedNodes,
];
}

getDiagramBuilder() {
return new DiagramBuilder(
this.descriptions()
this.descriptions(),
);
}

getExecutor({ diagram, storage, inputObserverController}: {
getExecutor({ diagram, storage, inputObserverController }: {
diagram: Diagram;
storage: Storage;
inputObserverController?: InputObserverController;
Expand All @@ -77,7 +77,7 @@ export class Application {
diagram,
registry: this.registry,
storage,
inputObserverController
inputObserverController,
})
}

Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/Diagram.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('add', () => {
name: 'MyNode',
inputs: [],
outputs: [],
params: []
params: [],
}

expect(diagram.nodes).toEqual([])
Expand All @@ -25,18 +25,18 @@ describe('nodeWithOutputPortId', () => {
const output: Port = {
id: 'output-port-id',
name: 'output',
schema: {}
schema: {},
}

const node: Node = {
id: 'node-id',
name: 'MyNode',
inputs: [],
outputs: [output],
params: []
params: [],
}

const diagram = new Diagram({ nodes: [node]})
const diagram = new Diagram({ nodes: [node] })
const result = diagram.nodeWithOutputPortId('output-port-id')

expect(result).toMatchObject(node)
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('clone', () => {
name: 'MyNode',
inputs: [],
outputs: [],
params: []
params: [],
};

const link: Link = {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Diagram {
this.viewport = options?.viewport || {
x: 0,
y: 0,
zoom: 1
zoom: 1,
}
}

Expand Down Expand Up @@ -91,7 +91,7 @@ export class Diagram {

return {
nodeId: targetNode.id,
portId: link.targetPortId
portId: link.targetPortId,
}
}

Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/DiagramBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('get', () => {

// Everything at default 0, 0
expect(diagram.nodes).toMatchObject([
{ position: { x: 0, y: 0} },
{ position: { x: 0, y: 0 } },
{ position: { x: 0, y: 0 } },
])

Expand Down Expand Up @@ -54,8 +54,8 @@ describe('add', () => {
expect(periodParam).toMatchObject({
name: 'period',
value: {
value: 99
}
value: 99,
},
})
})

Expand Down Expand Up @@ -174,8 +174,8 @@ describe('connect', () => {
expect(diagram.links).toMatchObject([
{
sourcePortId: 'Create.1.output',
targetPortId: 'Pass.1.input'
}
targetPortId: 'Pass.1.input',
},
])
})

Expand All @@ -194,12 +194,12 @@ describe('connect', () => {
expect(diagram.links).toMatchObject([
{
sourcePortId: 'Create.1.output',
targetPortId: 'Pass.1.input'
targetPortId: 'Pass.1.input',
},
{
sourcePortId: 'Create.1.output',
targetPortId: 'Ignore.1.input'
}
targetPortId: 'Ignore.1.input',
},
])
})

Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/DiagramBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class DiagramBuilder {
return this
}

jiggle(jitter = {x: 50, y: 25 }) {
jiggle(jitter = { x: 50, y: 25 }) {
for(const node of this.diagram.nodes) {
node.position!.x += (0.5 - Math.random()) * jitter.x
node.position!.y += (0.5 - Math.random()) * jitter.y
Expand Down Expand Up @@ -281,8 +281,8 @@ export class DiagramBuilder {
...param,
value: {
...(param.value as Object),
...value
}
...value,
},
}
continue
}
Expand Down
24 changes: 12 additions & 12 deletions packages/core/src/ExecutionMemory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('ExecutionMemory', () => {
it('returns the correct items for a link', () => {
const memory = new ExecutionMemory();
const linkId: LinkId = 'link1';
const items: ItemValue[] = [{i: 1}, {i: 2}, {i: 3}];
const items: ItemValue[] = [{ i: 1 }, { i: 2 }, { i: 3 }];

memory.setLinkItems(linkId, items);

Expand All @@ -119,26 +119,26 @@ describe('ExecutionMemory', () => {
it('pulls the correct number of items from a link', () => {
const memory = new ExecutionMemory();
const linkId: LinkId = 'link1';
const items: ItemValue[] = [{i: 1}, {i: 2}, {i: 3}];
const items: ItemValue[] = [{ i: 1 }, { i: 2 }, { i: 3 }];
memory.setLinkItems(linkId, items);

const count = 2;
const pulled = memory.pullLinkItems(linkId, count);

expect(pulled).toEqual([{i: 1}, {i: 2}]);
expect(memory.getLinkItems(linkId)).toEqual([{i: 3}]);
expect(pulled).toEqual([{ i: 1 }, { i: 2 }]);
expect(memory.getLinkItems(linkId)).toEqual([{ i: 3 }]);
});

it('pulls all items from a link if count exceeds the number of items', () => {
const memory = new ExecutionMemory();
const linkId: LinkId = 'link1';
const items: ItemValue[] = [{i: 1}, {i: 2}, {i: 3}];
const items: ItemValue[] = [{ i: 1 }, { i: 2 }, { i: 3 }];
memory.setLinkItems(linkId, items);

const count = 5; // Exceeds the number of items
const pulled = memory.pullLinkItems(linkId, count);

expect(pulled).toMatchObject([{i: 1}, {i: 2}, {i: 3}]);
expect(pulled).toMatchObject([{ i: 1 }, { i: 2 }, { i: 3 }]);
expect(memory.getLinkItems(linkId)).toEqual([]);
});
});
Expand All @@ -149,13 +149,13 @@ describe('ExecutionMemory', () => {

const memory = new ExecutionMemory({
linkItems: new Map()
.set('link1', [{i: 1}, {i: 2}]),
.set('link1', [{ i: 1 }, { i: 2 }]),
});

memory.pushLinkItems(linkId, [{i: 3}]);
memory.pushLinkItems(linkId, [{ i: 3 }]);

expect(memory.getLinkItems(linkId)).toMatchObject([
{i: 1}, {i: 2}, {i: 3}
{ i: 1 }, { i: 2 }, { i: 3 },
]);
});
});
Expand All @@ -164,7 +164,7 @@ describe('ExecutionMemory', () => {
it('sets the items of a link correctly', () => {
const memory = new ExecutionMemory();
const linkId: LinkId = 'link1';
const items: ItemValue[] = [{i: 1}, {i: 2}];
const items: ItemValue[] = [{ i: 1 }, { i: 2 }];

memory.setLinkItems(linkId, items);

Expand Down Expand Up @@ -245,7 +245,7 @@ describe('ExecutionMemory', () => {
const memory = new ExecutionMemory();
const hooks = [{
type: 'TEST_HOOK',
args: ['arg1', 'arg2']
args: ['arg1', 'arg2'],
}];

memory.pushHooks(hooks);
Expand All @@ -259,7 +259,7 @@ describe('ExecutionMemory', () => {
const memory = new ExecutionMemory();
const hooks = [{
type: 'TEST_HOOK',
args: ['arg1', 'arg2']
args: ['arg1', 'arg2'],
}];

memory.pushHooks(hooks);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/ExecutionMemory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class ExecutionMemory {
this.inputObserverController?.reportItems({
linkId,
type: RequestObserverType.observeLinkItems,
items
items,
})
}

Expand All @@ -101,7 +101,7 @@ export class ExecutionMemory {
this.inputObserverController?.reportLinksCount({
linkId,
type: RequestObserverType.observeLinkCounts,
count
count,
})

this.linkCounts.set(linkId, count)
Expand Down
Loading

0 comments on commit 88cf75b

Please sign in to comment.