@routier/core 0.7.0 → 0.8.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 (47) hide show
  1. package/dist/codegen/blocks.d.ts +17 -1
  2. package/dist/codegen/handlers/types.d.ts +13 -5
  3. package/dist/codegen/index.cjs +28 -0
  4. package/dist/codegen/index.cjs.map +1 -1
  5. package/dist/codegen/index.js +28 -0
  6. package/dist/codegen/index.js.map +1 -1
  7. package/dist/collections/MemoryDataCollection.d.ts +2 -4
  8. package/dist/collections/index.cjs +127 -15
  9. package/dist/collections/index.cjs.map +1 -1
  10. package/dist/collections/index.js +127 -15
  11. package/dist/collections/index.js.map +1 -1
  12. package/dist/expressions/index.cjs +226 -4
  13. package/dist/expressions/index.cjs.map +1 -1
  14. package/dist/expressions/index.js +228 -5
  15. package/dist/expressions/index.js.map +1 -1
  16. package/dist/expressions/parser.d.ts +42 -1
  17. package/dist/index.cjs +753 -345
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.js +756 -345
  20. package/dist/index.js.map +1 -1
  21. package/dist/plugins/EphemeralDataPlugin.d.ts +8 -0
  22. package/dist/plugins/index.cjs +566 -49
  23. package/dist/plugins/index.cjs.map +1 -1
  24. package/dist/plugins/index.js +566 -48
  25. package/dist/plugins/index.js.map +1 -1
  26. package/dist/plugins/query/QueryOptionsCollection.d.ts +15 -5
  27. package/dist/plugins/query/index.d.ts +1 -0
  28. package/dist/plugins/query/renames.d.ts +27 -0
  29. package/dist/plugins/query/types.d.ts +15 -1
  30. package/dist/plugins/translators/SqlTranslator.d.ts +15 -0
  31. package/dist/schema/SchemaDefinition.d.ts +8 -0
  32. package/dist/schema/changeTracker.d.ts +10 -0
  33. package/dist/schema/index.cjs +291 -274
  34. package/dist/schema/index.cjs.map +1 -1
  35. package/dist/schema/index.d.ts +1 -0
  36. package/dist/schema/index.js +294 -276
  37. package/dist/schema/index.js.map +1 -1
  38. package/dist/schema/types.d.ts +8 -7
  39. package/dist/schema/utils/storageDates.d.ts +25 -0
  40. package/dist/transfer/index.cjs.map +1 -1
  41. package/dist/transfer/index.js.map +1 -1
  42. package/dist/utilities/index.cjs +74 -29
  43. package/dist/utilities/index.cjs.map +1 -1
  44. package/dist/utilities/index.js +74 -29
  45. package/dist/utilities/index.js.map +1 -1
  46. package/package.json +2 -2
  47. package/dist/codegen/utils.d.ts +0 -22
@@ -1,6 +1,6 @@
1
1
  import { CreateBlockOptions } from "./types";
2
2
  type Line = string | Block;
3
- type Param = {
3
+ export type Param = {
4
4
  name: string;
5
5
  value: any;
6
6
  };
@@ -100,6 +100,11 @@ export declare class FunctionFactoryBuilder extends ContainerBlock {
100
100
  getParameters(): Param[];
101
101
  createParameter(value: any): Param;
102
102
  parameters(...params: Param[]): this;
103
+ /**
104
+ * Adds a factory parameter carrying `value` and returns its name, for generated code to
105
+ * refer to. See `CodeBuilder.bind` for why values travel this way.
106
+ */
107
+ bind(value: unknown): string;
103
108
  return(): this;
104
109
  appendBody(line: string): this;
105
110
  invoke(): any;
@@ -133,6 +138,17 @@ export declare class IfBuilder extends ContainerBlock {
133
138
  toString(): string;
134
139
  }
135
140
  export declare class CodeBuilder extends ContainerBlock {
141
+ private _bindings;
142
+ /**
143
+ * Makes `value` available to the generated function under the returned name.
144
+ *
145
+ * Generated code must never reach a runtime value by its source name or by pasting its
146
+ * source text: a minifier renames the declaration and cannot see inside the generated
147
+ * string, and pasted source loses the scope it closed over (#40, #46). A binding is passed
148
+ * in as a real value when the function is compiled, so it survives any bundler.
149
+ */
150
+ bind(value: unknown, name?: string): string;
151
+ getBindings(): Param[];
136
152
  toString(): string;
137
153
  }
138
154
  export {};
@@ -1,4 +1,4 @@
1
- import { CodeBuilder, ContainerBlock, IfBuilder, SlotBlock } from '..';
1
+ import { CodeBuilder, IfBuilder, SlotBlock } from '..';
2
2
  import { PropertyInfo } from '../../schema/PropertyInfo';
3
3
  import { SlotPath } from '../SlotPath';
4
4
  export interface IHandler {
@@ -65,8 +65,16 @@ export declare abstract class PropertyInfoHandler implements IHandler {
65
65
  */
66
66
  protected buildEnrichedObjectSlotPath(property: PropertyInfo<any>, base: SlotPath): SlotPath;
67
67
  protected setEnrichedProperty(property: PropertyInfo<any>, root: CodeBuilder): void;
68
- protected toNamedFunction(stringifiedFunction: string, parent: ContainerBlock): {
69
- builder: import("..").FunctionBuilder;
70
- parameters: string[];
71
- };
68
+ /**
69
+ * Binds a function the schema author supplied (a default, a computed, a serializer) into
70
+ * the generated code and returns the expression that calls it with `args`.
71
+ *
72
+ * The function is passed in by value rather than pasted in as source text. Pasted source
73
+ * loses the scope it was written in, so a default that called an imported helper threw, and
74
+ * it had to be parsed back apart, which only worked for arrows: a bundler that lowers arrows
75
+ * to `function` expressions, or renames what they refer to, broke every schema (#46).
76
+ */
77
+ protected emitBoundCall(target: {
78
+ bind(value: unknown): string;
79
+ }, fn: Function, args: string[]): string;
72
80
  }
@@ -358,6 +358,14 @@ class FunctionFactoryBuilder extends ContainerBlock {
358
358
  this._params.push(...params);
359
359
  return this;
360
360
  }
361
+ /**
362
+ * Adds a factory parameter carrying `value` and returns its name, for generated code to
363
+ * refer to. See `CodeBuilder.bind` for why values travel this way.
364
+ */ bind(value) {
365
+ const parameter = this.createParameter(value);
366
+ this._params.push(parameter);
367
+ return parameter.name;
368
+ }
361
369
  return() {
362
370
  this._return = true;
363
371
  return this;
@@ -473,6 +481,26 @@ class IfBuilder extends ContainerBlock {
473
481
  }
474
482
  }
475
483
  class CodeBuilder extends ContainerBlock {
484
+ _bindings = [];
485
+ /**
486
+ * Makes `value` available to the generated function under the returned name.
487
+ *
488
+ * Generated code must never reach a runtime value by its source name or by pasting its
489
+ * source text: a minifier renames the declaration and cannot see inside the generated
490
+ * string, and pasted source loses the scope it closed over (#40, #46). A binding is passed
491
+ * in as a real value when the function is compiled, so it survives any bundler.
492
+ */ bind(value, name = `binding${this._bindings.length}`) {
493
+ this._bindings.push({
494
+ name,
495
+ value
496
+ });
497
+ return name;
498
+ }
499
+ getBindings() {
500
+ return [
501
+ ...this._bindings
502
+ ];
503
+ }
476
504
  toString() {
477
505
  return this._lines.map((line)=>typeof line === 'string' ? this.indent(line) : line.toString()).join('\n\n');
478
506
  }
@@ -1 +1 @@
1
- {"version":3,"file":"codegen/index.cjs","sources":["webpack://@routier/core/./src/codegen/blocks.ts","webpack://@routier/core/./src/utilities/uuid.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/codegen/index.ts"],"sourcesContent":["import { uuid } from \"../utilities\";\nimport { CreateBlockOptions } from \"./types\";\n\ntype Line = string | Block;\n\ntype Param = { name: string, value: any };\ntype GenericParam = { name: string, callName: string };\n\n\nexport abstract class Block {\n readonly name: string;\n protected _lines: Line[] = [];\n protected _indent: string = \"\";\n protected _parent?: Block;\n\n constructor(name?: string, parentIndent: string = \"\", parent?: Block) {\n this.name = name != null ? name : uuid();\n this._indent = parentIndent;\n this._parent = parent;\n }\n\n indexOf(name: string) {\n return this._lines.findIndex(w => typeof w !== \"string\" && w.name === name);\n }\n\n getLines() {\n return this._lines;\n }\n\n getParent() {\n return this._parent;\n }\n\n getIndent() {\n return this._indent;\n }\n\n setLines(lines: Line[]) {\n this._lines = lines;\n }\n\n setParent(block: Block) {\n this._parent = block;\n }\n\n setIndent(indent: string) {\n this._indent = indent;\n }\n\n getOrDefault<T extends Block>(name: string): T | undefined {\n\n if (name.includes('.') === false) {\n return this._lines.find(w => typeof w !== \"string\" && w.name === name) as T | undefined;\n }\n\n const split = name.match(/(\\[[^\\]]+\\]|[^.]+)/g);\n // oxlint-disable-next-line no-this-alias\n let result: Block = this;\n\n for (const item of split) {\n const found = result._lines.find(w => typeof w !== \"string\" && w.name === item) as Block;\n\n if (found == null) {\n\n if (\"getValue\" in result && result.getValue instanceof Block && result.getValue.name === item) {\n result = result.getValue;\n continue;\n }\n\n return undefined;\n }\n\n result = found;\n }\n\n return result as T;\n }\n\n get<T extends Block>(name: string): T {\n const found = this.getOrDefault(name);\n\n if (found == null) {\n throw new Error(`Error finding code block for given path. Path: ${name}`)\n }\n\n return found as T;\n }\n\n has(name: string) {\n return this._lines.some(w => typeof w !== \"string\" && w.name === name);\n }\n\n remove(name: string) {\n this._lines = this._lines.filter(x => typeof x === \"object\" && typeof x.name === \"string\" && x.name !== name);\n }\n\n replace(name: string, line: Block) {\n\n const foundIndex = this._lines.findIndex(x => typeof x !== \"string\" && x.name === name);\n\n if (foundIndex === -1) {\n throw new Error(`Cannot find line by name. Name: ${name}`)\n }\n\n const found = this._lines[foundIndex];\n\n if (typeof found === \"string\") {\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n return;\n }\n\n line.setLines(found.getLines());\n line.setIndent(found.getIndent());\n line.setParent(found.getParent());\n\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n\n return;\n }\n\n protected push(line: Line) {\n this._lines.push(line);\n }\n\n protected unshift(line: Line) {\n this._lines.unshift(line);\n }\n\n protected indent(text: string): string {\n return this._indent + text;\n }\n\n\n abstract toString(): string;\n}\n\nexport abstract class ContainerBlock extends Block {\n if(condition: string, options?: CreateBlockOptions): IfBuilder {\n const builder = new IfBuilder(condition, options?.name, this._indent + \" \", this);\n if (options?.unshift === true) {\n this.unshift(builder);\n } else {\n this.push(builder);\n }\n\n return builder;\n }\n\n raw(raw: string, options?: CreateBlockOptions): RawBuilder {\n const builder = new RawBuilder(raw, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n function(name?: string, options?: CreateBlockOptions): FunctionBuilder {\n const builder = new FunctionBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n factory(name?: string, options?: CreateBlockOptions): FunctionFactoryBuilder {\n const builder = new FunctionFactoryBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n variable(declaration: string, options?: CreateBlockOptions): VariableBuilder {\n const builder = new VariableBuilder(declaration, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n assign(variableName: string, options?: CreateBlockOptions): AssignmentBuilder {\n const builder = new AssignmentBuilder(variableName, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const builder = new ObjectBuilder(options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n slot(name: string) {\n const builder = new SlotBlock(name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n array(accessor: string, options?: CreateBlockOptions) {\n const builder = new ArrayBuilder(accessor, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n}\n\nexport type StringType = \"template\" | \"default\";\n\nexport class StringBuilder extends Block {\n\n private _type: StringType;\n\n constructor(type: StringType, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._type = type;\n }\n\n append(value: string) {\n this._lines.push(value);\n return this;\n }\n\n toString() {\n if (this._type === \"template\") {\n return \"`\" + this._lines.join(\"\") + \"`\";\n }\n\n return `\"${this._lines.join(\"\")}\"`;\n }\n}\n\nexport class SlotBlock extends ContainerBlock {\n\n constructor(name: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n }\n\n insert(line: string | Block) {\n this.push(line);\n }\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\n');\n }\n}\n\nexport class AssignmentBuilder extends ContainerBlock {\n protected _variableName: string;\n protected _value?: string | Block;\n protected _functionName?: string;\n\n get getValue() {\n return this._value;\n }\n\n constructor(variableName: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._variableName = variableName;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n and(and: string, options?: CreateBlockOptions): this {\n this._value = new AndBuilder(and, options?.name, this._indent, this);\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n call(functionName: string, options?: CreateBlockOptions): ObjectBuilder {\n this._functionName = functionName;\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n string(type: StringType, options?: CreateBlockOptions) {\n const stringBuilder = new StringBuilder(type, options?.name, this._indent, this);\n\n this._value = stringBuilder;\n\n return stringBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for AssignmentBuilder Builder\")\n }\n\n if (this._functionName != null) {\n return this.indent(`${this._variableName} = ${this._functionName}(${this._value.toString()});`);\n }\n\n return this.indent(`${this._variableName} = ${this._value.toString()};`);\n }\n}\n\nexport class AndBuilder extends ContainerBlock {\n\n constructor(and: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(and);\n }\n\n and(and: string) {\n this._lines.push(and);\n }\n\n toString() {\n return this._lines.join(\" && \")\n }\n}\n\nexport class VariableBuilder extends Block {\n protected _declaration: string;\n protected _value?: string | Block;\n\n get getValue() {\n return this._value;\n }\n\n constructor(declaration: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._declaration = declaration;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n array(accessor: string, options?: CreateBlockOptions): ArrayBuilder {\n const arrayBuilder = new ArrayBuilder(accessor, options?.name, this._indent, this);\n\n this._value = arrayBuilder;\n\n return arrayBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for Variable Builder\")\n }\n\n return this.indent(`const ${this._declaration} = ${this._value.toString()};`);\n }\n}\n\nexport class RawBuilder extends ContainerBlock {\n private _raw: string;\n\n constructor(raw: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._raw = raw;\n }\n\n toString(): string {\n return `${this._raw}\\n`;\n }\n}\n\nexport class ObjectBuilder extends Block {\n\n property(line: string) {\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n this.push(line);\n return this;\n }\n\n nested(propertyName: string, name?: string) {\n const builder = new ObjectBuilder(name, this._indent + \" \", this);\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n // Add the property name and opening brace\n this.push(`${propertyName}: {`);\n // Add the nested builder\n this.push(builder);\n // Add the closing brace\n this.push(\"}\");\n return builder;\n }\n\n toString(): string {\n // Check if this is a nested object's content\n const isNestedContent = this._parent instanceof ObjectBuilder;\n\n if (isNestedContent) {\n // For nested object contents, just return the lines\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ).join('\\n');\n }\n\n // For root objects, include the braces\n const lines = [\n \"{\",\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionFactoryBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: Param[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n getParameters() {\n return [...this._params];\n }\n\n createParameter(value: any): Param {\n const name = `injection${this._params.length}`;\n return {\n name,\n value\n }\n }\n\n parameters(...params: Param[]): this {\n this._params.push(...params);\n return this;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n invoke() {\n const body = this.toString();\n const parameterNames = this._getParameterNames();\n const parameterValues = this._getParameterValues();\n\n return Function(...parameterNames, body)(...parameterValues)\n }\n\n private _getParameterNames() {\n return this._params.map(w => w.name).join(\", \")\n }\n\n private _getParameterValues() {\n return this._params.map(w => w.value);\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterNames()})`\n : `${r}function(${this._getParameterNames()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: (string | GenericParam)[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n parameters(...params: (string | GenericParam)[]): this {\n this._params.push(...params);\n return this;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n private _getParameterKeys() {\n return this._params.map(w => typeof w === \"object\" ? w.name : w).join(\", \")\n }\n\n toCallable() {\n return `${this._functionName}(${this._params.map(w => typeof w === \"object\" ? w.callName : w).join(\", \")})`\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterKeys()})`\n : `${r}function(${this._getParameterKeys()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class ArrayBuilder extends Block {\n constructor(accessor: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(accessor);\n }\n\n append(accessor: string) {\n this._lines.push(accessor);\n return this;\n }\n\n toString() {\n return `[${this._lines.join(\",\")}]`\n }\n}\n\nexport class IfBuilder extends ContainerBlock {\n private _condition: string;\n\n constructor(condition: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._condition = condition;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n unshiftBody(line: string): this {\n this.unshift(line);\n return this;\n }\n\n private stringifyLine(line: Line) {\n if (typeof line === 'string') {\n return this.indent(\" \" + line);\n }\n\n if (Array.isArray(line)) {\n return line.join(\"\\r\\n\")\n }\n\n return line.toString();\n }\n\n toString(): string {\n // need to join with \\r\\n because we are not an object\n const lines = [\n this.indent(`if (${this._condition}) {`),\n this._lines.map(x => this.stringifyLine(x)).join(\"\\r\\n\"),\n this.indent(\"}\")\n ]\n\n return lines.join(\"\\n\\n\");\n }\n}\n\nexport class CodeBuilder extends ContainerBlock {\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\n');\n }\n}","export const uuid = (length: number = 16): string => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charLength = chars.length;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.random() * charLength | 0];\n }\n return result;\n}\n\nconst HEX_CHARS = '0123456789abcdef';\nconst UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nconst hasCrypto =\n typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';\n\nconst hasRandomUUID =\n typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';\n\nexport const uuidv4 = (): string => {\n if (hasRandomUUID) {\n return crypto.randomUUID();\n }\n\n return uuidv4Fallback();\n};\n\nconst uuidv4Fallback = (): string => {\n let randomBytes: Uint8Array | null = null;\n if (hasCrypto) {\n randomBytes = crypto.getRandomValues(new Uint8Array(16));\n }\n\n let byteIndex = 0;\n let uuid = '';\n\n for (let i = 0; i < UUID_TEMPLATE.length; i++) {\n const c = UUID_TEMPLATE[i];\n if (c === '-') {\n uuid += '-';\n continue;\n }\n\n let r: number;\n if (hasCrypto && randomBytes) {\n // Each byte gives two hex digits (nibbles)\n r =\n (i % 2 === 0\n ? randomBytes[byteIndex] >> 4\n : randomBytes[byteIndex++] & 0x0f);\n } else {\n r = Math.floor(Math.random() * 16);\n }\n\n if (c === 'x') {\n uuid += HEX_CHARS[r];\n } else if (c === 'y') {\n // Variant bits: 8, 9, A, or B\n uuid += HEX_CHARS[(r & 0x3) | 0x8];\n } else if (c === '4') {\n uuid += '4';\n }\n }\n\n return uuid;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './blocks';\nexport * from './types';"],"names":["uuid","Block","name","parentIndent","parent","w","lines","block","indent","split","result","item","found","undefined","Error","x","line","foundIndex","text","ContainerBlock","condition","options","builder","IfBuilder","raw","RawBuilder","FunctionBuilder","FunctionFactoryBuilder","declaration","VariableBuilder","variableName","AssignmentBuilder","ObjectBuilder","SlotBlock","accessor","ArrayBuilder","StringBuilder","type","value","and","AndBuilder","objectBuilder","functionName","stringBuilder","arrayBuilder","lastLine","propertyName","isNestedContent","sectionName","params","body","parameterNames","parameterValues","Function","r","signature","Array","CodeBuilder","length","chars","charLength","i","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AOD,OAAO,UAAU;IAC5B;IAEA,OAAOG;AACX,EAAE;AAEF,MAAMA,iBAAiB;IACnB,IAAIC,cAAiC;IACrC,IAAIL,WAAW;QACXK,cAAcJ,OAAO,eAAe,CAAC,IAAIK,WAAW;IACxD;IAEA,IAAIC,YAAY;IAChB,IAAIxE,OAAO;IAEX,IAAK,IAAI6D,IAAI,GAAGA,IAAIG,cAAc,MAAM,EAAEH,IAAK;QAC3C,MAAMY,IAAIT,aAAa,CAACH,EAAE;QAC1B,IAAIY,MAAM,KAAK;YACXzE,QAAQ;YACR;QACJ;QAEA,IAAIsD;QACJ,IAAIW,aAAaK,aAAa;YAC1B,2CAA2C;YAC3ChB,IACKO,IAAI,MAAM,IACLS,WAAW,CAACE,UAAU,IAAI,IAC1BF,WAAW,CAACE,YAAY,GAAG;QACzC,OAAO;YACHlB,IAAIQ,KAAK,KAAK,CAACA,KAAK,MAAM,KAAK;QACnC;QAEA,IAAIW,MAAM,KAAK;YACXzE,QAAQ+D,SAAS,CAACT,EAAE;QACxB,OAAO,IAAImB,MAAM,KAAK;YAClB,8BAA8B;YAC9BzE,QAAQ+D,SAAS,CAAET,IAAI,MAAO,IAAI;QACtC,OAAO,IAAImB,MAAM,KAAK;YAClBzE,QAAQ;QACZ;IACJ;IAEA,OAAOA;AACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClEA;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D,E;;;;;;;;;;;;;;;;;;;;;;;ACNyB;AACD"}
1
+ {"version":3,"file":"codegen/index.cjs","sources":["webpack://@routier/core/./src/codegen/blocks.ts","webpack://@routier/core/./src/utilities/uuid.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/codegen/index.ts"],"sourcesContent":["import { uuid } from \"../utilities\";\nimport { CreateBlockOptions } from \"./types\";\n\ntype Line = string | Block;\n\nexport type Param = { name: string, value: any };\ntype GenericParam = { name: string, callName: string };\n\n\nexport abstract class Block {\n readonly name: string;\n protected _lines: Line[] = [];\n protected _indent: string = \"\";\n protected _parent?: Block;\n\n constructor(name?: string, parentIndent: string = \"\", parent?: Block) {\n this.name = name != null ? name : uuid();\n this._indent = parentIndent;\n this._parent = parent;\n }\n\n indexOf(name: string) {\n return this._lines.findIndex(w => typeof w !== \"string\" && w.name === name);\n }\n\n getLines() {\n return this._lines;\n }\n\n getParent() {\n return this._parent;\n }\n\n getIndent() {\n return this._indent;\n }\n\n setLines(lines: Line[]) {\n this._lines = lines;\n }\n\n setParent(block: Block) {\n this._parent = block;\n }\n\n setIndent(indent: string) {\n this._indent = indent;\n }\n\n getOrDefault<T extends Block>(name: string): T | undefined {\n\n if (name.includes('.') === false) {\n return this._lines.find(w => typeof w !== \"string\" && w.name === name) as T | undefined;\n }\n\n const split = name.match(/(\\[[^\\]]+\\]|[^.]+)/g);\n // oxlint-disable-next-line no-this-alias\n let result: Block = this;\n\n for (const item of split) {\n const found = result._lines.find(w => typeof w !== \"string\" && w.name === item) as Block;\n\n if (found == null) {\n\n if (\"getValue\" in result && result.getValue instanceof Block && result.getValue.name === item) {\n result = result.getValue;\n continue;\n }\n\n return undefined;\n }\n\n result = found;\n }\n\n return result as T;\n }\n\n get<T extends Block>(name: string): T {\n const found = this.getOrDefault(name);\n\n if (found == null) {\n throw new Error(`Error finding code block for given path. Path: ${name}`)\n }\n\n return found as T;\n }\n\n has(name: string) {\n return this._lines.some(w => typeof w !== \"string\" && w.name === name);\n }\n\n remove(name: string) {\n this._lines = this._lines.filter(x => typeof x === \"object\" && typeof x.name === \"string\" && x.name !== name);\n }\n\n replace(name: string, line: Block) {\n\n const foundIndex = this._lines.findIndex(x => typeof x !== \"string\" && x.name === name);\n\n if (foundIndex === -1) {\n throw new Error(`Cannot find line by name. Name: ${name}`)\n }\n\n const found = this._lines[foundIndex];\n\n if (typeof found === \"string\") {\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n return;\n }\n\n line.setLines(found.getLines());\n line.setIndent(found.getIndent());\n line.setParent(found.getParent());\n\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n\n return;\n }\n\n protected push(line: Line) {\n this._lines.push(line);\n }\n\n protected unshift(line: Line) {\n this._lines.unshift(line);\n }\n\n protected indent(text: string): string {\n return this._indent + text;\n }\n\n\n abstract toString(): string;\n}\n\nexport abstract class ContainerBlock extends Block {\n if(condition: string, options?: CreateBlockOptions): IfBuilder {\n const builder = new IfBuilder(condition, options?.name, this._indent + \" \", this);\n if (options?.unshift === true) {\n this.unshift(builder);\n } else {\n this.push(builder);\n }\n\n return builder;\n }\n\n raw(raw: string, options?: CreateBlockOptions): RawBuilder {\n const builder = new RawBuilder(raw, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n function(name?: string, options?: CreateBlockOptions): FunctionBuilder {\n const builder = new FunctionBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n factory(name?: string, options?: CreateBlockOptions): FunctionFactoryBuilder {\n const builder = new FunctionFactoryBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n variable(declaration: string, options?: CreateBlockOptions): VariableBuilder {\n const builder = new VariableBuilder(declaration, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n assign(variableName: string, options?: CreateBlockOptions): AssignmentBuilder {\n const builder = new AssignmentBuilder(variableName, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const builder = new ObjectBuilder(options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n slot(name: string) {\n const builder = new SlotBlock(name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n array(accessor: string, options?: CreateBlockOptions) {\n const builder = new ArrayBuilder(accessor, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n}\n\nexport type StringType = \"template\" | \"default\";\n\nexport class StringBuilder extends Block {\n\n private _type: StringType;\n\n constructor(type: StringType, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._type = type;\n }\n\n append(value: string) {\n this._lines.push(value);\n return this;\n }\n\n toString() {\n if (this._type === \"template\") {\n return \"`\" + this._lines.join(\"\") + \"`\";\n }\n\n return `\"${this._lines.join(\"\")}\"`;\n }\n}\n\nexport class SlotBlock extends ContainerBlock {\n\n constructor(name: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n }\n\n insert(line: string | Block) {\n this.push(line);\n }\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\n');\n }\n}\n\nexport class AssignmentBuilder extends ContainerBlock {\n protected _variableName: string;\n protected _value?: string | Block;\n protected _functionName?: string;\n\n get getValue() {\n return this._value;\n }\n\n constructor(variableName: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._variableName = variableName;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n and(and: string, options?: CreateBlockOptions): this {\n this._value = new AndBuilder(and, options?.name, this._indent, this);\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n call(functionName: string, options?: CreateBlockOptions): ObjectBuilder {\n this._functionName = functionName;\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n string(type: StringType, options?: CreateBlockOptions) {\n const stringBuilder = new StringBuilder(type, options?.name, this._indent, this);\n\n this._value = stringBuilder;\n\n return stringBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for AssignmentBuilder Builder\")\n }\n\n if (this._functionName != null) {\n return this.indent(`${this._variableName} = ${this._functionName}(${this._value.toString()});`);\n }\n\n return this.indent(`${this._variableName} = ${this._value.toString()};`);\n }\n}\n\nexport class AndBuilder extends ContainerBlock {\n\n constructor(and: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(and);\n }\n\n and(and: string) {\n this._lines.push(and);\n }\n\n toString() {\n return this._lines.join(\" && \")\n }\n}\n\nexport class VariableBuilder extends Block {\n protected _declaration: string;\n protected _value?: string | Block;\n\n get getValue() {\n return this._value;\n }\n\n constructor(declaration: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._declaration = declaration;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n array(accessor: string, options?: CreateBlockOptions): ArrayBuilder {\n const arrayBuilder = new ArrayBuilder(accessor, options?.name, this._indent, this);\n\n this._value = arrayBuilder;\n\n return arrayBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for Variable Builder\")\n }\n\n return this.indent(`const ${this._declaration} = ${this._value.toString()};`);\n }\n}\n\nexport class RawBuilder extends ContainerBlock {\n private _raw: string;\n\n constructor(raw: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._raw = raw;\n }\n\n toString(): string {\n return `${this._raw}\\n`;\n }\n}\n\nexport class ObjectBuilder extends Block {\n\n property(line: string) {\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n this.push(line);\n return this;\n }\n\n nested(propertyName: string, name?: string) {\n const builder = new ObjectBuilder(name, this._indent + \" \", this);\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n // Add the property name and opening brace\n this.push(`${propertyName}: {`);\n // Add the nested builder\n this.push(builder);\n // Add the closing brace\n this.push(\"}\");\n return builder;\n }\n\n toString(): string {\n // Check if this is a nested object's content\n const isNestedContent = this._parent instanceof ObjectBuilder;\n\n if (isNestedContent) {\n // For nested object contents, just return the lines\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ).join('\\n');\n }\n\n // For root objects, include the braces\n const lines = [\n \"{\",\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionFactoryBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: Param[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n getParameters() {\n return [...this._params];\n }\n\n createParameter(value: any): Param {\n const name = `injection${this._params.length}`;\n return {\n name,\n value\n }\n }\n\n parameters(...params: Param[]): this {\n this._params.push(...params);\n return this;\n }\n\n /**\n * Adds a factory parameter carrying `value` and returns its name, for generated code to\n * refer to. See `CodeBuilder.bind` for why values travel this way.\n */\n bind(value: unknown): string {\n const parameter = this.createParameter(value);\n this._params.push(parameter);\n return parameter.name;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n invoke() {\n const body = this.toString();\n const parameterNames = this._getParameterNames();\n const parameterValues = this._getParameterValues();\n\n return Function(...parameterNames, body)(...parameterValues)\n }\n\n private _getParameterNames() {\n return this._params.map(w => w.name).join(\", \")\n }\n\n private _getParameterValues() {\n return this._params.map(w => w.value);\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterNames()})`\n : `${r}function(${this._getParameterNames()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: (string | GenericParam)[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n parameters(...params: (string | GenericParam)[]): this {\n this._params.push(...params);\n return this;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n private _getParameterKeys() {\n return this._params.map(w => typeof w === \"object\" ? w.name : w).join(\", \")\n }\n\n toCallable() {\n return `${this._functionName}(${this._params.map(w => typeof w === \"object\" ? w.callName : w).join(\", \")})`\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterKeys()})`\n : `${r}function(${this._getParameterKeys()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class ArrayBuilder extends Block {\n constructor(accessor: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(accessor);\n }\n\n append(accessor: string) {\n this._lines.push(accessor);\n return this;\n }\n\n toString() {\n return `[${this._lines.join(\",\")}]`\n }\n}\n\nexport class IfBuilder extends ContainerBlock {\n private _condition: string;\n\n constructor(condition: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._condition = condition;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n unshiftBody(line: string): this {\n this.unshift(line);\n return this;\n }\n\n private stringifyLine(line: Line) {\n if (typeof line === 'string') {\n return this.indent(\" \" + line);\n }\n\n if (Array.isArray(line)) {\n return line.join(\"\\r\\n\")\n }\n\n return line.toString();\n }\n\n toString(): string {\n // need to join with \\r\\n because we are not an object\n const lines = [\n this.indent(`if (${this._condition}) {`),\n this._lines.map(x => this.stringifyLine(x)).join(\"\\r\\n\"),\n this.indent(\"}\")\n ]\n\n return lines.join(\"\\n\\n\");\n }\n}\n\nexport class CodeBuilder extends ContainerBlock {\n\n private _bindings: Param[] = [];\n\n /**\n * Makes `value` available to the generated function under the returned name.\n *\n * Generated code must never reach a runtime value by its source name or by pasting its\n * source text: a minifier renames the declaration and cannot see inside the generated\n * string, and pasted source loses the scope it closed over (#40, #46). A binding is passed\n * in as a real value when the function is compiled, so it survives any bundler.\n */\n bind(value: unknown, name: string = `binding${this._bindings.length}`): string {\n this._bindings.push({ name, value });\n return name;\n }\n\n getBindings() {\n return [...this._bindings];\n }\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\n');\n }\n}","export const uuid = (length: number = 16): string => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charLength = chars.length;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.random() * charLength | 0];\n }\n return result;\n}\n\nconst HEX_CHARS = '0123456789abcdef';\nconst UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nconst hasCrypto =\n typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';\n\nconst hasRandomUUID =\n typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';\n\nexport const uuidv4 = (): string => {\n if (hasRandomUUID) {\n return crypto.randomUUID();\n }\n\n return uuidv4Fallback();\n};\n\nconst uuidv4Fallback = (): string => {\n let randomBytes: Uint8Array | null = null;\n if (hasCrypto) {\n randomBytes = crypto.getRandomValues(new Uint8Array(16));\n }\n\n let byteIndex = 0;\n let uuid = '';\n\n for (let i = 0; i < UUID_TEMPLATE.length; i++) {\n const c = UUID_TEMPLATE[i];\n if (c === '-') {\n uuid += '-';\n continue;\n }\n\n let r: number;\n if (hasCrypto && randomBytes) {\n // Each byte gives two hex digits (nibbles)\n r =\n (i % 2 === 0\n ? randomBytes[byteIndex] >> 4\n : randomBytes[byteIndex++] & 0x0f);\n } else {\n r = Math.floor(Math.random() * 16);\n }\n\n if (c === 'x') {\n uuid += HEX_CHARS[r];\n } else if (c === 'y') {\n // Variant bits: 8, 9, A, or B\n uuid += HEX_CHARS[(r & 0x3) | 0x8];\n } else if (c === '4') {\n uuid += '4';\n }\n }\n\n return uuid;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './blocks';\nexport * from './types';"],"names":["uuid","Block","name","parentIndent","parent","w","lines","block","indent","split","result","item","found","undefined","Error","x","line","foundIndex","text","ContainerBlock","condition","options","builder","IfBuilder","raw","RawBuilder","FunctionBuilder","FunctionFactoryBuilder","declaration","VariableBuilder","variableName","AssignmentBuilder","ObjectBuilder","SlotBlock","accessor","ArrayBuilder","StringBuilder","type","value","and","AndBuilder","objectBuilder","functionName","stringBuilder","arrayBuilder","lastLine","propertyName","isNestedContent","sectionName","params","parameter","body","parameterNames","parameterValues","Function","r","signature","Array","CodeBuilder","length","chars","charLength","i","Math","HEX_CHARS","UUID_TEMPLATE","hasCrypto","crypto","hasRandomUUID","uuidv4","uuidv4Fallback","randomBytes","Uint8Array","byteIndex","c"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAoC;AAS7B,MAAeC;IACT,KAAa;IACZ,SAAiB,EAAE,CAAC;IACpB,UAAkB,GAAG;IACrB,QAAgB;IAE1B,YAAYC,IAAa,EAAEC,eAAuB,EAAE,EAAEC,MAAc,CAAE;QAClE,IAAI,CAAC,IAAI,GAAGF,QAAQ,OAAOA,OAAOF,4CAAIA;QACtC,IAAI,CAAC,OAAO,GAAGG;QACf,IAAI,CAAC,OAAO,GAAGC;IACnB;IAEA,QAAQF,IAAY,EAAE;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAACG,CAAAA,IAAK,OAAOA,MAAM,YAAYA,EAAE,IAAI,KAAKH;IAC1E;IAEA,WAAW;QACP,OAAO,IAAI,CAAC,MAAM;IACtB;IAEA,YAAY;QACR,OAAO,IAAI,CAAC,OAAO;IACvB;IAEA,YAAY;QACR,OAAO,IAAI,CAAC,OAAO;IACvB;IAEA,SAASI,KAAa,EAAE;QACpB,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,UAAUC,KAAY,EAAE;QACpB,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEA,UAAUC,MAAc,EAAE;QACtB,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEA,aAA8BN,IAAY,EAAiB;QAEvD,IAAIA,KAAK,QAAQ,CAAC,SAAS,OAAO;YAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAACG,CAAAA,IAAK,OAAOA,MAAM,YAAYA,EAAE,IAAI,KAAKH;QACrE;QAEA,MAAMO,QAAQP,KAAK,KAAK,CAAC;QACzB,yCAAyC;QACzC,IAAIQ,SAAgB,IAAI;QAExB,KAAK,MAAMC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IAAI,MAAO,IAAI;QACtC,OAAO,IAAImB,MAAM,KAAK;YAClB1E,QAAQ;QACZ;IACJ;IAEA,OAAOA;AACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClEA;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D,E;;;;;;;;;;;;;;;;;;;;;;;ACNyB;AACD"}
@@ -356,6 +356,14 @@ class FunctionFactoryBuilder extends ContainerBlock {
356
356
  this._params.push(...params);
357
357
  return this;
358
358
  }
359
+ /**
360
+ * Adds a factory parameter carrying `value` and returns its name, for generated code to
361
+ * refer to. See `CodeBuilder.bind` for why values travel this way.
362
+ */ bind(value) {
363
+ const parameter = this.createParameter(value);
364
+ this._params.push(parameter);
365
+ return parameter.name;
366
+ }
359
367
  return() {
360
368
  this._return = true;
361
369
  return this;
@@ -471,6 +479,26 @@ class IfBuilder extends ContainerBlock {
471
479
  }
472
480
  }
473
481
  class CodeBuilder extends ContainerBlock {
482
+ _bindings = [];
483
+ /**
484
+ * Makes `value` available to the generated function under the returned name.
485
+ *
486
+ * Generated code must never reach a runtime value by its source name or by pasting its
487
+ * source text: a minifier renames the declaration and cannot see inside the generated
488
+ * string, and pasted source loses the scope it closed over (#40, #46). A binding is passed
489
+ * in as a real value when the function is compiled, so it survives any bundler.
490
+ */ bind(value, name = `binding${this._bindings.length}`) {
491
+ this._bindings.push({
492
+ name,
493
+ value
494
+ });
495
+ return name;
496
+ }
497
+ getBindings() {
498
+ return [
499
+ ...this._bindings
500
+ ];
501
+ }
474
502
  toString() {
475
503
  return this._lines.map((line)=>typeof line === 'string' ? this.indent(line) : line.toString()).join('\n\n');
476
504
  }
@@ -1 +1 @@
1
- {"version":3,"file":"codegen/index.js","sources":["webpack://@routier/core/./src/codegen/blocks.ts","webpack://@routier/core/./src/utilities/uuid.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/./src/codegen/index.ts"],"sourcesContent":["import { uuid } from \"../utilities\";\nimport { CreateBlockOptions } from \"./types\";\n\ntype Line = string | Block;\n\ntype Param = { name: string, value: any };\ntype GenericParam = { name: string, callName: string };\n\n\nexport abstract class Block {\n readonly name: string;\n protected _lines: Line[] = [];\n protected _indent: string = \"\";\n protected _parent?: Block;\n\n constructor(name?: string, parentIndent: string = \"\", parent?: Block) {\n this.name = name != null ? name : uuid();\n this._indent = parentIndent;\n this._parent = parent;\n }\n\n indexOf(name: string) {\n return this._lines.findIndex(w => typeof w !== \"string\" && w.name === name);\n }\n\n getLines() {\n return this._lines;\n }\n\n getParent() {\n return this._parent;\n }\n\n getIndent() {\n return this._indent;\n }\n\n setLines(lines: Line[]) {\n this._lines = lines;\n }\n\n setParent(block: Block) {\n this._parent = block;\n }\n\n setIndent(indent: string) {\n this._indent = indent;\n }\n\n getOrDefault<T extends Block>(name: string): T | undefined {\n\n if (name.includes('.') === false) {\n return this._lines.find(w => typeof w !== \"string\" && w.name === name) as T | undefined;\n }\n\n const split = name.match(/(\\[[^\\]]+\\]|[^.]+)/g);\n // oxlint-disable-next-line no-this-alias\n let result: Block = this;\n\n for (const item of split) {\n const found = result._lines.find(w => typeof w !== \"string\" && w.name === item) as Block;\n\n if (found == null) {\n\n if (\"getValue\" in result && result.getValue instanceof Block && result.getValue.name === item) {\n result = result.getValue;\n continue;\n }\n\n return undefined;\n }\n\n result = found;\n }\n\n return result as T;\n }\n\n get<T extends Block>(name: string): T {\n const found = this.getOrDefault(name);\n\n if (found == null) {\n throw new Error(`Error finding code block for given path. Path: ${name}`)\n }\n\n return found as T;\n }\n\n has(name: string) {\n return this._lines.some(w => typeof w !== \"string\" && w.name === name);\n }\n\n remove(name: string) {\n this._lines = this._lines.filter(x => typeof x === \"object\" && typeof x.name === \"string\" && x.name !== name);\n }\n\n replace(name: string, line: Block) {\n\n const foundIndex = this._lines.findIndex(x => typeof x !== \"string\" && x.name === name);\n\n if (foundIndex === -1) {\n throw new Error(`Cannot find line by name. Name: ${name}`)\n }\n\n const found = this._lines[foundIndex];\n\n if (typeof found === \"string\") {\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n return;\n }\n\n line.setLines(found.getLines());\n line.setIndent(found.getIndent());\n line.setParent(found.getParent());\n\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n\n return;\n }\n\n protected push(line: Line) {\n this._lines.push(line);\n }\n\n protected unshift(line: Line) {\n this._lines.unshift(line);\n }\n\n protected indent(text: string): string {\n return this._indent + text;\n }\n\n\n abstract toString(): string;\n}\n\nexport abstract class ContainerBlock extends Block {\n if(condition: string, options?: CreateBlockOptions): IfBuilder {\n const builder = new IfBuilder(condition, options?.name, this._indent + \" \", this);\n if (options?.unshift === true) {\n this.unshift(builder);\n } else {\n this.push(builder);\n }\n\n return builder;\n }\n\n raw(raw: string, options?: CreateBlockOptions): RawBuilder {\n const builder = new RawBuilder(raw, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n function(name?: string, options?: CreateBlockOptions): FunctionBuilder {\n const builder = new FunctionBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n factory(name?: string, options?: CreateBlockOptions): FunctionFactoryBuilder {\n const builder = new FunctionFactoryBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n variable(declaration: string, options?: CreateBlockOptions): VariableBuilder {\n const builder = new VariableBuilder(declaration, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n assign(variableName: string, options?: CreateBlockOptions): AssignmentBuilder {\n const builder = new AssignmentBuilder(variableName, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const builder = new ObjectBuilder(options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n slot(name: string) {\n const builder = new SlotBlock(name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n array(accessor: string, options?: CreateBlockOptions) {\n const builder = new ArrayBuilder(accessor, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n}\n\nexport type StringType = \"template\" | \"default\";\n\nexport class StringBuilder extends Block {\n\n private _type: StringType;\n\n constructor(type: StringType, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._type = type;\n }\n\n append(value: string) {\n this._lines.push(value);\n return this;\n }\n\n toString() {\n if (this._type === \"template\") {\n return \"`\" + this._lines.join(\"\") + \"`\";\n }\n\n return `\"${this._lines.join(\"\")}\"`;\n }\n}\n\nexport class SlotBlock extends ContainerBlock {\n\n constructor(name: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n }\n\n insert(line: string | Block) {\n this.push(line);\n }\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\n');\n }\n}\n\nexport class AssignmentBuilder extends ContainerBlock {\n protected _variableName: string;\n protected _value?: string | Block;\n protected _functionName?: string;\n\n get getValue() {\n return this._value;\n }\n\n constructor(variableName: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._variableName = variableName;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n and(and: string, options?: CreateBlockOptions): this {\n this._value = new AndBuilder(and, options?.name, this._indent, this);\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n call(functionName: string, options?: CreateBlockOptions): ObjectBuilder {\n this._functionName = functionName;\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n string(type: StringType, options?: CreateBlockOptions) {\n const stringBuilder = new StringBuilder(type, options?.name, this._indent, this);\n\n this._value = stringBuilder;\n\n return stringBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for AssignmentBuilder Builder\")\n }\n\n if (this._functionName != null) {\n return this.indent(`${this._variableName} = ${this._functionName}(${this._value.toString()});`);\n }\n\n return this.indent(`${this._variableName} = ${this._value.toString()};`);\n }\n}\n\nexport class AndBuilder extends ContainerBlock {\n\n constructor(and: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(and);\n }\n\n and(and: string) {\n this._lines.push(and);\n }\n\n toString() {\n return this._lines.join(\" && \")\n }\n}\n\nexport class VariableBuilder extends Block {\n protected _declaration: string;\n protected _value?: string | Block;\n\n get getValue() {\n return this._value;\n }\n\n constructor(declaration: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._declaration = declaration;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n array(accessor: string, options?: CreateBlockOptions): ArrayBuilder {\n const arrayBuilder = new ArrayBuilder(accessor, options?.name, this._indent, this);\n\n this._value = arrayBuilder;\n\n return arrayBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for Variable Builder\")\n }\n\n return this.indent(`const ${this._declaration} = ${this._value.toString()};`);\n }\n}\n\nexport class RawBuilder extends ContainerBlock {\n private _raw: string;\n\n constructor(raw: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._raw = raw;\n }\n\n toString(): string {\n return `${this._raw}\\n`;\n }\n}\n\nexport class ObjectBuilder extends Block {\n\n property(line: string) {\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n this.push(line);\n return this;\n }\n\n nested(propertyName: string, name?: string) {\n const builder = new ObjectBuilder(name, this._indent + \" \", this);\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n // Add the property name and opening brace\n this.push(`${propertyName}: {`);\n // Add the nested builder\n this.push(builder);\n // Add the closing brace\n this.push(\"}\");\n return builder;\n }\n\n toString(): string {\n // Check if this is a nested object's content\n const isNestedContent = this._parent instanceof ObjectBuilder;\n\n if (isNestedContent) {\n // For nested object contents, just return the lines\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ).join('\\n');\n }\n\n // For root objects, include the braces\n const lines = [\n \"{\",\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionFactoryBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: Param[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n getParameters() {\n return [...this._params];\n }\n\n createParameter(value: any): Param {\n const name = `injection${this._params.length}`;\n return {\n name,\n value\n }\n }\n\n parameters(...params: Param[]): this {\n this._params.push(...params);\n return this;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n invoke() {\n const body = this.toString();\n const parameterNames = this._getParameterNames();\n const parameterValues = this._getParameterValues();\n\n return Function(...parameterNames, body)(...parameterValues)\n }\n\n private _getParameterNames() {\n return this._params.map(w => w.name).join(\", \")\n }\n\n private _getParameterValues() {\n return this._params.map(w => w.value);\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterNames()})`\n : `${r}function(${this._getParameterNames()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: (string | GenericParam)[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n parameters(...params: (string | GenericParam)[]): this {\n this._params.push(...params);\n return this;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n private _getParameterKeys() {\n return this._params.map(w => typeof w === \"object\" ? w.name : w).join(\", \")\n }\n\n toCallable() {\n return `${this._functionName}(${this._params.map(w => typeof w === \"object\" ? w.callName : w).join(\", \")})`\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterKeys()})`\n : `${r}function(${this._getParameterKeys()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class ArrayBuilder extends Block {\n constructor(accessor: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(accessor);\n }\n\n append(accessor: string) {\n this._lines.push(accessor);\n return this;\n }\n\n toString() {\n return `[${this._lines.join(\",\")}]`\n }\n}\n\nexport class IfBuilder extends ContainerBlock {\n private _condition: string;\n\n constructor(condition: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._condition = condition;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n unshiftBody(line: string): this {\n this.unshift(line);\n return this;\n }\n\n private stringifyLine(line: Line) {\n if (typeof line === 'string') {\n return this.indent(\" \" + line);\n }\n\n if (Array.isArray(line)) {\n return line.join(\"\\r\\n\")\n }\n\n return line.toString();\n }\n\n toString(): string {\n // need to join with \\r\\n because we are not an object\n const lines = [\n this.indent(`if (${this._condition}) {`),\n this._lines.map(x => this.stringifyLine(x)).join(\"\\r\\n\"),\n this.indent(\"}\")\n ]\n\n return lines.join(\"\\n\\n\");\n }\n}\n\nexport class CodeBuilder extends ContainerBlock {\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\n');\n }\n}","export const uuid = (length: number = 16): string => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charLength = chars.length;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.random() * charLength | 0];\n }\n return result;\n}\n\nconst HEX_CHARS = '0123456789abcdef';\nconst UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nconst hasCrypto =\n typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';\n\nconst hasRandomUUID =\n typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';\n\nexport const uuidv4 = (): string => {\n if (hasRandomUUID) {\n return crypto.randomUUID();\n }\n\n return uuidv4Fallback();\n};\n\nconst uuidv4Fallback = (): string => {\n let randomBytes: Uint8Array | null = null;\n if (hasCrypto) {\n randomBytes = crypto.getRandomValues(new Uint8Array(16));\n }\n\n let byteIndex = 0;\n let uuid = '';\n\n for (let i = 0; i < UUID_TEMPLATE.length; i++) {\n const c = UUID_TEMPLATE[i];\n if (c === '-') {\n uuid += '-';\n continue;\n }\n\n let r: number;\n if (hasCrypto && randomBytes) {\n // Each byte gives two hex digits (nibbles)\n r =\n (i % 2 === 0\n ? randomBytes[byteIndex] >> 4\n : randomBytes[byteIndex++] & 0x0f);\n } else {\n r = Math.floor(Math.random() * 16);\n }\n\n if (c === 'x') {\n uuid += HEX_CHARS[r];\n } else if (c === 'y') {\n // Variant bits: 8, 9, A, or B\n uuid += HEX_CHARS[(r & 0x3) | 0x8];\n } else if (c === '4') {\n uuid += '4';\n }\n }\n\n return uuid;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","export * from './blocks';\nexport * from './types';"],"names":["uuid","Block","name","parentIndent","parent","w","lines","block","indent","split","result","item","found","undefined","Error","x","line","foundIndex","text","ContainerBlock","condition","options","builder","IfBuilder","raw","RawBuilder","FunctionBuilder","FunctionFactoryBuilder","declaration","VariableBuilder","variableName","AssignmentBuilder","ObjectBuilder","SlotBlock","accessor","ArrayBuilder","StringBuilder","type","value","and","AndBuilder","objectBuilder","functionName","stringBuilder","arrayBuilder","lastLine","propertyName","isNestedContent","sectionName","params","body","parameterNames","parameterValues","Function","r","signature","Array","CodeBuilder","length","chars","charLength","i","Math","HEX_CHARS","UUID_TEMPLATE","hasCrypto","crypto","hasRandomUUID","uuidv4","uuidv4Fallback","randomBytes","Uint8Array","byteIndex","c"],"mappings":";;;;;;;;;;;;;;;;;;;AAAoC;AAS7B,MAAeC;IACT,KAAa;IACZ,SAAiB,EAAE,CAAC;IACpB,UAAkB,GAAG;IACrB,QAAgB;IAE1B,YAAYC,IAAa,EAAEC,eAAuB,EAAE,EAAEC,MAAc,CAAE;QAClE,IAAI,CAAC,IAAI,GAAGF,QAAQ,OAAOA,OAAOF,4CAAIA;QACtC,IAAI,CAAC,OAAO,GAAGG;QACf,IAAI,CAAC,OAAO,GAAGC;IACnB;IAEA,QAAQF,IAAY,EAAE;QAClB,OAAO,IAAI,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AW,CAACE,UAAU,IAAI,IAC1BF,WAAW,CAACE,YAAY,GAAG;QACzC,OAAO;YACHlB,IAAIQ,KAAK,KAAK,CAACA,KAAK,MAAM,KAAK;QACnC;QAEA,IAAIW,MAAM,KAAK;YACXzE,QAAQ+D,SAAS,CAACT,EAAE;QACxB,OAAO,IAAImB,MAAM,KAAK;YAClB,8BAA8B;YAC9BzE,QAAQ+D,SAAS,CAAET,IAAI,MAAO,IAAI;QACtC,OAAO,IAAImB,MAAM,KAAK;YAClBzE,QAAQ;QACZ;IACJ;IAEA,OAAOA;AACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClEA;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;;;;;;;;;;;;;;;;;;;ACAyB;AACD"}
1
+ {"version":3,"file":"codegen/index.js","sources":["webpack://@routier/core/./src/codegen/blocks.ts","webpack://@routier/core/./src/utilities/uuid.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/./src/codegen/index.ts"],"sourcesContent":["import { uuid } from \"../utilities\";\nimport { CreateBlockOptions } from \"./types\";\n\ntype Line = string | Block;\n\nexport type Param = { name: string, value: any };\ntype GenericParam = { name: string, callName: string };\n\n\nexport abstract class Block {\n readonly name: string;\n protected _lines: Line[] = [];\n protected _indent: string = \"\";\n protected _parent?: Block;\n\n constructor(name?: string, parentIndent: string = \"\", parent?: Block) {\n this.name = name != null ? name : uuid();\n this._indent = parentIndent;\n this._parent = parent;\n }\n\n indexOf(name: string) {\n return this._lines.findIndex(w => typeof w !== \"string\" && w.name === name);\n }\n\n getLines() {\n return this._lines;\n }\n\n getParent() {\n return this._parent;\n }\n\n getIndent() {\n return this._indent;\n }\n\n setLines(lines: Line[]) {\n this._lines = lines;\n }\n\n setParent(block: Block) {\n this._parent = block;\n }\n\n setIndent(indent: string) {\n this._indent = indent;\n }\n\n getOrDefault<T extends Block>(name: string): T | undefined {\n\n if (name.includes('.') === false) {\n return this._lines.find(w => typeof w !== \"string\" && w.name === name) as T | undefined;\n }\n\n const split = name.match(/(\\[[^\\]]+\\]|[^.]+)/g);\n // oxlint-disable-next-line no-this-alias\n let result: Block = this;\n\n for (const item of split) {\n const found = result._lines.find(w => typeof w !== \"string\" && w.name === item) as Block;\n\n if (found == null) {\n\n if (\"getValue\" in result && result.getValue instanceof Block && result.getValue.name === item) {\n result = result.getValue;\n continue;\n }\n\n return undefined;\n }\n\n result = found;\n }\n\n return result as T;\n }\n\n get<T extends Block>(name: string): T {\n const found = this.getOrDefault(name);\n\n if (found == null) {\n throw new Error(`Error finding code block for given path. Path: ${name}`)\n }\n\n return found as T;\n }\n\n has(name: string) {\n return this._lines.some(w => typeof w !== \"string\" && w.name === name);\n }\n\n remove(name: string) {\n this._lines = this._lines.filter(x => typeof x === \"object\" && typeof x.name === \"string\" && x.name !== name);\n }\n\n replace(name: string, line: Block) {\n\n const foundIndex = this._lines.findIndex(x => typeof x !== \"string\" && x.name === name);\n\n if (foundIndex === -1) {\n throw new Error(`Cannot find line by name. Name: ${name}`)\n }\n\n const found = this._lines[foundIndex];\n\n if (typeof found === \"string\") {\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n return;\n }\n\n line.setLines(found.getLines());\n line.setIndent(found.getIndent());\n line.setParent(found.getParent());\n\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n\n return;\n }\n\n protected push(line: Line) {\n this._lines.push(line);\n }\n\n protected unshift(line: Line) {\n this._lines.unshift(line);\n }\n\n protected indent(text: string): string {\n return this._indent + text;\n }\n\n\n abstract toString(): string;\n}\n\nexport abstract class ContainerBlock extends Block {\n if(condition: string, options?: CreateBlockOptions): IfBuilder {\n const builder = new IfBuilder(condition, options?.name, this._indent + \" \", this);\n if (options?.unshift === true) {\n this.unshift(builder);\n } else {\n this.push(builder);\n }\n\n return builder;\n }\n\n raw(raw: string, options?: CreateBlockOptions): RawBuilder {\n const builder = new RawBuilder(raw, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n function(name?: string, options?: CreateBlockOptions): FunctionBuilder {\n const builder = new FunctionBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n factory(name?: string, options?: CreateBlockOptions): FunctionFactoryBuilder {\n const builder = new FunctionFactoryBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n variable(declaration: string, options?: CreateBlockOptions): VariableBuilder {\n const builder = new VariableBuilder(declaration, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n assign(variableName: string, options?: CreateBlockOptions): AssignmentBuilder {\n const builder = new AssignmentBuilder(variableName, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const builder = new ObjectBuilder(options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n slot(name: string) {\n const builder = new SlotBlock(name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n array(accessor: string, options?: CreateBlockOptions) {\n const builder = new ArrayBuilder(accessor, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n}\n\nexport type StringType = \"template\" | \"default\";\n\nexport class StringBuilder extends Block {\n\n private _type: StringType;\n\n constructor(type: StringType, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._type = type;\n }\n\n append(value: string) {\n this._lines.push(value);\n return this;\n }\n\n toString() {\n if (this._type === \"template\") {\n return \"`\" + this._lines.join(\"\") + \"`\";\n }\n\n return `\"${this._lines.join(\"\")}\"`;\n }\n}\n\nexport class SlotBlock extends ContainerBlock {\n\n constructor(name: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n }\n\n insert(line: string | Block) {\n this.push(line);\n }\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\n');\n }\n}\n\nexport class AssignmentBuilder extends ContainerBlock {\n protected _variableName: string;\n protected _value?: string | Block;\n protected _functionName?: string;\n\n get getValue() {\n return this._value;\n }\n\n constructor(variableName: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._variableName = variableName;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n and(and: string, options?: CreateBlockOptions): this {\n this._value = new AndBuilder(and, options?.name, this._indent, this);\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n call(functionName: string, options?: CreateBlockOptions): ObjectBuilder {\n this._functionName = functionName;\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n string(type: StringType, options?: CreateBlockOptions) {\n const stringBuilder = new StringBuilder(type, options?.name, this._indent, this);\n\n this._value = stringBuilder;\n\n return stringBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for AssignmentBuilder Builder\")\n }\n\n if (this._functionName != null) {\n return this.indent(`${this._variableName} = ${this._functionName}(${this._value.toString()});`);\n }\n\n return this.indent(`${this._variableName} = ${this._value.toString()};`);\n }\n}\n\nexport class AndBuilder extends ContainerBlock {\n\n constructor(and: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(and);\n }\n\n and(and: string) {\n this._lines.push(and);\n }\n\n toString() {\n return this._lines.join(\" && \")\n }\n}\n\nexport class VariableBuilder extends Block {\n protected _declaration: string;\n protected _value?: string | Block;\n\n get getValue() {\n return this._value;\n }\n\n constructor(declaration: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._declaration = declaration;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n array(accessor: string, options?: CreateBlockOptions): ArrayBuilder {\n const arrayBuilder = new ArrayBuilder(accessor, options?.name, this._indent, this);\n\n this._value = arrayBuilder;\n\n return arrayBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for Variable Builder\")\n }\n\n return this.indent(`const ${this._declaration} = ${this._value.toString()};`);\n }\n}\n\nexport class RawBuilder extends ContainerBlock {\n private _raw: string;\n\n constructor(raw: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._raw = raw;\n }\n\n toString(): string {\n return `${this._raw}\\n`;\n }\n}\n\nexport class ObjectBuilder extends Block {\n\n property(line: string) {\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n this.push(line);\n return this;\n }\n\n nested(propertyName: string, name?: string) {\n const builder = new ObjectBuilder(name, this._indent + \" \", this);\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n // Add the property name and opening brace\n this.push(`${propertyName}: {`);\n // Add the nested builder\n this.push(builder);\n // Add the closing brace\n this.push(\"}\");\n return builder;\n }\n\n toString(): string {\n // Check if this is a nested object's content\n const isNestedContent = this._parent instanceof ObjectBuilder;\n\n if (isNestedContent) {\n // For nested object contents, just return the lines\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ).join('\\n');\n }\n\n // For root objects, include the braces\n const lines = [\n \"{\",\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionFactoryBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: Param[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n getParameters() {\n return [...this._params];\n }\n\n createParameter(value: any): Param {\n const name = `injection${this._params.length}`;\n return {\n name,\n value\n }\n }\n\n parameters(...params: Param[]): this {\n this._params.push(...params);\n return this;\n }\n\n /**\n * Adds a factory parameter carrying `value` and returns its name, for generated code to\n * refer to. See `CodeBuilder.bind` for why values travel this way.\n */\n bind(value: unknown): string {\n const parameter = this.createParameter(value);\n this._params.push(parameter);\n return parameter.name;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n invoke() {\n const body = this.toString();\n const parameterNames = this._getParameterNames();\n const parameterValues = this._getParameterValues();\n\n return Function(...parameterNames, body)(...parameterValues)\n }\n\n private _getParameterNames() {\n return this._params.map(w => w.name).join(\", \")\n }\n\n private _getParameterValues() {\n return this._params.map(w => w.value);\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterNames()})`\n : `${r}function(${this._getParameterNames()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: (string | GenericParam)[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n parameters(...params: (string | GenericParam)[]): this {\n this._params.push(...params);\n return this;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n private _getParameterKeys() {\n return this._params.map(w => typeof w === \"object\" ? w.name : w).join(\", \")\n }\n\n toCallable() {\n return `${this._functionName}(${this._params.map(w => typeof w === \"object\" ? w.callName : w).join(\", \")})`\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterKeys()})`\n : `${r}function(${this._getParameterKeys()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class ArrayBuilder extends Block {\n constructor(accessor: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(accessor);\n }\n\n append(accessor: string) {\n this._lines.push(accessor);\n return this;\n }\n\n toString() {\n return `[${this._lines.join(\",\")}]`\n }\n}\n\nexport class IfBuilder extends ContainerBlock {\n private _condition: string;\n\n constructor(condition: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._condition = condition;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n unshiftBody(line: string): this {\n this.unshift(line);\n return this;\n }\n\n private stringifyLine(line: Line) {\n if (typeof line === 'string') {\n return this.indent(\" \" + line);\n }\n\n if (Array.isArray(line)) {\n return line.join(\"\\r\\n\")\n }\n\n return line.toString();\n }\n\n toString(): string {\n // need to join with \\r\\n because we are not an object\n const lines = [\n this.indent(`if (${this._condition}) {`),\n this._lines.map(x => this.stringifyLine(x)).join(\"\\r\\n\"),\n this.indent(\"}\")\n ]\n\n return lines.join(\"\\n\\n\");\n }\n}\n\nexport class CodeBuilder extends ContainerBlock {\n\n private _bindings: Param[] = [];\n\n /**\n * Makes `value` available to the generated function under the returned name.\n *\n * Generated code must never reach a runtime value by its source name or by pasting its\n * source text: a minifier renames the declaration and cannot see inside the generated\n * string, and pasted source loses the scope it closed over (#40, #46). A binding is passed\n * in as a real value when the function is compiled, so it survives any bundler.\n */\n bind(value: unknown, name: string = `binding${this._bindings.length}`): string {\n this._bindings.push({ name, value });\n return name;\n }\n\n getBindings() {\n return [...this._bindings];\n }\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\n');\n }\n}","export const uuid = (length: number = 16): string => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charLength = chars.length;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.random() * charLength | 0];\n }\n return result;\n}\n\nconst HEX_CHARS = '0123456789abcdef';\nconst UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nconst hasCrypto =\n typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';\n\nconst hasRandomUUID =\n typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';\n\nexport const uuidv4 = (): string => {\n if (hasRandomUUID) {\n return crypto.randomUUID();\n }\n\n return uuidv4Fallback();\n};\n\nconst uuidv4Fallback = (): string => {\n let randomBytes: Uint8Array | null = null;\n if (hasCrypto) {\n randomBytes = crypto.getRandomValues(new Uint8Array(16));\n }\n\n let byteIndex = 0;\n let uuid = '';\n\n for (let i = 0; i < UUID_TEMPLATE.length; i++) {\n const c = UUID_TEMPLATE[i];\n if (c === '-') {\n uuid += '-';\n continue;\n }\n\n let r: number;\n if (hasCrypto && randomBytes) {\n // Each byte gives two hex digits (nibbles)\n r =\n (i % 2 === 0\n ? randomBytes[byteIndex] >> 4\n : randomBytes[byteIndex++] & 0x0f);\n } else {\n r = Math.floor(Math.random() * 16);\n }\n\n if (c === 'x') {\n uuid += HEX_CHARS[r];\n } else if (c === 'y') {\n // Variant bits: 8, 9, A, or B\n uuid += HEX_CHARS[(r & 0x3) | 0x8];\n } else if (c === '4') {\n uuid += '4';\n }\n }\n\n return uuid;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","export * from './blocks';\nexport * from './types';"],"names":["uuid","Block","name","parentIndent","parent","w","lines","block","indent","split","result","item","found","undefined","Error","x","line","foundIndex","text","ContainerBlock","condition","options","builder","IfBuilder","raw","RawBuilder","FunctionBuilder","FunctionFactoryBuilder","declaration","VariableBuilder","variableName","AssignmentBuilder","ObjectBuilder","SlotBlock","accessor","ArrayBuilder","StringBuilder","type","value","and","AndBuilder","objectBuilder","functionName","stringBuilder","arrayBuilder","lastLine","propertyName","isNestedContent","sectionName","params","parameter","body","parameterNames","parameterValues","Function","r","signature","Array","CodeBuilder","length","chars","charLength","i","Math","HEX_CHARS","UUID_TEMPLATE","hasCrypto","crypto","hasRandomUUID","uuidv4","uuidv4Fallback","randomBytes","Uint8Array","byteIndex","c"],"mappings":";;;;;;;;;;;;;;;;;;;AAAoC;AAS7B,MAAeC;IACT,KAAa;IACZ,SAAiB,EAAE,CAAC;IACpB,UAAkB,GAAG;IACrB,QAAgB;IAE1B,YAAYC,IAAa,EAAEC,eAAuB,EAAE,EAAEC,MAAc,CAAE;QAClE,IAAI,CAAC,IAAI,GAAGF,QAAQ,OAAOA,OAAOF,4CAAIA;QACtC,IAAI,CAAC,OAAO,GAAGG;QACf,IAAI,CAAC,OAAO,GAAGC;IACnB;IAEA,QAAQF,IAAY,EAAE;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAACG,CAAAA,IAAK,OAAOA,MAAM,YAAYA,EAAE,IAAI,KAAKH;IAC1E;IAEA,WAAW;QACP,OAAO,IAAI,CAAC,MAAM;IACtB;IAEA,YAAY;QACR,OAAO,IAAI,CAAC,OAAO;IACvB;IAEA,YA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X,IAAK,IAAI8D,IAAI,GAAGA,IAAIG,cAAc,MAAM,EAAEH,IAAK;QAC3C,MAAMY,IAAIT,aAAa,CAACH,EAAE;QAC1B,IAAIY,MAAM,KAAK;YACX1E,QAAQ;YACR;QACJ;QAEA,IAAIuD;QACJ,IAAIW,aAAaK,aAAa;YAC1B,2CAA2C;YAC3ChB,IACKO,IAAI,MAAM,IACLS,WAAW,CAACE,UAAU,IAAI,IAC1BF,WAAW,CAACE,YAAY,GAAG;QACzC,OAAO;YACHlB,IAAIQ,KAAK,KAAK,CAACA,KAAK,MAAM,KAAK;QACnC;QAEA,IAAIW,MAAM,KAAK;YACX1E,QAAQgE,SAAS,CAACT,EAAE;QACxB,OAAO,IAAImB,MAAM,KAAK;YAClB,8BAA8B;YAC9B1E,QAAQgE,SAAS,CAAET,IAAI,MAAO,IAAI;QACtC,OAAO,IAAImB,MAAM,KAAK;YAClB1E,QAAQ;QACZ;IACJ;IAEA,OAAOA;AACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClEA;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;;;;;;;;;;;;;;;;;;;ACAyB;AACD"}
@@ -13,14 +13,12 @@ export declare class MemoryDataCollection {
13
13
  private _getNextId;
14
14
  private resolveId;
15
15
  private getAndSetId;
16
- private _dateColumns?;
17
- /** Date columns, by the name a stored record uses. Nested dates live inside a JSON column. */
18
- private get dateColumns();
19
16
  /**
20
17
  * The record this collection keeps.
21
18
  *
22
19
  * A copy, so a caller holding the entity cannot write into the store afterwards. Dates are held
23
- * as Dates: a predicate compares a Date, and a stored ISO string never matches one.
20
+ * as Dates, at the root, in objects and in arrays: a predicate compares a Date, and a stored ISO
21
+ * string never matches one. A durable subclass hydrates parsed JSON through here too.
24
22
  */
25
23
  private toStored;
26
24
  seed(items: Record<string, unknown>[]): void;