@ms-cloudpack/data-bus 0.4.1 → 0.4.3
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 +1 -1
- package/lib/createDataBus.js.map +1 -1
- package/lib/getNode.js.map +1 -1
- package/lib/publish.js.map +1 -1
- package/lib/subscribe.js.map +1 -1
- package/package.json +3 -3
- package/lib/tsdoc-metadata.json +0 -11
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ Cloudpack runs a bundle service which is accessed to retrieve esm package bundle
|
|
|
122
122
|
|
|
123
123
|
Many consumers may request the same bundle at the same time. This implies 1. We need to dedupe redundant requests, and 2. We need to reuse the output to fulfill future requests.
|
|
124
124
|
|
|
125
|
-
In the original implementation, requests to the same resource would first check cache for results, find it missing, and start bundling by calling an imperative api like `async bundle(options: Options): Result`. This would write to a cache location, which would then
|
|
125
|
+
In the original implementation, requests to the same resource would first check cache for results, find it missing, and start bundling by calling an imperative api like `async bundle(options: Options): Result`. This would write to a cache location, which would then fulfill future requests. But this left race conditions because we weren't deduping in-flight requests, nor were we re-populating bundles that changed inputs slightly. This led to the question: what kind of architecture would we need to essentially dedupe redundant requests, and provide a general architecture for caching content?
|
|
126
126
|
|
|
127
127
|
We ran into other similar scenarios:
|
|
128
128
|
|
package/lib/createDataBus.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDataBus.js","sourceRoot":"","sources":["../src/createDataBus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQ3C;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,K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gBAED,eAAe,EAAE,CAAC;YACpB,CAAC,CAAC;YAEF,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAE1B,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,WAAW,CAAC,QAAyB;YACnC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC/B,CAAC;QAED,OAAO;YACL,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE,CAAC;gBAClC,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;KACF,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { addProvider } from './addProvider.js';\nimport { createNode } from './createNode.js';\nimport { getData } from './getData.js';\nimport { publish } from './publish.js';\nimport { subscribe } from './subscribe.js';\nimport type { DataBusChangeFunction } from './types/DataBusChangeFunction.js';\nimport type { DataBusProvider } from './types/DataBusProvider.js';\nimport type { DataBusState } from './types/DataBusState.js';\nimport type { DataBus } from './types/DataBus.js';\nimport type { DisposeFunction } from './types/DisposeFunction.js';\nimport type { DataBusPath } from './index.js';\n\n/**\n * Creates a new data bus instance.\n */\nexport function createDataBus(): DataBus {\n const state: DataBusState = {\n root: createNode(),\n };\n\n const disposables: DisposeFunction[] = [];\n\n const bus: DataBus = {\n publish<TData>(path: string[] | DataBusPath, value: TData) {\n const publishPath = Array.isArray(path) ? path : path.path;\n\n return publish(state, bus, publishPath, value);\n },\n\n getData<TData>(path: string[] | DataBusPath) {\n const publishPath = Array.isArray(path) ? path : path.path;\n\n return getData<TData>(state, publishPath);\n },\n\n subscribe(path: string[] | DataBusPath, change: DataBusChangeFunction) {\n const publishPath = Array.isArray(path) ? path : path.path;\n const internalDispose = subscribe(state, bus, publishPath, change);\n\n const dispose = () => {\n const index = disposables.indexOf(dispose);\n\n if (index !== -1) {\n disposables.splice(index, 1);\n }\n\n internalDispose();\n };\n\n disposables.push(dispose);\n\n return dispose;\n },\n\n addProvider(provider: DataBusProvider) {\n addProvider(state, provider);\n },\n\n dispose() {\n for (const dispose of disposables) {\n dispose();\n }\n },\n };\n\n return bus;\n}\n"]}
|
package/lib/getNode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNode.js","sourceRoot":"","sources":["../src/getNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAqB7C,MAAM,UAAU,OAAO,CACrB,KAAmB,EACnB,IAAc,EACd,UAAoB;IAKpB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,IAAI,GAA4B,KAAK,CAAC,IAAI,CAAC;IAC/C,MAAM,QAAQ,GAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE7C,OAAO,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"getNode.js","sourceRoot":"","sources":["../src/getNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAqB7C,MAAM,UAAU,OAAO,CACrB,KAAmB,EACnB,IAAc,EACd,UAAoB;IAKpB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,IAAI,GAA4B,KAAK,CAAC,IAAI,CAAC;IAC/C,MAAM,QAAQ,GAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE7C,OAAO,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAE/B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,IAAI,UAAU,EAAE,CAAC;YAC7C,IAAI,CAAC,QAAQ,KAAK,EAAE,CAAC;YACrB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QACjD,CAAC;QAED,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;QACjC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,IAAI;QACJ,QAAQ;KACT,CAAC;AACJ,CAAC","sourcesContent":["import { createNode } from './createNode.js';\nimport type { DataBusNode } from './types/DataBusNode.js';\nimport type { DataBusState } from './types/DataBusState.js';\n\nexport function getNode(\n state: DataBusState,\n path: string[],\n): {\n node: DataBusNode;\n nodePath: DataBusNode[];\n};\n\nexport function getNode(\n state: DataBusState,\n path: string[],\n createPath: true,\n): {\n node: DataBusNode;\n nodePath: DataBusNode[];\n};\n\nexport function getNode(\n state: DataBusState,\n path: string[],\n createPath?: boolean,\n): {\n node: DataBusNode | undefined;\n nodePath: DataBusNode[];\n} {\n let index = 0;\n let node: DataBusNode | undefined = state.root;\n const nodePath: DataBusNode[] = [state.root];\n\n while (node && index < path.length) {\n const pathName = path[index++];\n\n if (!node.children?.[pathName] && createPath) {\n node.children ??= {};\n node.children[pathName] = createNode(pathName);\n }\n\n node = node.children?.[pathName];\n node && nodePath.push(node);\n }\n\n return {\n node,\n nodePath,\n };\n}\n"]}
|
package/lib/publish.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;GAEG;AACH,MAAM,UAAU,OAAO,CAAQ,KAAmB,EAAE,GAAY,EAAE,IAAc,EAAE,KAAY;IAC5F,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAc,CAAC;IAErC,qGAAqG;IACrG,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAA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ataBusState.js';\nimport type { DataBus } from './types/DataBus.js';\nimport { getNode } from './getNode.js';\n\n/**\n * Publishes data to a given dataPath/Id.\n */\nexport function publish<TData>(state: DataBusState, bus: DataBus, path: string[], value: TData): void {\n const { node, nodePath } = getNode(state, path, true);\n const oldValue = node.value as TData;\n\n // Notify pre-publishing providers and allow them to apply transforms or publish additional metadata.\n for (let i = nodePath.length - 1; i >= 0; i--) {\n nodePath[i].providers?.forEach((provider) => {\n const newValue = provider.onPublish?.({ bus, value, oldValue, path }) as TData | undefined;\n\n if (newValue !== undefined) {\n value = newValue;\n }\n });\n }\n\n node.value = value;\n\n // Notify subscribers\n for (let i = nodePath.length - 1; i >= 0; i--) {\n nodePath[i].subscribers?.forEach((subscriber) => subscriber(value, oldValue, path));\n }\n}\n"]}
|
package/lib/subscribe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../src/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAMvC,MAAM,UAAU,SAAS,CACvB,KAAmB,EACnB,GAAY,EACZ,IAAc,EACd,MAA6B;IAE7B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACtD,mEAAmE;IACnE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACvB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAElC,IAAI,CAAC,WAAW,KAAK,IAAI,GAAG,EAAyB,CAAC;IACtD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE7B,0CAA0C;IAC1C,IAAI,KAAK,KAAK,SAAS,EAAE;
|
|
1
|
+
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../src/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,O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Ae,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAEjC,wBAAwB;QACxB,KAAK,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YAC1D,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;YAEpC,IAAI,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;gBAClC,MAAM,YAAY,GAAG,WAAW,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,CAAC;gBAE/D,IAAI,YAAY,EAAE,CAAC;oBACjB,YAAY,CAAC,KAAK,EAAE,CAAC;oBAErB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;wBACxB,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;wBACrD,OAAO,WAAW,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,CAAC;oBACnD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { getNode } from './getNode.js';\nimport type { DataBusChangeFunction } from './types/DataBusChangeFunction.js';\nimport type { DisposeFunction } from './types/DisposeFunction.js';\nimport type { DataBusState } from './types/DataBusState.js';\nimport type { DataBus } from './types/DataBus.js';\n\nexport function subscribe(\n state: DataBusState,\n bus: DataBus,\n path: string[],\n change: DataBusChangeFunction,\n): DisposeFunction {\n const { node, nodePath } = getNode(state, path, true);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const { value } = node;\n const pathString = path.join('/');\n\n node.subscribers ??= new Set<DataBusChangeFunction>();\n node.subscribers.add(change);\n\n // Fire the initial change with the value.\n if (value !== undefined) {\n change(value, value, path);\n }\n\n // Activate any deactivated providers available for this path.\n for (let index = nodePath.length - 1; index >= 0; index--) {\n const currentNode = nodePath[index];\n\n if (currentNode.providers?.length) {\n const activeProviders = (currentNode.activeProviders ??= {});\n\n currentNode.providers.forEach((provider) => {\n activeProviders[pathString] ??= { provider, count: 0 };\n\n if (activeProviders[pathString].count === 0) {\n provider.onActivate?.({ path, bus });\n }\n\n activeProviders[pathString].count++;\n });\n }\n }\n\n return () => {\n node.subscribers?.delete(change);\n\n // Deactivate providers.\n for (let index = nodePath.length - 1; index >= 0; index--) {\n const currentNode = nodePath[index];\n\n if (currentNode.providers?.length) {\n const activeRecord = currentNode.activeProviders?.[pathString];\n\n if (activeRecord) {\n activeRecord.count--;\n\n if (!activeRecord.count) {\n activeRecord?.provider.onDeactivate?.({ path, bus });\n delete currentNode.activeProviders?.[pathString];\n }\n }\n }\n }\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/data-bus",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "A data bus implementation.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"zod": "^3.21.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@ms-cloudpack/eslint-plugin-internal": "
|
|
31
|
-
"@ms-cloudpack/scripts": "
|
|
30
|
+
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
31
|
+
"@ms-cloudpack/scripts": "^0.0.1"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"lib/**/!(*.test.*)"
|
package/lib/tsdoc-metadata.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.36.4"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|