@iccandle/vuejs-widget 0.3.4 → 0.5.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/README.md CHANGED
@@ -16,7 +16,7 @@ Published as ESM and CommonJS with TypeScript declarations. Component styles are
16
16
  - **Correlated markets panel** — while a simulation is on the chart, the popup expands to show how the move is expected to ripple into correlated markets (ρ, direction, % move).
17
17
  - **Pattern Tracker** — subscribe to alerts when a selected pattern forms again.
18
18
  - **News / event overlays** — event marks, vertical lines, and event-anchored simulations.
19
- - **Theming** — light, dark, or system, plus CSS custom properties and custom backgrounds.
19
+ - **Theming** — light, dark, or system, CSS custom properties, and client styles from the ICCandle Plugin Portal via `apiKey`.
20
20
  - **8 UI languages** — `en`, `zh`, `vi`, `th`, `ko`, `ja`, `mn`, `ru`.
21
21
 
22
22
  ## Contents
@@ -237,7 +237,41 @@ Scan and Pattern Tracker require `localStorage.iccandle_token`. The results ifra
237
237
  | `"dark"` | Dark scanner chrome; adds `.iccandle-dark` on the root. |
238
238
  | `"system"` | Follows `prefers-color-scheme`. |
239
239
 
240
- The root uses CSS custom properties you can override: `--iccandle-primary`, `--iccandle-border`, `--iccandle-text`, `--iccandle-background`, `--iccandle-primary-gradient-end`, `--iccandle-font`.
240
+ The root uses CSS custom properties you can override: `--iccandle-primary`, `--iccandle-border`, `--iccandle-text`, `--iccandle-background`, `--iccandle-primary-gradient-end`, `--iccandle-font`. `--iccandle-secondary` is derived from the background.
241
+
242
+ ### Plugin Portal style (`apiKey`)
243
+
244
+ Clients manage their style in the ICCandle Plugin Portal and create an API key there. Pass it to the widget:
245
+
246
+ ```vue
247
+ <WidgetIccandle api-key="<KEY>" :chart-widget="chartWidget" :submit-callback="handleSubmit">
248
+ <!-- chart -->
249
+ </WidgetIccandle>
250
+ ```
251
+
252
+ - The widget calls `GET https://api.iccandle.ai/plugin-client/v1/plugin/style` with the `api-key` header once per key. The result is cached in memory and refetched only when `apiKey` changes (not on theme change). The request times out after 5 s and is aborted on unmount.
253
+ - The key is also forwarded to every results-iframe URL as `&apiKey=`, so the embed app uses the same style.
254
+ - The key is **publishable**: it only reads style data and is meant to ship in client-side code. Restrict it in the portal with **allowed origins** (`scheme://host[:port]`, e.g. `https://app.example.com`). With no allowed origins any site can use the key (the portal warns about this). Requests from other origins get `403` and the widget falls back to the defaults.
255
+
256
+ Supported style fields, per theme (`light` and `dark`):
257
+
258
+ | Field | CSS variable | Accepted values |
259
+ | ----- | ------------ | --------------- |
260
+ | `iccandle_primary` | `--iccandle-primary` | `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb(r, g, b)`, `rgba(r, g, b, a)` |
261
+ | `iccandle_primary_gradient_end` | `--iccandle-primary-gradient-end` | same as above |
262
+ | `iccandle_background` | `--iccandle-background` | same as above |
263
+ | `iccandle_border` | `--iccandle-border` | same as above |
264
+ | `iccandle_text` | `--iccandle-text` | same as above |
265
+ | `icc_font` | `--iccandle-font` | `Inter Tight`, `Inter`, `Roboto`, `Open Sans`, `Lato`, `Montserrat`, `Poppins`, `Nunito`, `Source Sans 3`, `IBM Plex Sans`, `system-ui` |
266
+
267
+ The portal also sets `default_theme` (`light` \| `dark`). The widget re-validates every value and ignores anything outside the formats above. Non-system fonts are loaded once from Google Fonts.
268
+
269
+ **Priority** (highest first):
270
+
271
+ 1. Theme: `theme` prop → portal `default_theme` → `light`.
272
+ 2. Colors: portal style → bundled defaults.
273
+
274
+ **Fallback:** with no `apiKey`, an invalid or revoked key, a disallowed origin, rate limiting, no saved style, or a network error, the widget uses the bundled defaults. The chart keeps working and nothing is thrown.
241
275
 
242
276
  ### Chart mask colors
243
277
 
@@ -314,7 +348,8 @@ See [`src/App.vue`](src/App.vue), [`src/tradingview/TradingviewChart.vue`](src/t
314
348
  | ---- | ---- | -------- | ------- | ----------- |
315
349
  | `chartWidget` | `IChartingLibraryWidget \| null` | Yes | — | Live TradingView widget (`null` until ready). |
316
350
  | `submitCallback` | `(iframeSrc: string) => void` | Yes | — | Called with the embed URL after a scan (and for some pricing / news navigations). |
317
- | `theme` | `"light" \| "dark" \| "system"` | No | `"light"` | Scanner and forwarded embed theme. |
351
+ | `theme` | `"light" \| "dark" \| "system"` | No | portal `default_theme`, else `"light"` | Scanner and forwarded embed theme. |
352
+ | `apiKey` | `string` | No | — | Publishable Plugin Portal key (`pk_live_…`). Loads the client's portal style and forwards `&apiKey=` to the results iframe. See [Plugin Portal style](#plugin-portal-style-apikey). |
318
353
  | `chartMaskColors` | `WidgetChartMaskColors` | No | `{ light: "#ffffff", dark: "#0F0F0F" }` | Per-theme color used to mask not-yet-revealed predicted candles. Must match your chart pane background. |
319
354
  | `language` | `WidgetLanguage` | No | `"en"` | Scanner UI language. |
320
355
  | `onCloseResult` | `() => void` | No | — | Called when the embed posts `selector.closeResult`. |
@@ -355,7 +390,7 @@ The widget handles JSON messages with a `name` (and optional `data`) from the re
355
390
  | `pattern.clearClassicPatternSelected` / `pattern.clear_custom_pattern_selected` | Clear pattern overlay. |
356
391
  | `nav.click` | Handle embed navigation (clears date range on `/news` routes). |
357
392
 
358
- The host → embed helpers use a different shape: `{ type: "parent-origin" | "payment-success" | "open-pricing" | "chart-resolution", ... }`.
393
+ The host → embed helpers use a different shape: `{ type: "parent-origin" | "payment-success" | "open-pricing" | "chart-resolution" | "chart-selection", ... }`. `chart-selection` carries the window selector's `symbol`, `resolution` and `endTimestamp` (unix seconds, or `null`) so the embed can disable Simulate once the selector no longer matches the scan.
359
394
 
360
395
  ## Optional: timescale marks (news / events)
361
396
 
@@ -373,6 +408,24 @@ If your datafeed implements `getTimescaleMarks`, you can surface stored events f
373
408
 
374
409
  ## Changelog
375
410
 
411
+ ### 0.5.1
412
+
413
+ - Post the window selector's symbol, resolution and last-candle time to the results iframe (`chart-selection`) so it can disable Simulate once the selector moves or the symbol/timeframe changes.
414
+
415
+ ### 0.5.0
416
+
417
+ - Scanner settings: new "Candles to generate" option (1–50, default 15), sent to the results iframe as `&horizon=`.
418
+ - Simulated candles show their 0–100 score above each candle, thinned out as you zoom.
419
+ - Simulate frames the chart around the generated candles (longer reveals draw faster); closing returns to the previous view.
420
+ - Scanning centres the chart on the window selector instead of jumping to a fixed range.
421
+
422
+ ### 0.4.0
423
+
424
+ - **Breaking:** removed the `bg_dark` / `bg_light` props. Use a Plugin Portal style via `apiKey` instead.
425
+ - New `apiKey` prop loads the client's Plugin Portal style (colors, font, default theme) and forwards `&apiKey=` to the results iframe.
426
+ - Without an explicit `theme`, the portal's `default_theme` is used, then `light`.
427
+ - Buttons and inputs inherit the widget font.
428
+
376
429
  ### 0.3.4
377
430
 
378
431
  - Correlated markets panel under the scanner popup during AI simulation replay.
@@ -386,7 +439,7 @@ If your datafeed implements `getTimescaleMarks`, you can surface stored events f
386
439
 
387
440
  | Script | Command | Purpose |
388
441
  | ------ | ------- | ------- |
389
- | Dev demo | `pnpm dev` | Vite app with a local charting library. |
442
+ | Dev demo | `pnpm dev` | Vite app with a local charting library. Copy `.env.example` to `.env` for demo sign-in. |
390
443
  | Library build | `pnpm build` | Emits `dist/` (ESM, CJS, injected CSS, declarations). |
391
444
  | App build | `pnpm build:app` | Full demo app build. |
392
445
 
package/dist/index.d.ts CHANGED
@@ -13,7 +13,6 @@ import { Ref } from 'vue';
13
13
  declare const __VLS_component: DefineComponent<__VLS_Props, {
14
14
  chartRefs: WidgetIccandleChartRefs;
15
15
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
- theme: "light" | "dark" | "system";
17
16
  iframeLoaded: boolean;
18
17
  isShowScanButton: boolean;
19
18
  isShowTrackerButton: boolean;
@@ -28,9 +27,14 @@ declare type __VLS_Props = {
28
27
  theme?: "light" | "dark" | "system";
29
28
  /** Simulate-candle mask colors per theme. Defaults: light `#ffffff`, dark `#0F0F0F`. */
30
29
  chartMaskColors?: WidgetChartMaskColors;
31
- /** Widget + embed background (hex, `#` optional). Omitted = CSS defaults. */
32
- bg_dark?: string;
33
- bg_light?: string;
30
+ /**
31
+ * Publishable Plugin Portal API key (`pk_live_…`). When set, the widget loads
32
+ * the client's portal style (colors, font, default theme) and forwards the
33
+ * key to the results iframe as `&apiKey=`. An explicit `theme` prop takes
34
+ * priority over the portal's default theme. Any failure falls
35
+ * back to the bundled defaults.
36
+ */
37
+ apiKey?: string;
34
38
  language?: WidgetLanguage;
35
39
  onCloseResult?: () => void;
36
40
  iframeLoaded?: boolean;
@@ -169,9 +173,14 @@ export declare type WidgetIccandleProps = {
169
173
  theme?: "light" | "dark" | "system";
170
174
  /** Simulate-candle mask colors per theme. Defaults: light `#ffffff`, dark `#0F0F0F`. */
171
175
  chartMaskColors?: WidgetChartMaskColors;
172
- /** Widget + embed background (hex, `#` optional). Omitted = CSS defaults. */
173
- bg_dark?: string;
174
- bg_light?: string;
176
+ /**
177
+ * Publishable Plugin Portal API key (`pk_live_…`). When set, the widget loads
178
+ * the client's portal style (colors, font, default theme) and forwards the
179
+ * key to the results iframe as `&apiKey=`. An explicit `theme` prop takes
180
+ * priority over the portal's default theme. Any failure falls
181
+ * back to the bundled defaults.
182
+ */
183
+ apiKey?: string;
175
184
  language?: WidgetLanguage;
176
185
  onCloseResult?: () => void;
177
186
  iframeLoaded?: boolean;