@favish/staffbase-utils 0.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/README.md +21 -0
- package/dist/log.cjs.js +2 -0
- package/dist/log.cjs.js.map +1 -0
- package/dist/log.es.mjs +14 -0
- package/dist/log.es.mjs.map +1 -0
- package/dist/src/log/index.d.ts +5 -0
- package/dist/src/log/index.d.ts.map +1 -0
- package/dist/src/log/logDebug.d.ts +6 -0
- package/dist/src/log/logDebug.d.ts.map +1 -0
- package/dist/src/log/logError.d.ts +6 -0
- package/dist/src/log/logError.d.ts.map +1 -0
- package/dist/src/log/logWarn.d.ts +6 -0
- package/dist/src/log/logWarn.d.ts.map +1 -0
- package/dist/src/log/loggingState.d.ts +9 -0
- package/dist/src/log/loggingState.d.ts.map +1 -0
- package/dist/src/log/setLoggingEnabled.d.ts +6 -0
- package/dist/src/log/setLoggingEnabled.d.ts.map +1 -0
- package/package.json +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @favish/staffbase-utils
|
|
2
|
+
|
|
3
|
+
Shared internal/host utilities for Staffbase widgets. Tree-shakeable subpath
|
|
4
|
+
modules; import only what you use.
|
|
5
|
+
|
|
6
|
+
## Modules
|
|
7
|
+
|
|
8
|
+
- `@favish/staffbase-utils/log` — `logError`, `logWarn`, `logDebug`, `setLoggingEnabled`
|
|
9
|
+
|
|
10
|
+
## Logging
|
|
11
|
+
|
|
12
|
+
The library never reads env flags directly (webview-safe). Enable console output
|
|
13
|
+
once at widget startup with your own flag:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { setLoggingEnabled } from '@favish/staffbase-utils/log'
|
|
17
|
+
|
|
18
|
+
setLoggingEnabled(import.meta.env.VITE_SHOW_CONSOLE_ERRORS === 'true')
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Disabled by default, so production stays silent.
|
package/dist/log.cjs.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={enabled:!1},t=(...t)=>{e.enabled&&console.log(...t)},n=(...t)=>{e.enabled&&console.error(...t)},r=(...t)=>{e.enabled&&console.warn(...t)},i=t=>{e.enabled=t};exports.logDebug=t,exports.logError=n,exports.logWarn=r,exports.setLoggingEnabled=i;
|
|
2
|
+
//# sourceMappingURL=log.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.cjs.js","names":[],"sources":["../src/log/loggingState.ts","../src/log/logDebug.ts","../src/log/logError.ts","../src/log/logWarn.ts","../src/log/setLoggingEnabled.ts"],"sourcesContent":["/**\n * Module-private on/off switch for console diagnostics. Default false keeps\n * production silent. Consumers flip it via setLoggingEnabled at startup so the\n * library never reads the host environment flags directly (webview-safe).\n */\nexport const loggingState: { enabled: boolean } = { enabled: false }\n","import { loggingState } from './loggingState'\n\n/**\n * Logs a debug message only when logging is enabled. Silent by default.\n * @param {...unknown} args - Arguments forwarded to console.log.\n */\nexport const logDebug = (...args: unknown[]): void => {\n // eslint-disable-next-line no-console\n if (loggingState.enabled) console.log(...args)\n}\n","import { loggingState } from './loggingState'\n\n/**\n * Logs an error only when logging is enabled. Silent by default.\n * @param {...unknown} args - Arguments forwarded to console.error.\n */\nexport const logError = (...args: unknown[]): void => {\n if (loggingState.enabled) console.error(...args)\n}\n","import { loggingState } from './loggingState'\n\n/**\n * Logs a warning only when logging is enabled. Silent by default.\n * @param {...unknown} args - Arguments forwarded to console.warn.\n */\nexport const logWarn = (...args: unknown[]): void => {\n if (loggingState.enabled) console.warn(...args)\n}\n","import { loggingState } from './loggingState'\n\n/**\n * Enable or disable console diagnostics for all log helpers.\n * @param {boolean} enabled - True to print, false to silence.\n */\nexport const setLoggingEnabled = (enabled: boolean): void => {\n loggingState.enabled = enabled\n}\n"],"mappings":"mEAKA,IAAa,EAAqC,CAAE,QAAS,EAAM,ECCtD,GAAY,GAAG,IAA0B,CAEhD,EAAa,SAAS,QAAQ,IAAI,GAAG,CAAI,CAC/C,ECHa,GAAY,GAAG,IAA0B,CAChD,EAAa,SAAS,QAAQ,MAAM,GAAG,CAAI,CACjD,ECFa,GAAW,GAAG,IAA0B,CAC/C,EAAa,SAAS,QAAQ,KAAK,GAAG,CAAI,CAChD,ECFa,EAAqB,GAA2B,CAC3D,EAAa,QAAU,CACzB"}
|
package/dist/log.es.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/log/loggingState.ts
|
|
2
|
+
var e = { enabled: !1 }, t = (...t) => {
|
|
3
|
+
e.enabled && console.log(...t);
|
|
4
|
+
}, n = (...t) => {
|
|
5
|
+
e.enabled && console.error(...t);
|
|
6
|
+
}, r = (...t) => {
|
|
7
|
+
e.enabled && console.warn(...t);
|
|
8
|
+
}, i = (t) => {
|
|
9
|
+
e.enabled = t;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as logDebug, n as logError, r as logWarn, i as setLoggingEnabled };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=log.es.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.es.mjs","names":[],"sources":["../src/log/loggingState.ts","../src/log/logDebug.ts","../src/log/logError.ts","../src/log/logWarn.ts","../src/log/setLoggingEnabled.ts"],"sourcesContent":["/**\n * Module-private on/off switch for console diagnostics. Default false keeps\n * production silent. Consumers flip it via setLoggingEnabled at startup so the\n * library never reads the host environment flags directly (webview-safe).\n */\nexport const loggingState: { enabled: boolean } = { enabled: false }\n","import { loggingState } from './loggingState'\n\n/**\n * Logs a debug message only when logging is enabled. Silent by default.\n * @param {...unknown} args - Arguments forwarded to console.log.\n */\nexport const logDebug = (...args: unknown[]): void => {\n // eslint-disable-next-line no-console\n if (loggingState.enabled) console.log(...args)\n}\n","import { loggingState } from './loggingState'\n\n/**\n * Logs an error only when logging is enabled. Silent by default.\n * @param {...unknown} args - Arguments forwarded to console.error.\n */\nexport const logError = (...args: unknown[]): void => {\n if (loggingState.enabled) console.error(...args)\n}\n","import { loggingState } from './loggingState'\n\n/**\n * Logs a warning only when logging is enabled. Silent by default.\n * @param {...unknown} args - Arguments forwarded to console.warn.\n */\nexport const logWarn = (...args: unknown[]): void => {\n if (loggingState.enabled) console.warn(...args)\n}\n","import { loggingState } from './loggingState'\n\n/**\n * Enable or disable console diagnostics for all log helpers.\n * @param {boolean} enabled - True to print, false to silence.\n */\nexport const setLoggingEnabled = (enabled: boolean): void => {\n loggingState.enabled = enabled\n}\n"],"mappings":";AAKA,IAAa,IAAqC,EAAE,SAAS,GAAM,GCCtD,KAAY,GAAG,MAA0B;CAEpD,AAAI,EAAa,WAAS,QAAQ,IAAI,GAAG,CAAI;AAC/C,GCHa,KAAY,GAAG,MAA0B;CACpD,AAAI,EAAa,WAAS,QAAQ,MAAM,GAAG,CAAI;AACjD,GCFa,KAAW,GAAG,MAA0B;CACnD,AAAI,EAAa,WAAS,QAAQ,KAAK,GAAG,CAAI;AAChD,GCFa,KAAqB,MAA2B;CAC3D,EAAa,UAAU;AACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/log/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logDebug.d.ts","sourceRoot":"","sources":["../../../src/log/logDebug.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,OAAO,EAAE,KAAG,IAG7C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logError.d.ts","sourceRoot":"","sources":["../../../src/log/logError.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,OAAO,EAAE,KAAG,IAE7C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logWarn.d.ts","sourceRoot":"","sources":["../../../src/log/logWarn.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,OAAO,EAAE,KAAG,IAE5C,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module-private on/off switch for console diagnostics. Default false keeps
|
|
3
|
+
* production silent. Consumers flip it via setLoggingEnabled at startup so the
|
|
4
|
+
* library never reads the host environment flags directly (webview-safe).
|
|
5
|
+
*/
|
|
6
|
+
export declare const loggingState: {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=loggingState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loggingState.d.ts","sourceRoot":"","sources":["../../../src/log/loggingState.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAuB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setLoggingEnabled.d.ts","sourceRoot":"","sources":["../../../src/log/setLoggingEnabled.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,OAAO,KAAG,IAEpD,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@favish/staffbase-utils",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared internal/host utilities for Staffbase widgets",
|
|
5
|
+
"author": "Favish <dev@favish.com>",
|
|
6
|
+
"packageManager": "pnpm@11.5.0",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": ["dist"],
|
|
10
|
+
"exports": {
|
|
11
|
+
"./log": {
|
|
12
|
+
"types": "./dist/src/log/index.d.ts",
|
|
13
|
+
"import": "./dist/log.es.mjs",
|
|
14
|
+
"require": "./dist/log.cjs.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "vite build",
|
|
19
|
+
"check:all": "pnpm run format && pnpm run lint:fix && pnpm run type-check && pnpm run test",
|
|
20
|
+
"format": "prettier --write \"src/**/*\" --list-different",
|
|
21
|
+
"lint": "eslint ./src",
|
|
22
|
+
"lint:fix": "eslint ./src --fix",
|
|
23
|
+
"prepare": "pnpm run format && pnpm run type-check && pnpm run lint:fix && pnpm run build",
|
|
24
|
+
"prepublishOnly": "pnpm run test",
|
|
25
|
+
"publish:major": "pnpm run prepare && pnpm version major && pnpm publish",
|
|
26
|
+
"publish:minor": "pnpm run prepare && pnpm version minor && pnpm publish",
|
|
27
|
+
"publish:patch": "pnpm run prepare && pnpm version patch && pnpm publish",
|
|
28
|
+
"test": "jest",
|
|
29
|
+
"test:watch": "jest --watch",
|
|
30
|
+
"type-check": "tsc --pretty --noEmit",
|
|
31
|
+
"type-check:watch": "tsc --pretty --noEmit --watch"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/favish/staffbase-utils"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"registry": "https://registry.npmjs.org/",
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
43
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"react": { "optional": true },
|
|
47
|
+
"react-dom": { "optional": true }
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
51
|
+
"@eslint/js": "^10.0.1",
|
|
52
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
53
|
+
"@types/jest": "^30.0.0",
|
|
54
|
+
"@types/node": "^25",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^8.60.0",
|
|
56
|
+
"@typescript-eslint/parser": "^8.60.0",
|
|
57
|
+
"eslint": "^10.4.0",
|
|
58
|
+
"eslint-config-prettier": "10.1.8",
|
|
59
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
60
|
+
"eslint-plugin-import": "^2.32.0",
|
|
61
|
+
"eslint-plugin-jsdoc": "^63.0.0",
|
|
62
|
+
"eslint-plugin-react": "^7.37.5",
|
|
63
|
+
"jest": "^30.4.2",
|
|
64
|
+
"jest-environment-jsdom": "^30.4.1",
|
|
65
|
+
"prettier": "^3.8.3",
|
|
66
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
67
|
+
"ts-jest": "^29.4.11",
|
|
68
|
+
"typescript": "^6.0.3",
|
|
69
|
+
"typescript-eslint": "^8.60.0",
|
|
70
|
+
"vite": "^8.0.14",
|
|
71
|
+
"vite-plugin-dts": "^5.0.1"
|
|
72
|
+
}
|
|
73
|
+
}
|