@financial-times/dotcom-ui-app-context 7.2.7 → 7.3.1
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/dist/browser/client/AppContext.d.ts +10 -0
- package/dist/browser/client/browser.d.ts +2 -0
- package/dist/browser/client/loadAppContext.d.ts +2 -0
- package/dist/browser/components/AppContextEmbed.d.ts +6 -0
- package/dist/browser/constants.d.ts +1 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/node/client/AppContext.d.ts +10 -0
- package/dist/node/client/browser.d.ts +2 -0
- package/dist/node/client/loadAppContext.d.ts +2 -0
- package/dist/node/components/AppContextEmbed.d.ts +6 -0
- package/dist/node/constants.d.ts +1 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/tsconfig.tsbuildinfo +2084 -0
- package/package.json +8 -6
- package/src/client/AppContext.ts +0 -20
- package/src/client/browser.ts +0 -11
- package/src/client/loadAppContext.ts +0 -7
- package/src/components/AppContextEmbed.ts +0 -11
- package/src/constants.ts +0 -1
- package/src/index.ts +0 -2
- package/src/types.d.ts +0 -14
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/dotcom-ui-app-context",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "component.js",
|
|
6
6
|
"browser": "browser.js",
|
|
7
7
|
"types": "src/index.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
-
"tsc": "../../node_modules/.bin/tsc --incremental",
|
|
11
10
|
"clean": "npm run clean:dist && npm run clean:node_modules",
|
|
12
11
|
"clean:dist": "rm -rf dist",
|
|
13
12
|
"clean:node_modules": "rm -rf node_modules",
|
|
14
13
|
"clean:install": "npm run clean && npm i",
|
|
15
|
-
"build:
|
|
16
|
-
"build:
|
|
14
|
+
"build:browser": "tsc --module es2015 --outDir ./dist/browser",
|
|
15
|
+
"build:node": "tsc",
|
|
17
16
|
"build": "npm run build:node && npm run build:browser",
|
|
18
17
|
"dev": "echo -n node browser | parallel -u -d ' ' npm run build:{} -- --watch",
|
|
19
18
|
"preinstall": "[ \"$INIT_CWD\" != \"$PWD\" ] || npm_config_yes=true npx check-engine"
|
|
@@ -25,6 +24,9 @@
|
|
|
25
24
|
"node": ">= 14.0.0",
|
|
26
25
|
"npm": "7.x || 8.x"
|
|
27
26
|
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/"
|
|
29
|
+
],
|
|
28
30
|
"repository": {
|
|
29
31
|
"type": "git",
|
|
30
32
|
"repository": "https://github.com/Financial-Times/dotcom-page-kit.git",
|
|
@@ -32,7 +34,7 @@
|
|
|
32
34
|
},
|
|
33
35
|
"homepage": "https://github.com/Financial-Times/dotcom-page-kit/tree/HEAD/packages/dotcom-ui-app-context",
|
|
34
36
|
"dependencies": {
|
|
35
|
-
"@financial-times/dotcom-ui-data-embed": "
|
|
37
|
+
"@financial-times/dotcom-ui-data-embed": "file:../dotcom-ui-data-embed"
|
|
36
38
|
},
|
|
37
39
|
"volta": {
|
|
38
40
|
"extends": "../../package.json"
|
|
@@ -40,4 +42,4 @@
|
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"check-engine": "^1.10.1"
|
|
42
44
|
}
|
|
43
|
-
}
|
|
45
|
+
}
|
package/src/client/AppContext.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { TAppContext } from '../types'
|
|
2
|
-
|
|
3
|
-
export type TAppContextOptions = {
|
|
4
|
-
appContext: TAppContext
|
|
5
|
-
}
|
|
6
|
-
export default class AppContext {
|
|
7
|
-
private appContext: TAppContext
|
|
8
|
-
|
|
9
|
-
constructor(options: TAppContextOptions) {
|
|
10
|
-
this.appContext = Object.freeze(options.appContext)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
get(property: string): any {
|
|
14
|
-
return this.appContext.hasOwnProperty(property) ? this.appContext[property] : undefined
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getAll(): TAppContext {
|
|
18
|
-
return this.appContext
|
|
19
|
-
}
|
|
20
|
-
}
|
package/src/client/browser.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import AppContext from './AppContext'
|
|
2
|
-
import loadEmbeddedAppContext from './loadAppContext'
|
|
3
|
-
|
|
4
|
-
export function init() {
|
|
5
|
-
const appContext = loadEmbeddedAppContext()
|
|
6
|
-
const client = new AppContext({ appContext })
|
|
7
|
-
|
|
8
|
-
console.log('Page Kit app context:', client.getAll()) // eslint-disable-line no-console
|
|
9
|
-
|
|
10
|
-
return client
|
|
11
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { loadDataEmbed } from '@financial-times/dotcom-ui-data-embed'
|
|
2
|
-
import { TAppContext } from '../types'
|
|
3
|
-
import { APP_CONTEXT_ELEMENT_ID } from '../constants'
|
|
4
|
-
|
|
5
|
-
export default function loadEmbeddedAppContext(): TAppContext {
|
|
6
|
-
return loadDataEmbed(APP_CONTEXT_ELEMENT_ID) as TAppContext
|
|
7
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DataEmbed } from '@financial-times/dotcom-ui-data-embed'
|
|
2
|
-
import { TAppContext } from '../types'
|
|
3
|
-
import { APP_CONTEXT_ELEMENT_ID } from '../constants'
|
|
4
|
-
|
|
5
|
-
export type TAppContextProps = {
|
|
6
|
-
appContext?: TAppContext
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function AppContextEmbed({ appContext }: TAppContextProps) {
|
|
10
|
-
return DataEmbed({ id: APP_CONTEXT_ELEMENT_ID, data: appContext })
|
|
11
|
-
}
|
package/src/constants.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const APP_CONTEXT_ELEMENT_ID = 'page-kit-app-context'
|
package/src/index.ts
DELETED
package/src/types.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface TAppContext {
|
|
2
|
-
appName: string
|
|
3
|
-
appVersion: string
|
|
4
|
-
product: string
|
|
5
|
-
edition: string
|
|
6
|
-
abTestState: string
|
|
7
|
-
contentId?: string
|
|
8
|
-
contentType?: string
|
|
9
|
-
conceptId?: string
|
|
10
|
-
conceptType?: string
|
|
11
|
-
isProduction: boolean
|
|
12
|
-
publishReference?: string
|
|
13
|
-
[key: string]: any
|
|
14
|
-
}
|