@fluidframework/synthesize 2.1.0-274160 → 2.1.0-276985
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/IFluidDependencySynthesizer.d.ts +3 -0
- package/dist/IFluidDependencySynthesizer.d.ts.map +1 -1
- package/dist/IFluidDependencySynthesizer.js +1 -0
- package/dist/IFluidDependencySynthesizer.js.map +1 -1
- package/dist/dependencyContainer.d.ts +1 -0
- package/dist/dependencyContainer.d.ts.map +1 -1
- package/dist/dependencyContainer.js +1 -0
- package/dist/dependencyContainer.js.map +1 -1
- package/dist/legacy.d.ts +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/lib/IFluidDependencySynthesizer.d.ts +3 -0
- package/lib/IFluidDependencySynthesizer.d.ts.map +1 -1
- package/lib/IFluidDependencySynthesizer.js +1 -0
- package/lib/IFluidDependencySynthesizer.js.map +1 -1
- package/lib/dependencyContainer.d.ts +1 -0
- package/lib/dependencyContainer.d.ts.map +1 -1
- package/lib/dependencyContainer.js +1 -0
- package/lib/dependencyContainer.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/types.d.ts +5 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +8 -8
- package/src/IFluidDependencySynthesizer.ts +3 -0
- package/src/dependencyContainer.ts +1 -0
- package/src/types.ts +5 -0
- /package/api-report/{synthesize.alpha.api.md → synthesize.legacy.alpha.api.md} +0 -0
package/README.md
CHANGED
|
@@ -9,10 +9,12 @@ An Ioc type library for synthesizing a FluidObject based on FluidObject provider
|
|
|
9
9
|
|
|
10
10
|
## Using Fluid Framework libraries
|
|
11
11
|
|
|
12
|
-
When taking a dependency on a Fluid Framework library, we recommend using a `^` (caret) version range, such as `^1.3.4`.
|
|
12
|
+
When taking a dependency on a Fluid Framework library's public APIs, we recommend using a `^` (caret) version range, such as `^1.3.4`.
|
|
13
13
|
While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
|
|
14
14
|
library consumers should always prefer `^`.
|
|
15
15
|
|
|
16
|
+
If using any of Fluid Framework's unstable APIs (for example, its `beta` APIs), we recommend using a more constrained version range, such as `~`.
|
|
17
|
+
|
|
16
18
|
<!-- prettier-ignore-end -->
|
|
17
19
|
|
|
18
20
|
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AsyncFluidObjectProvider, FluidObjectSymbolProvider } from "./types.js";
|
|
6
6
|
/**
|
|
7
|
+
* @legacy
|
|
7
8
|
* @alpha
|
|
8
9
|
*/
|
|
9
10
|
export declare const IFluidDependencySynthesizer: keyof IProvideFluidDependencySynthesizer;
|
|
10
11
|
/**
|
|
12
|
+
* @legacy
|
|
11
13
|
* @alpha
|
|
12
14
|
*/
|
|
13
15
|
export interface IProvideFluidDependencySynthesizer {
|
|
@@ -17,6 +19,7 @@ export interface IProvideFluidDependencySynthesizer {
|
|
|
17
19
|
* IFluidDependencySynthesizer can generate FluidObjects based on the IProvideFluidObject pattern.
|
|
18
20
|
* It allow for registering providers and uses synthesize to generate a new object with the optional
|
|
19
21
|
* and required types.
|
|
22
|
+
* @legacy
|
|
20
23
|
* @alpha
|
|
21
24
|
*/
|
|
22
25
|
export interface IFluidDependencySynthesizer extends IProvideFluidDependencySynthesizer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IFluidDependencySynthesizer.d.ts","sourceRoot":"","sources":["../src/IFluidDependencySynthesizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEjF
|
|
1
|
+
{"version":3,"file":"IFluidDependencySynthesizer.d.ts","sourceRoot":"","sources":["../src/IFluidDependencySynthesizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,kCAClB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,kCAAkC;IAClD,2BAA2B,EAAE,2BAA2B,CAAC;CACzD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,2BAA4B,SAAQ,kCAAkC;IACtF;;;;;;OAMG;IACH,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAClD,aAAa,EAAE,yBAAyB,CAAC,CAAC,CAAC,EAC3C,aAAa,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,GACnD,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAElC;;;OAGG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IFluidDependencySynthesizer.js","sourceRoot":"","sources":["../src/IFluidDependencySynthesizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH
|
|
1
|
+
{"version":3,"file":"IFluidDependencySynthesizer.js","sourceRoot":"","sources":["../src/IFluidDependencySynthesizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;GAGG;AACU,QAAA,2BAA2B,GACvC,6BAA6B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AsyncFluidObjectProvider, FluidObjectSymbolProvider } from \"./types.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport const IFluidDependencySynthesizer: keyof IProvideFluidDependencySynthesizer =\n\t\"IFluidDependencySynthesizer\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IProvideFluidDependencySynthesizer {\n\tIFluidDependencySynthesizer: IFluidDependencySynthesizer;\n}\n\n/**\n * IFluidDependencySynthesizer can generate FluidObjects based on the IProvideFluidObject pattern.\n * It allow for registering providers and uses synthesize to generate a new object with the optional\n * and required types.\n * @legacy\n * @alpha\n */\nexport interface IFluidDependencySynthesizer extends IProvideFluidDependencySynthesizer {\n\t/**\n\t * synthesize takes optional and required types and returns an object that will fulfill the\n\t * defined types based off objects that has been previously registered.\n\t *\n\t * @param optionalTypes - optional types to be in the Scope object\n\t * @param requiredTypes - required types that need to be in the Scope object\n\t */\n\tsynthesize<O, R = undefined | Record<string, never>>(\n\t\toptionalTypes: FluidObjectSymbolProvider<O>,\n\t\trequiredTypes: Required<FluidObjectSymbolProvider<R>>,\n\t): AsyncFluidObjectProvider<O, R>;\n\n\t/**\n\t * Check if a given type is registered\n\t * @param type - Type to check\n\t */\n\thas(type: string): boolean;\n}\n"]}
|
|
@@ -7,6 +7,7 @@ import { AsyncFluidObjectProvider, FluidObjectProvider, FluidObjectSymbolProvide
|
|
|
7
7
|
/**
|
|
8
8
|
* DependencyContainer is similar to a IoC Container. It takes providers and will
|
|
9
9
|
* synthesize an object based on them when requested.
|
|
10
|
+
* @legacy
|
|
10
11
|
* @alpha
|
|
11
12
|
*/
|
|
12
13
|
export declare class DependencyContainer<TMap> implements IFluidDependencySynthesizer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencyContainer.d.ts","sourceRoot":"","sources":["../src/dependencyContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACN,wBAAwB,EAGxB,mBAAmB,EACnB,yBAAyB,EACzB,MAAM,YAAY,CAAC;AAEpB
|
|
1
|
+
{"version":3,"file":"dependencyContainer.d.ts","sourceRoot":"","sources":["../src/dependencyContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACN,wBAAwB,EAGxB,mBAAmB,EACnB,yBAAyB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,qBAAa,mBAAmB,CAAC,IAAI,CAAE,YAAW,2BAA2B;IAC5E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmD;IAC7E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IACxD,IAAW,2BAA2B,SAErC;gBAEkB,GAAG,OAAO,EAAE,CAAC,2BAA2B,GAAG,SAAS,CAAC,EAAE;IAI1E;;;;;OAKG;IACI,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,IAAI,EAChD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAC1C,IAAI;IAUP;;;OAGG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI;IAMzC;;OAEG;IACI,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACzD,aAAa,EAAE,yBAAyB,CAAC,CAAC,CAAC,EAC3C,aAAa,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,GACnD,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC;IAQjC;;;OAGG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO;IAS3D;;OAEG;IACH,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,gBAAgB;IAkBxB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,eAAe;CA2CvB"}
|
|
@@ -10,6 +10,7 @@ const IFluidDependencySynthesizer_js_1 = require("./IFluidDependencySynthesizer.
|
|
|
10
10
|
/**
|
|
11
11
|
* DependencyContainer is similar to a IoC Container. It takes providers and will
|
|
12
12
|
* synthesize an object based on them when requested.
|
|
13
|
+
* @legacy
|
|
13
14
|
* @alpha
|
|
14
15
|
*/
|
|
15
16
|
class DependencyContainer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencyContainer.js","sourceRoot":"","sources":["../src/dependencyContainer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,qFAA+E;AAS/E;;;;GAIG;AACH,MAAa,mBAAmB;IAG/B,IAAW,2BAA2B;QACrC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,YAAmB,GAAG,OAAoD;QANzD,cAAS,GAAG,IAAI,GAAG,EAAwC,CAAC;QAO5E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAoC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IACzF,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CACd,IAAO,EACP,QAA4C;QAE5C,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACd,6CAA6C,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAC/E,CAAC;QACH,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,UAAU,CAAC,IAAgB;QACjC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACF,CAAC;IAED;;OAEG;IACI,UAAU,CAChB,aAA2C,EAC3C,aAAqD;QAErD,MAAM,IAAI,GAAmC,EAAS,CAAC;QACvD,IAAI,CAAC,gBAAgB,CAAI,IAAI,EAAE,aAAa,CAAC,CAAC;QAC9C,IAAI,CAAC,gBAAgB,CAAI,IAAI,EAAE,aAAa,CAAC,CAAC;QAC9C,MAAM,CAAC,c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T License.\n */\n\nimport { LazyPromise } from \"@fluidframework/core-utils/internal\";\n\nimport { IFluidDependencySynthesizer } from \"./IFluidDependencySynthesizer.js\";\nimport {\n\tAsyncFluidObjectProvider,\n\tAsyncOptionalFluidObjectProvider,\n\tAsyncRequiredFluidObjectProvider,\n\tFluidObjectProvider,\n\tFluidObjectSymbolProvider,\n} from \"./types.js\";\n\n/**\n * DependencyContainer is similar to a IoC Container. It takes providers and will\n * synthesize an object based on them when requested.\n * @alpha\n */\nexport class DependencyContainer<TMap> implements IFluidDependencySynthesizer {\n\tprivate readonly providers = new Map<keyof TMap, FluidObjectProvider<any>>();\n\tprivate readonly parents: IFluidDependencySynthesizer[];\n\tpublic get IFluidDependencySynthesizer() {\n\t\treturn this;\n\t}\n\n\tpublic constructor(...parents: (IFluidDependencySynthesizer | undefined)[]) {\n\t\tthis.parents = parents.filter((v): v is IFluidDependencySynthesizer => v !== undefined);\n\t}\n\n\t/**\n\t * Add a new provider\n\t * @param type - Name of the Type T being provided\n\t * @param provider - A provider that will resolve the T correctly when asked\n\t * @throws - If passing a type that's already registered\n\t */\n\tpublic register<T extends keyof TMap = keyof TMap>(\n\t\ttype: T,\n\t\tprovider: FluidObjectProvider<Pick<TMap, T>>,\n\t): void {\n\t\tif (this.providers.has(type)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Attempting to register a provider of type ${String(type)} that already exists`,\n\t\t\t);\n\t\t}\n\n\t\tthis.providers.set(type, provider);\n\t}\n\n\t/**\n\t * Remove a provider\n\t * @param type - Name of the provider to remove\n\t */\n\tpublic unregister(type: keyof TMap): void {\n\t\tif (this.providers.has(type)) {\n\t\t\tthis.providers.delete(type);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc (IFluidDependencySynthesizer:interface).synthesize}\n\t */\n\tpublic synthesize<O, R = undefined | Record<string, never>>(\n\t\toptionalTypes: FluidObjectSymbolProvider<O>,\n\t\trequiredTypes: Required<FluidObjectSymbolProvider<R>>,\n\t): AsyncFluidObjectProvider<O, R> {\n\t\tconst base: AsyncFluidObjectProvider<O, R> = {} as any;\n\t\tthis.generateRequired<R>(base, requiredTypes);\n\t\tthis.generateOptional<O>(base, optionalTypes);\n\t\tObject.defineProperty(base, IFluidDependencySynthesizer, { get: () => this });\n\t\treturn base;\n\t}\n\n\t/**\n\t * {@inheritDoc (IFluidDependencySynthesizer:interface).has}\n\t * @param excludeParents - If true, exclude checking parent registries\n\t */\n\tpublic has(type: string, excludeParents?: boolean): boolean {\n\t\tif (this.providers.has(type as keyof TMap)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (excludeParents !== true) {\n\t\t\treturn this.parents.some((p: IFluidDependencySynthesizer) => p.has(type));\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t * @deprecated Needed for backwards compatability.\n\t */\n\tprivate getProvider(provider: string & keyof TMap) {\n\t\t// this was removed, but some partners have trouble with back compat where they\n\t\t// use invalid patterns with FluidObject and IFluidDependencySynthesizer\n\t\t// this is just for back compat until those are removed\n\t\tif (this.has(provider)) {\n\t\t\tif (this.providers.has(provider)) {\n\t\t\t\treturn this.providers.get(provider);\n\t\t\t}\n\t\t\tfor (const parent of this.parents) {\n\t\t\t\tif (parent instanceof DependencyContainer) {\n\t\t\t\t\treturn parent.getProvider(provider);\n\t\t\t\t} else {\n\t\t\t\t\t// older implementations of the IFluidDependencySynthesizer exposed getProvider\n\t\t\t\t\tconst maybeGetProvider: { getProvider?(provider: string & keyof TMap) } =\n\t\t\t\t\t\tparent as any;\n\t\t\t\t\tif (maybeGetProvider?.getProvider !== undefined) {\n\t\t\t\t\t\treturn maybeGetProvider.getProvider(provider);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate generateRequired<T>(\n\t\tbase: AsyncRequiredFluidObjectProvider<T>,\n\t\ttypes: Required<FluidObjectSymbolProvider<T>>,\n\t) {\n\t\tif (types === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const key of Object.keys(types) as unknown as (keyof TMap)[]) {\n\t\t\tconst provider = this.resolveProvider(key);\n\t\t\tif (provider === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Object attempted to be created without registered required provider ${String(key)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tObject.defineProperty(base, key, provider);\n\t\t}\n\t}\n\n\tprivate generateOptional<T>(\n\t\tbase: AsyncOptionalFluidObjectProvider<T>,\n\t\ttypes: FluidObjectSymbolProvider<T>,\n\t) {\n\t\tif (types === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const key of Object.keys(types) as unknown as (keyof TMap)[]) {\n\t\t\t// back-compat: in 0.56 we allow undefined in the types, but we didn't before\n\t\t\t// this will keep runtime back compat, eventually we should support undefined properties\n\t\t\t// rather than properties that return promises that resolve to undefined\n\t\t\tconst provider = this.resolveProvider(key) ?? { get: async () => undefined };\n\t\t\tObject.defineProperty(base, key, provider);\n\t\t}\n\t}\n\n\tprivate resolveProvider<T extends keyof TMap>(t: T): PropertyDescriptor | undefined {\n\t\t// If we have the provider return it\n\t\tconst provider = this.providers.get(t);\n\t\tif (provider === undefined) {\n\t\t\tfor (const parent of this.parents) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\tconst sp = { [t]: t } as FluidObjectSymbolProvider<Pick<TMap, T>>;\n\t\t\t\tconst syn = parent.synthesize<Pick<TMap, T>, Record<string, unknown>>(sp, {});\n\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(syn, t);\n\t\t\t\tif (descriptor !== undefined) {\n\t\t\t\t\treturn descriptor;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// The double nested gets are required for lazy loading the provider resolution\n\t\tif (typeof provider === \"function\") {\n\t\t\treturn {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t\t\tget() {\n\t\t\t\t\tif (provider && typeof provider === \"function\") {\n\t\t\t\t\t\treturn Promise.resolve(this[IFluidDependencySynthesizer])\n\t\t\t\t\t\t\t.then(async (fds): Promise<any> => provider(fds))\n\t\t\t\t\t\t\t.then((p) => p?.[t]);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tget() {\n\t\t\t\tif (provider) {\n\t\t\t\t\treturn new LazyPromise(async () => {\n\t\t\t\t\t\treturn Promise.resolve(provider).then((p) => {\n\t\t\t\t\t\t\tif (p) {\n\t\t\t\t\t\t\t\treturn p[t];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dependencyContainer.js","sourceRoot":"","sources":["../src/dependencyContainer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,qFAA+E;AAS/E;;;;;GAKG;AACH,MAAa,mBAAmB;IAG/B,IAAW,2BAA2B;QACrC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,YAAmB,GAAG,OAAoD;QANzD,cAAS,GAAG,IAAI,GAAG,EAAwC,CAAC;QAO5E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAoC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IACzF,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CACd,IAAO,EACP,QAA4C;QAE5C,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACd,6CAA6C,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAC/E,CAAC;QACH,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,UAAU,CAAC,IAAgB;QACjC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC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OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;4BAC3C,IAAI,CAAC,EAAE,CAAC;gCACP,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;4BACb,CAAC;wBACF,CAAC,CAAC,CAAC;oBACJ,CAAC,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;SACD,CAAC;IACH,CAAC;CACD;AA1KD,kDA0KC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { LazyPromise } from \"@fluidframework/core-utils/internal\";\n\nimport { IFluidDependencySynthesizer } from \"./IFluidDependencySynthesizer.js\";\nimport {\n\tAsyncFluidObjectProvider,\n\tAsyncOptionalFluidObjectProvider,\n\tAsyncRequiredFluidObjectProvider,\n\tFluidObjectProvider,\n\tFluidObjectSymbolProvider,\n} from \"./types.js\";\n\n/**\n * DependencyContainer is similar to a IoC Container. It takes providers and will\n * synthesize an object based on them when requested.\n * @legacy\n * @alpha\n */\nexport class DependencyContainer<TMap> implements IFluidDependencySynthesizer {\n\tprivate readonly providers = new Map<keyof TMap, FluidObjectProvider<any>>();\n\tprivate readonly parents: IFluidDependencySynthesizer[];\n\tpublic get IFluidDependencySynthesizer() {\n\t\treturn this;\n\t}\n\n\tpublic constructor(...parents: (IFluidDependencySynthesizer | undefined)[]) {\n\t\tthis.parents = parents.filter((v): v is IFluidDependencySynthesizer => v !== undefined);\n\t}\n\n\t/**\n\t * Add a new provider\n\t * @param type - Name of the Type T being provided\n\t * @param provider - A provider that will resolve the T correctly when asked\n\t * @throws - If passing a type that's already registered\n\t */\n\tpublic register<T extends keyof TMap = keyof TMap>(\n\t\ttype: T,\n\t\tprovider: FluidObjectProvider<Pick<TMap, T>>,\n\t): void {\n\t\tif (this.providers.has(type)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Attempting to register a provider of type ${String(type)} that already exists`,\n\t\t\t);\n\t\t}\n\n\t\tthis.providers.set(type, provider);\n\t}\n\n\t/**\n\t * Remove a provider\n\t * @param type - Name of the provider to remove\n\t */\n\tpublic unregister(type: keyof TMap): void {\n\t\tif (this.providers.has(type)) {\n\t\t\tthis.providers.delete(type);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc (IFluidDependencySynthesizer:interface).synthesize}\n\t */\n\tpublic synthesize<O, R = undefined | Record<string, never>>(\n\t\toptionalTypes: FluidObjectSymbolProvider<O>,\n\t\trequiredTypes: Required<FluidObjectSymbolProvider<R>>,\n\t): AsyncFluidObjectProvider<O, R> {\n\t\tconst base: AsyncFluidObjectProvider<O, R> = {} as any;\n\t\tthis.generateRequired<R>(base, requiredTypes);\n\t\tthis.generateOptional<O>(base, optionalTypes);\n\t\tObject.defineProperty(base, IFluidDependencySynthesizer, { get: () => this });\n\t\treturn base;\n\t}\n\n\t/**\n\t * {@inheritDoc (IFluidDependencySynthesizer:interface).has}\n\t * @param excludeParents - If true, exclude checking parent registries\n\t */\n\tpublic has(type: string, excludeParents?: boolean): boolean {\n\t\tif (this.providers.has(type as keyof TMap)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (excludeParents !== true) {\n\t\t\treturn this.parents.some((p: IFluidDependencySynthesizer) => p.has(type));\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t * @deprecated Needed for backwards compatability.\n\t */\n\tprivate getProvider(provider: string & keyof TMap) {\n\t\t// this was removed, but some partners have trouble with back compat where they\n\t\t// use invalid patterns with FluidObject and IFluidDependencySynthesizer\n\t\t// this is just for back compat until those are removed\n\t\tif (this.has(provider)) {\n\t\t\tif (this.providers.has(provider)) {\n\t\t\t\treturn this.providers.get(provider);\n\t\t\t}\n\t\t\tfor (const parent of this.parents) {\n\t\t\t\tif (parent instanceof DependencyContainer) {\n\t\t\t\t\treturn parent.getProvider(provider);\n\t\t\t\t} else {\n\t\t\t\t\t// older implementations of the IFluidDependencySynthesizer exposed getProvider\n\t\t\t\t\tconst maybeGetProvider: { getProvider?(provider: string & keyof TMap) } =\n\t\t\t\t\t\tparent as any;\n\t\t\t\t\tif (maybeGetProvider?.getProvider !== undefined) {\n\t\t\t\t\t\treturn maybeGetProvider.getProvider(provider);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate generateRequired<T>(\n\t\tbase: AsyncRequiredFluidObjectProvider<T>,\n\t\ttypes: Required<FluidObjectSymbolProvider<T>>,\n\t) {\n\t\tif (types === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const key of Object.keys(types) as unknown as (keyof TMap)[]) {\n\t\t\tconst provider = this.resolveProvider(key);\n\t\t\tif (provider === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Object attempted to be created without registered required provider ${String(key)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tObject.defineProperty(base, key, provider);\n\t\t}\n\t}\n\n\tprivate generateOptional<T>(\n\t\tbase: AsyncOptionalFluidObjectProvider<T>,\n\t\ttypes: FluidObjectSymbolProvider<T>,\n\t) {\n\t\tif (types === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const key of Object.keys(types) as unknown as (keyof TMap)[]) {\n\t\t\t// back-compat: in 0.56 we allow undefined in the types, but we didn't before\n\t\t\t// this will keep runtime back compat, eventually we should support undefined properties\n\t\t\t// rather than properties that return promises that resolve to undefined\n\t\t\tconst provider = this.resolveProvider(key) ?? { get: async () => undefined };\n\t\t\tObject.defineProperty(base, key, provider);\n\t\t}\n\t}\n\n\tprivate resolveProvider<T extends keyof TMap>(t: T): PropertyDescriptor | undefined {\n\t\t// If we have the provider return it\n\t\tconst provider = this.providers.get(t);\n\t\tif (provider === undefined) {\n\t\t\tfor (const parent of this.parents) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\tconst sp = { [t]: t } as FluidObjectSymbolProvider<Pick<TMap, T>>;\n\t\t\t\tconst syn = parent.synthesize<Pick<TMap, T>, Record<string, unknown>>(sp, {});\n\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(syn, t);\n\t\t\t\tif (descriptor !== undefined) {\n\t\t\t\t\treturn descriptor;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// The double nested gets are required for lazy loading the provider resolution\n\t\tif (typeof provider === \"function\") {\n\t\t\treturn {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t\t\tget() {\n\t\t\t\t\tif (provider && typeof provider === \"function\") {\n\t\t\t\t\t\treturn Promise.resolve(this[IFluidDependencySynthesizer])\n\t\t\t\t\t\t\t.then(async (fds): Promise<any> => provider(fds))\n\t\t\t\t\t\t\t.then((p) => p?.[t]);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tget() {\n\t\t\t\tif (provider) {\n\t\t\t\t\treturn new LazyPromise(async () => {\n\t\t\t\t\t\treturn Promise.resolve(provider).then((p) => {\n\t\t\t\t\t\t\tif (p) {\n\t\t\t\t\t\t\t\treturn p[t];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n}\n"]}
|
package/dist/legacy.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { IFluidDependencySynthesizer } from "./IFluidDependencySynthesizer.js";
|
|
|
13
13
|
* ```typescript
|
|
14
14
|
* { IFoo: "IFoo" }
|
|
15
15
|
* ```
|
|
16
|
+
* @legacy
|
|
16
17
|
* @alpha
|
|
17
18
|
*/
|
|
18
19
|
export type FluidObjectSymbolProvider<T> = {
|
|
@@ -22,6 +23,7 @@ export type FluidObjectSymbolProvider<T> = {
|
|
|
22
23
|
* This is a condensed version of Record that requires the object has all
|
|
23
24
|
* the FluidObject properties as its type mapped to an object that implements
|
|
24
25
|
* the property.
|
|
26
|
+
* @legacy
|
|
25
27
|
* @alpha
|
|
26
28
|
*/
|
|
27
29
|
export type AsyncRequiredFluidObjectProvider<T> = T extends undefined ? Record<string, never> : {
|
|
@@ -31,6 +33,7 @@ export type AsyncRequiredFluidObjectProvider<T> = T extends undefined ? Record<s
|
|
|
31
33
|
* This is a condensed version of Record that requires the object has all
|
|
32
34
|
* the FluidObject properties as its type, mapped to an object that implements
|
|
33
35
|
* the property or undefined.
|
|
36
|
+
* @legacy
|
|
34
37
|
* @alpha
|
|
35
38
|
*/
|
|
36
39
|
export type AsyncOptionalFluidObjectProvider<T> = T extends undefined ? Record<string, never> : {
|
|
@@ -38,11 +41,13 @@ export type AsyncOptionalFluidObjectProvider<T> = T extends undefined ? Record<s
|
|
|
38
41
|
};
|
|
39
42
|
/**
|
|
40
43
|
* Combined type for Optional and Required Async Fluid object Providers
|
|
44
|
+
* @legacy
|
|
41
45
|
* @alpha
|
|
42
46
|
*/
|
|
43
47
|
export type AsyncFluidObjectProvider<O, R = undefined> = AsyncOptionalFluidObjectProvider<O> & AsyncRequiredFluidObjectProvider<R>;
|
|
44
48
|
/**
|
|
45
49
|
* Multiple ways to provide a Fluid object.
|
|
50
|
+
* @legacy
|
|
46
51
|
* @alpha
|
|
47
52
|
*/
|
|
48
53
|
export type FluidObjectProvider<T> = NonNullable<T> | Promise<NonNullable<T>> | ((dependencyContainer: IFluidDependencySynthesizer) => NonNullable<T>) | ((dependencyContainer: IFluidDependencySynthesizer) => Promise<NonNullable<T>>);
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E;;;;;;;;;;;;GA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!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidDependencySynthesizer } from \"./IFluidDependencySynthesizer.js\";\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type mapped to a string representation\n * of that property.\n *\n * @example\n *\n * ```typescript\n * { IFoo: \"IFoo\" }\n * ```\n * @alpha\n */\nexport type FluidObjectSymbolProvider<T> = {\n\t[P in keyof T]?: P;\n};\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type mapped to an object that implements\n * the property.\n * @alpha\n */\nexport type AsyncRequiredFluidObjectProvider<T> = T extends undefined\n\t? Record<string, never>\n\t: {\n\t\t\t[P in keyof T]: Promise<NonNullable<Exclude<T[P], undefined | null>>>;\n\t\t};\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type, mapped to an object that implements\n * the property or undefined.\n * @alpha\n */\nexport type AsyncOptionalFluidObjectProvider<T> = T extends undefined\n\t? Record<string, never>\n\t: {\n\t\t\t[P in keyof T]?: Promise<T[P] | undefined>;\n\t\t};\n\n/**\n * Combined type for Optional and Required Async Fluid object Providers\n * @alpha\n */\nexport type AsyncFluidObjectProvider<O, R = undefined> = AsyncOptionalFluidObjectProvider<O> &\n\tAsyncRequiredFluidObjectProvider<R>;\n\n/**\n * Multiple ways to provide a Fluid object.\n * @alpha\n */\nexport type FluidObjectProvider<T> =\n\t| NonNullable<T>\n\t| Promise<NonNullable<T>>\n\t| ((dependencyContainer: IFluidDependencySynthesizer) => NonNullable<T>)\n\t| ((dependencyContainer: IFluidDependencySynthesizer) => Promise<NonNullable<T>>);\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidDependencySynthesizer } from \"./IFluidDependencySynthesizer.js\";\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type mapped to a string representation\n * of that property.\n *\n * @example\n *\n * ```typescript\n * { IFoo: \"IFoo\" }\n * ```\n * @legacy\n * @alpha\n */\nexport type FluidObjectSymbolProvider<T> = {\n\t[P in keyof T]?: P;\n};\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type mapped to an object that implements\n * the property.\n * @legacy\n * @alpha\n */\nexport type AsyncRequiredFluidObjectProvider<T> = T extends undefined\n\t? Record<string, never>\n\t: {\n\t\t\t[P in keyof T]: Promise<NonNullable<Exclude<T[P], undefined | null>>>;\n\t\t};\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type, mapped to an object that implements\n * the property or undefined.\n * @legacy\n * @alpha\n */\nexport type AsyncOptionalFluidObjectProvider<T> = T extends undefined\n\t? Record<string, never>\n\t: {\n\t\t\t[P in keyof T]?: Promise<T[P] | undefined>;\n\t\t};\n\n/**\n * Combined type for Optional and Required Async Fluid object Providers\n * @legacy\n * @alpha\n */\nexport type AsyncFluidObjectProvider<O, R = undefined> = AsyncOptionalFluidObjectProvider<O> &\n\tAsyncRequiredFluidObjectProvider<R>;\n\n/**\n * Multiple ways to provide a Fluid object.\n * @legacy\n * @alpha\n */\nexport type FluidObjectProvider<T> =\n\t| NonNullable<T>\n\t| Promise<NonNullable<T>>\n\t| ((dependencyContainer: IFluidDependencySynthesizer) => NonNullable<T>)\n\t| ((dependencyContainer: IFluidDependencySynthesizer) => Promise<NonNullable<T>>);\n"]}
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AsyncFluidObjectProvider, FluidObjectSymbolProvider } from "./types.js";
|
|
6
6
|
/**
|
|
7
|
+
* @legacy
|
|
7
8
|
* @alpha
|
|
8
9
|
*/
|
|
9
10
|
export declare const IFluidDependencySynthesizer: keyof IProvideFluidDependencySynthesizer;
|
|
10
11
|
/**
|
|
12
|
+
* @legacy
|
|
11
13
|
* @alpha
|
|
12
14
|
*/
|
|
13
15
|
export interface IProvideFluidDependencySynthesizer {
|
|
@@ -17,6 +19,7 @@ export interface IProvideFluidDependencySynthesizer {
|
|
|
17
19
|
* IFluidDependencySynthesizer can generate FluidObjects based on the IProvideFluidObject pattern.
|
|
18
20
|
* It allow for registering providers and uses synthesize to generate a new object with the optional
|
|
19
21
|
* and required types.
|
|
22
|
+
* @legacy
|
|
20
23
|
* @alpha
|
|
21
24
|
*/
|
|
22
25
|
export interface IFluidDependencySynthesizer extends IProvideFluidDependencySynthesizer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IFluidDependencySynthesizer.d.ts","sourceRoot":"","sources":["../src/IFluidDependencySynthesizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEjF
|
|
1
|
+
{"version":3,"file":"IFluidDependencySynthesizer.d.ts","sourceRoot":"","sources":["../src/IFluidDependencySynthesizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,kCAClB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,kCAAkC;IAClD,2BAA2B,EAAE,2BAA2B,CAAC;CACzD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,2BAA4B,SAAQ,kCAAkC;IACtF;;;;;;OAMG;IACH,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAClD,aAAa,EAAE,yBAAyB,CAAC,CAAC,CAAC,EAC3C,aAAa,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,GACnD,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAElC;;;OAGG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IFluidDependencySynthesizer.js","sourceRoot":"","sources":["../src/IFluidDependencySynthesizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH
|
|
1
|
+
{"version":3,"file":"IFluidDependencySynthesizer.js","sourceRoot":"","sources":["../src/IFluidDependencySynthesizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACvC,6BAA6B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AsyncFluidObjectProvider, FluidObjectSymbolProvider } from \"./types.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport const IFluidDependencySynthesizer: keyof IProvideFluidDependencySynthesizer =\n\t\"IFluidDependencySynthesizer\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IProvideFluidDependencySynthesizer {\n\tIFluidDependencySynthesizer: IFluidDependencySynthesizer;\n}\n\n/**\n * IFluidDependencySynthesizer can generate FluidObjects based on the IProvideFluidObject pattern.\n * It allow for registering providers and uses synthesize to generate a new object with the optional\n * and required types.\n * @legacy\n * @alpha\n */\nexport interface IFluidDependencySynthesizer extends IProvideFluidDependencySynthesizer {\n\t/**\n\t * synthesize takes optional and required types and returns an object that will fulfill the\n\t * defined types based off objects that has been previously registered.\n\t *\n\t * @param optionalTypes - optional types to be in the Scope object\n\t * @param requiredTypes - required types that need to be in the Scope object\n\t */\n\tsynthesize<O, R = undefined | Record<string, never>>(\n\t\toptionalTypes: FluidObjectSymbolProvider<O>,\n\t\trequiredTypes: Required<FluidObjectSymbolProvider<R>>,\n\t): AsyncFluidObjectProvider<O, R>;\n\n\t/**\n\t * Check if a given type is registered\n\t * @param type - Type to check\n\t */\n\thas(type: string): boolean;\n}\n"]}
|
|
@@ -7,6 +7,7 @@ import { AsyncFluidObjectProvider, FluidObjectProvider, FluidObjectSymbolProvide
|
|
|
7
7
|
/**
|
|
8
8
|
* DependencyContainer is similar to a IoC Container. It takes providers and will
|
|
9
9
|
* synthesize an object based on them when requested.
|
|
10
|
+
* @legacy
|
|
10
11
|
* @alpha
|
|
11
12
|
*/
|
|
12
13
|
export declare class DependencyContainer<TMap> implements IFluidDependencySynthesizer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencyContainer.d.ts","sourceRoot":"","sources":["../src/dependencyContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACN,wBAAwB,EAGxB,mBAAmB,EACnB,yBAAyB,EACzB,MAAM,YAAY,CAAC;AAEpB
|
|
1
|
+
{"version":3,"file":"dependencyContainer.d.ts","sourceRoot":"","sources":["../src/dependencyContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACN,wBAAwB,EAGxB,mBAAmB,EACnB,yBAAyB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,qBAAa,mBAAmB,CAAC,IAAI,CAAE,YAAW,2BAA2B;IAC5E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmD;IAC7E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IACxD,IAAW,2BAA2B,SAErC;gBAEkB,GAAG,OAAO,EAAE,CAAC,2BAA2B,GAAG,SAAS,CAAC,EAAE;IAI1E;;;;;OAKG;IACI,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,IAAI,EAChD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAC1C,IAAI;IAUP;;;OAGG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI;IAMzC;;OAEG;IACI,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACzD,aAAa,EAAE,yBAAyB,CAAC,CAAC,CAAC,EAC3C,aAAa,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,GACnD,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC;IAQjC;;;OAGG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO;IAS3D;;OAEG;IACH,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,gBAAgB;IAkBxB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,eAAe;CA2CvB"}
|
|
@@ -7,6 +7,7 @@ import { IFluidDependencySynthesizer } from "./IFluidDependencySynthesizer.js";
|
|
|
7
7
|
/**
|
|
8
8
|
* DependencyContainer is similar to a IoC Container. It takes providers and will
|
|
9
9
|
* synthesize an object based on them when requested.
|
|
10
|
+
* @legacy
|
|
10
11
|
* @alpha
|
|
11
12
|
*/
|
|
12
13
|
export class DependencyContainer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencyContainer.js","sourceRoot":"","sources":["../src/dependencyContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAS/E;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAG/B,IAAW,2BAA2B;QACrC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,YAAmB,GAAG,OAAoD;QANzD,cAAS,GAAG,IAAI,GAAG,EAAwC,CAAC;QAO5E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAoC,EAAE,CAAC,CAAC,K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AAE,CAAC;wBAChD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;6BACvD,IAAI,CAAC,KAAK,EAAE,GAAG,EAAgB,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;6BAChD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;oBACvB,CAAC;gBACF,CAAC;aACD,CAAC;QACH,CAAC;QACD,OAAO;YACN,GAAG;gBACF,IAAI,QAAQ,EAAE,CAAC;oBACd,OAAO,IAAI,WAAW,CAAC,KAAK,IAAI,EAAE;wBACjC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;4BAC3C,IAAI,CAAC,EAAE,CAAC;gCACP,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;4BACb,CAAC;wBACF,CAAC,CAAC,CAAC;oBACJ,CAAC,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;SACD,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { LazyPromise } from \"@fluidframework/core-utils/internal\";\n\nimport { IFluidDependencySynthesizer } from \"./IFluidDependencySynthesizer.js\";\nimport {\n\tAsyncFluidObjectProvider,\n\tAsyncOptionalFluidObjectProvider,\n\tAsyncRequiredFluidObjectProvider,\n\tFluidObjectProvider,\n\tFluidObjectSymbolProvider,\n} from \"./types.js\";\n\n/**\n * DependencyContainer is similar to a IoC Container. It takes providers and will\n * synthesize an object based on them when requested.\n * @alpha\n */\nexport class DependencyContainer<TMap> implements IFluidDependencySynthesizer {\n\tprivate readonly providers = new Map<keyof TMap, FluidObjectProvider<any>>();\n\tprivate readonly parents: IFluidDependencySynthesizer[];\n\tpublic get IFluidDependencySynthesizer() {\n\t\treturn this;\n\t}\n\n\tpublic constructor(...parents: (IFluidDependencySynthesizer | undefined)[]) {\n\t\tthis.parents = parents.filter((v): v is IFluidDependencySynthesizer => v !== undefined);\n\t}\n\n\t/**\n\t * Add a new provider\n\t * @param type - Name of the Type T being provided\n\t * @param provider - A provider that will resolve the T correctly when asked\n\t * @throws - If passing a type that's already registered\n\t */\n\tpublic register<T extends keyof TMap = keyof TMap>(\n\t\ttype: T,\n\t\tprovider: FluidObjectProvider<Pick<TMap, T>>,\n\t): void {\n\t\tif (this.providers.has(type)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Attempting to register a provider of type ${String(type)} that already exists`,\n\t\t\t);\n\t\t}\n\n\t\tthis.providers.set(type, provider);\n\t}\n\n\t/**\n\t * Remove a provider\n\t * @param type - Name of the provider to remove\n\t */\n\tpublic unregister(type: keyof TMap): void {\n\t\tif (this.providers.has(type)) {\n\t\t\tthis.providers.delete(type);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc (IFluidDependencySynthesizer:interface).synthesize}\n\t */\n\tpublic synthesize<O, R = undefined | Record<string, never>>(\n\t\toptionalTypes: FluidObjectSymbolProvider<O>,\n\t\trequiredTypes: Required<FluidObjectSymbolProvider<R>>,\n\t): AsyncFluidObjectProvider<O, R> {\n\t\tconst base: AsyncFluidObjectProvider<O, R> = {} as any;\n\t\tthis.generateRequired<R>(base, requiredTypes);\n\t\tthis.generateOptional<O>(base, optionalTypes);\n\t\tObject.defineProperty(base, IFluidDependencySynthesizer, { get: () => this });\n\t\treturn base;\n\t}\n\n\t/**\n\t * {@inheritDoc (IFluidDependencySynthesizer:interface).has}\n\t * @param excludeParents - If true, exclude checking parent registries\n\t */\n\tpublic has(type: string, excludeParents?: boolean): boolean {\n\t\tif (this.providers.has(type as keyof TMap)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (excludeParents !== true) {\n\t\t\treturn this.parents.some((p: IFluidDependencySynthesizer) => p.has(type));\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t * @deprecated Needed for backwards compatability.\n\t */\n\tprivate getProvider(provider: string & keyof TMap) {\n\t\t// this was removed, but some partners have trouble with back compat where they\n\t\t// use invalid patterns with FluidObject and IFluidDependencySynthesizer\n\t\t// this is just for back compat until those are removed\n\t\tif (this.has(provider)) {\n\t\t\tif (this.providers.has(provider)) {\n\t\t\t\treturn this.providers.get(provider);\n\t\t\t}\n\t\t\tfor (const parent of this.parents) {\n\t\t\t\tif (parent instanceof DependencyContainer) {\n\t\t\t\t\treturn parent.getProvider(provider);\n\t\t\t\t} else {\n\t\t\t\t\t// older implementations of the IFluidDependencySynthesizer exposed getProvider\n\t\t\t\t\tconst maybeGetProvider: { getProvider?(provider: string & keyof TMap) } =\n\t\t\t\t\t\tparent as any;\n\t\t\t\t\tif (maybeGetProvider?.getProvider !== undefined) {\n\t\t\t\t\t\treturn maybeGetProvider.getProvider(provider);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate generateRequired<T>(\n\t\tbase: AsyncRequiredFluidObjectProvider<T>,\n\t\ttypes: Required<FluidObjectSymbolProvider<T>>,\n\t) {\n\t\tif (types === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const key of Object.keys(types) as unknown as (keyof TMap)[]) {\n\t\t\tconst provider = this.resolveProvider(key);\n\t\t\tif (provider === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Object attempted to be created without registered required provider ${String(key)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tObject.defineProperty(base, key, provider);\n\t\t}\n\t}\n\n\tprivate generateOptional<T>(\n\t\tbase: AsyncOptionalFluidObjectProvider<T>,\n\t\ttypes: FluidObjectSymbolProvider<T>,\n\t) {\n\t\tif (types === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const key of Object.keys(types) as unknown as (keyof TMap)[]) {\n\t\t\t// back-compat: in 0.56 we allow undefined in the types, but we didn't before\n\t\t\t// this will keep runtime back compat, eventually we should support undefined properties\n\t\t\t// rather than properties that return promises that resolve to undefined\n\t\t\tconst provider = this.resolveProvider(key) ?? { get: async () => undefined };\n\t\t\tObject.defineProperty(base, key, provider);\n\t\t}\n\t}\n\n\tprivate resolveProvider<T extends keyof TMap>(t: T): PropertyDescriptor | undefined {\n\t\t// If we have the provider return it\n\t\tconst provider = this.providers.get(t);\n\t\tif (provider === undefined) {\n\t\t\tfor (const parent of this.parents) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\tconst sp = { [t]: t } as FluidObjectSymbolProvider<Pick<TMap, T>>;\n\t\t\t\tconst syn = parent.synthesize<Pick<TMap, T>, Record<string, unknown>>(sp, {});\n\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(syn, t);\n\t\t\t\tif (descriptor !== undefined) {\n\t\t\t\t\treturn descriptor;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// The double nested gets are required for lazy loading the provider resolution\n\t\tif (typeof provider === \"function\") {\n\t\t\treturn {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t\t\tget() {\n\t\t\t\t\tif (provider && typeof provider === \"function\") {\n\t\t\t\t\t\treturn Promise.resolve(this[IFluidDependencySynthesizer])\n\t\t\t\t\t\t\t.then(async (fds): Promise<any> => provider(fds))\n\t\t\t\t\t\t\t.then((p) => p?.[t]);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tget() {\n\t\t\t\tif (provider) {\n\t\t\t\t\treturn new LazyPromise(async () => {\n\t\t\t\t\t\treturn Promise.resolve(provider).then((p) => {\n\t\t\t\t\t\t\tif (p) {\n\t\t\t\t\t\t\t\treturn p[t];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dependencyContainer.js","sourceRoot":"","sources":["../src/dependencyContainer.ts"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E,EAAE,EAAE,CAAC,CAAC;gBAC9E,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBAC3D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;oBAC9B,OAAO,UAAU,CAAC;gBACnB,CAAC;YACF,CAAC;YACD,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,+EAA+E;QAC/E,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACpC,OAAO;gBACN,qEAAqE;gBACrE,GAAG;oBACF,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;wBAChD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;6BACvD,IAAI,CAAC,KAAK,EAAE,GAAG,EAAgB,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;6BAChD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;oBACvB,CAAC;gBACF,CAAC;aACD,CAAC;QACH,CAAC;QACD,OAAO;YACN,GAAG;gBACF,IAAI,QAAQ,EAAE,CAAC;oBACd,OAAO,IAAI,WAAW,CAAC,KAAK,IAAI,EAAE;wBACjC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;4BAC3C,IAAI,CAAC,EAAE,CAAC;gCACP,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;4BACb,CAAC;wBACF,CAAC,CAAC,CAAC;oBACJ,CAAC,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;SACD,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { LazyPromise } from \"@fluidframework/core-utils/internal\";\n\nimport { IFluidDependencySynthesizer } from \"./IFluidDependencySynthesizer.js\";\nimport {\n\tAsyncFluidObjectProvider,\n\tAsyncOptionalFluidObjectProvider,\n\tAsyncRequiredFluidObjectProvider,\n\tFluidObjectProvider,\n\tFluidObjectSymbolProvider,\n} from \"./types.js\";\n\n/**\n * DependencyContainer is similar to a IoC Container. It takes providers and will\n * synthesize an object based on them when requested.\n * @legacy\n * @alpha\n */\nexport class DependencyContainer<TMap> implements IFluidDependencySynthesizer {\n\tprivate readonly providers = new Map<keyof TMap, FluidObjectProvider<any>>();\n\tprivate readonly parents: IFluidDependencySynthesizer[];\n\tpublic get IFluidDependencySynthesizer() {\n\t\treturn this;\n\t}\n\n\tpublic constructor(...parents: (IFluidDependencySynthesizer | undefined)[]) {\n\t\tthis.parents = parents.filter((v): v is IFluidDependencySynthesizer => v !== undefined);\n\t}\n\n\t/**\n\t * Add a new provider\n\t * @param type - Name of the Type T being provided\n\t * @param provider - A provider that will resolve the T correctly when asked\n\t * @throws - If passing a type that's already registered\n\t */\n\tpublic register<T extends keyof TMap = keyof TMap>(\n\t\ttype: T,\n\t\tprovider: FluidObjectProvider<Pick<TMap, T>>,\n\t): void {\n\t\tif (this.providers.has(type)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Attempting to register a provider of type ${String(type)} that already exists`,\n\t\t\t);\n\t\t}\n\n\t\tthis.providers.set(type, provider);\n\t}\n\n\t/**\n\t * Remove a provider\n\t * @param type - Name of the provider to remove\n\t */\n\tpublic unregister(type: keyof TMap): void {\n\t\tif (this.providers.has(type)) {\n\t\t\tthis.providers.delete(type);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc (IFluidDependencySynthesizer:interface).synthesize}\n\t */\n\tpublic synthesize<O, R = undefined | Record<string, never>>(\n\t\toptionalTypes: FluidObjectSymbolProvider<O>,\n\t\trequiredTypes: Required<FluidObjectSymbolProvider<R>>,\n\t): AsyncFluidObjectProvider<O, R> {\n\t\tconst base: AsyncFluidObjectProvider<O, R> = {} as any;\n\t\tthis.generateRequired<R>(base, requiredTypes);\n\t\tthis.generateOptional<O>(base, optionalTypes);\n\t\tObject.defineProperty(base, IFluidDependencySynthesizer, { get: () => this });\n\t\treturn base;\n\t}\n\n\t/**\n\t * {@inheritDoc (IFluidDependencySynthesizer:interface).has}\n\t * @param excludeParents - If true, exclude checking parent registries\n\t */\n\tpublic has(type: string, excludeParents?: boolean): boolean {\n\t\tif (this.providers.has(type as keyof TMap)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (excludeParents !== true) {\n\t\t\treturn this.parents.some((p: IFluidDependencySynthesizer) => p.has(type));\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t * @deprecated Needed for backwards compatability.\n\t */\n\tprivate getProvider(provider: string & keyof TMap) {\n\t\t// this was removed, but some partners have trouble with back compat where they\n\t\t// use invalid patterns with FluidObject and IFluidDependencySynthesizer\n\t\t// this is just for back compat until those are removed\n\t\tif (this.has(provider)) {\n\t\t\tif (this.providers.has(provider)) {\n\t\t\t\treturn this.providers.get(provider);\n\t\t\t}\n\t\t\tfor (const parent of this.parents) {\n\t\t\t\tif (parent instanceof DependencyContainer) {\n\t\t\t\t\treturn parent.getProvider(provider);\n\t\t\t\t} else {\n\t\t\t\t\t// older implementations of the IFluidDependencySynthesizer exposed getProvider\n\t\t\t\t\tconst maybeGetProvider: { getProvider?(provider: string & keyof TMap) } =\n\t\t\t\t\t\tparent as any;\n\t\t\t\t\tif (maybeGetProvider?.getProvider !== undefined) {\n\t\t\t\t\t\treturn maybeGetProvider.getProvider(provider);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate generateRequired<T>(\n\t\tbase: AsyncRequiredFluidObjectProvider<T>,\n\t\ttypes: Required<FluidObjectSymbolProvider<T>>,\n\t) {\n\t\tif (types === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const key of Object.keys(types) as unknown as (keyof TMap)[]) {\n\t\t\tconst provider = this.resolveProvider(key);\n\t\t\tif (provider === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Object attempted to be created without registered required provider ${String(key)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tObject.defineProperty(base, key, provider);\n\t\t}\n\t}\n\n\tprivate generateOptional<T>(\n\t\tbase: AsyncOptionalFluidObjectProvider<T>,\n\t\ttypes: FluidObjectSymbolProvider<T>,\n\t) {\n\t\tif (types === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const key of Object.keys(types) as unknown as (keyof TMap)[]) {\n\t\t\t// back-compat: in 0.56 we allow undefined in the types, but we didn't before\n\t\t\t// this will keep runtime back compat, eventually we should support undefined properties\n\t\t\t// rather than properties that return promises that resolve to undefined\n\t\t\tconst provider = this.resolveProvider(key) ?? { get: async () => undefined };\n\t\t\tObject.defineProperty(base, key, provider);\n\t\t}\n\t}\n\n\tprivate resolveProvider<T extends keyof TMap>(t: T): PropertyDescriptor | undefined {\n\t\t// If we have the provider return it\n\t\tconst provider = this.providers.get(t);\n\t\tif (provider === undefined) {\n\t\t\tfor (const parent of this.parents) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\tconst sp = { [t]: t } as FluidObjectSymbolProvider<Pick<TMap, T>>;\n\t\t\t\tconst syn = parent.synthesize<Pick<TMap, T>, Record<string, unknown>>(sp, {});\n\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(syn, t);\n\t\t\t\tif (descriptor !== undefined) {\n\t\t\t\t\treturn descriptor;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// The double nested gets are required for lazy loading the provider resolution\n\t\tif (typeof provider === \"function\") {\n\t\t\treturn {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t\t\tget() {\n\t\t\t\t\tif (provider && typeof provider === \"function\") {\n\t\t\t\t\t\treturn Promise.resolve(this[IFluidDependencySynthesizer])\n\t\t\t\t\t\t\t.then(async (fds): Promise<any> => provider(fds))\n\t\t\t\t\t\t\t.then((p) => p?.[t]);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tget() {\n\t\t\t\tif (provider) {\n\t\t\t\t\treturn new LazyPromise(async () => {\n\t\t\t\t\t\treturn Promise.resolve(provider).then((p) => {\n\t\t\t\t\t\t\tif (p) {\n\t\t\t\t\t\t\t\treturn p[t];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n}\n"]}
|
package/lib/legacy.d.ts
CHANGED
package/lib/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { IFluidDependencySynthesizer } from "./IFluidDependencySynthesizer.js";
|
|
|
13
13
|
* ```typescript
|
|
14
14
|
* { IFoo: "IFoo" }
|
|
15
15
|
* ```
|
|
16
|
+
* @legacy
|
|
16
17
|
* @alpha
|
|
17
18
|
*/
|
|
18
19
|
export type FluidObjectSymbolProvider<T> = {
|
|
@@ -22,6 +23,7 @@ export type FluidObjectSymbolProvider<T> = {
|
|
|
22
23
|
* This is a condensed version of Record that requires the object has all
|
|
23
24
|
* the FluidObject properties as its type mapped to an object that implements
|
|
24
25
|
* the property.
|
|
26
|
+
* @legacy
|
|
25
27
|
* @alpha
|
|
26
28
|
*/
|
|
27
29
|
export type AsyncRequiredFluidObjectProvider<T> = T extends undefined ? Record<string, never> : {
|
|
@@ -31,6 +33,7 @@ export type AsyncRequiredFluidObjectProvider<T> = T extends undefined ? Record<s
|
|
|
31
33
|
* This is a condensed version of Record that requires the object has all
|
|
32
34
|
* the FluidObject properties as its type, mapped to an object that implements
|
|
33
35
|
* the property or undefined.
|
|
36
|
+
* @legacy
|
|
34
37
|
* @alpha
|
|
35
38
|
*/
|
|
36
39
|
export type AsyncOptionalFluidObjectProvider<T> = T extends undefined ? Record<string, never> : {
|
|
@@ -38,11 +41,13 @@ export type AsyncOptionalFluidObjectProvider<T> = T extends undefined ? Record<s
|
|
|
38
41
|
};
|
|
39
42
|
/**
|
|
40
43
|
* Combined type for Optional and Required Async Fluid object Providers
|
|
44
|
+
* @legacy
|
|
41
45
|
* @alpha
|
|
42
46
|
*/
|
|
43
47
|
export type AsyncFluidObjectProvider<O, R = undefined> = AsyncOptionalFluidObjectProvider<O> & AsyncRequiredFluidObjectProvider<R>;
|
|
44
48
|
/**
|
|
45
49
|
* Multiple ways to provide a Fluid object.
|
|
50
|
+
* @legacy
|
|
46
51
|
* @alpha
|
|
47
52
|
*/
|
|
48
53
|
export type FluidObjectProvider<T> = NonNullable<T> | Promise<NonNullable<T>> | ((dependencyContainer: IFluidDependencySynthesizer) => NonNullable<T>) | ((dependencyContainer: IFluidDependencySynthesizer) => Promise<NonNullable<T>>);
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI;KACzC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,gCAAgC,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAClE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACrB;KACC,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC;CACrE,CAAC;AAEJ;;;;;;GAMG;AACH,MAAM,MAAM,gCAAgC,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAClE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACrB;KACC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CAC1C,CAAC;AAEJ;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,IAAI,gCAAgC,CAAC,CAAC,CAAC,GAC3F,gCAAgC,CAAC,CAAC,CAAC,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAC9B,WAAW,CAAC,CAAC,CAAC,GACd,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACvB,CAAC,CAAC,mBAAmB,EAAE,2BAA2B,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,GACtE,CAAC,CAAC,mBAAmB,EAAE,2BAA2B,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidDependencySynthesizer } from \"./IFluidDependencySynthesizer.js\";\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type mapped to a string representation\n * of that property.\n *\n * @example\n *\n * ```typescript\n * { IFoo: \"IFoo\" }\n * ```\n * @alpha\n */\nexport type FluidObjectSymbolProvider<T> = {\n\t[P in keyof T]?: P;\n};\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type mapped to an object that implements\n * the property.\n * @alpha\n */\nexport type AsyncRequiredFluidObjectProvider<T> = T extends undefined\n\t? Record<string, never>\n\t: {\n\t\t\t[P in keyof T]: Promise<NonNullable<Exclude<T[P], undefined | null>>>;\n\t\t};\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type, mapped to an object that implements\n * the property or undefined.\n * @alpha\n */\nexport type AsyncOptionalFluidObjectProvider<T> = T extends undefined\n\t? Record<string, never>\n\t: {\n\t\t\t[P in keyof T]?: Promise<T[P] | undefined>;\n\t\t};\n\n/**\n * Combined type for Optional and Required Async Fluid object Providers\n * @alpha\n */\nexport type AsyncFluidObjectProvider<O, R = undefined> = AsyncOptionalFluidObjectProvider<O> &\n\tAsyncRequiredFluidObjectProvider<R>;\n\n/**\n * Multiple ways to provide a Fluid object.\n * @alpha\n */\nexport type FluidObjectProvider<T> =\n\t| NonNullable<T>\n\t| Promise<NonNullable<T>>\n\t| ((dependencyContainer: IFluidDependencySynthesizer) => NonNullable<T>)\n\t| ((dependencyContainer: IFluidDependencySynthesizer) => Promise<NonNullable<T>>);\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidDependencySynthesizer } from \"./IFluidDependencySynthesizer.js\";\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type mapped to a string representation\n * of that property.\n *\n * @example\n *\n * ```typescript\n * { IFoo: \"IFoo\" }\n * ```\n * @legacy\n * @alpha\n */\nexport type FluidObjectSymbolProvider<T> = {\n\t[P in keyof T]?: P;\n};\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type mapped to an object that implements\n * the property.\n * @legacy\n * @alpha\n */\nexport type AsyncRequiredFluidObjectProvider<T> = T extends undefined\n\t? Record<string, never>\n\t: {\n\t\t\t[P in keyof T]: Promise<NonNullable<Exclude<T[P], undefined | null>>>;\n\t\t};\n\n/**\n * This is a condensed version of Record that requires the object has all\n * the FluidObject properties as its type, mapped to an object that implements\n * the property or undefined.\n * @legacy\n * @alpha\n */\nexport type AsyncOptionalFluidObjectProvider<T> = T extends undefined\n\t? Record<string, never>\n\t: {\n\t\t\t[P in keyof T]?: Promise<T[P] | undefined>;\n\t\t};\n\n/**\n * Combined type for Optional and Required Async Fluid object Providers\n * @legacy\n * @alpha\n */\nexport type AsyncFluidObjectProvider<O, R = undefined> = AsyncOptionalFluidObjectProvider<O> &\n\tAsyncRequiredFluidObjectProvider<R>;\n\n/**\n * Multiple ways to provide a Fluid object.\n * @legacy\n * @alpha\n */\nexport type FluidObjectProvider<T> =\n\t| NonNullable<T>\n\t| Promise<NonNullable<T>>\n\t| ((dependencyContainer: IFluidDependencySynthesizer) => NonNullable<T>)\n\t| ((dependencyContainer: IFluidDependencySynthesizer) => Promise<NonNullable<T>>);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/synthesize",
|
|
3
|
-
"version": "2.1.0-
|
|
3
|
+
"version": "2.1.0-276985",
|
|
4
4
|
"description": "A library for synthesizing scope objects.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -67,19 +67,19 @@
|
|
|
67
67
|
"temp-directory": "nyc/.nyc_output"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@fluidframework/core-utils": "2.1.0-
|
|
70
|
+
"@fluidframework/core-utils": "2.1.0-276985"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
74
74
|
"@biomejs/biome": "^1.7.3",
|
|
75
|
-
"@fluid-internal/mocha-test-setup": "2.1.0-
|
|
75
|
+
"@fluid-internal/mocha-test-setup": "2.1.0-276985",
|
|
76
76
|
"@fluid-tools/build-cli": "^0.39.0",
|
|
77
77
|
"@fluidframework/build-common": "^2.0.3",
|
|
78
78
|
"@fluidframework/build-tools": "^0.39.0",
|
|
79
|
-
"@fluidframework/core-interfaces": "2.1.0-
|
|
80
|
-
"@fluidframework/datastore": "2.1.0-
|
|
79
|
+
"@fluidframework/core-interfaces": "2.1.0-276985",
|
|
80
|
+
"@fluidframework/datastore": "2.1.0-276985",
|
|
81
81
|
"@fluidframework/eslint-config-fluid": "^5.3.0",
|
|
82
|
-
"@fluidframework/runtime-utils": "2.1.0-
|
|
82
|
+
"@fluidframework/runtime-utils": "2.1.0-276985",
|
|
83
83
|
"@fluidframework/synthesize-previous": "npm:@fluidframework/synthesize@2.0.0-rc.5.0.0",
|
|
84
84
|
"@microsoft/api-extractor": "^7.45.1",
|
|
85
85
|
"@types/mocha": "^9.1.1",
|
|
@@ -102,8 +102,8 @@
|
|
|
102
102
|
},
|
|
103
103
|
"scripts": {
|
|
104
104
|
"api": "fluid-build . --task api",
|
|
105
|
-
"api-extractor:commonjs": "flub generate entrypoints --
|
|
106
|
-
"api-extractor:esnext": "flub generate entrypoints --
|
|
105
|
+
"api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
|
|
106
|
+
"api-extractor:esnext": "flub generate entrypoints --outDir ./lib --node10TypeCompat",
|
|
107
107
|
"build": "fluid-build . --task build",
|
|
108
108
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
109
109
|
"build:compile": "fluid-build . --task compile",
|
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
import { AsyncFluidObjectProvider, FluidObjectSymbolProvider } from "./types.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
+
* @legacy
|
|
9
10
|
* @alpha
|
|
10
11
|
*/
|
|
11
12
|
export const IFluidDependencySynthesizer: keyof IProvideFluidDependencySynthesizer =
|
|
12
13
|
"IFluidDependencySynthesizer";
|
|
13
14
|
|
|
14
15
|
/**
|
|
16
|
+
* @legacy
|
|
15
17
|
* @alpha
|
|
16
18
|
*/
|
|
17
19
|
export interface IProvideFluidDependencySynthesizer {
|
|
@@ -22,6 +24,7 @@ export interface IProvideFluidDependencySynthesizer {
|
|
|
22
24
|
* IFluidDependencySynthesizer can generate FluidObjects based on the IProvideFluidObject pattern.
|
|
23
25
|
* It allow for registering providers and uses synthesize to generate a new object with the optional
|
|
24
26
|
* and required types.
|
|
27
|
+
* @legacy
|
|
25
28
|
* @alpha
|
|
26
29
|
*/
|
|
27
30
|
export interface IFluidDependencySynthesizer extends IProvideFluidDependencySynthesizer {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
/**
|
|
18
18
|
* DependencyContainer is similar to a IoC Container. It takes providers and will
|
|
19
19
|
* synthesize an object based on them when requested.
|
|
20
|
+
* @legacy
|
|
20
21
|
* @alpha
|
|
21
22
|
*/
|
|
22
23
|
export class DependencyContainer<TMap> implements IFluidDependencySynthesizer {
|
package/src/types.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { IFluidDependencySynthesizer } from "./IFluidDependencySynthesizer.js";
|
|
|
15
15
|
* ```typescript
|
|
16
16
|
* { IFoo: "IFoo" }
|
|
17
17
|
* ```
|
|
18
|
+
* @legacy
|
|
18
19
|
* @alpha
|
|
19
20
|
*/
|
|
20
21
|
export type FluidObjectSymbolProvider<T> = {
|
|
@@ -25,6 +26,7 @@ export type FluidObjectSymbolProvider<T> = {
|
|
|
25
26
|
* This is a condensed version of Record that requires the object has all
|
|
26
27
|
* the FluidObject properties as its type mapped to an object that implements
|
|
27
28
|
* the property.
|
|
29
|
+
* @legacy
|
|
28
30
|
* @alpha
|
|
29
31
|
*/
|
|
30
32
|
export type AsyncRequiredFluidObjectProvider<T> = T extends undefined
|
|
@@ -37,6 +39,7 @@ export type AsyncRequiredFluidObjectProvider<T> = T extends undefined
|
|
|
37
39
|
* This is a condensed version of Record that requires the object has all
|
|
38
40
|
* the FluidObject properties as its type, mapped to an object that implements
|
|
39
41
|
* the property or undefined.
|
|
42
|
+
* @legacy
|
|
40
43
|
* @alpha
|
|
41
44
|
*/
|
|
42
45
|
export type AsyncOptionalFluidObjectProvider<T> = T extends undefined
|
|
@@ -47,6 +50,7 @@ export type AsyncOptionalFluidObjectProvider<T> = T extends undefined
|
|
|
47
50
|
|
|
48
51
|
/**
|
|
49
52
|
* Combined type for Optional and Required Async Fluid object Providers
|
|
53
|
+
* @legacy
|
|
50
54
|
* @alpha
|
|
51
55
|
*/
|
|
52
56
|
export type AsyncFluidObjectProvider<O, R = undefined> = AsyncOptionalFluidObjectProvider<O> &
|
|
@@ -54,6 +58,7 @@ export type AsyncFluidObjectProvider<O, R = undefined> = AsyncOptionalFluidObjec
|
|
|
54
58
|
|
|
55
59
|
/**
|
|
56
60
|
* Multiple ways to provide a Fluid object.
|
|
61
|
+
* @legacy
|
|
57
62
|
* @alpha
|
|
58
63
|
*/
|
|
59
64
|
export type FluidObjectProvider<T> =
|
|
File without changes
|