mapples 0.1.0

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 (135) hide show
  1. package/README.md +42 -0
  2. package/dist/adopt/mappingTable.d.ts +1 -0
  3. package/dist/adopt/mappingTable.js +18 -0
  4. package/dist/adopt/mappingTable.js.map +1 -0
  5. package/dist/adopt/scan.d.ts +4 -0
  6. package/dist/adopt/scan.js +51 -0
  7. package/dist/adopt/scan.js.map +1 -0
  8. package/dist/api/canonical.d.ts +12 -0
  9. package/dist/api/canonical.js +65 -0
  10. package/dist/api/canonical.js.map +1 -0
  11. package/dist/api/client.d.ts +37 -0
  12. package/dist/api/client.js +79 -0
  13. package/dist/api/client.js.map +1 -0
  14. package/dist/api/commit.d.ts +18 -0
  15. package/dist/api/commit.js +47 -0
  16. package/dist/api/commit.js.map +1 -0
  17. package/dist/api/errors.d.ts +30 -0
  18. package/dist/api/errors.js +74 -0
  19. package/dist/api/errors.js.map +1 -0
  20. package/dist/api/objects.d.ts +55 -0
  21. package/dist/api/objects.js +48 -0
  22. package/dist/api/objects.js.map +1 -0
  23. package/dist/api/poll.d.ts +10 -0
  24. package/dist/api/poll.js +33 -0
  25. package/dist/api/poll.js.map +1 -0
  26. package/dist/assets/assets.d.ts +15 -0
  27. package/dist/assets/assets.js +110 -0
  28. package/dist/assets/assets.js.map +1 -0
  29. package/dist/codegen/emit.d.ts +8 -0
  30. package/dist/codegen/emit.js +33 -0
  31. package/dist/codegen/emit.js.map +1 -0
  32. package/dist/codegen/format.d.ts +8 -0
  33. package/dist/codegen/format.js +24 -0
  34. package/dist/codegen/format.js.map +1 -0
  35. package/dist/codegen/imports.d.ts +15 -0
  36. package/dist/codegen/imports.js +79 -0
  37. package/dist/codegen/imports.js.map +1 -0
  38. package/dist/commands/adopt.d.ts +2 -0
  39. package/dist/commands/adopt.js +11 -0
  40. package/dist/commands/adopt.js.map +1 -0
  41. package/dist/commands/create.d.ts +2 -0
  42. package/dist/commands/create.js +13 -0
  43. package/dist/commands/create.js.map +1 -0
  44. package/dist/commands/doctor.d.ts +2 -0
  45. package/dist/commands/doctor.js +11 -0
  46. package/dist/commands/doctor.js.map +1 -0
  47. package/dist/commands/impl/adoptImpl.d.ts +1 -0
  48. package/dist/commands/impl/adoptImpl.js +24 -0
  49. package/dist/commands/impl/adoptImpl.js.map +1 -0
  50. package/dist/commands/impl/createImpl.d.ts +2 -0
  51. package/dist/commands/impl/createImpl.js +65 -0
  52. package/dist/commands/impl/createImpl.js.map +1 -0
  53. package/dist/commands/impl/doctorImpl.d.ts +1 -0
  54. package/dist/commands/impl/doctorImpl.js +25 -0
  55. package/dist/commands/impl/doctorImpl.js.map +1 -0
  56. package/dist/commands/impl/initImpl.d.ts +1 -0
  57. package/dist/commands/impl/initImpl.js +65 -0
  58. package/dist/commands/impl/initImpl.js.map +1 -0
  59. package/dist/commands/impl/syncImpl.d.ts +1 -0
  60. package/dist/commands/impl/syncImpl.js +34 -0
  61. package/dist/commands/impl/syncImpl.js.map +1 -0
  62. package/dist/commands/init.d.ts +2 -0
  63. package/dist/commands/init.js +13 -0
  64. package/dist/commands/init.js.map +1 -0
  65. package/dist/commands/sync.d.ts +2 -0
  66. package/dist/commands/sync.js +13 -0
  67. package/dist/commands/sync.js.map +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +23 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/merge/applyOps.d.ts +11 -0
  72. package/dist/merge/applyOps.js +134 -0
  73. package/dist/merge/applyOps.js.map +1 -0
  74. package/dist/merge/deprecate.d.ts +3 -0
  75. package/dist/merge/deprecate.js +28 -0
  76. package/dist/merge/deprecate.js.map +1 -0
  77. package/dist/merge/diff.d.ts +15 -0
  78. package/dist/merge/diff.js +124 -0
  79. package/dist/merge/diff.js.map +1 -0
  80. package/dist/merge/mergePatch.d.ts +8 -0
  81. package/dist/merge/mergePatch.js +63 -0
  82. package/dist/merge/mergePatch.js.map +1 -0
  83. package/dist/merge/threeWay.d.ts +15 -0
  84. package/dist/merge/threeWay.js +242 -0
  85. package/dist/merge/threeWay.js.map +1 -0
  86. package/dist/merge/toEdits.d.ts +3 -0
  87. package/dist/merge/toEdits.js +92 -0
  88. package/dist/merge/toEdits.js.map +1 -0
  89. package/dist/nav/routeTree.d.ts +11 -0
  90. package/dist/nav/routeTree.js +182 -0
  91. package/dist/nav/routeTree.js.map +1 -0
  92. package/dist/project/baseStore.d.ts +19 -0
  93. package/dist/project/baseStore.js +78 -0
  94. package/dist/project/baseStore.js.map +1 -0
  95. package/dist/project/config.d.ts +13 -0
  96. package/dist/project/config.js +28 -0
  97. package/dist/project/config.js.map +1 -0
  98. package/dist/project/head.d.ts +6 -0
  99. package/dist/project/head.js +22 -0
  100. package/dist/project/head.js.map +1 -0
  101. package/dist/project/outbox.d.ts +14 -0
  102. package/dist/project/outbox.js +31 -0
  103. package/dist/project/outbox.js.map +1 -0
  104. package/dist/project/pagesMap.d.ts +8 -0
  105. package/dist/project/pagesMap.js +20 -0
  106. package/dist/project/pagesMap.js.map +1 -0
  107. package/dist/services/adoptService.d.ts +11 -0
  108. package/dist/services/adoptService.js +197 -0
  109. package/dist/services/adoptService.js.map +1 -0
  110. package/dist/services/doctorService.d.ts +11 -0
  111. package/dist/services/doctorService.js +135 -0
  112. package/dist/services/doctorService.js.map +1 -0
  113. package/dist/services/scaffold.d.ts +7 -0
  114. package/dist/services/scaffold.js +56 -0
  115. package/dist/services/scaffold.js.map +1 -0
  116. package/dist/services/syncEngine.d.ts +11 -0
  117. package/dist/services/syncEngine.js +618 -0
  118. package/dist/services/syncEngine.js.map +1 -0
  119. package/dist/style/theme.d.ts +12 -0
  120. package/dist/style/theme.js +125 -0
  121. package/dist/style/theme.js.map +1 -0
  122. package/dist/types.d.ts +136 -0
  123. package/dist/types.js +6 -0
  124. package/dist/types.js.map +1 -0
  125. package/dist/ui/report.d.ts +24 -0
  126. package/dist/ui/report.js +50 -0
  127. package/dist/ui/report.js.map +1 -0
  128. package/package.json +38 -0
  129. package/templates/app/_layout.tsx +5 -0
  130. package/templates/app.json +15 -0
  131. package/templates/babel.config.js +8 -0
  132. package/templates/gitignore +7 -0
  133. package/templates/mapples/sid.d.ts +13 -0
  134. package/templates/package.json +30 -0
  135. package/templates/tsconfig.json +10 -0
@@ -0,0 +1,78 @@
1
+ // .mapples/base/ — one canonical JSON per page/entity at the last synced HEAD.
2
+ // writeAll is atomic: everything lands in a tmp dir which is renamed over the
3
+ // old base, so a crash can never leave a torn base.
4
+ import { mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync, existsSync, } from 'node:fs';
5
+ import { join } from 'node:path';
6
+ import { CONFIG_DIR } from './config.js';
7
+ export class BaseStore {
8
+ root;
9
+ constructor(root) {
10
+ this.root = root;
11
+ }
12
+ get dir() {
13
+ return join(this.root, CONFIG_DIR, 'base');
14
+ }
15
+ exists() {
16
+ return existsSync(this.dir);
17
+ }
18
+ readAll() {
19
+ const snapshot = {
20
+ pages: new Map(),
21
+ components: new Map(),
22
+ navigation: null,
23
+ style: null,
24
+ assets: null,
25
+ };
26
+ if (!this.exists())
27
+ return snapshot;
28
+ const pagesDir = join(this.dir, 'pages');
29
+ if (existsSync(pagesDir)) {
30
+ for (const file of readdirSync(pagesDir).filter((f) => f.endsWith('.json'))) {
31
+ const page = JSON.parse(readFileSync(join(pagesDir, file), 'utf8'));
32
+ snapshot.pages.set(page.id, page);
33
+ }
34
+ }
35
+ const componentsDir = join(this.dir, 'components');
36
+ if (existsSync(componentsDir)) {
37
+ for (const file of readdirSync(componentsDir).filter((f) => f.endsWith('.json'))) {
38
+ const cmp = JSON.parse(readFileSync(join(componentsDir, file), 'utf8'));
39
+ snapshot.components.set(cmp.id, cmp);
40
+ }
41
+ }
42
+ for (const key of ['navigation', 'style', 'assets']) {
43
+ const path = join(this.dir, `${key}.json`);
44
+ if (existsSync(path)) {
45
+ snapshot[key] = JSON.parse(readFileSync(path, 'utf8'));
46
+ }
47
+ }
48
+ return snapshot;
49
+ }
50
+ readPageRoot(pageId) {
51
+ const path = join(this.dir, 'pages', `${pageId}.json`);
52
+ if (!existsSync(path))
53
+ return null;
54
+ return JSON.parse(readFileSync(path, 'utf8')).root;
55
+ }
56
+ /** Atomic: write everything into base.tmp, then rename over base. */
57
+ writeAll(snapshot) {
58
+ const tmp = join(this.root, CONFIG_DIR, 'base.tmp');
59
+ rmSync(tmp, { recursive: true, force: true });
60
+ mkdirSync(join(tmp, 'pages'), { recursive: true });
61
+ mkdirSync(join(tmp, 'components'), { recursive: true });
62
+ for (const page of snapshot.pages.values()) {
63
+ writeFileSync(join(tmp, 'pages', `${page.id}.json`), JSON.stringify(page, null, 2) + '\n');
64
+ }
65
+ for (const cmp of snapshot.components.values()) {
66
+ writeFileSync(join(tmp, 'components', `${cmp.id}.json`), JSON.stringify(cmp, null, 2) + '\n');
67
+ }
68
+ for (const key of ['navigation', 'style', 'assets']) {
69
+ const value = snapshot[key];
70
+ if (value !== null) {
71
+ writeFileSync(join(tmp, `${key}.json`), JSON.stringify(value, null, 2) + '\n');
72
+ }
73
+ }
74
+ rmSync(this.dir, { recursive: true, force: true });
75
+ renameSync(tmp, this.dir);
76
+ }
77
+ }
78
+ //# sourceMappingURL=baseStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseStore.js","sourceRoot":"","sources":["../../src/project/baseStore.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,oDAAoD;AAEpD,OAAO,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAUjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAUzC,MAAM,OAAO,SAAS;IACS;IAA7B,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAE7C,IAAY,GAA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AC;CACF"}
@@ -0,0 +1,13 @@
1
+ export interface MapplesConfig {
2
+ projectId: string;
3
+ apiUrl: string;
4
+ /** Directory (relative to the project root) holding Mapplet pages. */
5
+ appDir: string;
6
+ /** Directory holding the expo-router route wrappers (CLI-managed tree). */
7
+ routesDir?: string;
8
+ schema: 1;
9
+ }
10
+ export declare const CONFIG_DIR = ".mapples";
11
+ export declare function configPath(root: string): string;
12
+ export declare function readConfig(root: string): MapplesConfig;
13
+ export declare function writeConfig(root: string, config: MapplesConfig): void;
@@ -0,0 +1,28 @@
1
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ export const CONFIG_DIR = '.mapples';
4
+ export function configPath(root) {
5
+ return join(root, CONFIG_DIR, 'config.json');
6
+ }
7
+ export function readConfig(root) {
8
+ const path = configPath(root);
9
+ if (!existsSync(path)) {
10
+ throw new Error(`no ${CONFIG_DIR}/config.json in ${root} — run \`mapples init\` (or \`mapples create\`) first`);
11
+ }
12
+ const parsed = JSON.parse(readFileSync(path, 'utf8'));
13
+ if (typeof parsed.projectId !== 'string' || typeof parsed.apiUrl !== 'string') {
14
+ throw new Error(`${path} is malformed: projectId and apiUrl are required`);
15
+ }
16
+ return {
17
+ projectId: parsed.projectId,
18
+ apiUrl: parsed.apiUrl,
19
+ appDir: typeof parsed.appDir === 'string' ? parsed.appDir : 'mapples/pages',
20
+ routesDir: typeof parsed.routesDir === 'string' ? parsed.routesDir : 'app/(mapples)',
21
+ schema: 1,
22
+ };
23
+ }
24
+ export function writeConfig(root, config) {
25
+ mkdirSync(join(root, CONFIG_DIR), { recursive: true });
26
+ writeFileSync(configPath(root), JSON.stringify(config, null, 2) + '\n');
27
+ }
28
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/project/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAA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AS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface HeadRecord {
2
+ head: string;
3
+ seq: number;
4
+ }
5
+ export declare function readHead(root: string): HeadRecord | null;
6
+ export declare function writeHead(root: string, record: HeadRecord): void;
@@ -0,0 +1,22 @@
1
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { CONFIG_DIR } from './config.js';
4
+ function headPath(root) {
5
+ return join(root, CONFIG_DIR, 'head');
6
+ }
7
+ export function readHead(root) {
8
+ const path = headPath(root);
9
+ if (!existsSync(path))
10
+ return null;
11
+ const [head, seqRaw] = readFileSync(path, 'utf8').trim().split(' ');
12
+ if (!head || !seqRaw || Number.isNaN(Number(seqRaw))) {
13
+ throw new Error(`${path} is corrupt (“${readFileSync(path, 'utf8').trim()}”) — delete it and re-sync`);
14
+ }
15
+ return { head, seq: Number(seqRaw) };
16
+ }
17
+ export function writeHead(root, record) {
18
+ const path = headPath(root);
19
+ mkdirSync(dirname(path), { recursive: true });
20
+ writeFileSync(path, `${record.head} ${record.seq}\n`);
21
+ }
22
+ //# sourceMappingURL=head.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"head.js","sourceRoot":"","sources":["../../src/project/head.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpE,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,iBAAiB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,4BAA4B,CACtF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,MAAkB;IACxD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { JpatchOp } from '../types.js';
2
+ export interface OutboxEntry {
3
+ txId: string;
4
+ ops: JpatchOp[];
5
+ parkedAt: string;
6
+ }
7
+ export declare class Outbox {
8
+ private readonly root;
9
+ constructor(root: string);
10
+ private get dir();
11
+ list(): OutboxEntry[];
12
+ park(entry: OutboxEntry): void;
13
+ clear(txId: string): void;
14
+ }
@@ -0,0 +1,31 @@
1
+ // .mapples/outbox/ — ordered queue of unflushed transactions, persisted so an
2
+ // offline sync parks its ops and the next run drains them (same txId — the
3
+ // server's idempotency makes the drain safe).
4
+ import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync, existsSync } from 'node:fs';
5
+ import { join } from 'node:path';
6
+ import { CONFIG_DIR } from './config.js';
7
+ export class Outbox {
8
+ root;
9
+ constructor(root) {
10
+ this.root = root;
11
+ }
12
+ get dir() {
13
+ return join(this.root, CONFIG_DIR, 'outbox');
14
+ }
15
+ list() {
16
+ if (!existsSync(this.dir))
17
+ return [];
18
+ return readdirSync(this.dir)
19
+ .filter((f) => f.endsWith('.json'))
20
+ .sort() // txId is a ULID: lexicographic == chronological
21
+ .map((f) => JSON.parse(readFileSync(join(this.dir, f), 'utf8')));
22
+ }
23
+ park(entry) {
24
+ mkdirSync(this.dir, { recursive: true });
25
+ writeFileSync(join(this.dir, `${entry.txId}.json`), JSON.stringify(entry, null, 2) + '\n');
26
+ }
27
+ clear(txId) {
28
+ rmSync(join(this.dir, `${txId}.json`), { force: true });
29
+ }
30
+ }
31
+ //# sourceMappingURL=outbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox.js","sourceRoot":"","sources":["../../src/project/outbox.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,8CAA8C;AAE9C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQzC,MAAM,OAAO,MAAM;IACY;IAA7B,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAE7C,IAAY,GAAG;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI;QACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,EAAE,CAAC;QACrC,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;aACzB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;aAClC,IAAI,EAAE,CAAC,iDAAiD;aACxD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAgB,CAAC,CAAC;IACpF,CAAC;IAED,IAAI,CAAC,KAAkB;QACrB,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,OAAO,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7F,CAAC;IAED,KAAK,CAAC,IAAY;QAChB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ export interface PageMapping {
2
+ file: string;
3
+ name: string;
4
+ route: string;
5
+ }
6
+ export type PagesMap = Record<string, PageMapping>;
7
+ export declare function readPagesMap(root: string): PagesMap;
8
+ export declare function writePagesMap(root: string, map: PagesMap): void;
@@ -0,0 +1,20 @@
1
+ // .mapples/pages.json — the pageId <-> file mapping. Files are the code-side
2
+ // identity of a page; the map survives renames on either side.
3
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ import { CONFIG_DIR } from './config.js';
6
+ function mapPath(root) {
7
+ return join(root, CONFIG_DIR, 'pages.json');
8
+ }
9
+ export function readPagesMap(root) {
10
+ const path = mapPath(root);
11
+ if (!existsSync(path))
12
+ return {};
13
+ return JSON.parse(readFileSync(path, 'utf8'));
14
+ }
15
+ export function writePagesMap(root, map) {
16
+ mkdirSync(join(root, CONFIG_DIR), { recursive: true });
17
+ const sorted = Object.fromEntries(Object.entries(map).sort(([a], [b]) => (a < b ? -1 : 1)));
18
+ writeFileSync(mapPath(root), JSON.stringify(sorted, null, 2) + '\n');
19
+ }
20
+ //# sourceMappingURL=pagesMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagesMap.js","sourceRoot":"","sources":["../../src/project/pagesMap.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,+DAA+D;AAE/D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAUzC,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAa,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,GAAa;IACvD,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5F,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { JpatchClient } from '../api/client.js';
2
+ import type { SyncReport } from '../ui/report.js';
3
+ export interface AdoptInput {
4
+ root: string;
5
+ client: JpatchClient;
6
+ report: SyncReport;
7
+ yes: boolean;
8
+ /** When set, adopt exactly this file (relative or absolute) without prompting. */
9
+ file?: string;
10
+ }
11
+ export declare function proposeAdoptions(input: AdoptInput): Promise<void>;
@@ -0,0 +1,197 @@
1
+ // Adoption (RFC-0002 Phase 7, D7): `sync` scans and PROPOSES unmanaged
2
+ // components — per-item confirm or --yes; `mapples adopt <file>` skips the
3
+ // prompt. Supported primitives are codemodded via the mapping table; anything
4
+ // else becomes an opaque Custom node. One normal commit; idMap rewrite
5
+ // finishes it. Unadopted files are never touched.
6
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs';
7
+ import { join, relative, sep } from 'node:path';
8
+ import prompts from 'prompts';
9
+ import { codemodAdopt, extract } from '@mapples/sid-ast';
10
+ import { buildEnvelope, commitWithTransportRetry, mintCid, mintTxId } from '../api/commit.js';
11
+ import { HeadMismatchError } from '../api/errors.js';
12
+ import { PRIMITIVE_MAPPING } from '../adopt/mappingTable.js';
13
+ import { scanForCandidates } from '../adopt/scan.js';
14
+ import { diffTree } from '../merge/diff.js';
15
+ import { BaseStore } from '../project/baseStore.js';
16
+ import { readConfig } from '../project/config.js';
17
+ import { readHead, writeHead } from '../project/head.js';
18
+ import { readPagesMap, writePagesMap } from '../project/pagesMap.js';
19
+ export async function proposeAdoptions(input) {
20
+ const { root, client, report } = input;
21
+ const pagesMap = readPagesMap(root);
22
+ let candidates = scanForCandidates(root, pagesMap);
23
+ if (input.file) {
24
+ const rel = relative(root, join(root, input.file));
25
+ candidates = candidates.filter((c) => c.file === rel);
26
+ if (candidates.length === 0) {
27
+ throw new Error(`${input.file} is not an adoptable file (already managed, no JSX, or already $sid-tagged)`);
28
+ }
29
+ }
30
+ if (candidates.length === 0)
31
+ return;
32
+ let accepted;
33
+ if (input.yes || input.file) {
34
+ accepted = candidates;
35
+ }
36
+ else if (!process.stdout.isTTY) {
37
+ report.notes.push(`${candidates.length} unmanaged component file(s) found — run \`mapples sync --yes\` or \`mapples adopt <file>\` to adopt them: ${candidates.map((c) => c.file).join(', ')}`);
38
+ return;
39
+ }
40
+ else {
41
+ const answer = await prompts({
42
+ type: 'multiselect',
43
+ name: 'files',
44
+ message: 'Adopt these files into Mapples Creator?',
45
+ choices: candidates.map((c) => ({
46
+ title: `${c.file} (${c.kind})`,
47
+ value: c.file,
48
+ selected: true,
49
+ })),
50
+ });
51
+ const chosen = new Set(answer.files ?? []);
52
+ accepted = candidates.filter((c) => chosen.has(c.file));
53
+ }
54
+ if (accepted.length === 0)
55
+ return;
56
+ const config = readConfig(root);
57
+ const head = readHead(root);
58
+ if (!head)
59
+ throw new Error('run `mapples sync` once before adopting (no local head yet)');
60
+ const ops = [];
61
+ const adoptedPages = [];
62
+ const adoptedComponents = [];
63
+ for (const candidate of accepted) {
64
+ const filePath = join(root, candidate.file);
65
+ const source = readFileSync(filePath, 'utf8');
66
+ const result = codemodAdopt(source, { mapping: PRIMITIVE_MAPPING, mintSid: mintCid });
67
+ for (const skip of result.skipped) {
68
+ report.warnings.push({
69
+ kind: 'UNKNOWN_ELEMENT_WITH_SID',
70
+ detail: `${candidate.file}: ${skip.reason}`,
71
+ });
72
+ }
73
+ if (result.adopted.length === 0) {
74
+ report.notes.push(`${candidate.file}: nothing adoptable inside — left untouched`);
75
+ continue;
76
+ }
77
+ writeFileSync(filePath, result.source);
78
+ const extracted = extract(result.source);
79
+ for (const w of extracted.warnings) {
80
+ if (w.kind !== 'NON_LITERAL_PROP')
81
+ report.warnings.push({ ...w, file: candidate.file });
82
+ }
83
+ if (!extracted.dom) {
84
+ report.notes.push(`${candidate.file}: no root element extracted — skipped`);
85
+ continue;
86
+ }
87
+ ops.push(...diffTree(null, extracted.dom));
88
+ if (candidate.kind === 'page') {
89
+ const pageCid = mintCid();
90
+ const route = routeForFile(candidate, config.routesDir ?? 'app/(mapples)');
91
+ ops.push({
92
+ op: 'create',
93
+ entity: 'Page',
94
+ cid: pageCid,
95
+ data: { name: candidate.componentName, route, root: extracted.dom.sid },
96
+ });
97
+ adoptedPages.push({ candidate, dom: extracted.dom, pageCid, route });
98
+ }
99
+ else {
100
+ const cmpCid = mintCid();
101
+ ops.push({
102
+ op: 'create',
103
+ entity: 'Component',
104
+ cid: cmpCid,
105
+ data: { name: candidate.componentName, root: extracted.dom.sid },
106
+ });
107
+ adoptedComponents.push({ candidate, dom: extracted.dom, cmpCid });
108
+ }
109
+ report.files.push({
110
+ file: candidate.file,
111
+ action: 'updated',
112
+ detail: `adopted as ${candidate.kind} (${result.adopted.length} node(s))`,
113
+ });
114
+ }
115
+ if (ops.length === 0)
116
+ return;
117
+ // One normal commit, with the standard rebase loop.
118
+ const txId = mintTxId();
119
+ let base = head.head;
120
+ let result;
121
+ for (let attempt = 0;; attempt++) {
122
+ try {
123
+ result = await commitWithTransportRetry(client, buildEnvelope(client, { base, ops, txId }));
124
+ break;
125
+ }
126
+ catch (err) {
127
+ if (err instanceof HeadMismatchError && attempt < 5) {
128
+ base = err.head;
129
+ report.notes.push(`adoption rebase: HEAD moved to ${err.head}`);
130
+ continue;
131
+ }
132
+ throw err;
133
+ }
134
+ }
135
+ report.pushedOps += ops.length;
136
+ // idMap rewrite finishes it: c_ -> nd_/pg_/cmp_ in files, base, mapping.
137
+ const idMap = result.idMap;
138
+ const renameTree = (node) => {
139
+ node.sid = idMap[node.sid] ?? node.sid;
140
+ node.children.forEach(renameTree);
141
+ };
142
+ const baseStore = new BaseStore(root);
143
+ const snapshot = baseStore.readAll();
144
+ for (const { candidate, dom, pageCid, route } of adoptedPages) {
145
+ rewriteFileSids(join(root, candidate.file), idMap);
146
+ renameTree(dom);
147
+ const pageId = idMap[pageCid];
148
+ if (!pageId)
149
+ throw new Error(`server did not mint an id for page cid ${pageCid}`);
150
+ snapshot.pages.set(pageId, { id: pageId, name: candidate.componentName, route, root: dom });
151
+ pagesMap[pageId] = { file: candidate.file, name: candidate.componentName, route };
152
+ }
153
+ for (const { candidate, dom, cmpCid } of adoptedComponents) {
154
+ rewriteFileSids(join(root, candidate.file), idMap);
155
+ renameTree(dom);
156
+ const cmpId = idMap[cmpCid];
157
+ if (!cmpId)
158
+ throw new Error(`server did not mint an id for component cid ${cmpCid}`);
159
+ snapshot.components.set(cmpId, { id: cmpId, name: candidate.componentName, root: dom });
160
+ // TODO(RFC-0002 §8): component files are not yet merged by sync — record only.
161
+ }
162
+ baseStore.writeAll(snapshot);
163
+ writePagesMap(root, pagesMap);
164
+ writeHead(root, { head: result.head, seq: result.seq });
165
+ report.head = result.head;
166
+ report.notes.push(`adopted ${adoptedPages.length} page(s), ${adoptedComponents.length} component(s) @ ${result.head}`);
167
+ }
168
+ function routeForFile(candidate, _routesDir) {
169
+ const parts = candidate.file.split(sep);
170
+ if (parts[0] === 'app') {
171
+ // expo-router semantics: (group) segments don't contribute to the path.
172
+ const segments = parts
173
+ .slice(1)
174
+ .filter((p) => !(p.startsWith('(') && p.endsWith(')')))
175
+ .join('/')
176
+ .replace(/\.tsx$/, '');
177
+ return segments === 'index' || segments === '' ? '/' : `/${segments}`;
178
+ }
179
+ return `/${candidate.componentName.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()}`;
180
+ }
181
+ function rewriteFileSids(filePath, idMap) {
182
+ if (!existsSync(filePath))
183
+ return;
184
+ let source = readFileSync(filePath, 'utf8');
185
+ let changed = false;
186
+ for (const [cid, id] of Object.entries(idMap)) {
187
+ if (!cid.startsWith('c_'))
188
+ continue;
189
+ if (source.includes(`"${cid}"`)) {
190
+ source = source.split(`"${cid}"`).join(`"${id}"`);
191
+ changed = true;
192
+ }
193
+ }
194
+ if (changed)
195
+ writeFileSync(filePath, source);
196
+ }
197
+ //# sourceMappingURL=adoptService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adoptService.js","sourceRoot":"","sources":["../../src/services/adoptService.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,2EAA2E;AAC3E,8EAA8E;AAC9E,uEAAuE;AACvE,kDAAkD;AAElD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,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AAU,CAAC,IAAI,CAAC;YAAE,SAAS;QACpC,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAClD,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IACD,IAAI,OAAO;QAAE,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type DoctorIssueKind = 'missing-file' | 'duplicate-sid' | 'unknown-sid' | 'missing-sid' | 'orphaned-base' | 'drift' | 'no-head';
2
+ export interface DoctorIssue {
3
+ kind: DoctorIssueKind;
4
+ file?: string;
5
+ sid?: string;
6
+ detail: string;
7
+ }
8
+ export declare function runDoctorChecks(root: string): {
9
+ issues: DoctorIssue[];
10
+ checkedFiles: number;
11
+ };
@@ -0,0 +1,135 @@
1
+ // `mapples doctor` — $sid lint (RFC-0002 Phase 8): duplicate/edited/missing
2
+ // $sids, orphaned base entries, drift (re-extract vs base at HEAD).
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ import { extract } from '@mapples/sid-ast';
6
+ import { BaseStore } from '../project/baseStore.js';
7
+ import { readHead } from '../project/head.js';
8
+ import { readPagesMap } from '../project/pagesMap.js';
9
+ import { deepEqual } from '../merge/mergePatch.js';
10
+ function collectSids(root) {
11
+ const sids = new Set();
12
+ const walk = (n) => {
13
+ sids.add(n.sid);
14
+ n.children.forEach(walk);
15
+ };
16
+ if (root)
17
+ walk(root);
18
+ return sids;
19
+ }
20
+ export function runDoctorChecks(root) {
21
+ const issues = [];
22
+ const head = readHead(root);
23
+ if (!head) {
24
+ issues.push({ kind: 'no-head', detail: 'no .mapples/head — run `mapples sync` first' });
25
+ return { issues, checkedFiles: 0 };
26
+ }
27
+ const base = new BaseStore(root).readAll();
28
+ const pagesMap = readPagesMap(root);
29
+ let checkedFiles = 0;
30
+ // Orphaned base entries: base pages with no mapping.
31
+ for (const pageId of base.pages.keys()) {
32
+ if (!pagesMap[pageId]) {
33
+ issues.push({
34
+ kind: 'orphaned-base',
35
+ sid: pageId,
36
+ detail: `base has page ${pageId} but .mapples/pages.json does not map it to a file`,
37
+ });
38
+ }
39
+ }
40
+ const seenSids = new Map(); // sid -> file (cross-file duplicates)
41
+ for (const [pageId, mapping] of Object.entries(pagesMap)) {
42
+ const basePage = base.pages.get(pageId);
43
+ if (!basePage) {
44
+ issues.push({
45
+ kind: 'orphaned-base',
46
+ file: mapping.file,
47
+ detail: `pages.json maps ${pageId} -> ${mapping.file} but base has no such page`,
48
+ });
49
+ continue;
50
+ }
51
+ const filePath = join(root, mapping.file);
52
+ if (!existsSync(filePath)) {
53
+ issues.push({
54
+ kind: 'missing-file',
55
+ file: mapping.file,
56
+ detail: `mapped file is missing — the next sync will regenerate it`,
57
+ });
58
+ continue;
59
+ }
60
+ checkedFiles += 1;
61
+ const source = readFileSync(filePath, 'utf8');
62
+ const extracted = extract(source);
63
+ for (const w of extracted.warnings) {
64
+ if (w.kind === 'DUPLICATE_SID') {
65
+ issues.push({ kind: 'duplicate-sid', file: mapping.file, sid: w.sid, detail: w.detail });
66
+ }
67
+ }
68
+ const baseSids = collectSids(basePage.root);
69
+ const fileSids = collectSids(extracted.dom);
70
+ for (const sid of fileSids) {
71
+ const otherFile = seenSids.get(sid);
72
+ if (otherFile) {
73
+ issues.push({
74
+ kind: 'duplicate-sid',
75
+ file: mapping.file,
76
+ sid,
77
+ detail: `sid also appears in ${otherFile}`,
78
+ });
79
+ }
80
+ seenSids.set(sid, mapping.file);
81
+ if (!sid.startsWith('c_') && !baseSids.has(sid)) {
82
+ issues.push({
83
+ kind: 'unknown-sid',
84
+ file: mapping.file,
85
+ sid,
86
+ detail: `sid is not in the base snapshot at HEAD ${head.head} — was it hand-edited or copied?`,
87
+ });
88
+ }
89
+ }
90
+ for (const sid of baseSids) {
91
+ if (!fileSids.has(sid)) {
92
+ issues.push({
93
+ kind: 'missing-sid',
94
+ file: mapping.file,
95
+ sid,
96
+ detail: 'node exists in base but its $sid is gone from the file (deleted locally?)',
97
+ });
98
+ }
99
+ }
100
+ // Drift: re-extract vs base at HEAD (pending local edits — informational).
101
+ if (extracted.dom &&
102
+ fileSids.size === baseSids.size &&
103
+ [...fileSids].every((s) => baseSids.has(s)) &&
104
+ !deepEqual(stripNonLiteralHoles(extracted.dom, basePage.root), basePage.root)) {
105
+ issues.push({
106
+ kind: 'drift',
107
+ file: mapping.file,
108
+ detail: 'file drifted from base at HEAD — local edits pending; run `mapples sync` to push them',
109
+ });
110
+ }
111
+ }
112
+ return { issues, checkedFiles };
113
+ }
114
+ /** Fill NON_LITERAL holes from base so expression props don't read as drift. */
115
+ function stripNonLiteralHoles(local, baseRoot) {
116
+ const baseIndex = new Map();
117
+ const walk = (n) => {
118
+ baseIndex.set(n.sid, n);
119
+ n.children.forEach(walk);
120
+ };
121
+ walk(baseRoot);
122
+ const fill = (n) => {
123
+ const baseNode = baseIndex.get(n.sid);
124
+ const props = { ...n.props };
125
+ if (baseNode) {
126
+ for (const [key, value] of Object.entries(baseNode.props)) {
127
+ if (!(key in props))
128
+ props[key] = value;
129
+ }
130
+ }
131
+ return { ...n, props, children: n.children.map(fill) };
132
+ };
133
+ return fill(local);
134
+ }
135
+ //# sourceMappingURL=doctorService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctorService.js","sourceRoot":"","sources":["../../src/services/doctorService.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,oEAAoE;AAEpE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM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