@magmonium/cli 0.10.3 → 0.10.4
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.
- package/bin/commands/gen-code.js +208 -10
- package/codegen/index.js +103 -20
- package/package.json +1 -1
package/bin/commands/gen-code.js
CHANGED
|
@@ -85,13 +85,9 @@ function clearGeneratedSet(root, generatedSet) {
|
|
|
85
85
|
return removed;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
* operations snapshot standing in for the live spec. With `tests`, the Emitted
|
|
92
|
-
* tests beside the code as well.
|
|
93
|
-
*/
|
|
94
|
-
function generate({ root = process.cwd(), tests = false } = {}) {
|
|
88
|
+
// The DesignSource read off disk and emitted, without touching the folder. What
|
|
89
|
+
// `generate` writes whole and `syncGenerated` diffs.
|
|
90
|
+
function emitFrom(root, tests) {
|
|
95
91
|
if (!fs.existsSync(path.join(root, DESIGN_ROOT, 'index.json'))) {
|
|
96
92
|
throw new Error(
|
|
97
93
|
`${DESIGN_ROOT}/index.json not found in ${root} — not an app emitted by the editor`
|
|
@@ -119,7 +115,17 @@ function generate({ root = process.cwd(), tests = false } = {}) {
|
|
|
119
115
|
...source,
|
|
120
116
|
operationOf: codegen.operationResolverOf(source.operations),
|
|
121
117
|
};
|
|
122
|
-
|
|
118
|
+
return { codegen, files: codegen.emitGeneratedFiles(ws, stringify, tests) };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Regenerates the GeneratedSet from `.magmonium/` alone (ADR 0181): the
|
|
123
|
+
* DesignSource through the same codec and codegen the editor runs, its
|
|
124
|
+
* operations snapshot standing in for the live spec. With `tests`, the Emitted
|
|
125
|
+
* tests beside the code as well.
|
|
126
|
+
*/
|
|
127
|
+
function generate({ root = process.cwd(), tests = false } = {}) {
|
|
128
|
+
const { codegen, files } = emitFrom(root, tests);
|
|
123
129
|
const removed = clearGeneratedSet(root, codegen.GENERATED_SET);
|
|
124
130
|
for (const file of files) {
|
|
125
131
|
const target = path.join(root, file.path);
|
|
@@ -129,6 +135,180 @@ function generate({ root = process.cwd(), tests = false } = {}) {
|
|
|
129
135
|
return { written: files.length, removed };
|
|
130
136
|
}
|
|
131
137
|
|
|
138
|
+
// Every file under the GeneratedSet's folders and top-level globs, as POSIX
|
|
139
|
+
// paths from the app root, kept to what `inGeneratedSet` admits.
|
|
140
|
+
function listGeneratedSet(root, codegen) {
|
|
141
|
+
const found = [];
|
|
142
|
+
const walk = (dir) => {
|
|
143
|
+
if (!fs.existsSync(dir)) return;
|
|
144
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
145
|
+
const full = path.join(dir, entry.name);
|
|
146
|
+
if (entry.isDirectory()) walk(full);
|
|
147
|
+
else if (entry.isFile())
|
|
148
|
+
found.push(path.relative(root, full).split(path.sep).join('/'));
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const appDir = path.join(root, 'src', 'app');
|
|
152
|
+
for (const line of codegen.GENERATED_SET) {
|
|
153
|
+
const rel = line.replace(/^\//, '');
|
|
154
|
+
if (rel.endsWith('/')) walk(path.join(root, rel));
|
|
155
|
+
}
|
|
156
|
+
if (fs.existsSync(appDir)) {
|
|
157
|
+
for (const name of fs.readdirSync(appDir)) {
|
|
158
|
+
const rel = `src/app/${name}`;
|
|
159
|
+
if (codegen.inGeneratedSet(rel) && fs.statSync(path.join(appDir, name)).isFile())
|
|
160
|
+
found.push(rel);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return [...new Set(found)].filter((rel) => codegen.inGeneratedSet(rel));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The GeneratedSet brought to what `.magmonium/` emits, touching only what
|
|
168
|
+
* differs: a file whose contents already match is left alone, so a running
|
|
169
|
+
* `ng serve` rebuilds for the edit and not for the app. A generated file edited
|
|
170
|
+
* by hand is rewritten; one added by hand is removed. Without `tests`, Emitted
|
|
171
|
+
* tests are kept — the editor writes them and `gen-code` does not.
|
|
172
|
+
*/
|
|
173
|
+
function syncGenerated({ root = process.cwd(), tests = false } = {}) {
|
|
174
|
+
const { codegen, files } = emitFrom(root, tests);
|
|
175
|
+
const next = new Map(files.map((file) => [file.path, file.contents]));
|
|
176
|
+
const written = [];
|
|
177
|
+
const removed = [];
|
|
178
|
+
for (const [rel, contents] of next) {
|
|
179
|
+
const target = path.join(root, rel);
|
|
180
|
+
const current = fs.existsSync(target)
|
|
181
|
+
? fs.readFileSync(target, 'utf8')
|
|
182
|
+
: undefined;
|
|
183
|
+
if (current === contents) continue;
|
|
184
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
185
|
+
fs.writeFileSync(target, contents);
|
|
186
|
+
written.push(rel);
|
|
187
|
+
}
|
|
188
|
+
for (const rel of listGeneratedSet(root, codegen)) {
|
|
189
|
+
if (next.has(rel)) continue;
|
|
190
|
+
if (!tests && rel.endsWith('.spec.ts')) continue;
|
|
191
|
+
fs.rmSync(path.join(root, rel), { force: true });
|
|
192
|
+
removed.push(rel);
|
|
193
|
+
}
|
|
194
|
+
return { written, removed, files: next, codegen };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Quiet time after the last change before regenerating. */
|
|
198
|
+
const WATCH_DELAY_MS = 100;
|
|
199
|
+
/** The same path rewritten this often inside the window means two writers disagree. */
|
|
200
|
+
const FIGHT_LIMIT = 3;
|
|
201
|
+
const FIGHT_WINDOW_MS = 10000;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Keeps the GeneratedSet in step with `.magmonium/` while the app is worked on
|
|
205
|
+
* from an IDE (ADR 0222): a design file saved regenerates the code at once, and
|
|
206
|
+
* a generated file edited or deleted by hand is put back. Hand-written code
|
|
207
|
+
* belongs in `src/app/custom/`, which this never reads or writes.
|
|
208
|
+
*
|
|
209
|
+
* With `run`, starts that command beside the watch (`ng serve`) and exits with
|
|
210
|
+
* it. Resolves a `close()` for tests.
|
|
211
|
+
*/
|
|
212
|
+
async function watchGenerated({
|
|
213
|
+
root = process.cwd(),
|
|
214
|
+
tests = false,
|
|
215
|
+
run,
|
|
216
|
+
log = console.log,
|
|
217
|
+
delay = WATCH_DELAY_MS,
|
|
218
|
+
} = {}) {
|
|
219
|
+
const { watch } = await import('chokidar');
|
|
220
|
+
let last = new Map();
|
|
221
|
+
let codegen;
|
|
222
|
+
const fights = new Map();
|
|
223
|
+
|
|
224
|
+
const regenerate = (reason) => {
|
|
225
|
+
try {
|
|
226
|
+
const result = syncGenerated({ root, tests });
|
|
227
|
+
last = result.files;
|
|
228
|
+
codegen = result.codegen;
|
|
229
|
+
const now = Date.now();
|
|
230
|
+
const changed = [...result.written, ...result.removed];
|
|
231
|
+
for (const rel of changed) {
|
|
232
|
+
const hits = (fights.get(rel) || []).filter(
|
|
233
|
+
(at) => now - at < FIGHT_WINDOW_MS
|
|
234
|
+
);
|
|
235
|
+
hits.push(now);
|
|
236
|
+
fights.set(rel, hits);
|
|
237
|
+
}
|
|
238
|
+
if (changed.length)
|
|
239
|
+
log(
|
|
240
|
+
`🔁 gen-code: ${reason} → ${result.written.length} written, ${result.removed.length} removed`
|
|
241
|
+
);
|
|
242
|
+
} catch (error) {
|
|
243
|
+
// A design file mid-save or hand-broken: the code on disk stays as the
|
|
244
|
+
// last good emit until the next save reads cleanly.
|
|
245
|
+
log(`⚠️ gen-code: ${error.message}`);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
regenerate('start');
|
|
250
|
+
|
|
251
|
+
let timer;
|
|
252
|
+
let reason = '';
|
|
253
|
+
const schedule = (why) => {
|
|
254
|
+
reason = why;
|
|
255
|
+
clearTimeout(timer);
|
|
256
|
+
timer = setTimeout(() => regenerate(reason), delay);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const onEvent = (file) => {
|
|
260
|
+
const rel = file.split(path.sep).join('/');
|
|
261
|
+
if (rel === DESIGN_ROOT || rel.startsWith(`${DESIGN_ROOT}/`)) {
|
|
262
|
+
schedule(`${rel} changed`);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (!codegen || !codegen.inGeneratedSet(rel)) return;
|
|
266
|
+
if (!tests && rel.endsWith('.spec.ts') && !last.has(rel)) return;
|
|
267
|
+
const target = path.join(root, rel);
|
|
268
|
+
const current = fs.existsSync(target)
|
|
269
|
+
? fs.readFileSync(target, 'utf8')
|
|
270
|
+
: undefined;
|
|
271
|
+
// Its own write, or the editor's identical one.
|
|
272
|
+
if (current === last.get(rel)) return;
|
|
273
|
+
const hits = (fights.get(rel) || []).filter(
|
|
274
|
+
(at) => Date.now() - at < FIGHT_WINDOW_MS
|
|
275
|
+
);
|
|
276
|
+
if (hits.length >= FIGHT_LIMIT) {
|
|
277
|
+
log(
|
|
278
|
+
`⚠️ gen-code: ${rel} keeps changing under the watch — another writer emits it differently; left as is`
|
|
279
|
+
);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
schedule(`${rel} is generated — restored`);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const watcher = watch([DESIGN_ROOT, 'src/app'], {
|
|
286
|
+
cwd: root,
|
|
287
|
+
ignoreInitial: true,
|
|
288
|
+
ignored: (file) =>
|
|
289
|
+
file.split(path.sep).join('/').includes('src/app/custom'),
|
|
290
|
+
});
|
|
291
|
+
watcher.on('add', onEvent).on('change', onEvent).on('unlink', onEvent);
|
|
292
|
+
log(
|
|
293
|
+
`👀 gen-code: watching ${DESIGN_ROOT}/ — generated code is rebuilt on every design change; hand-written code goes in src/app/custom/`
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
const close = async () => {
|
|
297
|
+
clearTimeout(timer);
|
|
298
|
+
await watcher.close();
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
if (run) {
|
|
302
|
+
const { spawn } = require('child_process');
|
|
303
|
+
const child = spawn(run, { cwd: root, shell: true, stdio: 'inherit' });
|
|
304
|
+
child.on('exit', async (code) => {
|
|
305
|
+
await close();
|
|
306
|
+
process.exit(code ?? 0);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
return { close };
|
|
310
|
+
}
|
|
311
|
+
|
|
132
312
|
function genCodeCommand(program) {
|
|
133
313
|
program
|
|
134
314
|
.command('gen-code')
|
|
@@ -136,9 +316,24 @@ function genCodeCommand(program) {
|
|
|
136
316
|
'Regenerate the generated code (features, pages, widgets, shared/lib, shared/type, router and provide overlays) from .magmonium/'
|
|
137
317
|
)
|
|
138
318
|
.option('--root <path>', 'App root (default: cwd)')
|
|
139
|
-
.
|
|
319
|
+
.option(
|
|
320
|
+
'--watch',
|
|
321
|
+
'Keep regenerating on every .magmonium/ change, and put back hand edits to generated files'
|
|
322
|
+
)
|
|
323
|
+
.option('--run <command>', 'With --watch: run this command beside the watch (e.g. "ng serve")')
|
|
324
|
+
.action(async (options) => {
|
|
325
|
+
const root = options.root || process.cwd();
|
|
326
|
+
if (options.watch) {
|
|
327
|
+
try {
|
|
328
|
+
await watchGenerated({ root, run: options.run });
|
|
329
|
+
} catch (error) {
|
|
330
|
+
console.error(`❌ gen-code: ${error.message}`);
|
|
331
|
+
process.exit(1);
|
|
332
|
+
}
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
140
335
|
try {
|
|
141
|
-
const { written } = generate({ root
|
|
336
|
+
const { written } = generate({ root });
|
|
142
337
|
console.log(
|
|
143
338
|
`✅ gen-code: ${written} file(s) generated from ${DESIGN_ROOT}/`
|
|
144
339
|
);
|
|
@@ -154,3 +349,6 @@ module.exports.generate = generate;
|
|
|
154
349
|
module.exports.isNewer = isNewer;
|
|
155
350
|
module.exports.clearGeneratedSet = clearGeneratedSet;
|
|
156
351
|
module.exports.readDesignFiles = readDesignFiles;
|
|
352
|
+
module.exports.syncGenerated = syncGenerated;
|
|
353
|
+
module.exports.watchGenerated = watchGenerated;
|
|
354
|
+
module.exports.listGeneratedSet = listGeneratedSet;
|
package/codegen/index.js
CHANGED
|
@@ -1835,6 +1835,7 @@ __export(index_exports, {
|
|
|
1835
1835
|
variantsForCode: () => variantsForCode,
|
|
1836
1836
|
variantsForNewControl: () => variantsForNewControl,
|
|
1837
1837
|
variantsReferencing: () => variantsReferencing,
|
|
1838
|
+
vscodeSettings: () => vscodeSettings,
|
|
1838
1839
|
watchFields: () => watchFields,
|
|
1839
1840
|
watchKey: () => watchKey,
|
|
1840
1841
|
wcClassName: () => wcClassName,
|
|
@@ -9196,6 +9197,20 @@ var walkKeys = (keyIds, rootShapeId2, shapes) => {
|
|
|
9196
9197
|
}
|
|
9197
9198
|
return names;
|
|
9198
9199
|
};
|
|
9200
|
+
var keysHeldPresent = (keyIds, rootShapeId2, shapes) => {
|
|
9201
|
+
const held = [];
|
|
9202
|
+
let shapeId = rootShapeId2;
|
|
9203
|
+
for (const keyId of keyIds) {
|
|
9204
|
+
const key2 = (shapeId ? shapes[shapeId] : void 0)?.keys.find(
|
|
9205
|
+
(k) => k.id === keyId
|
|
9206
|
+
);
|
|
9207
|
+
held.push(
|
|
9208
|
+
!!key2 && key2.dataType?.type === "shape" && (key2.cardinality ?? "one") === "one" && !key2.optional
|
|
9209
|
+
);
|
|
9210
|
+
shapeId = key2?.dataType?.type === "shape" ? key2.dataType.shapeId : void 0;
|
|
9211
|
+
}
|
|
9212
|
+
return held;
|
|
9213
|
+
};
|
|
9199
9214
|
var rootShapeId = (binding, scope, seen) => {
|
|
9200
9215
|
const root = binding.root;
|
|
9201
9216
|
if (root.kind === "property") {
|
|
@@ -9475,15 +9490,16 @@ var bindingExpression = (binding, scope, guardAlias) => {
|
|
|
9475
9490
|
const fn = computed ? screenComputedFunction(computed, scope.functions ?? {}) : void 0;
|
|
9476
9491
|
if (!fn || returnCardinalityOf(fn) !== "one") return void 0;
|
|
9477
9492
|
}
|
|
9478
|
-
const
|
|
9479
|
-
|
|
9480
|
-
rootShapeId(binding, scope, /* @__PURE__ */ new Set()),
|
|
9481
|
-
shapesOf(scope)
|
|
9482
|
-
);
|
|
9493
|
+
const shapeId = rootShapeId(binding, scope, /* @__PURE__ */ new Set());
|
|
9494
|
+
const names = walkKeys(binding.path, shapeId, shapesOf(scope));
|
|
9483
9495
|
if (!names) return void 0;
|
|
9484
|
-
const
|
|
9485
|
-
|
|
9486
|
-
expr =
|
|
9496
|
+
const held = keysHeldPresent(binding.path, shapeId, shapesOf(scope));
|
|
9497
|
+
let present = !!guardAlias || rootIsPresent(binding, scope);
|
|
9498
|
+
expr = names.reduce((text3, name3, i) => {
|
|
9499
|
+
const step = memberStep(present ? "." : "?.", name3);
|
|
9500
|
+
present = present && held[i];
|
|
9501
|
+
return `${text3}${step}`;
|
|
9502
|
+
}, head);
|
|
9487
9503
|
}
|
|
9488
9504
|
if (!binding.transform) return expr;
|
|
9489
9505
|
const roots = transformRoots(scope);
|
|
@@ -9665,9 +9681,11 @@ var repeatHeader = (control, scope) => {
|
|
|
9665
9681
|
if (!source) return void 0;
|
|
9666
9682
|
const spec = repeatSpec(control);
|
|
9667
9683
|
const expr = bindingExpression(source, scope);
|
|
9684
|
+
const present = !!expr && sourceIsPresent(source, expr, scope);
|
|
9668
9685
|
if (expr && isKeyedRepeat(control, scope)) {
|
|
9669
9686
|
const entry2 = repeatEntryName(spec.itemAlias);
|
|
9670
|
-
|
|
9687
|
+
const entries = present ? `(${expr} | keyvalue)` : `((${expr} | keyvalue) ?? [])`;
|
|
9688
|
+
return `${entry2} of ${entries}; track ${entry2}.key; let ${spec.indexAlias} = $index`;
|
|
9671
9689
|
}
|
|
9672
9690
|
if (!spec.track) return void 0;
|
|
9673
9691
|
if (!expr) return void 0;
|
|
@@ -9679,7 +9697,34 @@ var repeatHeader = (control, scope) => {
|
|
|
9679
9697
|
scope
|
|
9680
9698
|
);
|
|
9681
9699
|
if (!track) return void 0;
|
|
9682
|
-
|
|
9700
|
+
const items = present ? `(${expr})` : `(${expr} ?? [])`;
|
|
9701
|
+
return `${spec.itemAlias} of ${items}; track ${track}; let ${spec.indexAlias} = $index`;
|
|
9702
|
+
};
|
|
9703
|
+
var sourceIsPresent = (source, expr, scope) => {
|
|
9704
|
+
if (source.transform || expr.includes("?.")) return false;
|
|
9705
|
+
if (!source.path.length) {
|
|
9706
|
+
const root = source.root;
|
|
9707
|
+
if (root.kind !== "screen_computed") return rootIsPresent(source, scope);
|
|
9708
|
+
const computed = scope.screenComputeds?.[root.id];
|
|
9709
|
+
const fn = computed ? screenComputedFunction(computed, scope.functions ?? {}) : void 0;
|
|
9710
|
+
return !!computed && !!fn && fn.returnUndefined !== true && !screenComputedIsOptional(
|
|
9711
|
+
computed,
|
|
9712
|
+
fn,
|
|
9713
|
+
scope.inputs ?? {},
|
|
9714
|
+
scope.screenComputeds ?? {},
|
|
9715
|
+
scope.functions ?? {}
|
|
9716
|
+
);
|
|
9717
|
+
}
|
|
9718
|
+
const shapes = shapesOf(scope);
|
|
9719
|
+
let shapeId = rootShapeId(source, scope, /* @__PURE__ */ new Set());
|
|
9720
|
+
let last;
|
|
9721
|
+
for (const keyId of source.path) {
|
|
9722
|
+
last = (shapeId ? shapes[shapeId] : void 0)?.keys.find(
|
|
9723
|
+
(k) => k.id === keyId
|
|
9724
|
+
);
|
|
9725
|
+
shapeId = last?.dataType?.type === "shape" ? last.dataType.shapeId : void 0;
|
|
9726
|
+
}
|
|
9727
|
+
return !!last && !last.optional;
|
|
9683
9728
|
};
|
|
9684
9729
|
var repeatEntryName = (itemAlias) => `${itemAlias}Entry`;
|
|
9685
9730
|
var repeatEntryLets = (control, scope) => {
|
|
@@ -22940,8 +22985,9 @@ function renderBranch(node, indent2, names, methods, operationOf, storeProp, ctx
|
|
|
22940
22985
|
const children = entry2.arm.childrens.filter(
|
|
22941
22986
|
(child) => projectionSlotOf(child) === slot
|
|
22942
22987
|
);
|
|
22943
|
-
const
|
|
22944
|
-
const
|
|
22988
|
+
const rendered = render(children, indent2 + 1);
|
|
22989
|
+
const wrap = !!slot && (children.length > 1 || rendered.some((text3) => opensWithLet(text3, `${pad2} `)));
|
|
22990
|
+
const inner = wrap ? rendered.map(indentLines) : rendered;
|
|
22945
22991
|
if (!inner.length) return;
|
|
22946
22992
|
if (wrap) {
|
|
22947
22993
|
lines.push(
|
|
@@ -23002,15 +23048,16 @@ function renderRepeat(node, indent2, names, methods, operationOf, storeProp, ctx
|
|
|
23002
23048
|
(child) => child.type !== "repeat_empty" /* REPEAT_EMPTY */
|
|
23003
23049
|
);
|
|
23004
23050
|
const table = enclosingSectionTable(control, ctx.controlMap ?? {});
|
|
23005
|
-
const sorted = table ? header.replace(
|
|
23006
|
-
/ of \((
|
|
23051
|
+
const sorted = table && !isKeyedRepeat(control, scope) ? header.replace(
|
|
23052
|
+
/ of \((.*?)(?: \?\? \[\])?\); track /,
|
|
23007
23053
|
(_, expr) => ` of ((${expr}) | sectionTableSort: ${sectionTableRef(table.id)}.sort()); track `
|
|
23008
23054
|
) : header;
|
|
23009
23055
|
const lines = [`${pad2}@for (${sorted}) {`];
|
|
23056
|
+
const inner = body(rows, indent2 + 1);
|
|
23010
23057
|
for (const line of repeatEntryLets(control, scope)) {
|
|
23011
|
-
|
|
23058
|
+
const name3 = letName(line);
|
|
23059
|
+
if (name3 && spellsName(inner, name3)) lines.push(`${pad2} ${line}`);
|
|
23012
23060
|
}
|
|
23013
|
-
const inner = body(rows, indent2 + 1);
|
|
23014
23061
|
if (inner) lines.push(inner);
|
|
23015
23062
|
if (empty) {
|
|
23016
23063
|
const emptyInner = body(empty.childrens, indent2 + 1);
|
|
@@ -23160,11 +23207,25 @@ function renderNode(node, indent2, names, methods, operationOf, storeProp, ctx,
|
|
|
23160
23207
|
);
|
|
23161
23208
|
ctx.letSink = outerSink;
|
|
23162
23209
|
if (!drawn) return "";
|
|
23210
|
+
const read = lets.filter((line) => {
|
|
23211
|
+
const name3 = letName(line);
|
|
23212
|
+
if (name3 && spellsName(drawn, name3)) return true;
|
|
23213
|
+
if (name3) ctx.letNames?.delete(name3);
|
|
23214
|
+
return false;
|
|
23215
|
+
});
|
|
23163
23216
|
const innerPad = " ".repeat(inner);
|
|
23164
|
-
const tag = `${
|
|
23217
|
+
const tag = `${read.map((line) => `${innerPad}${line}
|
|
23165
23218
|
`).join("")}${drawn}`;
|
|
23166
|
-
|
|
23167
|
-
}
|
|
23219
|
+
const slot = read.length && guard ? projectionSlotOf(node) : "";
|
|
23220
|
+
return `${gaps}${wrapInGuard(projectedRoot(tag, slot, innerPad), guard, " ".repeat(indent2))}`;
|
|
23221
|
+
}
|
|
23222
|
+
var letName = (line) => /^@let ([A-Za-z_$][\w$]*) =/.exec(line.trim())?.[1];
|
|
23223
|
+
var spellsName = (markup, name3) => new RegExp(`(^|[^\\w$])${name3.replace(/\$/g, "\\$")}(?![\\w$])`).test(markup);
|
|
23224
|
+
var projectedRoot = (markup, slot, pad2) => slot ? `${pad2}<ng-container ngProjectAs="${slot}">
|
|
23225
|
+
${indentLines(markup)}
|
|
23226
|
+
${pad2}</ng-container>` : markup;
|
|
23227
|
+
var indentLines = (markup) => markup.replace(/^(?=.)/gm, " ");
|
|
23228
|
+
var opensWithLet = (markup, pad2) => markup.split("\n").some((line) => line.startsWith(`${pad2}@let `));
|
|
23168
23229
|
var hoistLet = (ctx, read) => {
|
|
23169
23230
|
const sink = ctx.letSink;
|
|
23170
23231
|
const taken = ctx.letNames;
|
|
@@ -29010,7 +29071,7 @@ __export(package_exports2, {
|
|
|
29010
29071
|
version: () => version2
|
|
29011
29072
|
});
|
|
29012
29073
|
var name2 = "@magmonium/cli";
|
|
29013
|
-
var version2 = "0.10.
|
|
29074
|
+
var version2 = "0.10.4";
|
|
29014
29075
|
var description2 = "A powerful and extensible asset compilation tool that can be shared across multiple projects";
|
|
29015
29076
|
var bin = {
|
|
29016
29077
|
"mag-cli": "bin/cli.js"
|
|
@@ -34353,6 +34414,12 @@ var packageJson = (appName, version3, extraDeps = {}) => JSON.stringify(
|
|
|
34353
34414
|
"gen:test": "mag-cli gen-test",
|
|
34354
34415
|
prestart: "npm run gen:code && npm run assets:compile",
|
|
34355
34416
|
start: "ng serve",
|
|
34417
|
+
// Working from an IDE with the editor closed: every `.magmonium/` save
|
|
34418
|
+
// regenerates the code, and a hand edit to a generated file is put back
|
|
34419
|
+
// (ADR 0222). Hand-written code lives in `src/app/custom/`.
|
|
34420
|
+
"gen:watch": "mag-cli gen-code --watch",
|
|
34421
|
+
predev: "npm run assets:compile",
|
|
34422
|
+
dev: 'mag-cli gen-code --watch --run "ng serve"',
|
|
34356
34423
|
prebuild: "npm run gen:code && npm run assets:compile",
|
|
34357
34424
|
build: "ng build",
|
|
34358
34425
|
"prebuild:wc": "npm run gen:code",
|
|
@@ -35590,6 +35657,20 @@ ${GENERATED_SET.map((line) => line.slice(1)).join("\n")}
|
|
|
35590
35657
|
angular.json
|
|
35591
35658
|
tsconfig.app.json
|
|
35592
35659
|
`;
|
|
35660
|
+
var vscodeSettings = () => `${JSON.stringify(
|
|
35661
|
+
{
|
|
35662
|
+
"files.readonlyInclude": Object.fromEntries(
|
|
35663
|
+
GENERATED_SET.map((line) => [
|
|
35664
|
+
line.endsWith("/") ? `${line.slice(1)}**` : line.slice(1),
|
|
35665
|
+
true
|
|
35666
|
+
])
|
|
35667
|
+
),
|
|
35668
|
+
"files.readonlyExclude": { "src/app/custom/**": true }
|
|
35669
|
+
},
|
|
35670
|
+
null,
|
|
35671
|
+
2
|
|
35672
|
+
)}
|
|
35673
|
+
`;
|
|
35593
35674
|
var editorconfig = () => `root = true
|
|
35594
35675
|
|
|
35595
35676
|
[*]
|
|
@@ -35623,6 +35704,7 @@ function scaffoldFiles(appName, config, environment, extraDeps = {}, plugins = [
|
|
|
35623
35704
|
{ path: ".prettierrc", contents: prettierrc() },
|
|
35624
35705
|
{ path: ".prettierignore", contents: prettierignore() },
|
|
35625
35706
|
{ path: ".editorconfig", contents: editorconfig() },
|
|
35707
|
+
{ path: ".vscode/settings.json", contents: vscodeSettings() },
|
|
35626
35708
|
{ path: "mag-cli.config.js", contents: magCliConfig() },
|
|
35627
35709
|
{ path: "scripts/copy-one-assets.cjs", contents: copyOneAssetsCjs() },
|
|
35628
35710
|
{
|
|
@@ -39390,6 +39472,7 @@ var HISTORY_SELECTION_KEYS = [
|
|
|
39390
39472
|
variantsForCode,
|
|
39391
39473
|
variantsForNewControl,
|
|
39392
39474
|
variantsReferencing,
|
|
39475
|
+
vscodeSettings,
|
|
39393
39476
|
watchFields,
|
|
39394
39477
|
watchKey,
|
|
39395
39478
|
wcClassName,
|