@pwfabric/runtime 1.2.0 → 2.1.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.
- package/LICENSE +2 -2
- package/README.md +1 -1
- package/dist/binding/expression.js +4 -1
- package/dist/binding/expression.js.map +1 -1
- package/dist/connectors/types.d.ts +4 -2
- package/dist/connectors/types.js +4 -2
- package/dist/connectors/types.js.map +1 -1
- package/dist/entity/http-connector.js +1 -1
- package/dist/entity/http-connector.js.map +1 -1
- package/dist/entity/registry.js +1 -1
- package/dist/entity/registry.js.map +1 -1
- package/dist/forms/validator.js +1 -1
- package/dist/forms/validator.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/render/DataBoundSurfaceRenderer.d.ts +10 -0
- package/dist/render/DataBoundSurfaceRenderer.js +45 -11
- package/dist/render/DataBoundSurfaceRenderer.js.map +1 -1
- package/dist/render/data-binding-types.d.ts +13 -2
- package/dist/render/data-binding-types.js.map +1 -1
- package/dist/render/index.d.ts +3 -1
- package/dist/render/index.js +2 -1
- package/dist/render/index.js.map +1 -1
- package/dist/render/links.d.ts +50 -0
- package/dist/render/links.js +78 -0
- package/dist/render/links.js.map +1 -0
- package/dist/render/resolve-expressions.d.ts +22 -1
- package/dist/render/resolve-expressions.js +65 -5
- package/dist/render/resolve-expressions.js.map +1 -1
- package/dist/render/scoped-css.d.ts +8 -1
- package/dist/render/scoped-css.js +16 -0
- package/dist/render/scoped-css.js.map +1 -1
- package/dist/surface/expression.js +0 -1
- package/dist/surface/expression.js.map +1 -1
- package/dist/surface/output.js +4 -4
- package/dist/surface/output.js.map +1 -1
- package/dist/surface/schemas.d.ts +28 -96
- package/dist/surface/schemas.js +3 -3
- package/dist/surface/schemas.js.map +1 -1
- package/dist/surface/transforms.d.ts +7 -33
- package/dist/surface/transforms.js +2 -2
- package/dist/surface/transforms.js.map +1 -1
- package/dist/surface/validation.js +1 -1
- package/dist/surface/validation.js.map +1 -1
- package/dist/validator.js +1 -1
- package/dist/validator.js.map +1 -1
- package/package.json +8 -8
package/dist/entity/registry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/entity/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsDH,+DAA+D;AAC/D,4BAA4B;AAC5B,+DAA+D;AAE/D;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAChB,WAAW,GAAG,IAAI,GAAG,EAAkC,CAAA;IAExE,QAAQ,CAAC,UAA4B;QACnC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;QACtD,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;QACvD,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;QACzD,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;QAC7D,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,gBAAgB,UAAU,CAAC,EAAE,yBAAyB,CAAC,CAAA;QACzE,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,CAAA;IACjD,CAAC;IAED,GAAG,CAAC,EAAgB;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACjC,CAAC;IAED,GAAG,CAAC,EAAgB;QAClB,OAAO,IAAI,CAAC,WAA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,IAAI,EAAE,kBAAkB;qBACzB;iBACF;aACF,CAAA;QACH,CAAC;QAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAEhD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO;gBACL,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,MAAM,CAAC,IAA+B;aAC7C,CAAA;QACH,CAAC;QAED,MAAM,MAAM,GAA4B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC1E,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO;YAClD,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC,CAAA;QAEH,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM;SACP,CAAA;IACH,CAAC;IAED,UAAU,CAAC,EAAgB;QACzB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACpC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC;CACF;AAED,+DAA+D;AAC/D,mBAAmB;AACnB,+DAA+D;AAE/D;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,sBAAsB,EAAE,CAAA;AACrC,CAAC","sourcesContent":["/**\n * Entity Registry\n *\n * Registration and lookup of entity definitions with Zod-based validation.\n *\n * @module @pwfabric/runtime/entity/registry\n */\n\nimport type {\n EntityTypeId,\n EntityDefinition,\n EntityValidationResult,\n EntityValidationError,\n} from './types.js'\n\n// ============================================================\n// ENTITY REGISTRY INTERFACE\n// ============================================================\n\n/**\n * Registry for entity type definitions\n */\nexport interface EntityRegistry {\n /**\n * Register an entity definition\n * @throws Error if definition with the same id is already registered\n */\n register(definition: EntityDefinition): void\n\n /**\n * Get an entity definition by id\n */\n get(id: EntityTypeId): EntityDefinition | undefined\n\n /**\n * Check if an entity definition is registered\n */\n has(id: EntityTypeId): boolean\n\n /**\n * List all registered entity type ids\n */\n list(): readonly EntityTypeId[]\n\n /**\n * Validate data against an entity definition's Zod schema\n */\n validate(id: EntityTypeId, data: unknown): EntityValidationResult\n\n /**\n * Remove an entity definition\n */\n unregister(id: EntityTypeId): boolean\n\n /**\n * Remove all entity definitions\n */\n clear(): void\n}\n\n// ============================================================\n// IN-MEMORY ENTITY REGISTRY\n// ============================================================\n\n/**\n * In-memory implementation of EntityRegistry\n */\nexport class InMemoryEntityRegistry implements EntityRegistry {\n private readonly definitions = new Map<EntityTypeId, EntityDefinition>()\n\n register(definition: EntityDefinition): void {\n if (!definition.id) {\n throw new Error('Entity definition must have an id')\n }\n\n if (!definition.name) {\n throw new Error('Entity definition must have a name')\n }\n\n if (!definition.schema) {\n throw new Error('Entity definition must have a schema')\n }\n\n if (!definition.primaryKey) {\n throw new Error('Entity definition must have a primaryKey')\n }\n\n if (this.definitions.has(definition.id)) {\n throw new Error(`Entity type '${definition.id}' is already registered`)\n }\n\n this.definitions.set(definition.id, definition)\n }\n\n get(id: EntityTypeId): EntityDefinition | undefined {\n return this.definitions.get(id)\n }\n\n has(id: EntityTypeId): boolean {\n return this.definitions.has(id)\n }\n\n list(): readonly EntityTypeId[] {\n return Array.from(this.definitions.keys())\n }\n\n validate(id: EntityTypeId, data: unknown): EntityValidationResult {\n const definition = this.definitions.get(id)\n if (!definition) {\n return {\n valid: false,\n errors: [\n {\n field: '_entity',\n message: `Entity type '${id}' is not registered`,\n code: 'entity_not_found',\n },\n ],\n }\n }\n\n const result = definition.schema.safeParse(data)\n\n if (result.success) {\n return {\n valid: true,\n data: result.data as Record<string, unknown>,\n }\n }\n\n const errors: EntityValidationError[] = result.error.issues.map((issue) => ({\n field: issue.path.map(String).join('.') || '_root',\n message: issue.message,\n code: issue.code,\n }))\n\n return {\n valid: false,\n errors,\n }\n }\n\n unregister(id: EntityTypeId): boolean {\n return this.definitions.delete(id)\n }\n\n clear(): void {\n this.definitions.clear()\n }\n}\n\n// ============================================================\n// FACTORY FUNCTION\n// ============================================================\n\n/**\n * Create an entity registry\n */\nexport function createEntityRegistry(): EntityRegistry {\n return new InMemoryEntityRegistry()\n}\n"]}
|
package/dist/forms/validator.js
CHANGED
|
@@ -169,7 +169,7 @@ export function validateWithZod(values, schema) {
|
|
|
169
169
|
function formatZodErrors(error) {
|
|
170
170
|
const errors = {};
|
|
171
171
|
for (const issue of error.issues) {
|
|
172
|
-
const path = issue.path.join('.');
|
|
172
|
+
const path = issue.path.map(String).join('.');
|
|
173
173
|
if (!errors[path]) {
|
|
174
174
|
errors[path] = [];
|
|
175
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/forms/validator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAA+B,MAAM,KAAK,CAAA;AAQpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAExD,+DAA+D;AAC/D,yBAAyB;AACzB,+DAA+D;AAE/D;;GAEG;AACH,MAAM,OAAO,oBAAoB;IACd,QAAQ,CAAoB;IAE7C,YAAY,iBAA8C,EAAE;QAC1D,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,2BAA2B,EAAE,GAAG,cAAc,EAAE,CAAA;IACvE,CAAC;IAED,aAAa,CAAC,KAAc,EAAE,KAAgB;QAC5C,MAAM,MAAM,GAAa,EAAE,CAAA;QAE3B,iBAAiB;QACjB,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;YACnC,OAAO,MAA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0B,CAAC;IAE/C;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAAE,mCAAmC,CAAC;IAE/E;;OAEG;IACH,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,wCAAwC,CAAC;SAChD,KAAK,CAAC,UAAU,EAAE,2CAA2C,CAAC;SAC9D,KAAK,CAAC,OAAO,EAAE,2CAA2C,CAAC;CAC/D,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,cAA4C;IAC9E,OAAO,IAAI,oBAAoB,CAAC,cAAc,CAAC,CAAA;AACjD,CAAC","sourcesContent":["/**\n * Form Validator\n *\n * Form validation implementation\n *\n * @module @pwfabric/runtime/forms/validator\n */\n\nimport { z, type ZodType, type ZodError } from 'zod'\nimport type {\n FormValidator,\n FormField,\n ValidationRule,\n FormValidationResult,\n ValidationMessages,\n} from './types.js'\nimport { DEFAULT_VALIDATION_MESSAGES } from './types.js'\n\n// ============================================================\n// DEFAULT FORM VALIDATOR\n// ============================================================\n\n/**\n * Default form validator implementation\n */\nexport class DefaultFormValidator implements FormValidator {\n private readonly messages: ValidationMessages\n\n constructor(customMessages: Partial<ValidationMessages> = {}) {\n this.messages = { ...DEFAULT_VALIDATION_MESSAGES, ...customMessages }\n }\n\n validateField(value: unknown, field: FormField): string[] {\n const errors: string[] = []\n\n // Check required\n if (field.required && this.isEmpty(value)) {\n errors.push(this.messages.required)\n return errors // Return early if required and empty\n }\n\n // Skip other validations if value is empty and not required\n if (this.isEmpty(value) && !field.required) {\n return errors\n }\n\n // Run custom validation rules\n if (field.validation) {\n for (const rule of field.validation) {\n const error = this.validateRule(value, rule)\n if (error) {\n errors.push(error)\n }\n }\n }\n\n return errors\n }\n\n validateAll(values: Record<string, unknown>, fields: readonly FormField[]): FormValidationResult {\n const errors: Record<string, string[]> = {}\n let hasErrors = false\n\n for (const field of fields) {\n const value = values[field.name]\n const fieldErrors = this.validateField(value, field)\n\n if (fieldErrors.length > 0) {\n errors[field.name] = fieldErrors\n hasErrors = true\n }\n }\n\n return {\n valid: !hasErrors,\n errors,\n }\n }\n\n private validateRule(value: unknown, rule: ValidationRule): string | null {\n switch (rule.type) {\n case 'required':\n return this.isEmpty(value) ? rule.message : null\n\n case 'email':\n return this.validateEmail(value, rule.message)\n\n case 'url':\n return this.validateUrl(value, rule.message)\n\n case 'minLength':\n return this.validateMinLength(value, rule.value as number, rule.message)\n\n case 'maxLength':\n return this.validateMaxLength(value, rule.value as number, rule.message)\n\n case 'min':\n return this.validateMin(value, rule.value as number, rule.message)\n\n case 'max':\n return this.validateMax(value, rule.value as number, rule.message)\n\n case 'pattern':\n return this.validatePattern(value, rule.value as string | RegExp, rule.message)\n\n case 'custom':\n // Custom validation function is expected to be in rule.value\n if (typeof rule.value === 'function') {\n const isValid = (rule.value as (v: unknown) => boolean)(value)\n return isValid ? null : rule.message\n }\n return null\n\n default:\n return null\n }\n }\n\n private isEmpty(value: unknown): boolean {\n if (value === null || value === undefined) return true\n if (typeof value === 'string') return value.trim() === ''\n if (Array.isArray(value)) return value.length === 0\n return false\n }\n\n private validateEmail(value: unknown, message: string): string | null {\n if (typeof value !== 'string') return message\n\n // Basic email regex - covers most common cases\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n return emailRegex.test(value) ? null : message\n }\n\n private validateUrl(value: unknown, message: string): string | null {\n if (typeof value !== 'string') return message\n\n try {\n new URL(value)\n return null\n } catch {\n return message\n }\n }\n\n private validateMinLength(value: unknown, minLength: number, message: string): string | null {\n if (typeof value !== 'string') return message\n return value.length >= minLength ? null : this.formatMessage(message, minLength)\n }\n\n private validateMaxLength(value: unknown, maxLength: number, message: string): string | null {\n if (typeof value !== 'string') return message\n return value.length <= maxLength ? null : this.formatMessage(message, maxLength)\n }\n\n private validateMin(value: unknown, min: number, message: string): string | null {\n const num = Number(value)\n if (Number.isNaN(num)) return message\n return num >= min ? null : this.formatMessage(message, min)\n }\n\n private validateMax(value: unknown, max: number, message: string): string | null {\n const num = Number(value)\n if (Number.isNaN(num)) return message\n return num <= max ? null : this.formatMessage(message, max)\n }\n\n private validatePattern(\n value: unknown,\n pattern: string | RegExp,\n message: string\n ): string | null {\n if (typeof value !== 'string') return message\n\n const regex = typeof pattern === 'string' ? new RegExp(pattern) : pattern\n return regex.test(value) ? null : message\n }\n\n private formatMessage(message: string, value: unknown): string {\n return message.replace('{value}', String(value))\n }\n}\n\n// ============================================================\n// ZOD SCHEMA VALIDATOR\n// ============================================================\n\n/**\n * Validate values using a Zod schema\n */\nexport function validateWithZod<T>(\n values: Record<string, unknown>,\n schema: ZodType<T>\n): FormValidationResult {\n const result = schema.safeParse(values)\n\n if (result.success) {\n return {\n valid: true,\n errors: {},\n }\n }\n\n return {\n valid: false,\n errors: formatZodErrors(result.error),\n }\n}\n\n/**\n * Convert Zod errors to FormValidationResult format\n */\nfunction formatZodErrors(error: ZodError): Record<string, string[]> {\n const errors: Record<string, string[]> = {}\n\n for (const issue of error.issues) {\n const path = issue.path.join('.')\n if (!errors[path]) {\n errors[path] = []\n }\n errors[path].push(issue.message)\n }\n\n return errors\n}\n\n// ============================================================\n// BUILT-IN ZOD SCHEMAS\n// ============================================================\n\n/**\n * Common Zod schemas for form validation\n */\nexport const FormSchemas = {\n /**\n * Email validation schema\n */\n email: z.string().email('Please enter a valid email address'),\n\n /**\n * Required string schema\n */\n requiredString: z.string().min(1, 'This field is required'),\n\n /**\n * URL validation schema\n */\n url: z.string().url('Please enter a valid URL'),\n\n /**\n * Phone number schema (basic)\n */\n phone: z.string().regex(/^\\+?[\\d\\s-()]+$/, 'Please enter a valid phone number'),\n\n /**\n * Password schema (min 8 chars, at least one number and letter)\n */\n password: z\n .string()\n .min(8, 'Password must be at least 8 characters')\n .regex(/[a-zA-Z]/, 'Password must contain at least one letter')\n .regex(/[0-9]/, 'Password must contain at least one number'),\n}\n\n/**\n * Create a form validator\n */\nexport function createFormValidator(customMessages?: Partial<ValidationMessages>): FormValidator {\n return new DefaultFormValidator(customMessages)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/forms/validator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAA+B,MAAM,KAAK,CAAA;AAQpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAExD,+DAA+D;AAC/D,yBAAyB;AACzB,+DAA+D;AAE/D;;GAEG;AACH,MAAM,OAAO,oBAAoB;IACd,QAAQ,CAAoB;IAE7C,YAAY,iBAA8C,EAAE;QAC1D,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,2BAA2B,EAAE,GAAG,cAAc,EAAE,CAAA;IACvE,CAAC;IAED,aAAa,CAAC,KAAc,EAAE,KAAgB;QAC5C,MAAM,MAAM,GAAa,EAAE,CAAA;QAE3B,iBAAiB;QACjB,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;YACnC,OAAO,MAAM,CAAA,CAAC,qCAAqC;QACrD,CAAC;QAED,4DAA4D;QAC5D,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC3C,OAAO,MAAM,CAAA;QACf,CAAC;QAED,8BAA8B;QAC9B,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;YACrB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;gBACpC,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;gBAC5C,IAAI,KAAK,EAAE,CAAC;oBACV,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACpB,CAAC;YACH,CAAC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form Validator\n *\n * Form validation implementation\n *\n * @module @pwfabric/runtime/forms/validator\n */\n\nimport { z, type ZodType, type ZodError } from 'zod'\nimport type {\n FormValidator,\n FormField,\n ValidationRule,\n FormValidationResult,\n ValidationMessages,\n} from './types.js'\nimport { DEFAULT_VALIDATION_MESSAGES } from './types.js'\n\n// ============================================================\n// DEFAULT FORM VALIDATOR\n// ============================================================\n\n/**\n * Default form validator implementation\n */\nexport class DefaultFormValidator implements FormValidator {\n private readonly messages: ValidationMessages\n\n constructor(customMessages: Partial<ValidationMessages> = {}) {\n this.messages = { ...DEFAULT_VALIDATION_MESSAGES, ...customMessages }\n }\n\n validateField(value: unknown, field: FormField): string[] {\n const errors: string[] = []\n\n // Check required\n if (field.required && this.isEmpty(value)) {\n errors.push(this.messages.required)\n return errors // Return early if required and empty\n }\n\n // Skip other validations if value is empty and not required\n if (this.isEmpty(value) && !field.required) {\n return errors\n }\n\n // Run custom validation rules\n if (field.validation) {\n for (const rule of field.validation) {\n const error = this.validateRule(value, rule)\n if (error) {\n errors.push(error)\n }\n }\n }\n\n return errors\n }\n\n validateAll(values: Record<string, unknown>, fields: readonly FormField[]): FormValidationResult {\n const errors: Record<string, string[]> = {}\n let hasErrors = false\n\n for (const field of fields) {\n const value = values[field.name]\n const fieldErrors = this.validateField(value, field)\n\n if (fieldErrors.length > 0) {\n errors[field.name] = fieldErrors\n hasErrors = true\n }\n }\n\n return {\n valid: !hasErrors,\n errors,\n }\n }\n\n private validateRule(value: unknown, rule: ValidationRule): string | null {\n switch (rule.type) {\n case 'required':\n return this.isEmpty(value) ? rule.message : null\n\n case 'email':\n return this.validateEmail(value, rule.message)\n\n case 'url':\n return this.validateUrl(value, rule.message)\n\n case 'minLength':\n return this.validateMinLength(value, rule.value as number, rule.message)\n\n case 'maxLength':\n return this.validateMaxLength(value, rule.value as number, rule.message)\n\n case 'min':\n return this.validateMin(value, rule.value as number, rule.message)\n\n case 'max':\n return this.validateMax(value, rule.value as number, rule.message)\n\n case 'pattern':\n return this.validatePattern(value, rule.value as string | RegExp, rule.message)\n\n case 'custom':\n // Custom validation function is expected to be in rule.value\n if (typeof rule.value === 'function') {\n const isValid = (rule.value as (v: unknown) => boolean)(value)\n return isValid ? null : rule.message\n }\n return null\n\n default:\n return null\n }\n }\n\n private isEmpty(value: unknown): boolean {\n if (value === null || value === undefined) return true\n if (typeof value === 'string') return value.trim() === ''\n if (Array.isArray(value)) return value.length === 0\n return false\n }\n\n private validateEmail(value: unknown, message: string): string | null {\n if (typeof value !== 'string') return message\n\n // Basic email regex - covers most common cases\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n return emailRegex.test(value) ? null : message\n }\n\n private validateUrl(value: unknown, message: string): string | null {\n if (typeof value !== 'string') return message\n\n try {\n new URL(value)\n return null\n } catch {\n return message\n }\n }\n\n private validateMinLength(value: unknown, minLength: number, message: string): string | null {\n if (typeof value !== 'string') return message\n return value.length >= minLength ? null : this.formatMessage(message, minLength)\n }\n\n private validateMaxLength(value: unknown, maxLength: number, message: string): string | null {\n if (typeof value !== 'string') return message\n return value.length <= maxLength ? null : this.formatMessage(message, maxLength)\n }\n\n private validateMin(value: unknown, min: number, message: string): string | null {\n const num = Number(value)\n if (Number.isNaN(num)) return message\n return num >= min ? null : this.formatMessage(message, min)\n }\n\n private validateMax(value: unknown, max: number, message: string): string | null {\n const num = Number(value)\n if (Number.isNaN(num)) return message\n return num <= max ? null : this.formatMessage(message, max)\n }\n\n private validatePattern(\n value: unknown,\n pattern: string | RegExp,\n message: string\n ): string | null {\n if (typeof value !== 'string') return message\n\n const regex = typeof pattern === 'string' ? new RegExp(pattern) : pattern\n return regex.test(value) ? null : message\n }\n\n private formatMessage(message: string, value: unknown): string {\n return message.replace('{value}', String(value))\n }\n}\n\n// ============================================================\n// ZOD SCHEMA VALIDATOR\n// ============================================================\n\n/**\n * Validate values using a Zod schema\n */\nexport function validateWithZod<T>(\n values: Record<string, unknown>,\n schema: ZodType<T>\n): FormValidationResult {\n const result = schema.safeParse(values)\n\n if (result.success) {\n return {\n valid: true,\n errors: {},\n }\n }\n\n return {\n valid: false,\n errors: formatZodErrors(result.error),\n }\n}\n\n/**\n * Convert Zod errors to FormValidationResult format\n */\nfunction formatZodErrors(error: ZodError): Record<string, string[]> {\n const errors: Record<string, string[]> = {}\n\n for (const issue of error.issues) {\n const path = issue.path.map(String).join('.')\n if (!errors[path]) {\n errors[path] = []\n }\n errors[path].push(issue.message)\n }\n\n return errors\n}\n\n// ============================================================\n// BUILT-IN ZOD SCHEMAS\n// ============================================================\n\n/**\n * Common Zod schemas for form validation\n */\nexport const FormSchemas = {\n /**\n * Email validation schema\n */\n email: z.string().email('Please enter a valid email address'),\n\n /**\n * Required string schema\n */\n requiredString: z.string().min(1, 'This field is required'),\n\n /**\n * URL validation schema\n */\n url: z.string().url('Please enter a valid URL'),\n\n /**\n * Phone number schema (basic)\n */\n phone: z.string().regex(/^\\+?[\\d\\s-()]+$/, 'Please enter a valid phone number'),\n\n /**\n * Password schema (min 8 chars, at least one number and letter)\n */\n password: z\n .string()\n .min(8, 'Password must be at least 8 characters')\n .regex(/[a-zA-Z]/, 'Password must contain at least one letter')\n .regex(/[0-9]/, 'Password must contain at least one number'),\n}\n\n/**\n * Create a form validator\n */\nexport function createFormValidator(customMessages?: Partial<ValidationMessages>): FormValidator {\n return new DefaultFormValidator(customMessages)\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type { DynamicBlockWrapperProps, DynamicArtifactContextValue, DynamicArti
|
|
|
33
33
|
export { BlockModuleLoader, DynamicBlockWrapper, DynamicArtifactProvider, preloadDynamicBlocks, useDynamicBlocks, useDynamicStarters, } from './render/index.js';
|
|
34
34
|
export { BlockErrorBoundary } from './render/index.js';
|
|
35
35
|
export { dataSourceCacheKey } from './render/index.js';
|
|
36
|
-
export type { SurfaceDataCache } from './render/index.js';
|
|
36
|
+
export type { SurfaceDataCache, LinkHref } from './render/index.js';
|
|
37
37
|
export { createSurfaceEventBus } from './render/index.js';
|
|
38
38
|
export { SurfaceEventContext } from './render/index.js';
|
|
39
39
|
export { useSurfaceEvents } from './render/index.js';
|
|
@@ -42,9 +42,10 @@ export { BehaviorSurfaceProvider } from './render/index.js';
|
|
|
42
42
|
export { SurfaceIdContext } from './render/index.js';
|
|
43
43
|
export { useSurfaceId } from './render/index.js';
|
|
44
44
|
export type { ShellSelectionStore, ShellSelectionOptions, ShellSelectionProviderProps, } from './render/index.js';
|
|
45
|
+
export type { LiteralProps } from './render/index.js';
|
|
45
46
|
export { ShellSelectionContext, ShellSelectionProvider, createShellSelectionStore, useShellSelection, } from './render/index.js';
|
|
46
47
|
export { DefaultImageAdapter, NextImageAdapter } from './adapters/index.js';
|
|
47
|
-
export { SurfaceRenderer as BlockSurfaceRenderer, BlockRenderer, getBlockIds, findBlockById, updateBlockById, DataBoundSurfaceRenderer, surfaceNeedsDataBinding, blockActionsOf, resolveEndpoint, resolveBlockExpressions, resolveString, surfaceThemeToCSS, } from './render/index.js';
|
|
48
|
+
export { SurfaceRenderer as BlockSurfaceRenderer, BlockRenderer, getBlockIds, findBlockById, updateBlockById, DataBoundSurfaceRenderer, surfaceNeedsDataBinding, blockActionsOf, resolveEndpoint, resolveBlockExpressions, literalPropsOf, resolveString, isHrefKey, isLinkMember, isExpressionLink, surfaceThemeToCSS, } from './render/index.js';
|
|
48
49
|
export * from './capability/index.js';
|
|
49
50
|
export * from './data/index.js';
|
|
50
51
|
export * from './routing/index.js';
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ export { useSurfaceId } from './render/index.js';
|
|
|
58
58
|
export { ShellSelectionContext, ShellSelectionProvider, createShellSelectionStore, useShellSelection, } from './render/index.js';
|
|
59
59
|
// Image Adapters
|
|
60
60
|
export { DefaultImageAdapter, NextImageAdapter } from './adapters/index.js';
|
|
61
|
-
export { SurfaceRenderer as BlockSurfaceRenderer, BlockRenderer, getBlockIds, findBlockById, updateBlockById, DataBoundSurfaceRenderer, surfaceNeedsDataBinding, blockActionsOf, resolveEndpoint, resolveBlockExpressions, resolveString, surfaceThemeToCSS, } from './render/index.js';
|
|
61
|
+
export { SurfaceRenderer as BlockSurfaceRenderer, BlockRenderer, getBlockIds, findBlockById, updateBlockById, DataBoundSurfaceRenderer, surfaceNeedsDataBinding, blockActionsOf, resolveEndpoint, resolveBlockExpressions, literalPropsOf, resolveString, isHrefKey, isLinkMember, isExpressionLink, surfaceThemeToCSS, } from './render/index.js';
|
|
62
62
|
// legacy first-party `*Block` component re-exports +
|
|
63
63
|
// `defaultBlockComponents` map retired. Production rendering loads
|
|
64
64
|
// components from CDN bundles via `BlockModuleLoader`; the static
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,sCAAsC;AACtC,cAAc,qBAAqB,CAAA;AAEnC,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAExD,sBAAsB;AACtB,OAAO,EAA2B,0BAA0B,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEnG,qBAAqB;AACrB,OAAO,EAEL,wBAAwB,EACxB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,gBAAgB,CAAA;AAEvB,YAAY;AACZ,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE9E,oBAAoB;AACpB,OAAO,EAEL,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,cAAc,GAEf,MAAM,wBAAwB,CAAA;AAE/B,8CAA8C;AAC9C,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAE7B,6BAA6B;AAC7B,cAAc,oBAAoB,CAAA;AAElC,wBAAwB;AACxB,cAAc,oBAAoB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/runtime\n *\n * Runtime and execution engine for the PWFabric platform.\n *\n * Runtime spine implementation\n * Surface rendering pipeline, layout system, primitives\n * Binding engine, auth, cache, graph resolver\n *\n * @module @pwfabric/runtime\n */\n\n// Re-export contracts for convenience\nexport * from '@pwfabric/contracts'\n\n// Fabric kernel\nexport { FabricKernel, createFabric } from './kernel.js'\n\n// Capability registry\nexport { type CapabilityRegistry, InMemoryCapabilityRegistry, createRegistry } from './registry.js'\n\n// Contract validator\nexport {\n type ContractValidator,\n RuntimeContractValidator,\n createValidator,\n isValidationSuccess,\n isValidationFailure,\n formatValidationErrors,\n} from './validator.js'\n\n// Event bus\nexport { InMemoryEventBus, createEventBus, createFabricEvent } from './bus.js'\n\n// Execution context\nexport {\n type InvocationHandler,\n RuntimeExecutionContext,\n ConsoleExecutionLogger,\n NoOpExecutionLogger,\n createExecutionContext,\n generateTraceId,\n generateSpanId,\n type CreateExecutionContextOptions,\n} from './execution-context.js'\n\n// Legacy exports (for backward compatibility)\nexport * from './context.js'\nexport * from './executor.js'\n\n// Surface rendering pipeline\nexport * from './surface/index.js'\n\n// Binding, cache, graph\nexport * from './binding/index.js'\nexport * from './cache/index.js'\nexport * from './graph/index.js'\n\n// Auth is intentionally NOT part of the default export: it holds the\n// MSAL/API-key providers, and pulling them into the default barrel would make\n// every consumer of `.` — including `@pwfabric/embed`'s browser-facing IIFE\n// build — carry them along. Available explicitly via `@pwfabric/runtime/auth`.\n\n// State and forms capabilities\nexport * from './state/index.js'\nexport * from './forms/index.js'\n\n// Entity system\nexport * from './entity/index.js'\n\n// Connector engine loading + registry (platform-side\n// execution of CONNECTOR/PROVIDER atom engines)\nexport * from './connectors/index.js'\nexport { SurfaceConnectionsContext, useSurfaceConnections } from './render/index.js'\n\n// Surface renderer (avoiding duplicates with surface/index.js)\nexport type {\n BlockComponentProps,\n BlockComponent,\n BlockComponentRegistry,\n CapabilityProvider,\n BlockContext,\n SurfaceEventType,\n SurfaceEvent,\n SurfaceRendererProps,\n BlockRendererProps,\n RenderableSurface,\n CapabilityType,\n ImageAdapter,\n ImageAdapterProps,\n SurfaceDataSourceKind,\n SurfaceDataSourceDefinition,\n SurfaceActionType,\n SurfaceAction,\n BlockActionProp,\n DataBoundSurface,\n DataBoundSurfaceRendererProps,\n} from './render/index.js'\n\n// Capability Gate (Entitlement enforcement)\nexport type {\n EntitlementContextValue,\n EntitlementProviderProps,\n GatedBlockPlaceholderProps,\n} from './render/index.js'\nexport { EntitlementProvider, useEntitlements, GatedBlockPlaceholder } from './render/index.js'\n\n// Dynamic Artifact Loading\nexport type {\n DynamicBlockWrapperProps,\n DynamicArtifactContextValue,\n DynamicArtifactProviderProps,\n} from './render/index.js'\nexport {\n BlockModuleLoader,\n DynamicBlockWrapper,\n DynamicArtifactProvider,\n preloadDynamicBlocks,\n useDynamicBlocks,\n useDynamicStarters,\n} from './render/index.js'\n\n// Block Error Boundary (crash isolation)\nexport { BlockErrorBoundary } from './render/index.js'\nexport { dataSourceCacheKey } from './render/index.js'\nexport type { SurfaceDataCache } from './render/index.js'\n\n// Surface event protocol\nexport { createSurfaceEventBus } from './render/index.js'\nexport { SurfaceEventContext } from './render/index.js'\nexport { useSurfaceEvents } from './render/index.js'\n\n// BehaviorSurfaceProvider — runtime surface wiring\nexport type { BehaviorSurfaceProviderProps } from './render/index.js'\nexport { BehaviorSurfaceProvider } from './render/index.js'\nexport { SurfaceIdContext } from './render/index.js'\nexport { useSurfaceId } from './render/index.js'\n\n// Shell × body: SPLIT shell selection (URL-projected), and the shell/body\n// classification the renderer lays out by.\nexport type {\n ShellSelectionStore,\n ShellSelectionOptions,\n ShellSelectionProviderProps,\n} from './render/index.js'\nexport {\n ShellSelectionContext,\n ShellSelectionProvider,\n createShellSelectionStore,\n useShellSelection,\n} from './render/index.js'\n\n// Image Adapters\nexport { DefaultImageAdapter, NextImageAdapter } from './adapters/index.js'\nexport {\n SurfaceRenderer as BlockSurfaceRenderer,\n BlockRenderer,\n getBlockIds,\n findBlockById,\n updateBlockById,\n DataBoundSurfaceRenderer,\n surfaceNeedsDataBinding,\n blockActionsOf,\n resolveEndpoint,\n resolveBlockExpressions,\n resolveString,\n surfaceThemeToCSS,\n} from './render/index.js'\n// legacy first-party `*Block` component re-exports +\n// `defaultBlockComponents` map retired. Production rendering loads\n// components from CDN bundles via `BlockModuleLoader`; the static\n// component registry no longer ships from this package.\n\n// Capability system (definitions, type mapping, validation)\nexport * from './capability/index.js'\n\n// Data, routing, SEO, analytics, i18n capabilities\nexport * from './data/index.js'\nexport * from './routing/index.js'\nexport * from './seo/index.js'\nexport * from './analytics/index.js'\nexport * from './i18n/index.js'\n\n// Performance monitoring module\nexport type {\n WebVitalName,\n WebVitalRating,\n WebVitalMetric,\n WebVitalCallback,\n WebVitalsReport,\n RenderMetrics,\n RenderTimerConfig,\n PerformanceBudget,\n BudgetViolation,\n BudgetCheckResult,\n ReportDestination,\n ReporterConfig,\n PerformanceReport,\n} from './perf/index.js'\nexport {\n WebVitalsCollector,\n createWebVitalsCollector,\n rateMetric,\n RenderTimer,\n createRenderTimer,\n DEFAULT_BUDGET,\n BudgetChecker,\n createBudgetChecker,\n PerformanceReporter,\n createPerformanceReporter,\n} from './perf/index.js'\n\n// Accessibility (a11y) module\nexport type { AnnouncementLevel, LiveRegionConfig } from './a11y/index.js'\nexport { LiveRegionAnnouncer, createAnnouncer } from './a11y/index.js'\nexport type { FocusTrapConfig } from './a11y/index.js'\nexport {\n FocusTrapManager,\n FocusRestorer,\n createSkipLink,\n createFocusTrap,\n createFocusRestorer,\n} from './a11y/index.js'\nexport type { ArrowDirection, KeyboardNavConfig } from './a11y/index.js'\nexport {\n KeyboardNavigationManager,\n RovingTabIndex,\n createKeyboardNav,\n createRovingTabIndex,\n} from './a11y/index.js'\nexport type { ContrastResult } from './a11y/index.js'\nexport {\n hexToRgb,\n relativeLuminance,\n contrastRatio,\n checkContrast,\n meetsWCAG,\n} from './a11y/index.js'\n\n// tenant-scoped pack atom registry hook\nexport {\n useInstalledAtoms,\n type InstalledAtomDescriptor,\n type InstalledAtomKind,\n type InstalledAtomsState,\n type InstalledAtomsFetcher,\n type AtomManifestPayload,\n type AtomBlockDefinitionMetadata,\n} from './hooks/useInstalledAtoms.js'\n\n// The engine names no tenant: a host's tenant model (plan, entitlements,\n// storage, installations) belongs to the host.\n//\n// What the engine offers is the mechanism without the vocabulary: `EntitlementProvider`\n// and `useEntitlements` in ./render/capability-gate.tsx still enforce a claim\n// set, typed structurally as `EntitlementClaims`.\n\n// canonical home for block infrastructure (registry,\n// composition rules, rule engine, contexts, hooks, default block\n// components, schemas, 45 first-party block defs). Subpath import\n// `@pwfabric/runtime/blocks` is the recommended consumer entry; the root\n// re-exports above (SurfaceEventContext / useSurfaceEvents /\n// SurfaceIdContext / useSurfaceId / defaultBlockComponents / 21 block\n// components) now resolve via `runtime/render/*` → `runtime/blocks/*`\n// preserving React-context identity.\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,sCAAsC;AACtC,cAAc,qBAAqB,CAAA;AAEnC,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAExD,sBAAsB;AACtB,OAAO,EAA2B,0BAA0B,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEnG,qBAAqB;AACrB,OAAO,EAEL,wBAAwB,EACxB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,gBAAgB,CAAA;AAEvB,YAAY;AACZ,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE9E,oBAAoB;AACpB,OAAO,EAEL,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,cAAc,GAEf,MAAM,wBAAwB,CAAA;AAE/B,8CAA8C;AAC9C,cAAc,cAAc,CAAA;AAC5B,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AkD;AAElD,qDAAqD;AACrD,iEAAiE;AACjE,kEAAkE;AAClE,yEAAyE;AACzE,6DAA6D;AAC7D,sEAAsE;AACtE,sEAAsE;AACtE,qCAAqC","sourcesContent":["/**\n * @pwfabric/runtime\n *\n * Runtime and execution engine for the PWFabric platform.\n *\n * Runtime spine implementation\n * Surface rendering pipeline, layout system, primitives\n * Binding engine, auth, cache, graph resolver\n *\n * @module @pwfabric/runtime\n */\n\n// Re-export contracts for convenience\nexport * from '@pwfabric/contracts'\n\n// Fabric kernel\nexport { FabricKernel, createFabric } from './kernel.js'\n\n// Capability registry\nexport { type CapabilityRegistry, InMemoryCapabilityRegistry, createRegistry } from './registry.js'\n\n// Contract validator\nexport {\n type ContractValidator,\n RuntimeContractValidator,\n createValidator,\n isValidationSuccess,\n isValidationFailure,\n formatValidationErrors,\n} from './validator.js'\n\n// Event bus\nexport { InMemoryEventBus, createEventBus, createFabricEvent } from './bus.js'\n\n// Execution context\nexport {\n type InvocationHandler,\n RuntimeExecutionContext,\n ConsoleExecutionLogger,\n NoOpExecutionLogger,\n createExecutionContext,\n generateTraceId,\n generateSpanId,\n type CreateExecutionContextOptions,\n} from './execution-context.js'\n\n// Legacy exports (for backward compatibility)\nexport * from './context.js'\nexport * from './executor.js'\n\n// Surface rendering pipeline\nexport * from './surface/index.js'\n\n// Binding, cache, graph\nexport * from './binding/index.js'\nexport * from './cache/index.js'\nexport * from './graph/index.js'\n\n// Auth is intentionally NOT part of the default export: it holds the\n// MSAL/API-key providers, and pulling them into the default barrel would make\n// every consumer of `.` — including `@pwfabric/embed`'s browser-facing IIFE\n// build — carry them along. Available explicitly via `@pwfabric/runtime/auth`.\n\n// State and forms capabilities\nexport * from './state/index.js'\nexport * from './forms/index.js'\n\n// Entity system\nexport * from './entity/index.js'\n\n// Connector engine loading + registry (platform-side\n// execution of CONNECTOR/PROVIDER atom engines)\nexport * from './connectors/index.js'\nexport { SurfaceConnectionsContext, useSurfaceConnections } from './render/index.js'\n\n// Surface renderer (avoiding duplicates with surface/index.js)\nexport type {\n BlockComponentProps,\n BlockComponent,\n BlockComponentRegistry,\n CapabilityProvider,\n BlockContext,\n SurfaceEventType,\n SurfaceEvent,\n SurfaceRendererProps,\n BlockRendererProps,\n RenderableSurface,\n CapabilityType,\n ImageAdapter,\n ImageAdapterProps,\n SurfaceDataSourceKind,\n SurfaceDataSourceDefinition,\n SurfaceActionType,\n SurfaceAction,\n BlockActionProp,\n DataBoundSurface,\n DataBoundSurfaceRendererProps,\n} from './render/index.js'\n\n// Capability Gate (Entitlement enforcement)\nexport type {\n EntitlementContextValue,\n EntitlementProviderProps,\n GatedBlockPlaceholderProps,\n} from './render/index.js'\nexport { EntitlementProvider, useEntitlements, GatedBlockPlaceholder } from './render/index.js'\n\n// Dynamic Artifact Loading\nexport type {\n DynamicBlockWrapperProps,\n DynamicArtifactContextValue,\n DynamicArtifactProviderProps,\n} from './render/index.js'\nexport {\n BlockModuleLoader,\n DynamicBlockWrapper,\n DynamicArtifactProvider,\n preloadDynamicBlocks,\n useDynamicBlocks,\n useDynamicStarters,\n} from './render/index.js'\n\n// Block Error Boundary (crash isolation)\nexport { BlockErrorBoundary } from './render/index.js'\nexport { dataSourceCacheKey } from './render/index.js'\nexport type { SurfaceDataCache, LinkHref } from './render/index.js'\n\n// Surface event protocol\nexport { createSurfaceEventBus } from './render/index.js'\nexport { SurfaceEventContext } from './render/index.js'\nexport { useSurfaceEvents } from './render/index.js'\n\n// BehaviorSurfaceProvider — runtime surface wiring\nexport type { BehaviorSurfaceProviderProps } from './render/index.js'\nexport { BehaviorSurfaceProvider } from './render/index.js'\nexport { SurfaceIdContext } from './render/index.js'\nexport { useSurfaceId } from './render/index.js'\n\n// Shell × body: SPLIT shell selection (URL-projected), and the shell/body\n// classification the renderer lays out by.\nexport type {\n ShellSelectionStore,\n ShellSelectionOptions,\n ShellSelectionProviderProps,\n} from './render/index.js'\nexport type { LiteralProps } from './render/index.js'\nexport {\n ShellSelectionContext,\n ShellSelectionProvider,\n createShellSelectionStore,\n useShellSelection,\n} from './render/index.js'\n\n// Image Adapters\nexport { DefaultImageAdapter, NextImageAdapter } from './adapters/index.js'\nexport {\n SurfaceRenderer as BlockSurfaceRenderer,\n BlockRenderer,\n getBlockIds,\n findBlockById,\n updateBlockById,\n DataBoundSurfaceRenderer,\n surfaceNeedsDataBinding,\n blockActionsOf,\n resolveEndpoint,\n resolveBlockExpressions,\n literalPropsOf,\n resolveString,\n isHrefKey,\n isLinkMember,\n isExpressionLink,\n surfaceThemeToCSS,\n} from './render/index.js'\n// legacy first-party `*Block` component re-exports +\n// `defaultBlockComponents` map retired. Production rendering loads\n// components from CDN bundles via `BlockModuleLoader`; the static\n// component registry no longer ships from this package.\n\n// Capability system (definitions, type mapping, validation)\nexport * from './capability/index.js'\n\n// Data, routing, SEO, analytics, i18n capabilities\nexport * from './data/index.js'\nexport * from './routing/index.js'\nexport * from './seo/index.js'\nexport * from './analytics/index.js'\nexport * from './i18n/index.js'\n\n// Performance monitoring module\nexport type {\n WebVitalName,\n WebVitalRating,\n WebVitalMetric,\n WebVitalCallback,\n WebVitalsReport,\n RenderMetrics,\n RenderTimerConfig,\n PerformanceBudget,\n BudgetViolation,\n BudgetCheckResult,\n ReportDestination,\n ReporterConfig,\n PerformanceReport,\n} from './perf/index.js'\nexport {\n WebVitalsCollector,\n createWebVitalsCollector,\n rateMetric,\n RenderTimer,\n createRenderTimer,\n DEFAULT_BUDGET,\n BudgetChecker,\n createBudgetChecker,\n PerformanceReporter,\n createPerformanceReporter,\n} from './perf/index.js'\n\n// Accessibility (a11y) module\nexport type { AnnouncementLevel, LiveRegionConfig } from './a11y/index.js'\nexport { LiveRegionAnnouncer, createAnnouncer } from './a11y/index.js'\nexport type { FocusTrapConfig } from './a11y/index.js'\nexport {\n FocusTrapManager,\n FocusRestorer,\n createSkipLink,\n createFocusTrap,\n createFocusRestorer,\n} from './a11y/index.js'\nexport type { ArrowDirection, KeyboardNavConfig } from './a11y/index.js'\nexport {\n KeyboardNavigationManager,\n RovingTabIndex,\n createKeyboardNav,\n createRovingTabIndex,\n} from './a11y/index.js'\nexport type { ContrastResult } from './a11y/index.js'\nexport {\n hexToRgb,\n relativeLuminance,\n contrastRatio,\n checkContrast,\n meetsWCAG,\n} from './a11y/index.js'\n\n// tenant-scoped pack atom registry hook\nexport {\n useInstalledAtoms,\n type InstalledAtomDescriptor,\n type InstalledAtomKind,\n type InstalledAtomsState,\n type InstalledAtomsFetcher,\n type AtomManifestPayload,\n type AtomBlockDefinitionMetadata,\n} from './hooks/useInstalledAtoms.js'\n\n// The engine names no tenant: a host's tenant model (plan, entitlements,\n// storage, installations) belongs to the host.\n//\n// What the engine offers is the mechanism without the vocabulary: `EntitlementProvider`\n// and `useEntitlements` in ./render/capability-gate.tsx still enforce a claim\n// set, typed structurally as `EntitlementClaims`.\n\n// canonical home for block infrastructure (registry,\n// composition rules, rule engine, contexts, hooks, default block\n// components, schemas, 45 first-party block defs). Subpath import\n// `@pwfabric/runtime/blocks` is the recommended consumer entry; the root\n// re-exports above (SurfaceEventContext / useSurfaceEvents /\n// SurfaceIdContext / useSurfaceId / defaultBlockComponents / 21 block\n// components) now resolve via `runtime/render/*` → `runtime/blocks/*`\n// preserving React-context identity.\n"]}
|
|
@@ -58,6 +58,16 @@ export declare function surfaceNeedsDataBinding(surface: {
|
|
|
58
58
|
* - Otherwise → return trimmed lowercased (best-effort; won't match well-formed events)
|
|
59
59
|
*/
|
|
60
60
|
export declare function canonicalizeEventType(raw: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Whether a behavior aimed at `targetBlockId` hears an event from `blockId`.
|
|
63
|
+
*
|
|
64
|
+
* A block inside a `repeat` is drawn once per row, each copy with the id
|
|
65
|
+
* `<id>--<index>` (`<id>--<outer>--<inner>` in a nested repeat) — the id the
|
|
66
|
+
* event carries. The receipt can only name the TEMPLATE id; matching it
|
|
67
|
+
* exactly meant a behavior aimed at a repeated block never fired. The
|
|
68
|
+
* template id names every copy; a copy id still names that one copy.
|
|
69
|
+
*/
|
|
70
|
+
export declare function behaviorTargets(targetBlockId: string, blockId: string): boolean;
|
|
61
71
|
export declare function isSurfaceAction(value: unknown): value is SurfaceAction;
|
|
62
72
|
/**
|
|
63
73
|
* Guard the `navigate` action against XSS: only http(s) absolute URLs and
|
|
@@ -21,7 +21,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
21
21
|
*/
|
|
22
22
|
import * as React from 'react';
|
|
23
23
|
import { SurfaceRenderer } from './renderer.js';
|
|
24
|
-
import { resolveBlockExpressions } from './resolve-expressions.js';
|
|
24
|
+
import { literalPropsOf, resolveBlockExpressions } from './resolve-expressions.js';
|
|
25
|
+
import { useDynamicBlocks } from './dynamic-artifact-context.js';
|
|
26
|
+
import { readableUrl, urlSchemeOf } from './links.js';
|
|
25
27
|
import { endpointMissingPathValue, resolveEndpoint } from './endpoint.js';
|
|
26
28
|
import { resolveQueryState } from './query-state.js';
|
|
27
29
|
import { dataSourceCacheKey } from './data-cache.js';
|
|
@@ -374,8 +376,8 @@ writeOnly) {
|
|
|
374
376
|
// host-provided engine registry when that connection is registered
|
|
375
377
|
// there. Registered-but-failed surfaces the reason as an honest
|
|
376
378
|
// per-source error (`__errors.<id>`), never a crash; an unregistered
|
|
377
|
-
// connection (or no registry at all) falls through to
|
|
378
|
-
//
|
|
379
|
+
// connection (or no registry at all) falls through to the
|
|
380
|
+
// host's entity facade path.
|
|
379
381
|
// `{{state.x}}` inside the query resolves against CURRENT state, so
|
|
380
382
|
// a pagination block writing `state.page` or a segmented-control
|
|
381
383
|
// writing `state.severity` reaches `query.pagination` / `query.filter`.
|
|
@@ -491,7 +493,14 @@ writeOnly) {
|
|
|
491
493
|
meta: result.metadata.envelope ?? null,
|
|
492
494
|
};
|
|
493
495
|
}
|
|
494
|
-
|
|
496
|
+
// A refused read (401/403), a 404, a 500 or no answer at all: the source
|
|
497
|
+
// could not be served, and its `fallback` is bound like an entity
|
|
498
|
+
// source's (data-protocol §2). This branch reported the error and
|
|
499
|
+
// dropped the fallback, so under a host that rewrites entity sources
|
|
500
|
+
// into rest reads of its records (`pwf dev`), a page reading a
|
|
501
|
+
// create-only model showed neither rows nor its sample data.
|
|
502
|
+
const message = result.error.message;
|
|
503
|
+
return failed(source.fallback !== undefined ? new SourceFallback(message, source.fallback) : new Error(message), result.error.status ?? null);
|
|
495
504
|
}, [dataService, registerSource]);
|
|
496
505
|
// ---- Fetch a set of sources for the current state ----
|
|
497
506
|
const fetchSources = React.useCallback(async (sources) => {
|
|
@@ -773,6 +782,25 @@ export function canonicalizeEventType(raw) {
|
|
|
773
782
|
return s;
|
|
774
783
|
}
|
|
775
784
|
// ============================================================
|
|
785
|
+
// behaviorTargets
|
|
786
|
+
// ============================================================
|
|
787
|
+
/**
|
|
788
|
+
* Whether a behavior aimed at `targetBlockId` hears an event from `blockId`.
|
|
789
|
+
*
|
|
790
|
+
* A block inside a `repeat` is drawn once per row, each copy with the id
|
|
791
|
+
* `<id>--<index>` (`<id>--<outer>--<inner>` in a nested repeat) — the id the
|
|
792
|
+
* event carries. The receipt can only name the TEMPLATE id; matching it
|
|
793
|
+
* exactly meant a behavior aimed at a repeated block never fired. The
|
|
794
|
+
* template id names every copy; a copy id still names that one copy.
|
|
795
|
+
*/
|
|
796
|
+
export function behaviorTargets(targetBlockId, blockId) {
|
|
797
|
+
if (blockId === targetBlockId)
|
|
798
|
+
return true;
|
|
799
|
+
if (!blockId.startsWith(`${targetBlockId}--`))
|
|
800
|
+
return false;
|
|
801
|
+
return /^(--\d+)+$/.test(blockId.slice(targetBlockId.length));
|
|
802
|
+
}
|
|
803
|
+
// ============================================================
|
|
776
804
|
// isSurfaceAction
|
|
777
805
|
// ============================================================
|
|
778
806
|
export function isSurfaceAction(value) {
|
|
@@ -796,13 +824,11 @@ export function isSurfaceAction(value) {
|
|
|
796
824
|
export function isSafeNavigateUrl(url) {
|
|
797
825
|
if (typeof url !== 'string')
|
|
798
826
|
return false;
|
|
799
|
-
|
|
800
|
-
if (stripped === '')
|
|
827
|
+
if (readableUrl(url) === '')
|
|
801
828
|
return false;
|
|
802
|
-
const
|
|
803
|
-
if (
|
|
829
|
+
const s = urlSchemeOf(url);
|
|
830
|
+
if (s === null)
|
|
804
831
|
return true; // relative path / query / hash / protocol-relative
|
|
805
|
-
const s = (scheme[1] ?? '').toLowerCase();
|
|
806
832
|
return s === 'http' || s === 'https';
|
|
807
833
|
}
|
|
808
834
|
// ============================================================
|
|
@@ -864,13 +890,21 @@ function DataBoundInner({ surfaceId, blocks, dataSources, initialState, appearan
|
|
|
864
890
|
// SurfaceConnectionsContext provider via the rendererProps spread below).
|
|
865
891
|
const connections = rendererProps.connections;
|
|
866
892
|
const dataCache = rendererProps.dataCache;
|
|
893
|
+
const linkHref = rendererProps.linkHref;
|
|
867
894
|
// Keyed by the ids, so a re-render that changes nothing hands useSurfaceData
|
|
868
895
|
// the same set (its expression context depends on it).
|
|
869
896
|
const writeOnlyKey = React.useMemo(() => [...writeOnlySourceIds({ blocks, dataSources, capabilities, behaviors })].sort().join('\n'), [blocks, dataSources, capabilities, behaviors]);
|
|
870
897
|
const writeOnly = React.useMemo(() => new Set(writeOnlyKey === '' ? [] : writeOnlyKey.split('\n')), [writeOnlyKey]);
|
|
871
898
|
const { expressionData, initialLoaded, setStateValue, refreshSource, fetchAllSources } = useSurfaceData(dataSources, initialState, interactionMode, entityFacade, connections, dataCache, writeOnly);
|
|
899
|
+
// The props each block's manifest declares `bindable: false` stay as
|
|
900
|
+
// written; the descriptors the host handed the renderer carry them.
|
|
901
|
+
const { blocks: descriptors } = useDynamicBlocks();
|
|
902
|
+
const literalProps = React.useMemo(() => literalPropsOf(descriptors.values()), [descriptors]);
|
|
872
903
|
// Resolve expressions in blocks
|
|
873
|
-
const resolvedBlocks = React.useMemo(() => resolveBlockExpressions(blocks, expressionData
|
|
904
|
+
const resolvedBlocks = React.useMemo(() => resolveBlockExpressions(blocks, expressionData, undefined, {
|
|
905
|
+
literalProps,
|
|
906
|
+
...(linkHref ? { linkHref } : {}),
|
|
907
|
+
}), [blocks, expressionData, linkHref, literalProps]);
|
|
874
908
|
// Shared action dispatcher — handles all six action types
|
|
875
909
|
const dispatchAction = React.useCallback((action) => {
|
|
876
910
|
switch (action.type) {
|
|
@@ -938,7 +972,7 @@ function DataBoundInner({ surfaceId, blocks, dataSources, initialState, appearan
|
|
|
938
972
|
for (const b of behaviors) {
|
|
939
973
|
if (canonicalizeEventType(b.event) !== fired)
|
|
940
974
|
continue;
|
|
941
|
-
if (b.targetBlockId && b.targetBlockId
|
|
975
|
+
if (b.targetBlockId && !behaviorTargets(b.targetBlockId, event.blockId))
|
|
942
976
|
continue;
|
|
943
977
|
b.actions.forEach(dispatchAction);
|
|
944
978
|
}
|