@mmtitanl/tablets 0.1.1 → 0.2.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/dist/index.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  BUILTIN_DEVICES: () => BUILTIN_DEVICES,
24
+ CUSTOM_DEVICES: () => CUSTOM_DEVICES,
24
25
  DEVICE_LAYOUTS: () => DEVICE_LAYOUTS,
25
26
  DeviceRegistry: () => DeviceRegistry,
26
27
  GALAXY_S25_EDGE_FRAME: () => GALAXY_S25_EDGE_FRAME,
@@ -7175,6 +7176,56 @@ var GALAXY_Z_FOLD_7_OPEN_FRAME = {
7175
7176
  };
7176
7177
  var GALAXY_Z_FOLD_7_OPEN_SCREEN_RECT = { "x": 80.3916, "y": 85.6348, "width": 3074.1084, "height": 3407.9052, "rx": 20.97 };
7177
7178
 
7179
+ // src/svg/scope-ids.ts
7180
+ function scopeSVGIds(svgString, deviceId) {
7181
+ const safe = deviceId.replace(/[^a-zA-Z0-9_-]/g, "_");
7182
+ const prefix = `${safe}__`;
7183
+ const idRe = /\bid\s*=\s*["']([^"']+)["']/g;
7184
+ const ids = /* @__PURE__ */ new Set();
7185
+ let m;
7186
+ while (m = idRe.exec(svgString)) ids.add(m[1]);
7187
+ let out = svgString;
7188
+ for (const id of ids) {
7189
+ const escaped = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7190
+ out = out.replace(new RegExp(`\\bid\\s*=\\s*(["'])${escaped}\\1`, "g"), `id="${prefix}${id}"`);
7191
+ out = out.replace(new RegExp(`url\\(#${escaped}\\)`, "g"), `url(#${prefix}${id})`);
7192
+ out = out.replace(new RegExp(`\\bhref\\s*=\\s*(["'])#${escaped}\\1`, "g"), `href="#${prefix}${id}"`);
7193
+ out = out.replace(
7194
+ new RegExp(`\\bxlink:href\\s*=\\s*(["'])#${escaped}\\1`, "g"),
7195
+ `xlink:href="#${prefix}${id}"`
7196
+ );
7197
+ }
7198
+ return out;
7199
+ }
7200
+
7201
+ // src/custom/data.json
7202
+ var data_default = [];
7203
+
7204
+ // src/custom/index.tsx
7205
+ var import_jsx_runtime22 = require("react/jsx-runtime");
7206
+ function makeSVGComponent(svgString, scopeKey) {
7207
+ let svg = scopeSVGIds(svgString, scopeKey);
7208
+ svg = svg.replace(/<svg\b([^>]*)>/i, (_m, attrs) => {
7209
+ const stripped = attrs.replace(/\swidth\s*=\s*["'][^"']*["']/i, "").replace(/\sheight\s*=\s*["'][^"']*["']/i, "");
7210
+ return `<svg${stripped} width="100%" height="100%">`;
7211
+ });
7212
+ const Component = ({ style }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
7213
+ "span",
7214
+ {
7215
+ style: { display: "block", width: "100%", height: "100%", ...style },
7216
+ dangerouslySetInnerHTML: { __html: svg }
7217
+ }
7218
+ );
7219
+ Component.displayName = `CustomDeviceSVG(${scopeKey})`;
7220
+ return Component;
7221
+ }
7222
+ var data = data_default;
7223
+ var CUSTOM_DEVICES = data.map((d) => ({
7224
+ ...d,
7225
+ Component: makeSVGComponent(d.svgString, d.meta.id),
7226
+ LandscapeComponent: d.landscape ? makeSVGComponent(d.landscape.svgString, `${d.meta.id}-landscape`) : void 0
7227
+ }));
7228
+
7178
7229
  // src/builtin.ts
7179
7230
  var BUILTIN_METAS = {
7180
7231
  // Tablets
@@ -7230,6 +7281,10 @@ var BUILTIN_LAYOUTS = {
7230
7281
  [GALAXY_Z_FOLD_7_META.id]: GALAXY_Z_FOLD_7_LAYOUT,
7231
7282
  [GALAXY_Z_FOLD_7_OPEN_META.id]: GALAXY_Z_FOLD_7_OPEN_LAYOUT
7232
7283
  };
7284
+ for (const c of CUSTOM_DEVICES) {
7285
+ BUILTIN_METAS[c.meta.id] = c.meta;
7286
+ BUILTIN_LAYOUTS[c.meta.id] = { meta: c.meta, ...c.layout };
7287
+ }
7233
7288
 
7234
7289
  // src/registry/device-registry.ts
7235
7290
  var STORAGE_KEY = "bielaframe-custom-tablets";
@@ -7607,28 +7662,6 @@ function validateNormalizedSVG(result, targetWidth, targetHeight) {
7607
7662
  return { passed: errors.length === 0, warnings, errors };
7608
7663
  }
7609
7664
 
7610
- // src/svg/scope-ids.ts
7611
- function scopeSVGIds(svgString, deviceId) {
7612
- const safe = deviceId.replace(/[^a-zA-Z0-9_-]/g, "_");
7613
- const prefix = `${safe}__`;
7614
- const idRe = /\bid\s*=\s*["']([^"']+)["']/g;
7615
- const ids = /* @__PURE__ */ new Set();
7616
- let m;
7617
- while (m = idRe.exec(svgString)) ids.add(m[1]);
7618
- let out = svgString;
7619
- for (const id of ids) {
7620
- const escaped = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7621
- out = out.replace(new RegExp(`\\bid\\s*=\\s*(["'])${escaped}\\1`, "g"), `id="${prefix}${id}"`);
7622
- out = out.replace(new RegExp(`url\\(#${escaped}\\)`, "g"), `url(#${prefix}${id})`);
7623
- out = out.replace(new RegExp(`\\bhref\\s*=\\s*(["'])#${escaped}\\1`, "g"), `href="#${prefix}${id}"`);
7624
- out = out.replace(
7625
- new RegExp(`\\bxlink:href\\s*=\\s*(["'])#${escaped}\\1`, "g"),
7626
- `xlink:href="#${prefix}${id}"`
7627
- );
7628
- }
7629
- return out;
7630
- }
7631
-
7632
7665
  // src/svg/auto-detect.ts
7633
7666
  var KEYWORDS = [
7634
7667
  { kw: "screen", type: "screen-area" },
@@ -7755,6 +7788,7 @@ function listSVGLayerNames(svgString) {
7755
7788
  // Annotate the CommonJS export names for ESM import in node:
7756
7789
  0 && (module.exports = {
7757
7790
  BUILTIN_DEVICES,
7791
+ CUSTOM_DEVICES,
7758
7792
  DEVICE_LAYOUTS,
7759
7793
  DeviceRegistry,
7760
7794
  GALAXY_S25_EDGE_FRAME,