diff --git a/goldens/public-api/core/errors.md b/goldens/public-api/core/errors.md index b1f8a40e7ef91..f714696142095 100644 --- a/goldens/public-api/core/errors.md +++ b/goldens/public-api/core/errors.md @@ -125,6 +125,8 @@ export const enum RuntimeErrorCode { // (undocumented) REQUIRED_QUERY_NO_VALUE = -951, // (undocumented) + REQUIRED_MODEL_NO_VALUE = -952, + // (undocumented) RUNTIME_DEPS_INVALID_IMPORTED_TYPE = 1000, // (undocumented) RUNTIME_DEPS_ORPHAN_COMPONENT = 1001, diff --git a/goldens/public-api/core/index.md b/goldens/public-api/core/index.md index fc110bd1e120e..b9498b123833b 100644 --- a/goldens/public-api/core/index.md +++ b/goldens/public-api/core/index.md @@ -1075,6 +1075,32 @@ export enum MissingTranslationStrategy { Warning = 1 } +// @public +export const model: ModelFunction; + +// @public +export interface ModelFunction { + (): ModelSignal; + // (undocumented) + (initialValue: T, opts?: ModelOptions): ModelSignal; + required(opts?: ModelOptions): ModelSignal; +} + +// @public +export interface ModelOptions { + alias?: string; +} + +// @public +export interface ModelSignal extends WritableSignal { + // (undocumented) + [ɵINPUT_SIGNAL_BRAND_READ_TYPE]: T; + // (undocumented) + [ɵINPUT_SIGNAL_BRAND_WRITE_TYPE]: T; + // (undocumented) + [SIGNAL]: ModelSignalNode; +} + // @public @deprecated export class ModuleWithComponentFactories { constructor(ngModuleFactory: NgModuleFactory, componentFactories: ComponentFactory[]); diff --git a/packages/core/src/authoring.ts b/packages/core/src/authoring.ts index f942a218bae6b..52a7f8a9b525a 100644 --- a/packages/core/src/authoring.ts +++ b/packages/core/src/authoring.ts @@ -6,12 +6,13 @@ * found in the LICENSE file at https://angular.io/license */ -// Note: `input` is exported in `core.ts` due to: +// Note: `input` and `model` are exported in `core.ts` due to: // https://docs.google.com/document/d/1RXb1wYwsbJotO1KBgSDsAtKpduGmIHod9ADxuXcAvV4/edit?tab=t.0. export {InputFunction} from './authoring/input/input'; export {InputOptions, InputOptionsWithoutTransform, InputOptionsWithTransform, InputSignal, InputSignalWithTransform, ɵINPUT_SIGNAL_BRAND_WRITE_TYPE} from './authoring/input/input_signal'; export {ɵUnwrapDirectiveSignalInputs} from './authoring/input/input_type_checking'; export {ModelFunction} from './authoring/model/model'; +export {ModelOptions, ModelSignal} from './authoring/model/model_signal'; export {output as ɵoutput, OutputEmitter as ɵOutputEmitter, OutputOptions as ɵOutputOptions} from './authoring/output'; export {ContentChildFunction, ViewChildFunction} from './authoring/queries'; diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 1dc6a704003a6..8751647e73cbf 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -13,14 +13,12 @@ */ export * from './authoring'; -// Input and query authoring functions are exported separately as this file is exempted from +// Authoring functions are exported separately as this file is exempted from // JSCompiler's conformance requirement for inferred const exports. See: // https://docs.google.com/document/d/1RXb1wYwsbJotO1KBgSDsAtKpduGmIHod9ADxuXcAvV4/edit?tab=t.0 export {input} from './authoring/input/input'; export {contentChild, contentChildren, viewChild, viewChildren} from './authoring/queries'; - -// TODO(crisbeto): export as a public API -// export {model} from './authoring/model/model'; +export {model} from './authoring/model/model'; export * from './metadata'; export * from './version'; diff --git a/packages/core/test/bundling/defer/bundle.golden_symbols.json b/packages/core/test/bundling/defer/bundle.golden_symbols.json index 6bd1274d5466f..a4858c770d076 100644 --- a/packages/core/test/bundling/defer/bundle.golden_symbols.json +++ b/packages/core/test/bundling/defer/bundle.golden_symbols.json @@ -1556,6 +1556,15 @@ { "name": "init_misc_utils" }, + { + "name": "init_model" + }, + { + "name": "init_model_signal" + }, + { + "name": "init_model_signal_node" + }, { "name": "init_module" }, diff --git a/packages/core/test/bundling/forms_template_driven/bundle.golden_symbols.json b/packages/core/test/bundling/forms_template_driven/bundle.golden_symbols.json index a3e0622dac2f6..6796dfb1c4c32 100644 --- a/packages/core/test/bundling/forms_template_driven/bundle.golden_symbols.json +++ b/packages/core/test/bundling/forms_template_driven/bundle.golden_symbols.json @@ -881,6 +881,9 @@ { "name": "diPublicInInjector" }, + { + "name": "elementPropertyInternal" + }, { "name": "enterDI" }, @@ -1289,6 +1292,9 @@ { "name": "isReadableStreamLike" }, + { + "name": "isSignal" + }, { "name": "isStylingMatch" }, @@ -1331,6 +1337,9 @@ { "name": "leaveViewLight" }, + { + "name": "listenerInternal" + }, { "name": "lookupTokenUsingModuleInjector" },