@qr-platform/qr-code.js 0.10.1 → 0.10.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.
@@ -341,12 +341,13 @@ const qrCodeWithLogo = new QRCodeJs({
341
341
  | `value` | `string` | `''` | The text content or image URL/data URI. |
342
342
  | `enableText` | `boolean` | `false` | Enables the decoration for this side. |
343
343
  | `disabled` | `boolean` | `false` | Disables the decoration for this side. |
344
- | `style` | `object` | `{}` | Text styling options (`fontFace`, `fontSize`, `fontColor`, `letterSpacing`, `fontWeight`). |
344
+ | `style` | `object` | `{}` | Text styling options (`fontFace`, `fontSize`, `fontColor`, `letterSpacing`, `fontWeight`). |
345
345
  | `style.fontFace` | `string` | `'Helvetica'` | The font face for the text. |
346
346
  | `style.fontSize` | `number` | `28` | The font size for the text in pixels. |
347
347
  | `style.fontColor` | `string` | `'#ffffff'` | The color of the text. |
348
348
  | `style.letterSpacing` | `number` | `0` | The letter spacing for the text in pixels. |
349
- | `style.fontWeight` | `'normal' \| 'bold'` | `'normal'` | The font weight for the text. |
349
+ | `style.fontWeight` | `'normal' \| 'bold'` | `'bold'` | The font weight for the text. |
350
+ | `style.textTransform` | `'uppercase' \| 'lowercase' \| 'capitalize'` | `'uppercase'` | The text transformation style. |
350
351
  | `offset` | `number` | `0` | Vertical (top/bottom) or horizontal (left/right) offset from the border center. |
351
352
  | `curveDisabled` | `boolean` | `false` | If `true`, text is drawn straight instead of curved along the border. |
352
353
  | `curveRadius` | `string` | `'50%'` | Overrides the curve radius for text (e.g., `'50%'`). Defaults to `borderOptions.radius`. |
@@ -500,67 +501,62 @@ if (validationResult.isValid) {
500
501
  - **`validateScanning(): Promise<{ isValid: boolean; decodedText?: string; message?: string }>`**
501
502
  Validates that the QR code is scannable (Premium feature).
502
503
 
503
- #### Static Methods
504
-
505
- - **`QRCodeJs.license(licenseKey: string): Promise<ValidationResult>`**
506
- Activates a license using a license key.
507
-
508
- - **`QRCodeJs.token(token: string | null): Promise<ValidationResult>`**
509
- Activates a license using a pre-fetched JWT token.
510
-
511
- - **`QRCodeJs.getLicenseDetails(): DecodedLicenseToken | null`**
512
- Retrieves current license information.
513
-
514
- - **`QRCodeJs.setLicenseUrl(url: string): void`**
515
- Sets the URL endpoint for license key validation.
516
-
517
- - **`QRCodeJs.configureLicenseFetcher(fetcher: (licenseKey: string) => Promise<string>): void`**
518
- Configures a custom function for fetching license tokens.
519
-
520
- - **`QRCodeJs.setTemplate(templateNameOrOptions: string | RecursivePartial<Options>): void`**
521
- Sets a global default template (by name or options object) for subsequent instances.
522
-
523
- - **`QRCodeJs.setTemplateId(templateId: string): void`**
524
- Sets a global default template by its ID.
525
504
 
526
- - **`QRCodeJs.setStyle(styleNameOrOptions: string | StyleOptions): void`**
527
- Sets a global default style (by name or options object) for subsequent instances.
528
-
529
- - **`QRCodeJs.setStyleId(styleId: string): void`**
530
- Sets a global default style by its ID.
531
-
532
- - **`QRCodeJs.setBorder(borderNameOrOptions: string | RecursivePartial<BorderOptions>): void`**
533
- Sets a global default border configuration (by name or options object) for subsequent instances.
534
-
535
- - **`QRCodeJs.setBorderId(borderId: string): void`**
536
- Sets a global default border configuration by its ID.
537
-
538
- - **`QRCodeJs.useTemplate(templateNameOrOptions: string | RecursivePartial<Options>): QRCodeBuilder`**
539
- Initiates the builder pattern pre-configured with a template (by name or options object).
540
-
541
- - **`QRCodeJs.useTemplateId(templateId: string): QRCodeBuilder`**
542
- Initiates the builder pattern pre-configured with a template by its ID.
505
+ #### Static Methods
543
506
 
544
- - **`QRCodeJs.useStyle(styleNameOrOptions: string | StyleOptions): QRCodeBuilder`**
545
- Initiates the builder pattern pre-configured with a style (by name or options object).
507
+ These methods are called directly on the `QRCodeJs` class (e.g., `QRCodeJs.setTemplate(...)`).
508
+
509
+ - **License Management:**
510
+ - `QRCodeJs.license(licenseKey: string): Promise<ValidationResult>`: Activates a license using a license key.
511
+ - `QRCodeJs.token(token: string | null): Promise<ValidationResult>`: Activates a license using a pre-fetched JWT token.
512
+ - `QRCodeJs.getLicenseDetails(): DecodedLicenseToken | null`: Retrieves current license information.
513
+ - `QRCodeJs.setLicenseUrl(url: string): void`: Sets the URL endpoint for license key validation.
514
+ - `QRCodeJs.configureLicenseFetcher(fetcher: (licenseKey: string) => Promise<string>): void`: Configures a custom function for fetching license tokens.
515
+
516
+ - **Global Configuration Defaults:**
517
+ - `QRCodeJs.setTemplate(templateNameOrOptions: string | RecursivePartial<Options> | null): typeof QRCodeJs`: Sets a global default template.
518
+ - `QRCodeJs.setTemplateId(templateId: string | null): typeof QRCodeJs`: Sets a global default template by its ID.
519
+ - `QRCodeJs.setStyle(styleNameOrOptions: string | StyleOptions | null): typeof QRCodeJs`: Sets a global default style.
520
+ - `QRCodeJs.setStyleId(styleId: string | null): typeof QRCodeJs`: Sets a global default style by its ID.
521
+ - `QRCodeJs.setBorder(borderNameOrOptions: string | RecursivePartial<BorderOptions> | null): typeof QRCodeJs`: Sets a global default border configuration.
522
+ - `QRCodeJs.setBorderId(borderId: string | null): typeof QRCodeJs`: Sets a global default border configuration by its ID.
523
+ - `QRCodeJs.setText(textNameOrOptions: string | TextOptions | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs`: Sets global default border text. `overrideOpts` (e.g., `{ override: true }`) ensures precedence.
524
+ - `QRCodeJs.setTextId(textId: string | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs`: Sets global default border text by ID. `overrideOpts` ensures precedence.
525
+ - `QRCodeJs.setImage(imageUrl: string | DataURL | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs`: Sets a global default image. `overrideOpts` ensures precedence.
526
+ - `QRCodeJs.setData(data: string | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs`: Sets a global default data string. `overrideOpts` ensures precedence.
527
+ - `QRCodeJs.setOptions(options: RecursivePartial<Options> | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs`: Sets global default options (merged deeply). `overrideOpts` ensures higher precedence.
528
+ - `QRCodeJs.setSettings(settings: SettingsOptions | null): typeof QRCodeJs`: Sets multiple global defaults from a `SettingsOptions` object. Acts as a macro, calling other static setters. Clears all static defaults if `null` is passed. See [Centralized Settings Configuration](#centralized-settings-configuration-settingsoptions-setsettings-and-usesettings) for more details.
529
+
530
+ **Example: Setting Global Data and Options**
531
+ ```typescript
532
+ // Set global data that will be used if no data is provided at instantiation
533
+ QRCodeJs.setData('https://www.default-link.com');
546
534
 
547
- - **`QRCodeJs.useStyleId(styleId: string): QRCodeBuilder`**
548
- Initiates the builder pattern pre-configured with a style by its ID.
535
+ // Set global options for margin and error correction
536
+ QRCodeJs.setOptions({
537
+ margin: 15,
538
+ qrOptions: { errorCorrectionLevel: 'M' }
539
+ });
549
540
 
550
- - **`QRCodeJs.useBorder(borderNameOrOptions: string | BorderOptions): QRCodeBuilder`**
551
- Initiates the builder pattern pre-configured with a border configuration (by name or options object).
541
+ // This QR code will use the global data, margin, and error correction level
542
+ const qrWithGlobalSettings = new QRCodeJs({}); // Data is optional now
543
+ qrWithGlobalSettings.append(document.getElementById('qr-global-container'));
552
544
 
553
- - **`QRCodeJs.useBorderId(borderId: string): QRCodeBuilder`**
554
- Initiates the builder pattern pre-configured with a border configuration by its ID.
545
+ // Override global data with an instance-specific value
546
+ const qrOverrideData = new QRCodeJs({ data: 'https://specific-link.com' });
547
+ // qrOverrideData will use 'https://specific-link.com', but still use global margin and EC level.
555
548
 
556
- - **`QRCodeJs.setImage(imageUrl: string | DataURL | null): void`**
557
- Sets a global default image URL for subsequent `QRCodeJs` instances.
549
+ // Using override to make global data sticky
550
+ QRCodeJs.setData('https://sticky-link.com', { override: true });
551
+ const qrStickyData = new QRCodeJs({ data: 'https://ignored-link.com' });
552
+ // qrStickyData will use 'https://sticky-link.com' due to the override.
558
553
 
559
- - **`QRCodeJs.useImage(imageUrl: string | DataURL): QRCodeBuilder`**
560
- Initiates the builder pattern pre-configured with an image URL.
554
+ // Clear global settings when no longer needed
555
+ QRCodeJs.setData(null);
556
+ QRCodeJs.setOptions(null);
557
+ ```
561
558
 
562
559
  ### Setting Global Defaults for Styles, Borders, and Images (`setStyle`, `setBorder`, `setImage`)
563
-
564
560
  Similar to `setTemplate`, you can set global defaults for styles, border configurations, and images that will apply to subsequently created instances:
565
561
 
566
562
  - **`QRCodeJs.setStyle(styleNameOrOptions)` / `QRCodeJs.setStyleId(styleId)`**: Sets a default style by name, object, or ID.
@@ -603,17 +599,144 @@ const qrCode = QRCodeJs.useTemplate('dots') // Base: dots template (e.g.,
603
599
 
604
600
  qrCode.append(document.getElementById('builder-example-container'));
605
601
 
606
- ### Builder Pattern for Styles, Borders, and Images (`useStyle`, `useBorder`, `useImage`)
607
602
 
608
- The builder pattern fully supports styles, borders, and images:
603
+ ### Builder Pattern Methods (`useStyle`, `useBorder`, `useImage`, `useData`, `useOptions`, `useSettings`)
604
+
605
+ These methods are called on `QRCodeJs` to initiate a builder chain (e.g., `QRCodeJs.useStyle(...)`) or on an existing `QRCodeBuilder` instance (e.g., `builder.useStyle(...)`).
606
+
607
+ - **`useStyle(styleNameOrOptions)` / `useStyleId(styleId)`**: Applies a style.
608
+ - **`useBorder(borderNameOrOptions)` / `useBorderId(borderId)`**: Applies a border configuration.
609
+ - **`useImage(imageUrl, overrideOpts?)`**: Sets an image. `overrideOpts` ensures precedence over image in final `.options()`.
610
+ - **`useData(data, overrideOpts?)`**: Sets the data. `overrideOpts` ensures precedence over data in final `.options()`.
611
+ - **`useOptions(options, overrideOpts?)`**: Merges general options. `overrideOpts` ensures precedence for these specific options over final `.options()`.
612
+ - **`useSettings(settings)`**: Applies a comprehensive `SettingsOptions` object as a new baseline for the builder chain, **resetting** any configurations previously applied to *that builder instance* via other `use...` methods.
613
+
614
+ You can chain these methods (e.g., `QRCodeJs.useTemplate(...).useStyle(...).useBorder(...).useImage(...)`) before finalizing with `.options(...)` or `.build()`. Options are merged progressively, with later calls overriding earlier ones for the same properties, unless an `override: true` was used.
615
+
616
+ **Example: Using Builder Methods**
617
+ ```typescript
618
+ // Start with a template, layer on a style, then specific data and options
619
+ const qrBuilt = QRCodeJs.useTemplate('dots') // Start with 'dots' template
620
+ .useStyle({ dotsOptions: { color: 'green' } }) // Override dot color to green
621
+ .useData('https://example.com/builder-path') // Set data via builder
622
+ .useOptions({ margin: 5 }) // Set margin via builder
623
+ .options({ qrOptions: { errorCorrectionLevel: 'Q' } }); // Final options, builds the instance
624
+
625
+ qrBuilt.append(document.getElementById('qr-builder-container'));
626
+
627
+ // Using useData with override
628
+ const qrBuilderDataOverride = QRCodeJs.useTemplate('rounded')
629
+ .useData('https://forced-builder-link.com', { override: true })
630
+ .options({ data: 'https://this-data-is-ignored.com' }); // Data from useData takes precedence
631
+
632
+ qrBuilderDataOverride.append(document.getElementById('qr-builder-data-override'));
633
+ ```
634
+
635
+ ---
636
+
637
+ ## Centralized Settings Configuration (`SettingsOptions`, `setSettings`, and `useSettings`)
638
+
639
+ For a comprehensive way to define or apply a complete QR code configuration in one go, QRCode.js provides:
640
+ - A `SettingsOptions` interface to structure a full configuration.
641
+ - A static `QRCodeJs.setSettings()` method for establishing global defaults using a `SettingsOptions` object.
642
+ - A `useSettings()` method for the `QRCodeBuilder` to apply a `SettingsOptions` object as a baseline for a specific builder chain.
643
+
644
+ ### `SettingsOptions` Object
645
+
646
+ The `SettingsOptions` interface allows you to define multiple aspects of a QR code configuration simultaneously, including `id`, `name`, `description`, `data`, `image`, `template`/`templateId`, `style`/`styleId`, `text`/`textId`, `border`/`borderId`, and a general `options` field for direct overrides.
647
+
648
+ Refer to the [TypeScript Types and Definitions](./typescript-types-definitions.md#settingsoptions) for the full structure.
649
+
650
+ ### Static `QRCodeJs.setSettings(settings: SettingsOptions | null)`
651
+
652
+ This static method is used to set multiple global defaults at once using a comprehensive `SettingsOptions` object.
653
+
654
+ - **Behavior**: It acts as a macro, internally calling other static setters (like `QRCodeJs.setTemplate()`, `QRCodeJs.setStyle()`, `QRCodeJs.setData()`, `QRCodeJs.setImage()`, `QRCodeJs.setOptions()`, etc.) based on the properties provided in the `settings` object. It will **override/reset** any previously set static configurations for the aspects it covers.
655
+ - If `null` is passed, all static configurations (template, style, text, border, image, data, and options) are cleared.
609
656
 
610
- - **`QRCodeJs.useStyle(styleNameOrOptions)` / `QRCodeJs.useStyleId(styleId)`**: Starts the builder pre-configured with a style.
611
- - **`QRCodeJs.useBorder(borderNameOrOptions)` / `QRCodeJs.useBorderId(borderId)`**: Starts the builder pre-configured with a border configuration.
612
- - **`QRCodeJs.useImage(imageUrl)`**: Starts the builder pre-configured with an image.
657
+ **Example: Using Static `setSettings()`**
658
+
659
+ ```typescript
660
+ const myCompanyPreset: SettingsOptions = {
661
+ name: 'CompanyStandardQR',
662
+ description: 'Standard QR code style for company communications.',
663
+ data: 'https://company.website.com', // Default data
664
+ image: 'https://company.website.com/assets/logo.png', // Default image
665
+ templateId: 'modern-dark', // Assumes this template ID exists
666
+ style: { dotsOptions: { color: '#00447C' } }, // Company blue dots
667
+ borderOptions: { hasBorder: true, thickness: 10, color: '#00447C' },
668
+ options: { // General options
669
+ margin: 10,
670
+ qrOptions: { errorCorrectionLevel: 'Q' }
671
+ }
672
+ };
673
+
674
+ QRCodeJs.setSettings(myCompanyPreset);
675
+
676
+ // This instance will use the 'CompanyStandardQR' preset
677
+ const qrFromPreset = new QRCodeJs({ /* Data can be omitted if in preset */ });
678
+ qrFromPreset.append(document.getElementById('qr-preset-container'));
679
+
680
+ // Override specific parts of the preset for another instance
681
+ const qrModifiedPreset = new QRCodeJs({
682
+ data: 'https://company.website.com/specific-campaign', // Override data
683
+ image: 'https://company.website.com/assets/campaign-logo.png' // Override image
684
+ // Other settings like template, style, border, margin, EC level from preset still apply
685
+ });
686
+ qrModifiedPreset.append(document.getElementById('qr-modified-preset-container'));
613
687
 
614
- You can chain these methods (e.g., `QRCodeJs.useTemplate(...).useStyle(...).useBorder(...).useImage(...)`) before finalizing with `.options(...)` or `.build()`. Options are merged progressively, with later calls overriding earlier ones.
688
+ // Clearing all static settings
689
+ QRCodeJs.setSettings(null);
690
+ const qrAfterClear = new QRCodeJs({ data: 'https://another.link.com/after-clear' }); // Uses base defaults, requires data
691
+ qrAfterClear.append(document.getElementById('qr-cleared-container'));
615
692
  ```
616
693
 
694
+ ### Builder `useSettings(settings: SettingsOptions)`
695
+
696
+ The `QRCodeBuilder.useSettings(settings: SettingsOptions)` method applies a `SettingsOptions` object as a new baseline for a specific builder chain.
697
+
698
+ - **Behavior**: Calling `useSettings()` on a builder instance will **reset** any configurations previously applied to *that builder instance* via methods like `useTemplate()`, `useStyle()`, `useBorder()`, `useText()`, `useImage()`, `useData()`, or `useOptions()`. The provided `settings` object then establishes the new comprehensive baseline for that builder.
699
+ - Subsequent builder methods chained *after* `useSettings()` (e.g., `.useStyle()`, `.options()`) will then modify this new baseline.
700
+
701
+ **Example: Using Builder `useSettings()`**
702
+ ```typescript
703
+ const eventSpecificConfig: SettingsOptions = {
704
+ name: 'TechConference2024',
705
+ data: 'https://techconf.example/schedule', // Baseline data for this builder
706
+ image: 'https://techconf.example/assets/event-banner-qr.png', // Baseline image
707
+ styleId: 'modern-dark', // Assumes 'modern-dark' style ID exists
708
+ text: { // Border text configuration
709
+ topValue: 'Tech Conference 2024',
710
+ bottomValue: 'Scan for Schedule & Info'
711
+ },
712
+ borderOptions: {
713
+ hasBorder: true,
714
+ thickness: 25,
715
+ color: '#333333',
716
+ radius: '5px'
717
+ },
718
+ options: { // Baseline general options
719
+ qrOptions: { errorCorrectionLevel: 'H' },
720
+ isResponsive: true
721
+ }
722
+ };
723
+
724
+ const qrEvent = QRCodeJs.useTemplate('basic') // Initial template (will be reset by useSettings)
725
+ .useStyle({ dotsOptions: { color: 'red'} }) // This style will also be reset
726
+ .useSettings(eventSpecificConfig) // Resets builder and applies eventSpecificConfig as baseline
727
+ .useStyle({ // Further refine the style from useSettings
728
+ dotsOptions: { gradient: { type: 'linear', colorStops: [{offset:0, color:'blue'}, {offset:1, color:'green'}] } }
729
+ })
730
+ .options({ // Final data override and other specific options
731
+ data: 'https://techconf.example/live-updates', // Overrides data from eventSpecificConfig
732
+ margin: 5 // Overrides margin if it was part of eventSpecificConfig.options
733
+ })
734
+ .build();
735
+
736
+ qrEvent.append(document.getElementById('event-qr-container'));
737
+ ```
738
+ ---
739
+
617
740
  ## FAQ
618
741
  ### How do I handle CORS issues with embedded images?
619
742
 
@@ -710,7 +833,7 @@ const qrCodePremium = new QRCodeJs({
710
833
  bottom: {
711
834
  type: 'text',
712
835
  value: 'LICENSED FEATURE',
713
- style: { fontColor: '#FFFFFF', fontSize: 18, fontWeight: '500' },
836
+ style: { fontColor: '#FFFFFF', fontSize: 18, fontWeight: 'bold' },
714
837
  curveDisabled: true // Straight text
715
838
  }
716
839
  }
@@ -728,3 +851,55 @@ const qrCodePremium = new QRCodeJs({
728
851
  - [License Management](./license-management.md#start)
729
852
  - [Basic Examples](./examples.md#start)
730
853
  - [Advanced Examples](./advanced-examples.md#start)
854
+
855
+ </file_content>
856
+
857
+ Now that you have the latest state of the file, try the operation again with fewer, more precise SEARCH blocks. For large files especially, it may be prudent to try to limit yourself to <5 SEARCH/REPLACE blocks at a time, then wait for the user to respond with the result of the operation before following up with another replace_in_file call to make additional edits.
858
+ (If you run into this error 3 times in a row, you may use the write_to_file tool as a fallback.)
859
+ </error><environment_details>
860
+ # VSCode Visible Files
861
+ docs/usage-guide.md
862
+
863
+ # VSCode Open Tabs
864
+ src/types/text-options.ts
865
+ src/core/templates/qr-templates.ts
866
+ src/core/qr-code-js.ts
867
+ src/index.ts
868
+ src/node.ts
869
+ docs/ft009-settings-option-continuation-plan.md
870
+ tests/node/node.settings.test.ts
871
+ docs/api-reference-guide.md
872
+ docs/usage-guide.md
873
+ src/types/settings-options.ts
874
+ src/index.html
875
+ src/node-pdf-demo.js
876
+ src/options-demo.ts
877
+ src/templates/borders-templates.html
878
+ docs/documentation.md
879
+ tests/node/node.text-image.test.ts
880
+ docs/ft009-settings-option-plan.md
881
+ ../../../../../Untitled-2
882
+ ../../../../../Untitled-1
883
+ docs/typescript-types-definitions.md
884
+ src/license/LicenseManager.ts
885
+ rollup.config.ts
886
+ package.json
887
+ node_modules/rollup-plugin-minify-template-literals/dist/index.d.ts
888
+ src/config/runtime-config.js
889
+ src/core/templates/qr-styles-dark.ts
890
+ src/core/qr-svg.ts
891
+ src/templates/borders-inner-outter.ts
892
+ src/demo.ts
893
+ src/core/templates/qr-template-borders.ts
894
+ src/core/templates/qr-styles.ts
895
+ docs/border-text-implementation-plan.md
896
+
897
+ # Current Time
898
+ 5/11/2025, 5:15:20 PM (America/New_York, UTC-4:00)
899
+
900
+ # Context Window Usage
901
+ 258,040 / 1,048.576K tokens used (25%)
902
+
903
+ # Current Mode
904
+ ACT MODE
905
+ </environment_details>
@@ -1,5 +1,6 @@
1
1
  import { CanvasOptions } from '~/utils/canvas-options';
2
2
  import { MethodOverrideOptions, RecursivePartial } from '../types/helper';
3
+ import { SettingsOptions } from '../types/settings-options';
3
4
  import { StyleOptions } from '../types/style-options';
4
5
  import { QRTextTemplateDefinition, TextOptions } from '../types/text-options';
5
6
  import { BorderOptions, Options } from '../utils/options';
@@ -25,6 +26,10 @@ export declare class QRCodeJs {
25
26
  private static _selectedImageOverride;
26
27
  private static _selectedText;
27
28
  private static _selectedTextOverride;
29
+ private static _selectedData;
30
+ private static _selectedDataOverride;
31
+ private static _selectedOptions;
32
+ private static _selectedOptionsOverride;
28
33
  private options;
29
34
  private container?;
30
35
  private qr?;
@@ -36,7 +41,7 @@ export declare class QRCodeJs {
36
41
  width: number;
37
42
  height: number;
38
43
  } | undefined;
39
- constructor(options: RecursivePartial<Options>, _?: boolean);
44
+ constructor(options: RecursivePartial<Options> | undefined, _?: boolean);
40
45
  /**
41
46
  * Sets the static template to be used as a base for new instances,
42
47
  * accepting either a template name or a template options object.
@@ -97,6 +102,13 @@ export declare class QRCodeJs {
97
102
  * @returns The QRCodeJs class for chaining.
98
103
  */
99
104
  static setImage(imageUrl: string | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs;
105
+ /**
106
+ * Sets the static Data to be used by new instances.
107
+ * @param data - The data to be encoded in the QR code.
108
+ * @returns The QRCodeJs class for chaining.
109
+ */
110
+ static setData(data: string | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs;
111
+ static setOptions(options: RecursivePartial<Options> | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs;
100
112
  /**
101
113
  * Sets the static text template or options to be used for new instances.
102
114
  * @param textNameOrOptions - The name of the text template, a TextOptions object, or null to clear.
@@ -109,6 +121,7 @@ export declare class QRCodeJs {
109
121
  * @returns The QRCodeJs class for chaining.
110
122
  */
111
123
  static setTextId(textId: string | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs;
124
+ static setSettings(settings: SettingsOptions | null): typeof QRCodeJs;
112
125
  getOptions(): Options;
113
126
  update(options?: RecursivePartial<Options>): Promise<void>;
114
127
  append(container?: HTMLElement): this;
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { QRCodeJs as _QRCodeJs } from './core/qr-code-js';
2
2
  import { MethodOverrideOptions, RecursivePartial } from './types/helper';
3
+ import { SettingsOptions } from './types/settings-options';
3
4
  import { StyleOptions } from './types/style-options';
4
5
  import { TextOptions } from './types/text-options';
5
6
  import { type Options as _QRCodeJsOptions, type BorderOptions } from './utils/options';
@@ -115,14 +116,18 @@ export declare class QRCodeJs extends _QRCodeJs {
115
116
  * @returns A new QRCodeBuilder instance.
116
117
  */
117
118
  static useTextId(textId: string, overrideOpts?: MethodOverrideOptions): QRCodeBuilder;
119
+ static useData(data: string, overrideOpts?: MethodOverrideOptions): QRCodeBuilder;
120
+ static useOptions(options: RecursivePartial<Options>, // Changed from Options to RecursivePartial<Options>
121
+ overrideOpts?: MethodOverrideOptions): QRCodeBuilder;
122
+ static useSettings(settings: SettingsOptions): QRCodeBuilder;
118
123
  }
119
124
  export declare class _ extends QRCodeJs {
120
125
  protected _hls(): boolean;
121
126
  constructor(options: Options);
122
127
  }
123
- declare class QRCodeBuilder {
128
+ export declare class QRCodeBuilder {
124
129
  private _qrCodeConstructor;
125
- protected _templateSource: string | Options | null;
130
+ protected _templateSource: string | RecursivePartial<Options> | null;
126
131
  protected _borderSource: string | BorderOptions | null;
127
132
  protected _styleSource: string | StyleOptions | null;
128
133
  protected _imageSource: string | null;
@@ -133,83 +138,25 @@ declare class QRCodeBuilder {
133
138
  protected _isBorderById: boolean;
134
139
  protected _isStyleById: boolean;
135
140
  protected _isTextById: boolean;
136
- protected _initialOptions: Options | null;
137
- /**
138
- * Creates a new QRCodeBuilder instance.
139
- * @param qrCodeConstructor - The constructor function (QRCodeJs or _) to use for the final instance.
140
- * @param templateNameOrOptions - Optional name of a predefined template or a partial options object to start with.
141
- */
142
- constructor(qrCodeConstructor: QRCodeJsConstructor, templateNameOrOptions?: string | Options);
143
- /**
144
- * Sets the template to use by its name. Overwrites any previously set template.
145
- * @param templateName - The user-friendly name of the template to apply.
146
- * @returns The builder instance for chaining.
147
- */
141
+ protected _optionsSource: RecursivePartial<Options> | null;
142
+ protected _optionsOverride: boolean;
143
+ protected _dataSource: string | null;
144
+ protected _dataOverride: boolean;
145
+ protected _initialOptions: RecursivePartial<Options> | null;
146
+ constructor(qrCodeConstructor: QRCodeJsConstructor, templateNameOrOptions?: string | RecursivePartial<Options>);
148
147
  useTemplate(templateName: string): this;
149
- /**
150
- * Sets the template to use by its ID. Overwrites any previously set template.
151
- * @param templateId - The ID (original key) of the template to apply.
152
- * @returns The builder instance for chaining.
153
- */
154
148
  useTemplateId(templateId: string): this;
155
- /**
156
- * Sets the style to use by its name or a style options object. Overwrites any previously set style.
157
- * @param styleNameOrOptions - Name of a predefined style or a StyleOptions object to apply.
158
- * @returns The builder instance for chaining.
159
- */
160
149
  useStyle(styleNameOrOptions: string | StyleOptions): this;
161
- /**
162
- * Sets the style to use by its ID. Overwrites any previously set style.
163
- * @param styleId - ID of the predefined style to apply.
164
- * @returns The builder instance for chaining.
165
- */
166
150
  useStyleId(styleId: string): this;
167
- /**
168
- * Sets the border to use by its name or a border options object. Overwrites any previously set border.
169
- * @param borderNameOrOptions - Name of a predefined border or a BorderOptions object to apply.
170
- * @returns The builder instance for chaining.
171
- */
172
151
  useBorder(borderNameOrOptions: string | BorderOptions): this;
173
- /**
174
- * Sets the border to use by its ID. Overwrites any previously set border.
175
- * @param borderId - ID of the predefined border to apply.
176
- * @returns The builder instance for chaining.
177
- */
178
152
  useBorderId(borderId: string): this;
179
- /**
180
- * Sets the image to use. Overwrites any previously set image from other sources like templates.
181
- * @param imageUrl - The URL or data URL of the image to apply.
182
- * @returns The builder instance for chaining.
183
- */
184
153
  useImage(imageUrl: string, overrideOpts?: MethodOverrideOptions): this;
185
- /**
186
- * Sets the text to use by its name or a text options object. Overwrites any previously set text.
187
- * @param textNameOrOptions - Name of a predefined text template or a TextOptions object to apply.
188
- * @returns The builder instance for chaining.
189
- */
154
+ useData(data: string, overrideOpts?: MethodOverrideOptions): this;
190
155
  useText(textNameOrOptions: string | TextOptions, overrideOpts?: MethodOverrideOptions): this;
191
- /**
192
- * Sets the text to use by its ID. Overwrites any previously set text.
193
- * @param textId - ID of the predefined text template to apply.
194
- * @returns The builder instance for chaining.
195
- */
196
156
  useTextId(textId: string, overrideOpts?: MethodOverrideOptions): this;
197
- /**
198
- * Resolves the template, border, style, and image sources and merges them in the correct order.
199
- * Order: Base Template -> Selected Template -> Selected Border -> Selected Text -> Selected Style -> Selected Image -> Final Options
200
- * @param finalOptions - The final options object passed to .options() or .build().
201
- * @returns The fully resolved and merged Options object.
202
- */
157
+ useOptions(options: RecursivePartial<Options>, overrideOpts?: MethodOverrideOptions): this;
158
+ useSettings(settings: SettingsOptions): this;
203
159
  private _resolveAndMergeConfig;
204
- /**
205
- * Merges the provided options into the builder's configuration and creates the QRCodeJs instance.
206
- * @param options - A partial options object to merge as the final step.
207
- * @returns The created QRCodeJs instance.
208
- */
209
- options(options: Options): QRCodeJs;
210
- /**
211
- * Builds the QRCodeJs instance with the accumulated configuration.
212
- * @returns The created QRCodeJs instance.
213
- */
160
+ options(options: RecursivePartial<Options>): QRCodeJs;
214
161
  build(): QRCodeJs;
215
162
  }