s3db.js 13.6.0 → 13.6.1
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/README.md +83 -28
- package/dist/s3db.cjs +32 -1
- package/dist/s3db.cjs.map +1 -1
- package/dist/s3db.es.js +32 -1
- package/dist/s3db.es.js.map +1 -1
- package/package.json +12 -2
- package/src/plugins/api/concerns/opengraph-helper.js +116 -0
- package/src/plugins/api/concerns/state-machine.js +288 -0
- package/src/plugins/api/index.js +12 -1
- package/src/plugins/api/utils/template-engine.js +77 -3
- package/src/plugins/tfstate/README.md +126 -126
package/dist/s3db.es.js
CHANGED
|
@@ -6737,6 +6737,16 @@ async function loadEJS() {
|
|
|
6737
6737
|
);
|
|
6738
6738
|
}
|
|
6739
6739
|
}
|
|
6740
|
+
async function loadPug() {
|
|
6741
|
+
try {
|
|
6742
|
+
const pug = await import('pug');
|
|
6743
|
+
return pug.default || pug;
|
|
6744
|
+
} catch (err) {
|
|
6745
|
+
throw new Error(
|
|
6746
|
+
"Pug template engine not installed. Install with: npm install pug\nPug is a peer dependency to keep the core package lightweight."
|
|
6747
|
+
);
|
|
6748
|
+
}
|
|
6749
|
+
}
|
|
6740
6750
|
function setupTemplateEngine(options = {}) {
|
|
6741
6751
|
const {
|
|
6742
6752
|
engine = "jsx",
|
|
@@ -6751,6 +6761,27 @@ function setupTemplateEngine(options = {}) {
|
|
|
6751
6761
|
if (typeof template === "object" && template !== null) {
|
|
6752
6762
|
return c.html(template);
|
|
6753
6763
|
}
|
|
6764
|
+
if (engine === "pug") {
|
|
6765
|
+
const pug = await loadPug();
|
|
6766
|
+
const templateFile = template.endsWith(".pug") ? template : `${template}.pug`;
|
|
6767
|
+
const templatePath = join(templatesPath, templateFile);
|
|
6768
|
+
if (!existsSync(templatePath)) {
|
|
6769
|
+
throw new Error(`Template not found: ${templatePath}`);
|
|
6770
|
+
}
|
|
6771
|
+
const renderData = {
|
|
6772
|
+
...data,
|
|
6773
|
+
// Add helpers that Pug templates might expect
|
|
6774
|
+
_url: c.req.url,
|
|
6775
|
+
_path: c.req.path,
|
|
6776
|
+
_method: c.req.method
|
|
6777
|
+
};
|
|
6778
|
+
const html = pug.renderFile(templatePath, {
|
|
6779
|
+
...renderData,
|
|
6780
|
+
...engineOptions,
|
|
6781
|
+
...renderOptions
|
|
6782
|
+
});
|
|
6783
|
+
return c.html(html);
|
|
6784
|
+
}
|
|
6754
6785
|
if (engine === "ejs") {
|
|
6755
6786
|
const ejs = await loadEJS();
|
|
6756
6787
|
const templateFile = template.endsWith(".ejs") ? template : `${template}.ejs`;
|
|
@@ -34063,7 +34094,7 @@ class Database extends EventEmitter {
|
|
|
34063
34094
|
})();
|
|
34064
34095
|
this.version = "1";
|
|
34065
34096
|
this.s3dbVersion = (() => {
|
|
34066
|
-
const [ok, err, version] = tryFn(() => true ? "13.6.
|
|
34097
|
+
const [ok, err, version] = tryFn(() => true ? "13.6.1" : "latest");
|
|
34067
34098
|
return ok ? version : "latest";
|
|
34068
34099
|
})();
|
|
34069
34100
|
this._resourcesMap = {};
|