@platformos/platformos-graph 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/getWebComponentMap.js +1 -1
  3. package/dist/getWebComponentMap.js.map +1 -1
  4. package/dist/graph/augment.js +0 -3
  5. package/dist/graph/augment.js.map +1 -1
  6. package/dist/graph/build.d.ts +2 -2
  7. package/dist/graph/build.js +11 -8
  8. package/dist/graph/build.js.map +1 -1
  9. package/dist/graph/module.d.ts +6 -9
  10. package/dist/graph/module.js +53 -117
  11. package/dist/graph/module.js.map +1 -1
  12. package/dist/graph/serialize.d.ts +2 -2
  13. package/dist/graph/serialize.js +2 -2
  14. package/dist/graph/serialize.js.map +1 -1
  15. package/dist/graph/test-helpers.d.ts +0 -13
  16. package/dist/graph/test-helpers.js +0 -10
  17. package/dist/graph/test-helpers.js.map +1 -1
  18. package/dist/graph/traverse.d.ts +3 -3
  19. package/dist/graph/traverse.js +19 -349
  20. package/dist/graph/traverse.js.map +1 -1
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +4 -6
  23. package/dist/index.js.map +1 -1
  24. package/dist/toSourceCode.d.ts +1 -4
  25. package/dist/toSourceCode.js +8 -52
  26. package/dist/toSourceCode.js.map +1 -1
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/dist/types.d.ts +21 -78
  29. package/dist/types.js.map +1 -1
  30. package/dist/utils/index.d.ts +0 -3
  31. package/dist/utils/index.js +0 -18
  32. package/dist/utils/index.js.map +1 -1
  33. package/fixtures/skeleton/{layout/theme.liquid → app/views/layouts/application.liquid} +3 -4
  34. package/fixtures/skeleton/app/views/pages/index.liquid +5 -0
  35. package/fixtures/skeleton/app/views/partials/header.liquid +3 -0
  36. package/package.json +4 -4
  37. package/src/getWebComponentMap.ts +1 -1
  38. package/src/graph/augment.ts +1 -13
  39. package/src/graph/build.spec.ts +31 -171
  40. package/src/graph/build.ts +18 -14
  41. package/src/graph/module.ts +59 -135
  42. package/src/graph/serialize.spec.ts +22 -29
  43. package/src/graph/serialize.ts +2 -2
  44. package/src/graph/test-helpers.ts +1 -18
  45. package/src/graph/traverse.ts +28 -501
  46. package/src/index.ts +3 -3
  47. package/src/toSourceCode.ts +14 -55
  48. package/src/types.ts +23 -100
  49. package/src/utils/index.ts +0 -24
  50. package/fixtures/skeleton/blocks/_private.liquid +0 -1
  51. package/fixtures/skeleton/blocks/_static.liquid +0 -10
  52. package/fixtures/skeleton/blocks/group.liquid +0 -27
  53. package/fixtures/skeleton/blocks/render-static.liquid +0 -22
  54. package/fixtures/skeleton/blocks/text.liquid +0 -14
  55. package/fixtures/skeleton/jsconfig.json +0 -9
  56. package/fixtures/skeleton/sections/custom-section.liquid +0 -6
  57. package/fixtures/skeleton/sections/header-group.json +0 -36
  58. package/fixtures/skeleton/sections/header.liquid +0 -1
  59. package/fixtures/skeleton/templates/index.json +0 -20
@@ -1,59 +1,52 @@
1
1
  import { path as pathUtils } from '@platformos/platformos-check-common';
2
2
  import { describe, expect, it } from 'vitest';
3
- import { ThemeGraph } from '../types';
4
- import { getSectionModule, getPartialModule, getTemplateModule } from './module';
5
- import { serializeThemeGraph } from './serialize';
3
+ import { AppGraph } from '../types';
4
+ import { getLayoutModule, getPartialModule } from './module';
5
+ import { serializeAppGraph } from './serialize';
6
6
  import { bind } from './traverse';
7
7
 
8
- describe('Unit: serializeThemeGraph', () => {
8
+ describe('Unit: serializeAppGraph', () => {
9
9
  it('serialize the graph', () => {
10
- const rootUri = 'file:///theme';
10
+ const rootUri = 'file:///app';
11
11
  const p = (part: string) => pathUtils.join(rootUri, part);
12
- const graph: ThemeGraph = {
12
+ const graph: AppGraph = {
13
13
  entryPoints: [],
14
14
  modules: {},
15
15
  rootUri,
16
16
  };
17
17
 
18
- const template = getTemplateModule(graph, p('templates/index.json'));
19
- const customSection = getSectionModule(graph, 'custom-section');
18
+ const layout = getLayoutModule(graph, p('app/views/layouts/application.liquid'))!;
19
+ const headerPartial = getPartialModule(graph, 'header');
20
20
  const parentPartial = getPartialModule(graph, 'parent');
21
21
  const childPartial = getPartialModule(graph, 'child');
22
- bind(template, customSection, { sourceRange: [0, 5] });
23
- bind(customSection, parentPartial, { sourceRange: [10, 15] });
24
- bind(parentPartial, childPartial, { sourceRange: [20, 25] });
25
22
 
26
- const section2 = getSectionModule(graph, 'section2');
27
- bind(template, section2, { sourceRange: [20, 25] });
23
+ bind(layout, headerPartial, { sourceRange: [0, 5] });
24
+ bind(layout, parentPartial, { sourceRange: [10, 15] });
25
+ bind(parentPartial, childPartial, { sourceRange: [20, 25] });
28
26
 
29
- graph.entryPoints = [template];
30
- [template, customSection, section2, parentPartial, childPartial].forEach((module) => {
27
+ graph.entryPoints = [layout];
28
+ [layout, headerPartial, parentPartial, childPartial].forEach((module) => {
31
29
  graph.modules[module.uri] = module;
32
30
  });
33
31
 
34
- const { nodes, edges } = serializeThemeGraph(graph);
35
- expect(nodes).toHaveLength(5);
36
- expect(edges).toHaveLength(4);
32
+ const { nodes, edges } = serializeAppGraph(graph);
33
+ expect(nodes).toHaveLength(4);
34
+ expect(edges).toHaveLength(3);
37
35
  expect(edges).toEqual(
38
36
  expect.arrayContaining([
39
37
  {
40
- source: { uri: 'file:///theme/templates/index.json', range: [0, 5] },
41
- target: { uri: 'file:///theme/sections/custom-section.liquid' },
42
- type: 'direct',
43
- },
44
- {
45
- source: { uri: 'file:///theme/sections/custom-section.liquid', range: [10, 15] },
46
- target: { uri: 'file:///theme/app/views/partials/parent.liquid' },
38
+ source: { uri: p('app/views/layouts/application.liquid'), range: [0, 5] },
39
+ target: { uri: p('app/views/partials/header.liquid') },
47
40
  type: 'direct',
48
41
  },
49
42
  {
50
- source: { uri: 'file:///theme/app/views/partials/parent.liquid', range: [20, 25] },
51
- target: { uri: 'file:///theme/app/views/partials/child.liquid' },
43
+ source: { uri: p('app/views/layouts/application.liquid'), range: [10, 15] },
44
+ target: { uri: p('app/views/partials/parent.liquid') },
52
45
  type: 'direct',
53
46
  },
54
47
  {
55
- source: { uri: 'file:///theme/templates/index.json', range: [20, 25] },
56
- target: { uri: 'file:///theme/sections/section2.liquid' },
48
+ source: { uri: p('app/views/partials/parent.liquid'), range: [20, 25] },
49
+ target: { uri: p('app/views/partials/child.liquid') },
57
50
  type: 'direct',
58
51
  },
59
52
  ]),
@@ -1,6 +1,6 @@
1
- import { SerializableEdge, SerializableGraph, SerializableNode, ThemeGraph } from '../types';
1
+ import { SerializableEdge, SerializableGraph, SerializableNode, AppGraph } from '../types';
2
2
 
3
- export function serializeThemeGraph(graph: ThemeGraph): SerializableGraph {
3
+ export function serializeAppGraph(graph: AppGraph): SerializableGraph {
4
4
  const nodes: SerializableNode[] = Object.values(graph.modules).map((module) => ({
5
5
  uri: module.uri,
6
6
  type: module.type,
@@ -1,11 +1,4 @@
1
- import {
2
- LiquidSourceCode,
3
- memoize,
4
- path as pathUtils,
5
- SectionSchema,
6
- ThemeBlockSchema,
7
- toSchema,
8
- } from '@platformos/platformos-check-common';
1
+ import { memoize, path as pathUtils } from '@platformos/platformos-check-common';
9
2
  import { AbstractFileSystem } from '@platformos/platformos-common';
10
3
  import { NodeFileSystem } from '@platformos/platformos-check-node';
11
4
  import { vi } from 'vitest';
@@ -28,16 +21,6 @@ export async function getDependencies(rootUri: string, fs: AbstractFileSystem =
28
21
  const getSourceCode = makeGetSourceCode(fs);
29
22
  const deps = {
30
23
  fs,
31
- getSectionSchema: memoize(async (name: string) => {
32
- const uri = pathUtils.join(skeleton, 'sections', `${name}.liquid`);
33
- const sourceCode = (await getSourceCode(uri)) as LiquidSourceCode;
34
- return (await toSchema('theme', uri, sourceCode, async () => true)) as SectionSchema;
35
- }, identity),
36
- getBlockSchema: memoize(async (name: string) => {
37
- const uri = pathUtils.join(skeleton, 'blocks', `${name}.liquid`);
38
- const sourceCode = (await getSourceCode(uri)) as LiquidSourceCode;
39
- return (await toSchema('theme', uri, sourceCode, async () => true)) as ThemeBlockSchema;
40
- }, identity),
41
24
  getSourceCode,
42
25
  getWebComponentDefinitionReference: (customElementName: string) =>
43
26
  webComponentDefs.get(customElementName),