@panomc/sdk 1.0.0-dev.4 → 1.0.0-dev.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panomc/sdk",
3
- "version": "1.0.0-dev.4",
3
+ "version": "1.0.0-dev.6",
4
4
  "author": "PanoMC",
5
5
  "repository": {
6
6
  "url": "https://github.com/PanoMC/sdk"
@@ -47,6 +47,10 @@
47
47
  "./variables": {
48
48
  "svelte": "./src/variables.js",
49
49
  "default": "./src/variables.js"
50
+ },
51
+ "./svelte": {
52
+ "svelte": "./src/svelte.js",
53
+ "default": "./src/svelte.js"
50
54
  }
51
55
  },
52
56
  "files": [
package/src/api/plugin.js CHANGED
@@ -1,7 +1,22 @@
1
1
  import { createPluginContext } from "./plugin-context.js";
2
2
 
3
+ /**
4
+ * @typedef {import('../types.js').Pano} Pano
5
+ * @typedef {import('../types.js').PanoPluginContext} PanoPluginContext
6
+ */
7
+
3
8
  export class PanoPlugin {
4
9
  static isPanoPlugin = true;
10
+
11
+ /** @type {Pano} */
12
+ pano;
13
+
14
+ /** @type {PanoPluginContext} */
15
+ contextApi;
16
+
17
+ /** @type {any} */
18
+ context;
19
+
5
20
  constructor({ pluginId, scope } = {}) {
6
21
  if (!pluginId) {
7
22
  throw new Error("[PanoPlugin] pluginId is required");
@@ -14,9 +29,11 @@ export class PanoPlugin {
14
29
  this._unsubscribers = [];
15
30
  }
16
31
 
17
- /** lifecycle hooks */
18
- onLoad(pano) {}
19
- onUnload() {}
32
+ /**
33
+ * @param {Pano} pano
34
+ */
35
+ onLoad(pano) { }
36
+ onUnload() { }
20
37
 
21
38
  /** plugin context helper */
22
39
  setContext(partial) {
@@ -10,6 +10,13 @@ function getStore() {
10
10
  return globalThis[GLOBAL_KEY];
11
11
  }
12
12
 
13
+ /**
14
+ * @typedef {import('../types.js').Pano} Pano
15
+ */
16
+
17
+ /**
18
+ * @param {Partial<Pano>} partial
19
+ */
13
20
  export function setPanoContext(partial) {
14
21
  const store = getStore();
15
22
 
@@ -29,6 +36,9 @@ export function setPanoContext(partial) {
29
36
  });
30
37
  }
31
38
 
39
+ /**
40
+ * @returns {{ context: Pano, subscribe: (fn: (ctx: Pano) => void) => () => void }}
41
+ */
32
42
  export function getPanoContext() {
33
43
  const store = getStore();
34
44
 
package/src/svelte.js ADDED
@@ -0,0 +1,6 @@
1
+ import { getPanoContext } from "./internal/index.js";
2
+
3
+ const panoContext = getPanoContext();
4
+ const { page, base, navigating, browser } = panoContext.context;
5
+
6
+ export { page, base, navigating, browser };
package/src/types.js ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @typedef {Object} Pano
3
+ * @property {boolean} isPanel
4
+ * @property {any} page - SvelteKit page store
5
+ * @property {string} base
6
+ * @property {any} navigating - SvelteKit navigating store
7
+ * @property {boolean} browser
8
+ * @property {Object} ui
9
+ * @property {Object} ui.page
10
+ * @property {function({path: string, component: any, layout?: any, resetLayout?: boolean}): void} ui.page.register
11
+ * @property {Object} ui.nav
12
+ * @property {Object} ui.nav.site
13
+ * @property {function(function(any[]): any[]): void} ui.nav.site.editNavLinks
14
+ * @property {Object} utils
15
+ * @property {Object} utils.api
16
+ * @property {any} utils.api.ApiUtil
17
+ * @property {function(Record<string, any>): string} utils.api.buildQueryParams
18
+ * @property {string} utils.api.NETWORK_ERROR
19
+ * @property {Object} utils.api.networkErrorBody
20
+ * @property {string} utils.api.networkErrorBody.result
21
+ * @property {string} utils.api.networkErrorBody.error
22
+ * @property {Object} utils.language
23
+ * @property {any} utils.language.init
24
+ * @property {any} utils.language._ - i18n store or function
25
+ * @property {Object} utils.tooltip
26
+ * @property {any} utils.tooltip.tooltip
27
+ * @property {any} utils.toast
28
+ * @property {Record<string, any>} components
29
+ * @property {Record<string, any>} variables
30
+ */
31
+
32
+ /**
33
+ * @typedef {Object} PanoPluginContext
34
+ * @property {any} context
35
+ * @property {function(any): void} set
36
+ * @property {function(function(any): void): function(): void} subscribe
37
+ * @property {function(): void} [destroy]
38
+ */
39
+
40
+ export { }
@@ -11,6 +11,7 @@ const getAcceptedLanguage = languageStuff.getAcceptedLanguage;
11
11
  const loadLanguage = languageStuff.loadLanguage;
12
12
  const changeLanguage = languageStuff.changeLanguage;
13
13
  const getLanguageByLocale = languageStuff.getLanguageByLocale;
14
+ const _ = languageStuff._;
14
15
 
15
16
  export {
16
17
  languageLoading,
@@ -21,4 +22,5 @@ export {
21
22
  loadLanguage,
22
23
  changeLanguage,
23
24
  getLanguageByLocale,
25
+ _
24
26
  };