clovie 0.2.5 → 0.2.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.
package/AGENTS.md CHANGED
@@ -152,7 +152,7 @@ export class MyService extends ServiceProvider {
152
152
  **`useContext` idioms:**
153
153
  - Positional: `const [file, log] = useContext('file', 'log');` — resolves at action-construction time.
154
154
  - Whole context: `const { cache } = useContext();` — returns the full context object.
155
- - Late-bound: `this.useContext('server')` inside async methods for services that may not be installed yet.
155
+ - Late-bound: `this.inject('server')` inside async methods for services that may not be installed yet.
156
156
 
157
157
  Use `#private` fields for internal state.
158
158
 
@@ -232,7 +232,7 @@ export class Compile extends ServiceProvider {
232
232
  }
233
233
 
234
234
  #remove(sourcePath) {
235
- const file = this.useContext('file');
235
+ const file = this.inject('file');
236
236
  const outputPaths = this.#pathMap.get(sourcePath);
237
237
  if (outputPaths) {
238
238
  outputPaths.forEach(outputPath => {
@@ -242,7 +242,7 @@ export class Compile extends ServiceProvider {
242
242
  }
243
243
 
244
244
  async #asset(filePath, opts) {
245
- const [file, log] = this.useContext('file', 'log');
245
+ const [file, log] = this.inject('file', 'log');
246
246
  const content = file.read(filePath);
247
247
 
248
248
  if (content) {
@@ -259,7 +259,7 @@ export class Compile extends ServiceProvider {
259
259
  }
260
260
 
261
261
  async #style(filePath, opts) {
262
- const [file, log] = this.useContext('file', 'log');
262
+ const [file, log] = this.inject('file', 'log');
263
263
  const content = file.read(filePath);
264
264
 
265
265
  if (content && opts.styleCompiler && typeof opts.styleCompiler === 'function') {
@@ -284,7 +284,7 @@ export class Compile extends ServiceProvider {
284
284
  }
285
285
 
286
286
  #loadPartial(filePath, opts) {
287
- const [file, log] = this.useContext('file', 'log');
287
+ const [file, log] = this.inject('file', 'log');
288
288
 
289
289
  if (file.exists(filePath) && opts.renderEngine) {
290
290
  try {
@@ -307,7 +307,7 @@ export class Compile extends ServiceProvider {
307
307
  }
308
308
 
309
309
  async #view(filePath, opts) {
310
- const [file, liveReload, log] = this.useContext('file', 'liveReload', 'log');
310
+ const [file, liveReload, log] = this.inject('file', 'liveReload', 'log');
311
311
 
312
312
  if (file.exists(filePath) && opts.renderEngine) {
313
313
  const fileName = path.basename(filePath);
@@ -324,7 +324,7 @@ export class Compile extends ServiceProvider {
324
324
  }
325
325
 
326
326
  async #route(route, opts, value, key) {
327
- const [file, log] = this.useContext('file', 'log');
327
+ const [file, log] = this.inject('file', 'log');
328
328
  const data = route.data(opts.data, value, key);
329
329
  const relativePath = replaceRouteParams(route.path, data);
330
330
  const outputPath = formatOutputPath(relativePath);
@@ -340,7 +340,7 @@ export class Compile extends ServiceProvider {
340
340
  }
341
341
 
342
342
  async #template(templatePath, data, opts) {
343
- const [file, log] = this.useContext('file', 'log');
343
+ const [file, log] = this.inject('file', 'log');
344
344
  try {
345
345
  const template = file.read(templatePath);
346
346
  let renderedContent = await opts.renderEngine.render(template, data);
@@ -352,7 +352,7 @@ export class Compile extends ServiceProvider {
352
352
  }
353
353
 
354
354
  async #injectLiveReloadScript(renderedContent, opts) {
355
- const [liveReload, log] = this.useContext('liveReload', 'log');
355
+ const [liveReload, log] = this.inject('liveReload', 'log');
356
356
  try {
357
357
  if (liveReload && renderedContent.includes('</body>')) {
358
358
  log.debug('Injecting live reload script');
@@ -383,7 +383,7 @@ export class Compile extends ServiceProvider {
383
383
  }
384
384
 
385
385
  #write(filePath, content, outputDir) {
386
- const [file, fileCache, log, liveReload] = this.useContext('file', 'fileCache', 'log', 'liveReload');
386
+ const [file, fileCache, log, liveReload] = this.inject('file', 'fileCache', 'log', 'liveReload');
387
387
  const outputPath = path.join(outputDir, filePath);
388
388
 
389
389
  // Cache based on OUTPUT content (handles both template and data changes)
@@ -74,7 +74,7 @@ export class Configurator extends ServiceProvider {
74
74
  this.#stopWacher = null;
75
75
  }
76
76
 
77
- const [file, log] = this.useContext('file', 'log');
77
+ const [file, log] = this.inject('file', 'log');
78
78
  path = path || this.#optsPath;
79
79
 
80
80
  if (path) {
@@ -264,7 +264,7 @@ export class File extends ServiceProvider {
264
264
  }
265
265
  } catch (err) {
266
266
  // Get logger from the service context if available
267
- const log = this.useContext?.('log');
267
+ const log = this.inject?.('log');
268
268
  if (log) {
269
269
  log.error(`Error reading file ${filePath}:`, err);
270
270
  } else {
@@ -72,7 +72,7 @@ export class FileCache extends ServiceProvider {
72
72
  }
73
73
 
74
74
  #hasChanged(filePath, newContent) {
75
- const cache = this.useContext('cache');
75
+ const cache = this.inject('cache');
76
76
  const entry = cache.get(['.cache', filePath]);
77
77
 
78
78
  if (!entry) {
@@ -21,7 +21,7 @@ export class LiveReload extends ServiceProvider {
21
21
  actions() {
22
22
  return {
23
23
  initializeServer: async (server, opts) => {
24
- const log = this.useContext('log');
24
+ const log = this.inject('log');
25
25
  if (opts.mode === 'development') {
26
26
  await this.#setupSocketIO(server, log);
27
27
  }
@@ -90,13 +90,13 @@ export class Run extends ServiceProvider {
90
90
  }
91
91
 
92
92
  async #normalizeRoutes(opts) {
93
- opts.api = opts.api && opts.api.length ? await resolveRoutes(opts.api, (...args) => this.useContext(...args), opts) : [];
94
- opts.routes = opts.routes && opts.routes.length ? await resolveRoutes(opts.routes, (...args) => this.useContext(...args), opts) : [];
93
+ opts.api = opts.api && opts.api.length ? await resolveRoutes(opts.api, (...args) => this.inject(...args), opts) : [];
94
+ opts.routes = opts.routes && opts.routes.length ? await resolveRoutes(opts.routes, (...args) => this.inject(...args), opts) : [];
95
95
  return opts;
96
96
  }
97
97
 
98
98
  async #build(opts) {
99
- const [file, compile, log] = this.useContext('file', 'compile', 'log');
99
+ const [file, compile, log] = this.inject('file', 'compile', 'log');
100
100
 
101
101
  log.info('🧹 Cleaning output directory...');
102
102
  file.clean(opts.outputDir);
@@ -135,7 +135,7 @@ export class Run extends ServiceProvider {
135
135
  async #buildScripts(opts, htmlStrings, compile, log) {
136
136
  if (!opts.scripts) return;
137
137
 
138
- const esBuild = this.useContext('esBuild');
138
+ const esBuild = this.inject('esBuild');
139
139
  if (!esBuild) return;
140
140
 
141
141
  const entryPoints = extractScriptSources({
@@ -158,7 +158,7 @@ export class Run extends ServiceProvider {
158
158
  }
159
159
 
160
160
  async #serve (opts) {
161
- const [server, file, liveReload] = this.useContext('server', 'file', 'liveReload');
161
+ const [server, file, liveReload] = this.inject('server', 'file', 'liveReload');
162
162
  const services = { file, liveReload };
163
163
 
164
164
  const viewRoutes = viewsToRoutes(opts, services);
@@ -177,7 +177,7 @@ export class Run extends ServiceProvider {
177
177
  }
178
178
 
179
179
  async #watch(opts) {
180
- const [file, compile, log] = this.useContext('file', 'compile', 'log');
180
+ const [file, compile, log] = this.inject('file', 'compile', 'log');
181
181
  log.info('Watching for changes...');
182
182
 
183
183
  const closeWatchers = [];
@@ -185,7 +185,7 @@ export class Run extends ServiceProvider {
185
185
  const rebuildScriptsIfNeeded = async (htmlStrings) => {
186
186
  if (!opts.scripts) return;
187
187
 
188
- const esBuild = this.useContext('esBuild');
188
+ const esBuild = this.inject('esBuild');
189
189
  if (!esBuild) return;
190
190
 
191
191
  const newEntryPoints = extractScriptSources({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clovie",
3
- "version": "0.2.5",
3
+ "version": "0.2.8",
4
4
  "description": "Vintage web dev tooling with modern quality of life",
5
5
  "keywords": [
6
6
  "static-site-generator",
@@ -85,7 +85,7 @@
85
85
  "update:jucie.io": "npx npm-check-updates '@jucie.io/*' --target latest -u && npm install"
86
86
  },
87
87
  "dependencies": {
88
- "@jucie.io/engine": "^1.1.68",
88
+ "@jucie.io/engine": "^1.1.70",
89
89
  "@jucie.io/engine-esbuild": "^1.0.10",
90
90
  "@jucie.io/engine-server": "^1.0.26",
91
91
  "@jucie.io/reactive": "^1.0.30",