diff --git a/.kit/src/lib/JSDB/IncompleteQueryProxy.js b/.kit/src/lib/JSDB/IncompleteQueryProxy.js index c7bb7a0..ef30f8f 100644 --- a/.kit/src/lib/JSDB/IncompleteQueryProxy.js +++ b/.kit/src/lib/JSDB/IncompleteQueryProxy.js @@ -27,15 +27,20 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// import QueryOperators from './QueryOperators.js' -import QueryProxy from './QueryProxy.js' export default class IncompleteQueryProxy { - constructor (table, data, property) { + constructor (table, data, property, QueryProxy) { this.table = table this.data = data this.query = property + // Injecting a reference to the QueryProxy class + // since Vite (and thus SvelteKit) cannot handle + // circular references in SSR apps right now. + // (See https://github.com/vitejs/vite/issues/2491) + this.QueryProxy = QueryProxy + // Note: we return a proxy instance; not an instance of DataProxy. Use accordingly. return new Proxy({}, { get: this.getHandler.bind(this) }) } @@ -50,7 +55,7 @@ export default class IncompleteQueryProxy { return (function (value) { if (isNaN(value)) value = `'${value}'` const updatedQuery = `${this.query} ${QueryOperators.RELATIONAL_OPERATORS[property]} ${value}` - return new QueryProxy(this.table, this.data, updatedQuery) + return new this.QueryProxy(this.table, this.data, updatedQuery, IncompleteQueryProxy) }).bind(this) } else if (QueryOperators.FUNCTIONAL_OPERATORS.includes(property)) { return (function (value) { @@ -66,7 +71,7 @@ export default class IncompleteQueryProxy { // so that it’s correct JavaScript. property = property.replace('CaseInsensitive', '') updatedQuery += `.${property}(${value})` - return new QueryProxy(this.table, this.data, updatedQuery) + return new this.QueryProxy(this.table, this.data, updatedQuery, IncompleteQueryProxy) }).bind(this) } else { diff --git a/.kit/src/lib/JSDB/QueryProxy.js b/.kit/src/lib/JSDB/QueryProxy.js index eaca7af..211edd2 100644 --- a/.kit/src/lib/JSDB/QueryProxy.js +++ b/.kit/src/lib/JSDB/QueryProxy.js @@ -18,16 +18,21 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// import QuerySanitiser from './QuerySanitiser.js' -import IncompleteQueryProxy from './IncompleteQueryProxy.js' export default class QueryProxy { cachedResult = null - constructor (table, data, query) { + constructor (table, data, query, IncompleteQueryProxy) { this.table = table this.data = data this.query = query + // Injecting a reference to the IncompleteQueryProxy class + // since Vite (and thus SvelteKit) cannot handle + // circular references in SSR apps right now. + // (See https://github.com/vitejs/vite/issues/2491) + this.IncompleteQueryProxy = IncompleteQueryProxy + return new Proxy({}, { get: this.getHandler.bind(this), set: this.setHandler.bind(this), @@ -71,12 +76,12 @@ export default class QueryProxy { // if (property === 'and') return (function (connectiveProperty) { const incompleteQuery = `${this.query} && valueOf.${connectiveProperty}` - return new IncompleteQueryProxy(this.table, this.data, incompleteQuery) + return new this.IncompleteQueryProxy(this.table, this.data, incompleteQuery) }).bind(this) if (property === 'or') return (function (connectiveProperty) { const incompleteQuery = `${this.query} || valueOf.${connectiveProperty}` - return new IncompleteQueryProxy(this.table, this.data, incompleteQuery) + return new this.IncompleteQueryProxy(this.table, this.data, incompleteQuery) }).bind(this) // If nothing else matches, just do the default.